summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_bitstr.c
diff options
context:
space:
mode:
authortb <>2023-07-28 10:30:16 +0000
committertb <>2023-07-28 10:30:16 +0000
commita6fe4431097f0743a991627e730ef8ceebc499b6 (patch)
treebed307ec2023eb715c5a9083f129a7d671153bc5 /src/lib/libcrypto/asn1/a_bitstr.c
parent0c95ea0b6649ecf3b2740991ddf8d8f17000653d (diff)
downloadopenbsd-a6fe4431097f0743a991627e730ef8ceebc499b6.tar.gz
openbsd-a6fe4431097f0743a991627e730ef8ceebc499b6.tar.bz2
openbsd-a6fe4431097f0743a991627e730ef8ceebc499b6.zip
Remove ASN1_BIT_STRING_check
This was added with the TS code for no discernible reason. I could not find a single consumer. In the unlikely event that you need this, it is easy enough to write a better version of it yourself. ok jsing
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)