BN_BLINDING_new.3ossl 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 "BN_BLINDING_NEW 3ossl"
  58. .TH BN_BLINDING_NEW 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. BN_BLINDING_new, BN_BLINDING_free, BN_BLINDING_update, BN_BLINDING_convert,
  65. BN_BLINDING_invert, BN_BLINDING_convert_ex, BN_BLINDING_invert_ex,
  66. BN_BLINDING_is_current_thread, BN_BLINDING_set_current_thread,
  67. BN_BLINDING_lock, BN_BLINDING_unlock, BN_BLINDING_get_flags,
  68. BN_BLINDING_set_flags, BN_BLINDING_create_param \- blinding related BIGNUM functions
  69. .SH SYNOPSIS
  70. .IX Header "SYNOPSIS"
  71. .Vb 1
  72. \& #include <openssl/bn.h>
  73. \&
  74. \& BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai,
  75. \& BIGNUM *mod);
  76. \& void BN_BLINDING_free(BN_BLINDING *b);
  77. \& int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);
  78. \& int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
  79. \& int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
  80. \& int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b,
  81. \& BN_CTX *ctx);
  82. \& int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
  83. \& BN_CTX *ctx);
  84. \& int BN_BLINDING_is_current_thread(BN_BLINDING *b);
  85. \& void BN_BLINDING_set_current_thread(BN_BLINDING *b);
  86. \& int BN_BLINDING_lock(BN_BLINDING *b);
  87. \& int BN_BLINDING_unlock(BN_BLINDING *b);
  88. \& unsigned long BN_BLINDING_get_flags(const BN_BLINDING *b);
  89. \& void BN_BLINDING_set_flags(BN_BLINDING *b, unsigned long flags);
  90. \& BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
  91. \& const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
  92. \& int (*bn_mod_exp)(BIGNUM *r,
  93. \& const BIGNUM *a,
  94. \& const BIGNUM *p,
  95. \& const BIGNUM *m,
  96. \& BN_CTX *ctx,
  97. \& BN_MONT_CTX *m_ctx),
  98. \& BN_MONT_CTX *m_ctx);
  99. .Ve
  100. .SH DESCRIPTION
  101. .IX Header "DESCRIPTION"
  102. \&\fBBN_BLINDING_new()\fR allocates a new \fBBN_BLINDING\fR structure and copies
  103. the \fBA\fR and \fBAi\fR values into the newly created \fBBN_BLINDING\fR object.
  104. .PP
  105. \&\fBBN_BLINDING_free()\fR frees the \fBBN_BLINDING\fR structure.
  106. If \fBb\fR is NULL, nothing is done.
  107. .PP
  108. \&\fBBN_BLINDING_update()\fR updates the \fBBN_BLINDING\fR parameters by squaring
  109. the \fBA\fR and \fBAi\fR or, after specific number of uses and if the
  110. necessary parameters are set, by re-creating the blinding parameters.
  111. .PP
  112. \&\fBBN_BLINDING_convert_ex()\fR multiplies \fBn\fR with the blinding factor \fBA\fR.
  113. If \fBr\fR is not NULL a copy the inverse blinding factor \fBAi\fR will be
  114. returned in \fBr\fR (this is useful if a \fBRSA\fR object is shared among
  115. several threads). \fBBN_BLINDING_invert_ex()\fR multiplies \fBn\fR with the
  116. inverse blinding factor \fBAi\fR. If \fBr\fR is not NULL it will be used as
  117. the inverse blinding.
  118. .PP
  119. \&\fBBN_BLINDING_convert()\fR and \fBBN_BLINDING_invert()\fR are wrapper
  120. functions for \fBBN_BLINDING_convert_ex()\fR and \fBBN_BLINDING_invert_ex()\fR
  121. with \fBr\fR set to NULL.
  122. .PP
  123. \&\fBBN_BLINDING_is_current_thread()\fR returns whether the \fBBN_BLINDING\fR
  124. structure is owned by the current thread. This is to help users
  125. provide proper locking if needed for multi-threaded use.
  126. .PP
  127. \&\fBBN_BLINDING_set_current_thread()\fR sets the current thread as the
  128. owner of the \fBBN_BLINDING\fR structure.
  129. .PP
  130. \&\fBBN_BLINDING_lock()\fR locks the \fBBN_BLINDING\fR structure.
  131. .PP
  132. \&\fBBN_BLINDING_unlock()\fR unlocks the \fBBN_BLINDING\fR structure.
  133. .PP
  134. \&\fBBN_BLINDING_get_flags()\fR returns the BN_BLINDING flags. Currently
  135. there are two supported flags: \fBBN_BLINDING_NO_UPDATE\fR and
  136. \&\fBBN_BLINDING_NO_RECREATE\fR. \fBBN_BLINDING_NO_UPDATE\fR inhibits the
  137. automatic update of the \fBBN_BLINDING\fR parameters after each use
  138. and \fBBN_BLINDING_NO_RECREATE\fR inhibits the automatic re-creation
  139. of the \fBBN_BLINDING\fR parameters after a fixed number of uses (currently
  140. 32). In newly allocated \fBBN_BLINDING\fR objects no flags are set.
  141. \&\fBBN_BLINDING_set_flags()\fR sets the \fBBN_BLINDING\fR parameters flags.
  142. .PP
  143. \&\fBBN_BLINDING_create_param()\fR creates new \fBBN_BLINDING\fR parameters
  144. using the exponent \fBe\fR and the modulus \fBm\fR. \fBbn_mod_exp\fR and
  145. \&\fBm_ctx\fR can be used to pass special functions for exponentiation
  146. (normally \fBBN_mod_exp_mont()\fR and \fBBN_MONT_CTX\fR).
  147. .SH "RETURN VALUES"
  148. .IX Header "RETURN VALUES"
  149. \&\fBBN_BLINDING_new()\fR returns the newly allocated \fBBN_BLINDING\fR structure
  150. or NULL in case of an error.
  151. .PP
  152. \&\fBBN_BLINDING_update()\fR, \fBBN_BLINDING_convert()\fR, \fBBN_BLINDING_invert()\fR,
  153. \&\fBBN_BLINDING_convert_ex()\fR and \fBBN_BLINDING_invert_ex()\fR return 1 on
  154. success and 0 if an error occurred.
  155. .PP
  156. \&\fBBN_BLINDING_is_current_thread()\fR returns 1 if the current thread owns
  157. the \fBBN_BLINDING\fR object, 0 otherwise.
  158. .PP
  159. \&\fBBN_BLINDING_set_current_thread()\fR doesn't return anything.
  160. .PP
  161. \&\fBBN_BLINDING_lock()\fR, \fBBN_BLINDING_unlock()\fR return 1 if the operation
  162. succeeded or 0 on error.
  163. .PP
  164. \&\fBBN_BLINDING_get_flags()\fR returns the currently set \fBBN_BLINDING\fR flags
  165. (a \fBunsigned long\fR value).
  166. .PP
  167. \&\fBBN_BLINDING_create_param()\fR returns the newly created \fBBN_BLINDING\fR
  168. parameters or NULL on error.
  169. .SH HISTORY
  170. .IX Header "HISTORY"
  171. \&\fBBN_BLINDING_thread_id()\fR was first introduced in OpenSSL 1.0.0, and it
  172. deprecates \fBBN_BLINDING_set_thread_id()\fR and \fBBN_BLINDING_get_thread_id()\fR.
  173. .SH COPYRIGHT
  174. .IX Header "COPYRIGHT"
  175. Copyright 2005\-2017 The OpenSSL Project Authors. All Rights Reserved.
  176. .PP
  177. Licensed under the Apache License 2.0 (the "License"). You may not use
  178. this file except in compliance with the License. You can obtain a copy
  179. in the file LICENSE in the source distribution or at
  180. <https://www.openssl.org/source/license.html>.