diff options
author | schwarze <> | 2022-11-15 17:55:00 +0000 |
---|---|---|
committer | schwarze <> | 2022-11-15 17:55:00 +0000 |
commit | 577b016c5bd66bca55e18700f981fc0cbe1aecde (patch) | |
tree | 383ce3a0faca54105da3387012d08580ab014bf1 /src/lib/libcrypto/man/BN_mod_sqrt.3 | |
parent | d1754918c3f3852e6b8e9c7bad5f8fa171ba8718 (diff) | |
download | openbsd-577b016c5bd66bca55e18700f981fc0cbe1aecde.tar.gz openbsd-577b016c5bd66bca55e18700f981fc0cbe1aecde.tar.bz2 openbsd-577b016c5bd66bca55e18700f981fc0cbe1aecde.zip |
document BN_mod_sqrt(3)
Diffstat (limited to 'src/lib/libcrypto/man/BN_mod_sqrt.3')
-rw-r--r-- | src/lib/libcrypto/man/BN_mod_sqrt.3 | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_mod_sqrt.3 b/src/lib/libcrypto/man/BN_mod_sqrt.3 new file mode 100644 index 0000000000..a3f84e5519 --- /dev/null +++ b/src/lib/libcrypto/man/BN_mod_sqrt.3 | |||
@@ -0,0 +1,111 @@ | |||
1 | .\" $OpenBSD: BN_mod_sqrt.3,v 1.1 2022/11/15 17:55:00 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .\" | ||
17 | .Dd $Mdocdate: November 15 2022 $ | ||
18 | .Dt BN_MOD_SQRT 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm BN_mod_sqrt | ||
22 | .Nd square root in a prime field | ||
23 | .Sh SYNOPSIS | ||
24 | .In openssl/bn.h | ||
25 | .Ft BIGNUM * | ||
26 | .Fo BN_mod_sqrt | ||
27 | .Fa "BIGNUM *r" | ||
28 | .Fa "const BIGNUM *a" | ||
29 | .Fa "const BIGNUM *p" | ||
30 | .Fa "BN_CTX *ctx" | ||
31 | .Fc | ||
32 | .Sh DESCRIPTION | ||
33 | .Fn BN_mod_sqrt | ||
34 | solves | ||
35 | .Bd -unfilled -offset indent | ||
36 | .EQ | ||
37 | r sup 2 == a ( roman mod p ) | ||
38 | .EN | ||
39 | .Ed | ||
40 | .Pp | ||
41 | for | ||
42 | .Fa r | ||
43 | in the prime field of characteristic | ||
44 | .Fa p | ||
45 | using the Tonelli-Shanks algorithm if needed | ||
46 | and places one of the two solutions into | ||
47 | .Fa r . | ||
48 | The other solution is | ||
49 | .Fa p | ||
50 | \- | ||
51 | .Fa r . | ||
52 | .Pp | ||
53 | The argument | ||
54 | .Fa p | ||
55 | is expected to be a prime number. | ||
56 | .Sh RETURN VALUES | ||
57 | In case of success, | ||
58 | .Fn BN_mod_sqrt | ||
59 | returns | ||
60 | .Fa r , | ||
61 | or a newly allocated | ||
62 | .Vt BIGNUM | ||
63 | object if the | ||
64 | .Fa r | ||
65 | argument is | ||
66 | .Dv NULL . | ||
67 | .Pp | ||
68 | In case of failure, | ||
69 | .Dv NULL | ||
70 | is returned. | ||
71 | This for example happens if | ||
72 | .Fa a | ||
73 | is not a quadratic residue or if memory allocation fails. | ||
74 | .Sh SEE ALSO | ||
75 | .Xr BN_CTX_new 3 , | ||
76 | .Xr BN_kronecker 3 , | ||
77 | .Xr BN_mod_sqr 3 , | ||
78 | .Xr BN_new 3 | ||
79 | .Rs | ||
80 | .%A Henri Cohen | ||
81 | .%B A Course in Computational Algebraic Number Theory | ||
82 | .%I Springer | ||
83 | .%C Berlin | ||
84 | .%D 1993 | ||
85 | .%O Algorithm 1.5.1 | ||
86 | .Re | ||
87 | .Sh HISTORY | ||
88 | .Fn BN_mod_sqrt | ||
89 | first appeared in OpenSSL 0.9.7 and has been available since | ||
90 | .Ox 3.2 . | ||
91 | .Sh CAVEATS | ||
92 | If | ||
93 | .Fa p | ||
94 | is not prime, | ||
95 | .Fn BN_mod_sqrt | ||
96 | may succeed or fail. | ||
97 | If it succeeds, the square of the returned value is congruent to | ||
98 | .Fa a | ||
99 | modulo | ||
100 | .Fa p . | ||
101 | If it fails, the reason reported by | ||
102 | .Xr ERR_get_error 3 | ||
103 | is often misleading. | ||
104 | In particular, even if | ||
105 | .Fa a | ||
106 | is a perfect square, | ||
107 | .Fn BN_mod_sqrt | ||
108 | often reports | ||
109 | .Dq not a square | ||
110 | instead of | ||
111 | .Dq p is not prime . | ||