summaryrefslogtreecommitdiffstats
path: root/src/crypto/bytestring/ber.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/bytestring/ber.c')
-rw-r--r--src/crypto/bytestring/ber.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/crypto/bytestring/ber.c b/src/crypto/bytestring/ber.c
index 2729fa1..e3b150c 100644
--- a/src/crypto/bytestring/ber.c
+++ b/src/crypto/bytestring/ber.c
@@ -43,7 +43,7 @@ static int cbs_find_ber(CBS *orig_in, char *ber_found, unsigned depth) {
unsigned tag;
size_t header_len;
- if (!CBS_get_any_asn1_element(&in, &contents, &tag, &header_len)) {
+ if (!CBS_get_any_ber_asn1_element(&in, &contents, &tag, &header_len)) {
return 0;
}
if (CBS_len(&contents) == header_len &&
@@ -74,7 +74,7 @@ static char is_primitive_type(unsigned tag) {
}
/* is_eoc returns true if |header_len| and |contents|, as returned by
- * |CBS_get_any_asn1_element|, indicate an "end of contents" (EOC) value. */
+ * |CBS_get_any_ber_asn1_element|, indicate an "end of contents" (EOC) value. */
static char is_eoc(size_t header_len, CBS *contents) {
return header_len == 2 && CBS_len(contents) == 2 &&
memcmp(CBS_data(contents), "\x00\x00", 2) == 0;
@@ -98,7 +98,7 @@ static int cbs_convert_ber(CBS *in, CBB *out, char squash_header,
size_t header_len;
CBB *out_contents, out_contents_storage;
- if (!CBS_get_any_asn1_element(in, &contents, &tag, &header_len)) {
+ if (!CBS_get_any_ber_asn1_element(in, &contents, &tag, &header_len)) {
return 0;
}
out_contents = out;
@@ -129,8 +129,8 @@ static int cbs_convert_ber(CBS *in, CBB *out, char squash_header,
size_t inner_header_len;
CBS_init(&in_copy, CBS_data(in), CBS_len(in));
- if (!CBS_get_any_asn1_element(&in_copy, &inner_contents, &inner_tag,
- &inner_header_len)) {
+ if (!CBS_get_any_ber_asn1_element(&in_copy, &inner_contents,
+ &inner_tag, &inner_header_len)) {
return 0;
}
if (CBS_len(&inner_contents) > inner_header_len &&
@@ -209,7 +209,9 @@ int CBS_asn1_ber_to_der(CBS *in, uint8_t **out, size_t *out_len) {
return 1;
}
- CBB_init(&cbb, CBS_len(in));
+ if (!CBB_init(&cbb, CBS_len(in))) {
+ return 0;
+ }
if (!cbs_convert_ber(in, &cbb, 0, 0, 0)) {
CBB_cleanup(&cbb);
return 0;