diff options
Diffstat (limited to 'src/lib/libcrypto/man/BN_mod_mul_reciprocal.3')
| -rw-r--r-- | src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 new file mode 100644 index 0000000000..ceb1ffae5b --- /dev/null +++ b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 | |||
| @@ -0,0 +1,147 @@ | |||
| 1 | .Dd $Mdocdate: February 23 2015 $ | ||
| 2 | .Dt BN_MOD_MUL_RECIPROCAL 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm BN_mod_mul_reciprocal , | ||
| 6 | .Nm BN_div_recp , | ||
| 7 | .Nm BN_RECP_CTX_new , | ||
| 8 | .Nm BN_RECP_CTX_init , | ||
| 9 | .Nm BN_RECP_CTX_free , | ||
| 10 | .Nm BN_RECP_CTX_set | ||
| 11 | .Nd modular multiplication using reciprocal | ||
| 12 | .Sh SYNOPSIS | ||
| 13 | .In openssl/bn.h | ||
| 14 | .Ft BN_RECP_CTX * | ||
| 15 | .Fo BN_RECP_CTX_new | ||
| 16 | .Fa void | ||
| 17 | .Fc | ||
| 18 | .Ft void | ||
| 19 | .Fo BN_RECP_CTX_init | ||
| 20 | .Fa "BN_RECP_CTX *recp" | ||
| 21 | .Fc | ||
| 22 | .Ft void | ||
| 23 | .Fo BN_RECP_CTX_free | ||
| 24 | .Fa "BN_RECP_CTX *recp" | ||
| 25 | .Fc | ||
| 26 | .Ft int | ||
| 27 | .Fo BN_RECP_CTX_set | ||
| 28 | .Fa "BN_RECP_CTX *recp" | ||
| 29 | .Fa "const BIGNUM *m" | ||
| 30 | .Fa "BN_CTX *ctx" | ||
| 31 | .Fc | ||
| 32 | .Ft int | ||
| 33 | .Fo BN_div_recp | ||
| 34 | .Fa "BIGNUM *dv" | ||
| 35 | .Fa "BIGNUM *rem" | ||
| 36 | .Fa "BIGNUM *a" | ||
| 37 | .Fa "BN_RECP_CTX *recp" | ||
| 38 | .Fa "BN_CTX *ctx" | ||
| 39 | .Fc | ||
| 40 | .Ft int | ||
| 41 | .Fo BN_mod_mul_reciprocal | ||
| 42 | .Fa "BIGNUM *r" | ||
| 43 | .Fa "BIGNUM *a" | ||
| 44 | .Fa "BIGNUM *b" | ||
| 45 | .Fa "BN_RECP_CTX *recp" | ||
| 46 | .Fa "BN_CTX *ctx" | ||
| 47 | .Fc | ||
| 48 | .Sh DESCRIPTION | ||
| 49 | .Fn BN_mod_mul_reciprocal | ||
| 50 | can be used to perform an efficient | ||
| 51 | .Xr BN_mod_mul 3 | ||
| 52 | operation when the operation will be performed repeatedly with the same | ||
| 53 | modulus. | ||
| 54 | It computes | ||
| 55 | .Fa r Ns =( Ns Fa a Ns * Ns Fa b Ns )% Ns Fa m | ||
| 56 | using | ||
| 57 | .Fa recp Ns =1/ Ns Fa m , | ||
| 58 | which is set as described below. | ||
| 59 | .Fa ctx | ||
| 60 | is a previously allocated | ||
| 61 | .Vt BN_CTX | ||
| 62 | used for temporary variables. | ||
| 63 | .Pp | ||
| 64 | .Fn BN_RECP_CTX_new | ||
| 65 | allocates and initializes a | ||
| 66 | .Vt BN_RECP_CTX | ||
| 67 | structure. | ||
| 68 | .Fn BN_RECP_CTX_init | ||
| 69 | initializes an existing uninitialized | ||
| 70 | .Vt BN_RECP_CTX . | ||
| 71 | .Pp | ||
| 72 | .Fn BN_RECP_CTX_free | ||
| 73 | frees the components of the | ||
| 74 | .Vt BN_RECP_CTX , | ||
| 75 | and, if it was created by | ||
| 76 | .Fn BN_RECP_CTX_new , | ||
| 77 | also the structure itself. | ||
| 78 | .Pp | ||
| 79 | .Fn BN_RECP_CTX_set | ||
| 80 | stores | ||
| 81 | .Fa m | ||
| 82 | in | ||
| 83 | .Fa recp | ||
| 84 | and sets it up for computing | ||
| 85 | .Pf 1/ Fa m | ||
| 86 | and shifting it left by | ||
| 87 | .Fn BN_num_bits m Ns +1 | ||
| 88 | to make it an integer. | ||
| 89 | The result and the number of bits it was shifted left will later be | ||
| 90 | stored in | ||
| 91 | .Fa recp . | ||
| 92 | .Pp | ||
| 93 | .Fn BN_div_recp | ||
| 94 | divides | ||
| 95 | .Fa a | ||
| 96 | by | ||
| 97 | .Fa m | ||
| 98 | using | ||
| 99 | .Fa recp . | ||
| 100 | It places the quotient in | ||
| 101 | .Fa dv | ||
| 102 | and the remainder in | ||
| 103 | .Fa rem . | ||
| 104 | .Pp | ||
| 105 | The | ||
| 106 | .Vt BN_RECP_CTX | ||
| 107 | structure is defined as follows: | ||
| 108 | .Bd -literal | ||
| 109 | typedef struct bn_recp_ctx_st { | ||
| 110 | BIGNUM N; /* the divisor */ | ||
| 111 | BIGNUM Nr; /* the reciprocal */ | ||
| 112 | int num_bits; | ||
| 113 | int shift; | ||
| 114 | int flags; | ||
| 115 | } BN_RECP_CTX; | ||
| 116 | .Ed | ||
| 117 | .Pp | ||
| 118 | It cannot be shared between threads. | ||
| 119 | .Sh RETURN VALUES | ||
| 120 | .Fn BN_RECP_CTX_new | ||
| 121 | returns the newly allocated | ||
| 122 | .Vt BN_RECP_CTX , | ||
| 123 | or | ||
| 124 | .Dv NULL | ||
| 125 | on error. | ||
| 126 | .Pp | ||
| 127 | .Fn BN_RECP_CTX_init | ||
| 128 | and | ||
| 129 | .Fn BN_RECP_CTX_free | ||
| 130 | return no values. | ||
| 131 | .Pp | ||
| 132 | For the other functions, 1 is returned for success, 0 on error. | ||
| 133 | The error codes can be obtained by | ||
| 134 | .Xr ERR_get_error 3 . | ||
| 135 | .Sh SEE ALSO | ||
| 136 | .Xr bn 3 , | ||
| 137 | .Xr BN_add 3 , | ||
| 138 | .Xr BN_CTX_new 3 , | ||
| 139 | .Xr ERR_get_error 3 | ||
| 140 | .Sh HISTORY | ||
| 141 | .Vt BN_RECP_CTX | ||
| 142 | was added in SSLeay 0.9.0. | ||
| 143 | Before that, a function | ||
| 144 | .Fn BN_reciprocal | ||
| 145 | was used instead, and the | ||
| 146 | .Fn BN_mod_mul_reciprocal | ||
| 147 | arguments were different. | ||
