summaryrefslogtreecommitdiffstats
path: root/src/crypto/bytestring/cbs.c
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2015-09-24 23:03:06 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-24 23:03:06 +0000
commitc737bc23bc868fff21e5c1b95940813f709ea550 (patch)
treedd743d9d64af3145fe96b8d5fc2f3427544794bd /src/crypto/bytestring/cbs.c
parent0267d647a4d272af8b9e7c91063d374f7e2775bb (diff)
parent3781a60670f92c3c6fca860cb4589495cefa2e56 (diff)
downloadexternal_boringssl-c737bc23bc868fff21e5c1b95940813f709ea550.zip
external_boringssl-c737bc23bc868fff21e5c1b95940813f709ea550.tar.gz
external_boringssl-c737bc23bc868fff21e5c1b95940813f709ea550.tar.bz2
am 3781a606: am 1e4884f6: external/boringssl: sync with upstream.
* commit '3781a60670f92c3c6fca860cb4589495cefa2e56': external/boringssl: sync with upstream.
Diffstat (limited to 'src/crypto/bytestring/cbs.c')
-rw-r--r--src/crypto/bytestring/cbs.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/crypto/bytestring/cbs.c b/src/crypto/bytestring/cbs.c
index b8caedd..5e0c538 100644
--- a/src/crypto/bytestring/cbs.c
+++ b/src/crypto/bytestring/cbs.c
@@ -137,6 +137,15 @@ int CBS_get_bytes(CBS *cbs, CBS *out, size_t len) {
return 1;
}
+int CBS_copy_bytes(CBS *cbs, uint8_t *out, size_t len) {
+ const uint8_t *v;
+ if (!cbs_get(cbs, &v, len)) {
+ return 0;
+ }
+ memcpy(out, v, len);
+ return 1;
+}
+
static int cbs_get_length_prefixed(CBS *cbs, CBS *out, size_t len_len) {
uint32_t len;
if (!cbs_get_u(cbs, &len, len_len)) {
@@ -320,14 +329,19 @@ int CBS_get_asn1_uint64(CBS *cbs, uint64_t *out) {
}
int CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present, unsigned tag) {
+ int present = 0;
+
if (CBS_peek_asn1_tag(cbs, tag)) {
if (!CBS_get_asn1(cbs, out, tag)) {
return 0;
}
- *out_present = 1;
- } else {
- *out_present = 0;
+ present = 1;
+ }
+
+ if (out_present != NULL) {
+ *out_present = present;
}
+
return 1;
}