summaryrefslogtreecommitdiffstats
path: root/src/include/openssl
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2015-05-18 17:27:14 -0700
committerKenny Root <kroot@google.com>2015-05-22 15:54:04 -0700
commit4f05b238eec1f3f026657a6da19058143d34ceaa (patch)
tree7eb21ce466bb6cafcdcace93b010c6d5cc1f6693 /src/include/openssl
parent3f3c43ff4f6f9ed103f550e469805f2d8c0f6f86 (diff)
downloadexternal_boringssl-4f05b238eec1f3f026657a6da19058143d34ceaa.zip
external_boringssl-4f05b238eec1f3f026657a6da19058143d34ceaa.tar.gz
external_boringssl-4f05b238eec1f3f026657a6da19058143d34ceaa.tar.bz2
Add |BIO_read_asn1| to read a single ASN.1 object.
Android needs to be able to read a PKCS#7 blob from a Java InputStream. This change adds |BIO_read_asn1| which reads a single ASN.1 object from the start of a BIO without overreading. (Taken from upstream's https://boringssl-review.googlesource.com/4800) (cherry picked from commit f5cea4e0c1c842a9de02ce39cd6ff7ae66363b21) Bug: 21396526 Bug: 21209493 Change-Id: Id88f34bedfdff4963c72bcd5c84f2915785d1fcd
Diffstat (limited to 'src/include/openssl')
-rw-r--r--src/include/openssl/bio.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/include/openssl/bio.h b/src/include/openssl/bio.h
index b70b42f..a37077c 100644
--- a/src/include/openssl/bio.h
+++ b/src/include/openssl/bio.h
@@ -338,6 +338,21 @@ OPENSSL_EXPORT int BIO_hexdump(BIO *bio, const uint8_t *data, size_t len,
* using human readable strings where possible. */
OPENSSL_EXPORT void BIO_print_errors(BIO *bio);
+/* BIO_read_asn1 reads a single ASN.1 object from |bio|. If successful it sets
+ * |*out| to be an allocated buffer (that should be freed with |OPENSSL_free|),
+ * |*out_size| to the length, in bytes, of that buffer and returns one.
+ * Otherwise it returns zero.
+ *
+ * If the length of the object is greater than |max_len| or 2^32 then the
+ * function will fail. Long-form tags are not supported. If the length of the
+ * object is indefinite the full contents of |bio| are read, unless it would be
+ * greater than |max_len|, in which case the function fails.
+ *
+ * If the function fails then some unknown amount of data may have been read
+ * from |bio|. */
+OPENSSL_EXPORT int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len,
+ size_t max_len);
+
/* Memory BIOs.
*