summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_bitstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_bitstr.c')
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 8076723de8..b985db60da 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.39 2023/07/05 21:23:36 beck Exp $ */ 1/* $OpenBSD: a_bitstr.c,v 1.40 2023/07/28 10:30:16 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 *
@@ -162,33 +162,6 @@ ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n)
162} 162}
163LCRYPTO_ALIAS(ASN1_BIT_STRING_get_bit); 163LCRYPTO_ALIAS(ASN1_BIT_STRING_get_bit);
164 164
165/*
166 * Checks if the given bit string contains only bits specified by
167 * the flags vector. Returns 0 if there is at least one bit set in 'a'
168 * which is not specified in 'flags', 1 otherwise.
169 * 'len' is the length of 'flags'.
170 */
171int
172ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags,
173 int flags_len)
174{
175 int i, ok;
176
177 /* Check if there is one bit set at all. */
178 if (!a || !a->data)
179 return 1;
180
181 /* Check each byte of the internal representation of the bit string. */
182 ok = 1;
183 for (i = 0; i < a->length && ok; ++i) {
184 unsigned char mask = i < flags_len ? ~flags[i] : 0xff;
185 /* We are done if there is an unneeded bit set. */
186 ok = (a->data[i] & mask) == 0;
187 }
188 return ok;
189}
190LCRYPTO_ALIAS(ASN1_BIT_STRING_check);
191
192int 165int
193ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 166ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
194 BIT_STRING_BITNAME *tbl, int indent) 167 BIT_STRING_BITNAME *tbl, int indent)