Sortix 1.1dev ports manual
This manual documents Sortix 1.1dev ports. You can instead view this document in the latest official manual.
ASN1_INTEGER_GET(3) | Library Functions Manual | ASN1_INTEGER_GET(3) |
NAME
ASN1_INTEGER_get, ASN1_INTEGER_set, BN_to_ASN1_INTEGER, ASN1_INTEGER_to_BN, i2a_ASN1_INTEGER, ASN1_ENUMERATED_get, ASN1_ENUMERATED_set, BN_to_ASN1_ENUMERATED, ASN1_ENUMERATED_to_BN — ASN.1 INTEGER and ENUMERATED utilitiesSYNOPSIS
#include <openssl/asn1.h> longASN1_INTEGER_get(const ASN1_INTEGER *a); int
ASN1_INTEGER_set(ASN1_INTEGER *a, long v); ASN1_INTEGER *
BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); BIGNUM *
ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); int
i2a_ASN1_INTEGER(BIO *out_bio, const ASN1_INTEGER *a); long
ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a); int
ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); ASN1_ENUMERATED *
BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai); BIGNUM *
ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);
DESCRIPTION
These functions convert to and from ASN1_INTEGER and ASN1_ENUMERATED objects. ASN1_INTEGER_get() converts a to the long type. ASN1_INTEGER_set() sets the value of a to v. BN_to_ASN1_INTEGER() converts bn to an ASN1_INTEGER. If ai isNULL
, a new
ASN1_INTEGER object is returned. Otherwise,
the existing object ai is used instead.
ASN1_INTEGER_to_BN() converts
ai into a
BIGNUM. If
bn is
NULL
, a new
BIGNUM object is returned. Otherwise, the
existing object bn is used instead.
i2a_ASN1_INTEGER() writes a hexadecimal
representation of a to
out_bio. The output optionally starts with a
minus sign, followed by an even number of upper case ASCII hexadecimal digits.
After each group of 70 digits, a backslash and a linefeed are inserted before
the next digit.
ASN1_ENUMERATED_get(),
ASN1_ENUMERATED_set(),
BN_to_ASN1_ENUMERATED(), and
ASN1_ENUMERATED_to_BN() behave like their
ASN1_INTEGER counterparts except that they
operate on an ASN1_ENUMERATED object.
RETURN VALUES
ASN1_INTEGER_get() and ASN1_ENUMERATED_get() return the converted value, 0 if a isNULL
, or -1 on error, which is ambiguous
because -1 is a legitimate value for an
ASN1_INTEGER.
ASN1_INTEGER_set() and
ASN1_ENUMERATED_set() return 1 for success or 0
for failure. They only fail if a memory allocation error occurs.
BN_to_ASN1_INTEGER() and
BN_to_ASN1_ENUMERATED() return an
ASN1_INTEGER or
ASN1_ENUMERATED object, respectively, or
NULL
if an error occurs. They only fail due
to memory allocation errors.
ASN1_INTEGER_to_BN() and
ASN1_ENUMERATED_to_BN() return a
BIGNUM object of
NULL
if an error occurs. They can fail if
the passed type is incorrect (due to a programming error) or due to memory
allocation failures.
In case of success, i2a_ASN1_INTEGER() returns the
total number of bytes written, which is at least 2. It returns 0 if
a is NULL
or -1 if
BIO_write(3)
fails.
SEE ALSO
ASN1_INTEGER_new(3)HISTORY
ASN1_INTEGER_set() first appeared in SSLeay 0.5.1. ASN1_INTEGER_get(), BN_to_ASN1_INTEGER(), ASN1_INTEGER_to_BN(), and i2a_ASN1_INTEGER() first appeared in SSLeay 0.6.0. These functions have been available since OpenBSD 2.3. ASN1_ENUMERATED_get(), ASN1_ENUMERATED_set(), BN_to_ASN1_ENUMERATED(), and ASN1_ENUMERATED_to_BN() first appeared in OpenSSL 0.9.2b and have been available since OpenBSD 2.6.CAVEATS
In general an ASN1_INTEGER or ASN1_ENUMERATED type can contain an integer of almost arbitrary size and so cannot always be represented by a C long type. The ambiguous return values of ASN1_INTEGER_get() and ASN1_ENUMERATED_get() imply that these functions should be avoided if possible.August 26, 2019 | Debian |