.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.48) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "ASN1_BIT_STRING_GET_LENGTH 3ssl" .TH ASN1_BIT_STRING_GET_LENGTH 3ssl 2026-10-23 4.1.0 OpenSSL .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME ASN1_BIT_STRING_set, ASN1_BIT_STRING_set1, ASN1_BIT_STRING_set_bit, ASN1_BIT_STRING_get_bit, ASN1_BIT_STRING_check, ASN1_BIT_STRING_name_print, ASN1_BIT_STRING_num_asc, ASN1_BIT_STRING_set_asc, ASN1_BIT_STRING_get_length \- ASN1_BIT_STRING accessors .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& typedef struct BIT_STRING_BITNAME_st { \& int bitnum; \& const char *lname; \& const char *sname; \& } BIT_STRING_BITNAME; \& \& int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); \& int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); \& int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, \& const unsigned char *flags, int flags_len); \& \& int ASN1_BIT_STRING_get_length(const ASN1_BIT_STRING *bitstr, \& size_t *length, int *unused_bits); \& int ASN1_BIT_STRING_set1(ASN1_BIT_STRING *bitstr, const uint8_t *data, \& size_t length, int unused_bits); .Ve .PP The following function have been deprecated since OpenSSL 4.1, and can be hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value, see \fBopenssl_user_macros\fR\|(7): .PP .Vb 6 \& int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); \& int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, \& BIT_STRING_BITNAME *tbl, int indent); \& int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); \& int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, \& int value, BIT_STRING_BITNAME *tbl); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" The ASN.1 BIT STRING type holds a bit string of arbitrary bit length. In the distinguished encoding rules DER, its bits are encoded in groups of eight, leaving between zero and seven bits of the last octet unused. If there are unused bits, they must all be set to zero. .PP \&\fBASN1_BIT_STRING_set_bit()\fR sets the \fIn\fRth bit (counted from 0 as the least significant bit) of a bit string \fIa\fR to \fIvalue\fR which is interpreted as a boolean. .PP \&\fBASN1_BIT_STRING_get_bit()\fR returns the bit value of the \fIn\fRth bit in the bit string \fIa\fR. .PP \&\fBASN1_BIT_STRING_check()\fR checks if the \fIa\fR bit string contains only bits specified by the \fIflags\fR vector. \fIflags_len\fR is the length of \fIflags\fR in bytes. .PP \&\fBASN1_BIT_STRING_get_length()\fR returns the number of octets in \fIbitstr\fR containing bit values in \fIlength\fR and the number of unused bits in the last octet in \fIunused_bits\fR. The value returned in \&\fIunused_bits\fR is guaranteed to be between 0 and 7, inclusive. .PP \&\fBASN1_BIT_STRING_set()\fR sets the octets of \fIa\fR to the bits in the byte string \fId\fR of \fIlength\fR octets. .PP \&\fBASN1_BIT_STRING_set1()\fR sets the type of \fIbitstr\fR to \&\fIV_ASN1_BIT_STRING\fR and its octets to the bits in the byte string \&\fIdata\fR of length \fIlength\fR octets, making sure that the last \&\fIunused_bits\fR bits in the last byte are zero. .PP \&\fBASN1_BIT_STRING_name_print()\fR prints the corresponding bit name specified in \fItbl\fR to \fIout\fR based on the bit string \fIbs\fR. \fIindent\fR might be specified for a number of spaces to indent the line. This function has been deprecated as of OpenSSL 4.1. For a replacement strategy, consider using a descriptive #define for the bit value, or if your application truly needs to do this with strings, implementing your own string to integer lookup table. .PP \&\fBASN1_BIT_STRING_num_asc()\fR searches for the provided \fIname\fR in \fIlname\fR and \fIsname\fR fields of \fItbl\fR\*(Aqs elements and returns the corresponding \&\fIbitnum\fR field value in case there is a match found. This function has been deprecated as of OpenSSL 4.1. For a replacement strategy, consider using a descriptive #define for the bit value, or if your application truly needs to do this with strings, implementing your own string to integer lookup table. .PP \&\fBASN1_BIT_STRING_set_asc()\fR sets the corresponding bit to \fIname\fR in \fIbs\fR based on the conversion table \fItbl\fR. This function has been deprecated as of OpenSSL 4.1. For a replacement strategy, consider using a descriptive #define for the bit value, or if your application truly needs to do this with strings, implementing your own string to integer lookup table. .SH "RETURN VALUES" .IX Header "RETURN VALUES" \&\fBASN1_BIT_STRING_set_bit()\fR returns 1 on success or 0 on incorrect input values. .PP \&\fBASN1_BIT_STRING_get_bit()\fR returns the value of the requested bit or 0 when data not available for the requested arguments. .PP \&\fBASN1_BIT_STRING_check()\fR returns 0 if there is at least one bit set in \&\fIa\fR which is not specified in \fIflags\fR, 1 otherwise. .PP \&\fBASN1_BIT_STRING_name_print()\fR returns 1 on success, or 0 when the print functions fail. .PP \&\fBASN1_BIT_STRING_num_asc()\fR returns the bit number of the requested \&\fIname\fR or \-1 when the name was not found. .PP \&\fBASN1_BIT_STRING_set_asc()\fR returns 1 on success or 0 on failure. .PP \&\fBASN1_BIT_STRING_get_length()\fR returns 1 on success or 0 if the encoding of \fIbitstr\fR is internally inconsistent, or if one of \fIbitstr\fR, \&\fIlength\fR, or \fIunused_bits\fR is NULL. .PP \&\fBASN1_BIT_STRING_set()\fR returns 1 on success or 0 if memory allocation fails, \&\fIlength\fR is not specified (value less than 0) and \fId\fR is NULL or \&\fIlength\fR is larger than INT_MAX\-1. .PP \&\fBASN1_BIT_STRING_set1()\fR returns 1 on success or 0 if memory allocation fails or if \fIbitstr\fR is NULL, \fIlength\fR is too large, \fIlength\fR is zero and \fIunused_bits\fR is nonzero, \fIunused_bits\fR is less than 0 or greater than 7, or any unused bit in the last octet of \fIdata\fR is nonzero. .SH HISTORY .IX Header "HISTORY" Functions \fBASN1_BIT_STRING_get_length()\fR and \fBASN1_BIT_STRING_set1()\fR were added in OpenSSL version 4.0. .PP \&\fBASN1_BIT_STRING_set()\fR was deprecated in OpenSSL 4.1 in favour of \&\fBASN1_BIT_STRING_set1()\fR. \&\fBASN1_BIT_STRING_name_print()\fR \fBASN1_BIT_STRING_num_asc()\fR, and \&\fBASN1_BIT_STRING_set_asc()\fR, Along with the BIT_STRING_BITNAME structure were present but undocumented in all versions of OpenSSL as public API. They are unused by the library. They were documented and then deprecated in OpenSSL 4.1. .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright 2025\-2026 The OpenSSL Project Authors. All Rights Reserved. .PP Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at .