Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2014-08-13 21:31:04 +0400
committerAdam Langley <agl@google.com>2014-08-14 20:37:22 +0400
commit660140206ed32aa217ba3f299debae8d9ac472ec (patch)
treefb2321bcc1ffe3dc95b6dfa09e9b6859bfcb9761 /crypto/base64
parente2c4d262141f9a7de9baf6d0d7151682e9947357 (diff)
Add EVP_EncodedLength.
Several callers of EVP_EncodeBlock are doing ad-hoc versions of this function without any overflow checks. Change-Id: I4d0cad2347ea8c44b42465e8b14b2783db69ee8f Reviewed-on: https://boringssl-review.googlesource.com/1511 Reviewed-by: David Benjamin <davidben@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/base64')
-rw-r--r--crypto/base64/base64.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/base64/base64.c b/crypto/base64/base64.c
index 4cd95d60..2336cf53 100644
--- a/crypto/base64/base64.c
+++ b/crypto/base64/base64.c
@@ -402,3 +402,21 @@ int EVP_DecodeBlock(uint8_t *dst, const uint8_t *src, size_t src_len) {
return ret;
}
+
+int EVP_EncodedLength(size_t *out_len, size_t len) {
+ if (len + 2 < len) {
+ return 0;
+ }
+ len += 2;
+ len /= 3;
+ if (((len << 2) >> 2) != len) {
+ return 0;
+ }
+ len <<= 2;
+ if (len + 1 < len) {
+ return 0;
+ }
+ len++;
+ *out_len = len;
+ return 1;
+}