summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2022-04-26 20:00:18 +0000
committerjsing <>2022-04-26 20:00:18 +0000
commit96fcb9bb1156a80f7ecf943f678799e3f82229d2 (patch)
treefec9a82c257f4ca26cfe78d9eb92d1020b194c8d /src
parenta21700d1cbc0c5673e9dc658afc73350b8dd01ff (diff)
downloadopenbsd-96fcb9bb1156a80f7ecf943f678799e3f82229d2.tar.gz
openbsd-96fcb9bb1156a80f7ecf943f678799e3f82229d2.tar.bz2
openbsd-96fcb9bb1156a80f7ecf943f678799e3f82229d2.zip
Decode via c2i_ASN1_BIT_STRING_cbs() from asn1_ex_c2i().
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c11
-rw-r--r--src/lib/libcrypto/asn1/asn1_locl.h6
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c6
3 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 52fe0eb9cd..aa854f1d7a 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_bitstr.c,v 1.34 2022/04/23 18:56:54 jsing Exp $ */ 1/* $OpenBSD: a_bitstr.c,v 1.35 2022/04/26 20:00:18 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -291,7 +291,7 @@ i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
291 return (ret); 291 return (ret);
292} 292}
293 293
294static int 294int
295c2i_ASN1_BIT_STRING_cbs(ASN1_BIT_STRING **out_abs, CBS *cbs) 295c2i_ASN1_BIT_STRING_cbs(ASN1_BIT_STRING **out_abs, CBS *cbs)
296{ 296{
297 ASN1_BIT_STRING *abs = NULL; 297 ASN1_BIT_STRING *abs = NULL;
@@ -300,9 +300,14 @@ c2i_ASN1_BIT_STRING_cbs(ASN1_BIT_STRING **out_abs, CBS *cbs)
300 uint8_t unused_bits; 300 uint8_t unused_bits;
301 int ret = 0; 301 int ret = 0;
302 302
303 if (out_abs == NULL || *out_abs != NULL) 303 if (out_abs == NULL)
304 goto err; 304 goto err;
305 305
306 if (*out_abs != NULL) {
307 ASN1_BIT_STRING_free(*out_abs);
308 *out_abs = NULL;
309 }
310
306 if (!CBS_get_u8(cbs, &unused_bits)) { 311 if (!CBS_get_u8(cbs, &unused_bits)) {
307 ASN1error(ASN1_R_STRING_TOO_SHORT); 312 ASN1error(ASN1_R_STRING_TOO_SHORT);
308 goto err; 313 goto err;
diff --git a/src/lib/libcrypto/asn1/asn1_locl.h b/src/lib/libcrypto/asn1/asn1_locl.h
index d4ea3a9db8..ae9445c382 100644
--- a/src/lib/libcrypto/asn1/asn1_locl.h
+++ b/src/lib/libcrypto/asn1/asn1_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_locl.h,v 1.25 2022/04/23 18:47:08 jsing Exp $ */ 1/* $OpenBSD: asn1_locl.h,v 1.26 2022/04/26 20:00:18 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -201,9 +201,11 @@ int asn1_get_primitive(CBS *cbs, int der_mode, uint32_t *out_tag_number,
201 201
202int asn1_tag2charwidth(int tag); 202int asn1_tag2charwidth(int tag);
203 203
204int c2i_ASN1_BIT_STRING_cbs(ASN1_BIT_STRING **out_abs, CBS *cbs);
205
206int c2i_ASN1_OBJECT_cbs(ASN1_OBJECT **out_aobj, CBS *content);
204int i2t_ASN1_OBJECT_internal(const ASN1_OBJECT *aobj, char *buf, int buf_len, 207int i2t_ASN1_OBJECT_internal(const ASN1_OBJECT *aobj, char *buf, int buf_len,
205 int no_name); 208 int no_name);
206int c2i_ASN1_OBJECT_cbs(ASN1_OBJECT **out_aobj, CBS *content);
207ASN1_OBJECT *t2i_ASN1_OBJECT_internal(const char *oid); 209ASN1_OBJECT *t2i_ASN1_OBJECT_internal(const char *oid);
208 210
209__END_HIDDEN_DECLS 211__END_HIDDEN_DECLS
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 76dceaabef..5c68834461 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_dec.c,v 1.50 2022/04/23 18:47:08 jsing Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.51 2022/04/26 20:00:18 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -856,9 +856,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, CBS *content, int utype, const ASN1_ITEM *it)
856 break; 856 break;
857 857
858 case V_ASN1_BIT_STRING: 858 case V_ASN1_BIT_STRING:
859 p = CBS_data(content); 859 if (!c2i_ASN1_BIT_STRING_cbs((ASN1_BIT_STRING **)pval, content))
860 if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &p,
861 CBS_len(content)))
862 goto err; 860 goto err;
863 break; 861 break;
864 862