diff options
author | schwarze <> | 2020-06-24 17:00:38 +0000 |
---|---|---|
committer | schwarze <> | 2020-06-24 17:00:38 +0000 |
commit | 6d11d9e45909678859ee8e9429bd486185758061 (patch) | |
tree | 98f1c89402251d8c4050718e99264826edb74efa | |
parent | 0957e35e584e81a70ad31e3756c631131ed5bba9 (diff) | |
download | openbsd-6d11d9e45909678859ee8e9429bd486185758061.tar.gz openbsd-6d11d9e45909678859ee8e9429bd486185758061.tar.bz2 openbsd-6d11d9e45909678859ee8e9429bd486185758061.zip |
new manual page ChaCha(3);
OK tb@
-rw-r--r-- | src/lib/libcrypto/man/ChaCha.3 | 253 | ||||
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/man/crypto.3 | 3 |
3 files changed, 257 insertions, 2 deletions
diff --git a/src/lib/libcrypto/man/ChaCha.3 b/src/lib/libcrypto/man/ChaCha.3 new file mode 100644 index 0000000000..909d8ca77d --- /dev/null +++ b/src/lib/libcrypto/man/ChaCha.3 | |||
@@ -0,0 +1,253 @@ | |||
1 | .\" $OpenBSD: ChaCha.3,v 1.1 2020/06/24 17:00:38 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2020 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: June 24 2020 $ | ||
18 | .Dt CHACHA 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm ChaCha_set_key , | ||
22 | .Nm ChaCha_set_iv , | ||
23 | .Nm ChaCha , | ||
24 | .Nm CRYPTO_chacha_20 , | ||
25 | .Nm CRYPTO_hchacha_20 , | ||
26 | .Nm CRYPTO_xchacha_20 | ||
27 | .Nd ChaCha20 stream cipher | ||
28 | .Sh SYNOPSIS | ||
29 | .In openssl/chacha.h | ||
30 | .Ft void | ||
31 | .Fo ChaCha_set_key | ||
32 | .Fa "ChaCha_ctx *ctx" | ||
33 | .Fa "const unsigned char *key" | ||
34 | .Fa "unsigned int keybits" | ||
35 | .Fc | ||
36 | .Ft void | ||
37 | .Fo ChaCha_set_iv | ||
38 | .Fa "ChaCha_ctx *ctx" | ||
39 | .Fa "const unsigned char *iv" | ||
40 | .Fa "const unsigned char *counter" | ||
41 | .Fc | ||
42 | .Ft void | ||
43 | .Fo ChaCha | ||
44 | .Fa "ChaCha_ctx *ctx" | ||
45 | .Fa "unsigned char *out" | ||
46 | .Fa "const unsigned char *in" | ||
47 | .Fa "size_t len" | ||
48 | .Fc | ||
49 | .Ft void | ||
50 | .Fo CRYPTO_chacha_20 | ||
51 | .Fa "unsigned char *out" | ||
52 | .Fa "const unsigned char *in" | ||
53 | .Fa "size_t len" | ||
54 | .Fa "const unsigned char key[32]" | ||
55 | .Fa "const unsigned char iv[8]" | ||
56 | .Fa "uint64_t counter" | ||
57 | .Fc | ||
58 | .Ft void | ||
59 | .Fo CRYPTO_hchacha_20 | ||
60 | .Fa "unsigned char out[32]" | ||
61 | .Fa "const unsigned char key[32]" | ||
62 | .Fa "const unsigned char iv[16]" | ||
63 | .Fc | ||
64 | .Ft void | ||
65 | .Fo CRYPTO_xchacha_20 | ||
66 | .Fa "unsigned char *out" | ||
67 | .Fa "const unsigned char *in" | ||
68 | .Fa "size_t len" | ||
69 | .Fa "const unsigned char key[32]" | ||
70 | .Fa "const unsigned char iv[24]" | ||
71 | .Fc | ||
72 | .Sh DESCRIPTION | ||
73 | These functions provide a low-level implementation | ||
74 | of the ChaCha stream cipher with 256 and 128 bit keys. | ||
75 | The number of rounds is hardcoded to 20; | ||
76 | variants with 8 or 12 rounds are not supported. | ||
77 | .Pp | ||
78 | Instead of using these functions directly, | ||
79 | application programs normally use the more portable | ||
80 | .Xr EVP_chacha20 3 | ||
81 | high-level interface. | ||
82 | .Pp | ||
83 | The ChaCha state is contained in the | ||
84 | .Vt ChaCha_ctx | ||
85 | structure and consists of sixteen 32-bit unsigned integers. | ||
86 | .Pp | ||
87 | For the recommended value of 256 | ||
88 | .Fa keybits , | ||
89 | .Fn ChaCha_set_key | ||
90 | copies 32 bytes (256 bits) from | ||
91 | .Fa key | ||
92 | to the middle eight integers of the ChaCha state, | ||
93 | using little endian order for each integer. | ||
94 | For the alternative value of 128 | ||
95 | .Fa keybits , | ||
96 | only 16 bytes (128 bits) are copied from | ||
97 | .Fa key | ||
98 | to the ChaCha state, but they are copied twice, | ||
99 | once to the second quarter and once to the third quarter. | ||
100 | The first quarter of the ChaCha state is set to four constant integers; | ||
101 | these constants differ depending on whether | ||
102 | .Fa keybits | ||
103 | is 128 or 256. | ||
104 | The last quarter of the ChaCha state remains unchanged. | ||
105 | .Pp | ||
106 | .Fn ChaCha_set_iv | ||
107 | copies eight bytes (64 bits) from | ||
108 | .Fa counter | ||
109 | and eight bytes (64 bits) from | ||
110 | .Fa iv | ||
111 | to the last quarter of the ChaCha state, the counter to the first | ||
112 | two integers and the initialization vector to the last two integers, | ||
113 | again in little endian order. | ||
114 | If | ||
115 | .Fa counter | ||
116 | is | ||
117 | .Dv NULL , | ||
118 | the two respective integers are set to 0 instead. | ||
119 | The first three quarters of the ChaCha state remain unchanged. | ||
120 | .Pp | ||
121 | .Fn ChaCha | ||
122 | encrypts | ||
123 | .Fa len | ||
124 | bytes of data from | ||
125 | .Fa in | ||
126 | to | ||
127 | .Fa out | ||
128 | using the | ||
129 | .Fa ctx | ||
130 | that was previously set up with | ||
131 | .Fn ChaCha_set_key | ||
132 | and | ||
133 | .Fn ChaCha_set_iv . | ||
134 | Providing an | ||
135 | .Fa out | ||
136 | buffer of at least | ||
137 | .Fa len | ||
138 | bytes is the responsibility of the caller. | ||
139 | This function can be called multiple times in a row with varying | ||
140 | .Fa len | ||
141 | arguments. | ||
142 | The | ||
143 | .Fa len | ||
144 | does not need to be a multiple of 64. | ||
145 | .Pp | ||
146 | .Fn CRYPTO_chacha_20 | ||
147 | encrypts | ||
148 | .Fa len | ||
149 | bytes of data from | ||
150 | .Fa in | ||
151 | to | ||
152 | .Fa out | ||
153 | in a one-shot operation, using the given | ||
154 | .Fa key | ||
155 | and | ||
156 | .Fa iv | ||
157 | as described for | ||
158 | .Fn ChaCha_set_key | ||
159 | and | ||
160 | .Fn ChaCha_set_iv | ||
161 | and copying the less significant half of | ||
162 | .Fa counter | ||
163 | to the first counter integer in the initial ChaCha state | ||
164 | and the more significant half to the second integer. | ||
165 | Providing an | ||
166 | .Fa out | ||
167 | buffer of at least | ||
168 | .Fa len | ||
169 | bytes is again the responsibility of the caller. | ||
170 | The maximum supported value for | ||
171 | .Fa len | ||
172 | is 2^32 \- 1. | ||
173 | .Pp | ||
174 | XChaCha is a variant of ChaCha designed to support longer nonces, | ||
175 | just like XSalsa20 is a variant of Salsa20 supporting longer nonces. | ||
176 | .Pp | ||
177 | .Fn CRYPTO_xchacha_20 | ||
178 | encrypts | ||
179 | .Fa len | ||
180 | bytes of data from | ||
181 | .Fa in | ||
182 | to | ||
183 | .Fa out | ||
184 | in a one-shot operation with the XChaCha algorithm, using the given | ||
185 | .Fa key | ||
186 | and | ||
187 | .Fa iv . | ||
188 | It is equivalent to | ||
189 | .Fn CRYPTO_chacha_20 | ||
190 | with the last third of | ||
191 | .Fa iv , | ||
192 | a | ||
193 | .Fa counter | ||
194 | of 0, and a key generated with | ||
195 | .Fn CRYPTO_hchacha_20 | ||
196 | from the first two thirds of | ||
197 | .Fa iv . | ||
198 | .Sh SEE ALSO | ||
199 | .Xr crypto 3 , | ||
200 | .Xr EVP_chacha20 3 | ||
201 | .Rs | ||
202 | .%A Daniel J. Bernstein | ||
203 | .%T ChaCha, a variant of Salsa20 | ||
204 | .%U http://cr.yp.to/chacha/chacha-20080128.pdf | ||
205 | .%C Chicago | ||
206 | .%D January 28, 2008 | ||
207 | .Re | ||
208 | .Rs | ||
209 | .%A Daniel J. Bernstein | ||
210 | .%T Extending the Salsa20 nonce | ||
211 | .%U https://cr.yp.to/snuffle/xsalsa-20110204.pdf | ||
212 | .%C Chicago | ||
213 | .%D August 22, 2017 | ||
214 | .Re | ||
215 | .Sh STANDARDS | ||
216 | RFC 8439: ChaCha20 and Poly1305 for IETF Protocols | ||
217 | .Pp | ||
218 | Note that the standard specifies | ||
219 | a 32 bit counter and a 96 bit initialization vector whereas | ||
220 | this implementation follows Bernstein's original specification | ||
221 | and uses a 64 bit counter and a 64 bit initialization vector. | ||
222 | .Pp | ||
223 | These functions are specific to LibreSSL and not provided by OpenSSL. | ||
224 | BoringSSL does provide | ||
225 | .Fn CRYPTO_chacha_20 , | ||
226 | but with an incompatible interface, taking a 96 bit | ||
227 | .Fa iv | ||
228 | and a 32 bit | ||
229 | .Fa counter . | ||
230 | .Sh HISTORY | ||
231 | .Fn ChaCha_set_key , | ||
232 | .Fn ChaCha_set_iv , | ||
233 | .Fn ChaCha , | ||
234 | and | ||
235 | .Fn CRYPTO_chacha_20 | ||
236 | first appeared in | ||
237 | .Ox 5.6 . | ||
238 | .\" Committed on May 1, 2014. | ||
239 | .\" BoringSSL added CRYPTO_chacha_20 on June 20, 2014. | ||
240 | .Pp | ||
241 | .Fn CRYPTO_hchacha_20 | ||
242 | and | ||
243 | .Fn CRYPTO_xchacha_20 | ||
244 | first appeared in | ||
245 | .Ox 6.5 . | ||
246 | .Sh AUTHORS | ||
247 | .An -nosplit | ||
248 | This implementation was written by | ||
249 | .An Daniel J. Bernstein Aq Mt djb@cr.yp.to . | ||
250 | The API layer was added by | ||
251 | .An Joel Sing Aq Mt jsing@openbsd.org | ||
252 | for ChaCha, and for XChaCha by | ||
253 | .An David Gwynne Aq Mt dlg@openbsd.org . | ||
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index de6e446f2f..8114f5b96b 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.169 2020/06/24 16:06:26 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.170 2020/06/24 17:00:38 schwarze Exp $ |
2 | 2 | ||
3 | .include <bsd.own.mk> | 3 | .include <bsd.own.mk> |
4 | 4 | ||
@@ -92,6 +92,7 @@ MAN= \ | |||
92 | CRYPTO_lock.3 \ | 92 | CRYPTO_lock.3 \ |
93 | CRYPTO_memcmp.3 \ | 93 | CRYPTO_memcmp.3 \ |
94 | CRYPTO_set_ex_data.3 \ | 94 | CRYPTO_set_ex_data.3 \ |
95 | ChaCha.3 \ | ||
95 | DES_set_key.3 \ | 96 | DES_set_key.3 \ |
96 | DH_generate_key.3 \ | 97 | DH_generate_key.3 \ |
97 | DH_generate_parameters.3 \ | 98 | DH_generate_parameters.3 \ |
diff --git a/src/lib/libcrypto/man/crypto.3 b/src/lib/libcrypto/man/crypto.3 index 9f29698e80..6e98f643de 100644 --- a/src/lib/libcrypto/man/crypto.3 +++ b/src/lib/libcrypto/man/crypto.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: crypto.3,v 1.24 2020/06/24 16:06:27 schwarze Exp $ | 1 | .\" $OpenBSD: crypto.3,v 1.25 2020/06/24 17:00:38 schwarze Exp $ |
2 | .\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100 | 2 | .\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100 |
3 | .\" | 3 | .\" |
4 | .\" This file was written by Ulf Moeller <ulf@openssl.org> and | 4 | .\" This file was written by Ulf Moeller <ulf@openssl.org> and |
@@ -69,6 +69,7 @@ are provided by the generic interface | |||
69 | Low-level stand-alone interfaces include | 69 | Low-level stand-alone interfaces include |
70 | .Xr AES_encrypt 3 , | 70 | .Xr AES_encrypt 3 , |
71 | .Xr BF_set_key 3 , | 71 | .Xr BF_set_key 3 , |
72 | .Xr ChaCha 3 , | ||
72 | .Xr DES_set_key 3 , | 73 | .Xr DES_set_key 3 , |
73 | and | 74 | and |
74 | .Xr RC4 3 . | 75 | .Xr RC4 3 . |