ASN1_INTEGER_get_int64.3ossl 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "ASN1_INTEGER_GET_INT64 3ossl"
  58. .TH ASN1_INTEGER_GET_INT64 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. ASN1_INTEGER_get_uint64, ASN1_INTEGER_set_uint64,
  65. ASN1_INTEGER_get_int64, ASN1_INTEGER_get, ASN1_INTEGER_set_int64, ASN1_INTEGER_set, BN_to_ASN1_INTEGER, ASN1_INTEGER_to_BN, ASN1_ENUMERATED_get_int64, ASN1_ENUMERATED_get, ASN1_ENUMERATED_set_int64, ASN1_ENUMERATED_set, BN_to_ASN1_ENUMERATED, ASN1_ENUMERATED_to_BN
  66. \&\- ASN.1 INTEGER and ENUMERATED utilities
  67. .SH SYNOPSIS
  68. .IX Header "SYNOPSIS"
  69. .Vb 1
  70. \& #include <openssl/asn1.h>
  71. \&
  72. \& int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);
  73. \& long ASN1_INTEGER_get(const ASN1_INTEGER *a);
  74. \&
  75. \& int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
  76. \& int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
  77. \&
  78. \& int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
  79. \& int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
  80. \&
  81. \& ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
  82. \& BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
  83. \&
  84. \& int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);
  85. \& long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
  86. \&
  87. \& int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);
  88. \& int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
  89. \&
  90. \& ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);
  91. \& BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);
  92. .Ve
  93. .SH DESCRIPTION
  94. .IX Header "DESCRIPTION"
  95. These functions convert to and from \fBASN1_INTEGER\fR and \fBASN1_ENUMERATED\fR
  96. structures.
  97. .PP
  98. \&\fBASN1_INTEGER_get_int64()\fR converts an \fBASN1_INTEGER\fR into an \fBint64_t\fR type
  99. If successful it returns 1 and sets \fI*pr\fR to the value of \fIa\fR. If it fails
  100. (due to invalid type or the value being too big to fit into an \fBint64_t\fR type)
  101. it returns 0.
  102. .PP
  103. \&\fBASN1_INTEGER_get_uint64()\fR is similar to \fBASN1_INTEGER_get_int64_t()\fR except it
  104. converts to a \fBuint64_t\fR type and an error is returned if the passed integer
  105. is negative.
  106. .PP
  107. \&\fBASN1_INTEGER_get()\fR also returns the value of \fIa\fR but it returns 0 if \fIa\fR is
  108. NULL and \-1 on error (which is ambiguous because \-1 is a legitimate value for
  109. an \fBASN1_INTEGER\fR). New applications should use \fBASN1_INTEGER_get_int64()\fR
  110. instead.
  111. .PP
  112. \&\fBASN1_INTEGER_set_int64()\fR sets the value of \fBASN1_INTEGER\fR \fIa\fR to the
  113. \&\fBint64_t\fR value \fIr\fR.
  114. .PP
  115. \&\fBASN1_INTEGER_set_uint64()\fR sets the value of \fBASN1_INTEGER\fR \fIa\fR to the
  116. \&\fBuint64_t\fR value \fIr\fR.
  117. .PP
  118. \&\fBASN1_INTEGER_set()\fR sets the value of \fBASN1_INTEGER\fR \fIa\fR to the \fIlong\fR value
  119. \&\fIv\fR.
  120. .PP
  121. \&\fBBN_to_ASN1_INTEGER()\fR converts \fBBIGNUM\fR \fIbn\fR to an \fBASN1_INTEGER\fR. If \fIai\fR
  122. is NULL a new \fBASN1_INTEGER\fR structure is returned. If \fIai\fR is not NULL then
  123. the existing structure will be used instead.
  124. .PP
  125. \&\fBASN1_INTEGER_to_BN()\fR converts ASN1_INTEGER \fIai\fR into a \fBBIGNUM\fR. If \fIbn\fR is
  126. NULL a new \fBBIGNUM\fR structure is returned. If \fIbn\fR is not NULL then the
  127. existing structure will be used instead.
  128. .PP
  129. \&\fBASN1_ENUMERATED_get_int64()\fR, \fBASN1_ENUMERATED_set_int64()\fR,
  130. \&\fBASN1_ENUMERATED_set()\fR, \fBBN_to_ASN1_ENUMERATED()\fR and \fBASN1_ENUMERATED_to_BN()\fR
  131. behave in an identical way to their ASN1_INTEGER counterparts except they
  132. operate on an \fBASN1_ENUMERATED\fR value.
  133. .PP
  134. \&\fBASN1_ENUMERATED_get()\fR returns the value of \fIa\fR in a similar way to
  135. \&\fBASN1_INTEGER_get()\fR but it returns \fB0xffffffffL\fR if the value of \fIa\fR will not
  136. fit in a long type. New applications should use \fBASN1_ENUMERATED_get_int64()\fR
  137. instead.
  138. .SH NOTES
  139. .IX Header "NOTES"
  140. In general an \fBASN1_INTEGER\fR or \fBASN1_ENUMERATED\fR type can contain an
  141. integer of almost arbitrary size and so cannot always be represented by a C
  142. \&\fBint64_t\fR type. However, in many cases (for example version numbers) they
  143. represent small integers which can be more easily manipulated if converted to
  144. an appropriate C integer type.
  145. .SH BUGS
  146. .IX Header "BUGS"
  147. The ambiguous return values of \fBASN1_INTEGER_get()\fR and \fBASN1_ENUMERATED_get()\fR
  148. mean these functions should be avoided if possible. They are retained for
  149. compatibility. Normally the ambiguous return values are not legitimate
  150. values for the fields they represent.
  151. .SH "RETURN VALUES"
  152. .IX Header "RETURN VALUES"
  153. \&\fBASN1_INTEGER_set_int64()\fR, \fBASN1_INTEGER_set()\fR, \fBASN1_ENUMERATED_set_int64()\fR and
  154. \&\fBASN1_ENUMERATED_set()\fR return 1 for success and 0 for failure. They will only
  155. fail if a memory allocation error occurs.
  156. .PP
  157. \&\fBASN1_INTEGER_get_int64()\fR and \fBASN1_ENUMERATED_get_int64()\fR return 1 for success
  158. and 0 for failure. They will fail if the passed type is incorrect (this will
  159. only happen if there is a programming error) or if the value exceeds the range
  160. of an \fBint64_t\fR type.
  161. .PP
  162. \&\fBBN_to_ASN1_INTEGER()\fR and \fBBN_to_ASN1_ENUMERATED()\fR return an \fBASN1_INTEGER\fR or
  163. \&\fBASN1_ENUMERATED\fR structure respectively or NULL if an error occurs. They will
  164. only fail due to a memory allocation error.
  165. .PP
  166. \&\fBASN1_INTEGER_to_BN()\fR and \fBASN1_ENUMERATED_to_BN()\fR return a \fBBIGNUM\fR structure
  167. of NULL if an error occurs. They can fail if the passed type is incorrect
  168. (due to programming error) or due to a memory allocation failure.
  169. .SH "SEE ALSO"
  170. .IX Header "SEE ALSO"
  171. \&\fBERR_get_error\fR\|(3)
  172. .SH HISTORY
  173. .IX Header "HISTORY"
  174. \&\fBASN1_INTEGER_set_int64()\fR, \fBASN1_INTEGER_get_int64()\fR,
  175. \&\fBASN1_ENUMERATED_set_int64()\fR and \fBASN1_ENUMERATED_get_int64()\fR
  176. were added in OpenSSL 1.1.0.
  177. .SH COPYRIGHT
  178. .IX Header "COPYRIGHT"
  179. Copyright 2015\-2020 The OpenSSL Project Authors. All Rights Reserved.
  180. .PP
  181. Licensed under the Apache License 2.0 (the "License"). You may not use
  182. this file except in compliance with the License. You can obtain a copy
  183. in the file LICENSE in the source distribution or at
  184. <https://www.openssl.org/source/license.html>.