NAME
ASN1_BIT_STRING_set
,
ASN1_BIT_STRING_set_bit
,
ASN1_BIT_STRING_get_bit
,
ASN1_BIT_STRING_check
—
ASN.1 BIT STRING accessors
SYNOPSIS
#include
<openssl/asn1.h>
int
ASN1_BIT_STRING_set
(ASN1_BIT_STRING
*bitstr, unsigned char *data,
int len);
int
ASN1_BIT_STRING_set_bit
(ASN1_BIT_STRING
*bitstr, int bitnumber, int
set);
int
ASN1_BIT_STRING_get_bit
(ASN1_BIT_STRING
*bitstr, int bitnumber);
int
ASN1_BIT_STRING_check
(ASN1_BIT_STRING
*bitstr, const unsigned char *goodbits,
int goodbits_len);
DESCRIPTION
ASN1_BIT_STRING_set
()
sets the length attribute of bitstr to
len and copies that number of bytes from
data into bitstr, overwriting
any previous data, by merely calling
ASN1_STRING_set(3). This function does no validation
whatsoever. In particular, it neither checks that
bitstr is actually of the type
V_ASN1_BIT_STRING
nor, even if it is, that the
data and len arguments make
sense for this particular bit string.
If the set
argument is non-zero,
ASN1_BIT_STRING_set_bit
()
sets the bit with the given bitnumber in the
bitstr; otherwise, it clears that bit. A
bitnumber of 0 addresses the most significant bit in
the first data byte of bitstr, 7 the least significant
bit in the same byte, 8 the most significant bit in the second data byte,
and so on.
If setting a bit is requested beyond the last existing data byte, additional bytes are added to the bitstr as needed. After clearing a bit, any trailing NUL bytes are removed from the bitstr.
ASN1_BIT_STRING_get_bit
()
checks that the bit with the given bitnumber is set in
bitstr.
ASN1_BIT_STRING_check
()
checks that all bits set in bitstr are also set in
goodbits. Expressed symbolically, it evaluates:
The buffer goodbits is expected to contain goodbits_len bytes.
RETURN VALUES
ASN1_BIT_STRING_set
() returns 1 on success
or 0 if memory allocation fails or if data is
NULL
and len is -1 in the same
call.
ASN1_BIT_STRING_set_bit
() returns 1 on
success or 0 if bitstr is NULL
or if memory allocation fails.
ASN1_BIT_STRING_get_bit
() returns 1 if the
bit with the given bitnumber is set in the
bitstr or 0 if bitstr is
NULL
, if bitnumber points
beyond the last data byte in bitstr, or if the
requested bit is not set.
ASN1_BIT_STRING_check
() returns 0 if at
least one bit is set in bitstr that is not set in
goodbits, or 1 otherwise. In particular, it returns 1
if bitstr is NULL
or if no bit
is set in bitstr.
SEE ALSO
ASN1_BIT_STRING_new(3), ASN1_BIT_STRING_num_asc(3), ASN1_STRING_set(3), d2i_ASN1_BIT_STRING(3)
HISTORY
ASN1_BIT_STRING_set
() first appeared in
SSLeay 0.6.5. ASN1_BIT_STRING_set_bit
() and
ASN1_BIT_STRING_get_bit
() first appeared in SSLeay
0.9.0. These functions have been available since OpenBSD
2.4.
ASN1_BIT_STRING_check
() first appeared in
OpenSSL 1.0.0 and has have been available since OpenBSD
4.9.