diff options
author | tb <> | 2022-05-24 19:59:14 +0000 |
---|---|---|
committer | tb <> | 2022-05-24 19:59:14 +0000 |
commit | 0480fe6a94e3afde7e2d8ac3ee22ef700a08d7cf (patch) | |
tree | 83ed238c56e95764e6b209f8accea1369b5d286e /src | |
parent | 902ecd13701cbd4f5d20e7dd3b1e4dcb8c6eac99 (diff) | |
download | openbsd-0480fe6a94e3afde7e2d8ac3ee22ef700a08d7cf.tar.gz openbsd-0480fe6a94e3afde7e2d8ac3ee22ef700a08d7cf.tar.bz2 openbsd-0480fe6a94e3afde7e2d8ac3ee22ef700a08d7cf.zip |
Rewrite X509_PUBKEY_set0_param() to use asn1_abs_set_unused_bits()
This streamlines the logic and uses ASN1_STRING_set0() and
asn1_abs_set_unused_bits() instead of inlining them.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/asn1/x_pubkey.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c index 69be6ed1f9..a2c3d88e8a 100644 --- a/src/lib/libcrypto/asn1/x_pubkey.c +++ b/src/lib/libcrypto/asn1/x_pubkey.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x_pubkey.c,v 1.31 2021/12/25 13:17:48 jsing Exp $ */ | 1 | /* $OpenBSD: x_pubkey.c,v 1.32 2022/05/24 19:59:14 tb 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 | * |
@@ -716,15 +716,13 @@ X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, int ptype, | |||
716 | { | 716 | { |
717 | if (!X509_ALGOR_set0(pub->algor, aobj, ptype, pval)) | 717 | if (!X509_ALGOR_set0(pub->algor, aobj, ptype, pval)) |
718 | return 0; | 718 | return 0; |
719 | if (penc) { | 719 | |
720 | free(pub->public_key->data); | 720 | if (penc == NULL) |
721 | pub->public_key->data = penc; | 721 | return 1; |
722 | pub->public_key->length = penclen; | 722 | |
723 | /* Set number of unused bits to zero */ | 723 | ASN1_STRING_set0(pub->public_key, penc, penclen); |
724 | pub->public_key->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); | 724 | |
725 | pub->public_key->flags |= ASN1_STRING_FLAG_BITS_LEFT; | 725 | return asn1_abs_set_unused_bits(pub->public_key, 0); |
726 | } | ||
727 | return 1; | ||
728 | } | 726 | } |
729 | 727 | ||
730 | int | 728 | int |