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:
authorPaul Lietar <lietar@google.com>2015-09-03 16:40:21 +0300
committerAdam Langley <agl@google.com>2015-09-03 21:46:17 +0300
commit23b185a3cf7dfab0834f28619568a6444fdea9aa (patch)
tree4f1cadf4241daeaf4e14543ec28b6658e0ca32b4 /crypto/bytestring
parentc9d40ba5b06e3ea79e61467a2495a68a7fd9c843 (diff)
Allow out_present to be NULL in CBS_get_optional_asn1
This is useful to skip an optional element, and mirrors the behaviour of CBS_get_optional_asn1_octet_string. Change-Id: Icb538c5e99a1d4e46412cae3c438184a94fab339 Reviewed-on: https://boringssl-review.googlesource.com/5800 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/bytestring')
-rw-r--r--crypto/bytestring/cbs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/bytestring/cbs.c b/crypto/bytestring/cbs.c
index c0fb6773..5e0c538a 100644
--- a/crypto/bytestring/cbs.c
+++ b/crypto/bytestring/cbs.c
@@ -329,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;
}