1ASN1_INTEGER_GET_INT64(3)           OpenSSL          ASN1_INTEGER_GET_INT64(3)
2
3
4

NAME

6       ASN1_INTEGER_get_uint64, ASN1_INTEGER_set_uint64,
7       ASN1_INTEGER_get_int64, ASN1_INTEGER_get, ASN1_INTEGER_set_int64,
8       ASN1_INTEGER_set, BN_to_ASN1_INTEGER, ASN1_INTEGER_to_BN,
9       ASN1_ENUMERATED_get_int64, ASN1_ENUMERATED_get,
10       ASN1_ENUMERATED_set_int64, ASN1_ENUMERATED_set, BN_to_ASN1_ENUMERATED,
11       ASN1_ENUMERATED_to_BN - ASN.1 INTEGER and ENUMERATED utilities
12

SYNOPSIS

14        #include <openssl/asn1.h>
15
16        int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);
17        long ASN1_INTEGER_get(const ASN1_INTEGER *a);
18
19        int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
20        int ASN1_INTEGER_set(const ASN1_INTEGER *a, long v);
21
22        int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
23        int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
24
25        ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
26        BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
27
28        int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);
29        long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
30
31        int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);
32        int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
33
34        ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);
35        BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn);
36

DESCRIPTION

38       These functions convert to and from ASN1_INTEGER and ASN1_ENUMERATED
39       structures.
40
41       ASN1_INTEGER_get_int64() converts an ASN1_INTEGER into an int64_t type
42       If successful it returns 1 and sets *pr to the value of a. If it fails
43       (due to invalid type or the value being too big to fit into an int64_t
44       type) it returns 0.
45
46       ASN1_INTEGER_get_uint64() is similar to ASN1_INTEGER_get_int64_t()
47       except it converts to a uint64_t type and an error is returned if the
48       passed integer is negative.
49
50       ASN1_INTEGER_get() also returns the value of a but it returns 0 if a is
51       NULL and -1 on error (which is ambiguous because -1 is a legitimate
52       value for an ASN1_INTEGER). New applications should use
53       ASN1_INTEGER_get_int64() instead.
54
55       ASN1_INTEGER_set_int64() sets the value of ASN1_INTEGER a to the
56       int64_t value r.
57
58       ASN1_INTEGER_set_uint64() sets the value of ASN1_INTEGER a to the
59       uint64_t value r.
60
61       ASN1_INTEGER_set() sets the value of ASN1_INTEGER a to the long value
62       v.
63
64       BN_to_ASN1_INTEGER() converts BIGNUM bn to an ASN1_INTEGER. If ai is
65       NULL a new ASN1_INTEGER structure is returned. If ai is not NULL then
66       the existing structure will be used instead.
67
68       ASN1_INTEGER_to_BN() converts ASN1_INTEGER ai into a BIGNUM. If bn is
69       NULL a new BIGNUM structure is returned. If bn is not NULL then the
70       existing structure will be used instead.
71
72       ASN1_ENUMERATED_get_int64(), ASN1_ENUMERATED_set_int64(),
73       ASN1_ENUMERATED_set(), BN_to_ASN1_ENUMERATED() and
74       ASN1_ENUMERATED_to_BN() behave in an identical way to their
75       ASN1_INTEGER counterparts except they operate on an ASN1_ENUMERATED
76       value.
77
78       ASN1_ENUMERATED_get() returns the value of a in a similar way to
79       ASN1_INTEGER_get() but it returns 0xffffffffL if the value of a will
80       not fit in a long type. New applications should use
81       ASN1_ENUMERATED_get_int64() instead.
82

NOTES

84       In general an ASN1_INTEGER or ASN1_ENUMERATED type can contain an
85       integer of almost arbitrary size and so cannot always be represented by
86       a C int64_t type. However, in many cases (for example version numbers)
87       they represent small integers which can be more easily manipulated if
88       converted to an appropriate C integer type.
89

BUGS

91       The ambiguous return values of ASN1_INTEGER_get() and
92       ASN1_ENUMERATED_get() mean these functions should be avoided if
93       possible. They are retained for compatibility. Normally the ambiguous
94       return values are not legitimate values for the fields they represent.
95

RETURN VALUES

97       ASN1_INTEGER_set_int64(), ASN1_INTEGER_set(),
98       ASN1_ENUMERATED_set_int64() and ASN1_ENUMERATED_set() return 1 for
99       success and 0 for failure. They will only fail if a memory allocation
100       error occurs.
101
102       ASN1_INTEGER_get_int64() and ASN1_ENUMERATED_get_int64() return 1 for
103       success and 0 for failure. They will fail if the passed type is
104       incorrect (this will only happen if there is a programming error) or if
105       the value exceeds the range of an int64_t type.
106
107       BN_to_ASN1_INTEGER() and BN_to_ASN1_ENUMERATED() return an ASN1_INTEGER
108       or ASN1_ENUMERATED structure respectively or NULL if an error occurs.
109       They will only fail due to a memory allocation error.
110
111       ASN1_INTEGER_to_BN() and ASN1_ENUMERATED_to_BN() return a BIGNUM
112       structure of NULL if an error occurs. They can fail if the passed type
113       is incorrect (due to programming error) or due to a memory allocation
114       failure.
115

SEE ALSO

117       ERR_get_error(3)
118

HISTORY

120       ASN1_INTEGER_set_int64(), ASN1_INTEGER_get_int64(),
121       ASN1_ENUMERATED_set_int64() and ASN1_ENUMERATED_get_int64() were added
122       in OpenSSL 1.1.0.
123
125       Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
126
127       Licensed under the OpenSSL license (the "License").  You may not use
128       this file except in compliance with the License.  You can obtain a copy
129       in the file LICENSE in the source distribution or at
130       <https://www.openssl.org/source/license.html>.
131
132
133
1341.1.1k                            2021-03-26         ASN1_INTEGER_GET_INT64(3)
Impressum