diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/doc/DES_set_key.pod | 339 | ||||
| -rw-r--r-- | src/lib/libcrypto/doc/DH_generate_key.pod | 51 | ||||
| -rw-r--r-- | src/lib/libcrypto/doc/DH_generate_parameters.pod | 80 | ||||
| -rw-r--r-- | src/lib/libcrypto/doc/DH_get_ex_new_index.pod | 37 | ||||
| -rw-r--r-- | src/lib/libcrypto/doc/DH_new.pod | 38 | ||||
| -rw-r--r-- | src/lib/libcrypto/doc/DH_set_method.pod | 129 | ||||
| -rw-r--r-- | src/lib/libcrypto/doc/DH_size.pod | 33 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DES_set_key.3 | 697 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DH_generate_key.3 | 71 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DH_generate_parameters.3 | 125 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DH_get_ex_new_index.3 | 47 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DH_new.3 | 44 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DH_set_method.3 | 223 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/DH_size.3 | 29 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/Makefile | 16 |
15 files changed, 1244 insertions, 715 deletions
diff --git a/src/lib/libcrypto/doc/DES_set_key.pod b/src/lib/libcrypto/doc/DES_set_key.pod deleted file mode 100644 index d1bd43c592..0000000000 --- a/src/lib/libcrypto/doc/DES_set_key.pod +++ /dev/null | |||
| @@ -1,339 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked, | ||
| 6 | DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key, | ||
| 7 | DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt, | ||
| 8 | DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt, | ||
| 9 | DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt, | ||
| 10 | DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt, | ||
| 11 | DES_ede3_cbcm_encrypt, DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt, | ||
| 12 | DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys, | ||
| 13 | DES_fcrypt, DES_crypt, DES_enc_read, DES_enc_write - DES encryption | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | #include <openssl/des.h> | ||
| 18 | |||
| 19 | void DES_random_key(DES_cblock *ret); | ||
| 20 | |||
| 21 | int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); | ||
| 22 | int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); | ||
| 23 | int DES_set_key_checked(const_DES_cblock *key, | ||
| 24 | DES_key_schedule *schedule); | ||
| 25 | void DES_set_key_unchecked(const_DES_cblock *key, | ||
| 26 | DES_key_schedule *schedule); | ||
| 27 | |||
| 28 | void DES_set_odd_parity(DES_cblock *key); | ||
| 29 | int DES_is_weak_key(const_DES_cblock *key); | ||
| 30 | |||
| 31 | void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, | ||
| 32 | DES_key_schedule *ks, int enc); | ||
| 33 | void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output, | ||
| 34 | DES_key_schedule *ks1, DES_key_schedule *ks2, int enc); | ||
| 35 | void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, | ||
| 36 | DES_key_schedule *ks1, DES_key_schedule *ks2, | ||
| 37 | DES_key_schedule *ks3, int enc); | ||
| 38 | |||
| 39 | void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, | ||
| 40 | long length, DES_key_schedule *schedule, DES_cblock *ivec, | ||
| 41 | int enc); | ||
| 42 | void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, | ||
| 43 | int numbits, long length, DES_key_schedule *schedule, | ||
| 44 | DES_cblock *ivec, int enc); | ||
| 45 | void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, | ||
| 46 | int numbits, long length, DES_key_schedule *schedule, | ||
| 47 | DES_cblock *ivec); | ||
| 48 | void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, | ||
| 49 | long length, DES_key_schedule *schedule, DES_cblock *ivec, | ||
| 50 | int enc); | ||
| 51 | void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, | ||
| 52 | long length, DES_key_schedule *schedule, DES_cblock *ivec, | ||
| 53 | int *num, int enc); | ||
| 54 | void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, | ||
| 55 | long length, DES_key_schedule *schedule, DES_cblock *ivec, | ||
| 56 | int *num); | ||
| 57 | |||
| 58 | void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, | ||
| 59 | long length, DES_key_schedule *schedule, DES_cblock *ivec, | ||
| 60 | const_DES_cblock *inw, const_DES_cblock *outw, int enc); | ||
| 61 | |||
| 62 | void DES_ede2_cbc_encrypt(const unsigned char *input, | ||
| 63 | unsigned char *output, long length, DES_key_schedule *ks1, | ||
| 64 | DES_key_schedule *ks2, DES_cblock *ivec, int enc); | ||
| 65 | void DES_ede2_cfb64_encrypt(const unsigned char *in, | ||
| 66 | unsigned char *out, long length, DES_key_schedule *ks1, | ||
| 67 | DES_key_schedule *ks2, DES_cblock *ivec, int *num, int enc); | ||
| 68 | void DES_ede2_ofb64_encrypt(const unsigned char *in, | ||
| 69 | unsigned char *out, long length, DES_key_schedule *ks1, | ||
| 70 | DES_key_schedule *ks2, DES_cblock *ivec, int *num); | ||
| 71 | |||
| 72 | void DES_ede3_cbc_encrypt(const unsigned char *input, | ||
| 73 | unsigned char *output, long length, DES_key_schedule *ks1, | ||
| 74 | DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, | ||
| 75 | int enc); | ||
| 76 | void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, | ||
| 77 | long length, DES_key_schedule *ks1, DES_key_schedule *ks2, | ||
| 78 | DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2, | ||
| 79 | int enc); | ||
| 80 | void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, | ||
| 81 | long length, DES_key_schedule *ks1, DES_key_schedule *ks2, | ||
| 82 | DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc); | ||
| 83 | void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, | ||
| 84 | long length, DES_key_schedule *ks1, | ||
| 85 | DES_key_schedule *ks2, DES_key_schedule *ks3, | ||
| 86 | DES_cblock *ivec, int *num); | ||
| 87 | |||
| 88 | DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, | ||
| 89 | long length, DES_key_schedule *schedule, | ||
| 90 | const_DES_cblock *ivec); | ||
| 91 | DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], | ||
| 92 | long length, int out_count, DES_cblock *seed); | ||
| 93 | void DES_string_to_key(const char *str, DES_cblock *key); | ||
| 94 | void DES_string_to_2keys(const char *str, DES_cblock *key1, | ||
| 95 | DES_cblock *key2); | ||
| 96 | |||
| 97 | char *DES_fcrypt(const char *buf, const char *salt, char *ret); | ||
| 98 | char *DES_crypt(const char *buf, const char *salt); | ||
| 99 | |||
| 100 | int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, | ||
| 101 | DES_cblock *iv); | ||
| 102 | int DES_enc_write(int fd, const void *buf, int len, | ||
| 103 | DES_key_schedule *sched, DES_cblock *iv); | ||
| 104 | |||
| 105 | =head1 DESCRIPTION | ||
| 106 | |||
| 107 | This library contains a fast implementation of the DES encryption | ||
| 108 | algorithm. | ||
| 109 | |||
| 110 | There are two phases to the use of DES encryption. The first is the | ||
| 111 | generation of a I<DES_key_schedule> from a key, the second is the | ||
| 112 | actual encryption. A DES key is of type I<DES_cblock>. This type is | ||
| 113 | consists of 8 bytes with odd parity. The least significant bit in | ||
| 114 | each byte is the parity bit. The key schedule is an expanded form of | ||
| 115 | the key; it is used to speed the encryption process. | ||
| 116 | |||
| 117 | DES_random_key() generates a random key in odd parity. | ||
| 118 | |||
| 119 | Before a DES key can be used, it must be converted into the | ||
| 120 | architecture dependent I<DES_key_schedule> via the | ||
| 121 | DES_set_key_checked() or DES_set_key_unchecked() function. | ||
| 122 | |||
| 123 | DES_set_key_checked() will check that the key passed is of odd parity | ||
| 124 | and is not a week or semi-weak key. If the parity is wrong, then -1 | ||
| 125 | is returned. If the key is a weak key, then -2 is returned. If an | ||
| 126 | error is returned, the key schedule is not generated. | ||
| 127 | |||
| 128 | DES_set_key() works like | ||
| 129 | DES_set_key_checked() if the I<DES_check_key> flag is non-zero, | ||
| 130 | otherwise like DES_set_key_unchecked(). These functions are available | ||
| 131 | for compatibility; it is recommended to use a function that does not | ||
| 132 | depend on a global variable. | ||
| 133 | |||
| 134 | DES_set_odd_parity() sets the parity of the passed I<key> to odd. | ||
| 135 | |||
| 136 | DES_is_weak_key() returns 1 is the passed key is a weak key, 0 if it | ||
| 137 | is ok. | ||
| 138 | |||
| 139 | The following routines mostly operate on an input and output stream of | ||
| 140 | I<DES_cblock>s. | ||
| 141 | |||
| 142 | DES_ecb_encrypt() is the basic DES encryption routine that encrypts or | ||
| 143 | decrypts a single 8-byte I<DES_cblock> in I<electronic code book> | ||
| 144 | (ECB) mode. It always transforms the input data, pointed to by | ||
| 145 | I<input>, into the output data, pointed to by the I<output> argument. | ||
| 146 | If the I<encrypt> argument is non-zero (DES_ENCRYPT), the I<input> | ||
| 147 | (cleartext) is encrypted in to the I<output> (ciphertext) using the | ||
| 148 | key_schedule specified by the I<schedule> argument, previously set via | ||
| 149 | I<DES_set_key>. If I<encrypt> is zero (DES_DECRYPT), the I<input> (now | ||
| 150 | ciphertext) is decrypted into the I<output> (now cleartext). Input | ||
| 151 | and output may overlap. DES_ecb_encrypt() does not return a value. | ||
| 152 | |||
| 153 | DES_ecb3_encrypt() encrypts/decrypts the I<input> block by using | ||
| 154 | three-key Triple-DES encryption in ECB mode. This involves encrypting | ||
| 155 | the input with I<ks1>, decrypting with the key schedule I<ks2>, and | ||
| 156 | then encrypting with I<ks3>. This routine greatly reduces the chances | ||
| 157 | of brute force breaking of DES and has the advantage of if I<ks1>, | ||
| 158 | I<ks2> and I<ks3> are the same, it is equivalent to just encryption | ||
| 159 | using ECB mode and I<ks1> as the key. | ||
| 160 | |||
| 161 | The macro DES_ecb2_encrypt() is provided to perform two-key Triple-DES | ||
| 162 | encryption by using I<ks1> for the final encryption. | ||
| 163 | |||
| 164 | DES_ncbc_encrypt() encrypts/decrypts using the I<cipher-block-chaining> | ||
| 165 | (CBC) mode of DES. If the I<encrypt> argument is non-zero, the | ||
| 166 | routine cipher-block-chain encrypts the cleartext data pointed to by | ||
| 167 | the I<input> argument into the ciphertext pointed to by the I<output> | ||
| 168 | argument, using the key schedule provided by the I<schedule> argument, | ||
| 169 | and initialization vector provided by the I<ivec> argument. If the | ||
| 170 | I<length> argument is not an integral multiple of eight bytes, the | ||
| 171 | last block is copied to a temporary area and zero filled. The output | ||
| 172 | is always an integral multiple of eight bytes. | ||
| 173 | |||
| 174 | DES_xcbc_encrypt() is RSA's DESX mode of DES. It uses I<inw> and | ||
| 175 | I<outw> to 'whiten' the encryption. I<inw> and I<outw> are secret | ||
| 176 | (unlike the iv) and are as such, part of the key. So the key is sort | ||
| 177 | of 24 bytes. This is much better than CBC DES. | ||
| 178 | |||
| 179 | DES_ede3_cbc_encrypt() implements outer triple CBC DES encryption with | ||
| 180 | three keys. This means that each DES operation inside the CBC mode is | ||
| 181 | really an C<C=E(ks3,D(ks2,E(ks1,M)))>. This mode is used by SSL. | ||
| 182 | |||
| 183 | The DES_ede2_cbc_encrypt() macro implements two-key Triple-DES by | ||
| 184 | reusing I<ks1> for the final encryption. C<C=E(ks1,D(ks2,E(ks1,M)))>. | ||
| 185 | This form of Triple-DES is used by the RSAREF library. | ||
| 186 | |||
| 187 | DES_pcbc_encrypt() encrypt/decrypts using the propagating cipher block | ||
| 188 | chaining mode used by Kerberos v4. Its parameters are the same as | ||
| 189 | DES_ncbc_encrypt(). | ||
| 190 | |||
| 191 | DES_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This | ||
| 192 | method takes an array of characters as input and outputs and array of | ||
| 193 | characters. It does not require any padding to 8 character groups. | ||
| 194 | Note: the I<ivec> variable is changed and the new changed value needs to | ||
| 195 | be passed to the next call to this function. Since this function runs | ||
| 196 | a complete DES ECB encryption per I<numbits>, this function is only | ||
| 197 | suggested for use when sending small numbers of characters. | ||
| 198 | |||
| 199 | DES_cfb64_encrypt() | ||
| 200 | implements CFB mode of DES with 64bit feedback. Why is this | ||
| 201 | useful you ask? Because this routine will allow you to encrypt an | ||
| 202 | arbitrary number of bytes, no 8 byte padding. Each call to this | ||
| 203 | routine will encrypt the input bytes to output and then update ivec | ||
| 204 | and num. num contains 'how far' we are though ivec. If this does | ||
| 205 | not make much sense, read more about cfb mode of DES :-). | ||
| 206 | |||
| 207 | DES_ede3_cfb64_encrypt() and DES_ede2_cfb64_encrypt() is the same as | ||
| 208 | DES_cfb64_encrypt() except that Triple-DES is used. | ||
| 209 | |||
| 210 | DES_ofb_encrypt() encrypts using output feedback mode. This method | ||
| 211 | takes an array of characters as input and outputs and array of | ||
| 212 | characters. It does not require any padding to 8 character groups. | ||
| 213 | Note: the I<ivec> variable is changed and the new changed value needs to | ||
| 214 | be passed to the next call to this function. Since this function runs | ||
| 215 | a complete DES ECB encryption per numbits, this function is only | ||
| 216 | suggested for use when sending small numbers of characters. | ||
| 217 | |||
| 218 | DES_ofb64_encrypt() is the same as DES_cfb64_encrypt() using Output | ||
| 219 | Feed Back mode. | ||
| 220 | |||
| 221 | DES_ede3_ofb64_encrypt() and DES_ede2_ofb64_encrypt() is the same as | ||
| 222 | DES_ofb64_encrypt(), using Triple-DES. | ||
| 223 | |||
| 224 | The following functions are included in the DES library for | ||
| 225 | compatibility with the MIT Kerberos library. | ||
| 226 | |||
| 227 | DES_cbc_cksum() produces an 8 byte checksum based on the input stream | ||
| 228 | (via CBC encryption). The last 4 bytes of the checksum are returned | ||
| 229 | and the complete 8 bytes are placed in I<output>. This function is | ||
| 230 | used by Kerberos v4. Other applications should use | ||
| 231 | L<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead. | ||
| 232 | |||
| 233 | DES_quad_cksum() is a Kerberos v4 function. It returns a 4 byte | ||
| 234 | checksum from the input bytes. The algorithm can be iterated over the | ||
| 235 | input, depending on I<out_count>, 1, 2, 3 or 4 times. If I<output> is | ||
| 236 | non-NULL, the 8 bytes generated by each pass are written into | ||
| 237 | I<output>. | ||
| 238 | |||
| 239 | The following are DES-based transformations: | ||
| 240 | |||
| 241 | DES_fcrypt() is a fast version of the Unix crypt(3) function. This | ||
| 242 | version takes only a small amount of space relative to other fast | ||
| 243 | crypt() implementations. This is different to the normal crypt in | ||
| 244 | that the third parameter is the buffer that the return value is | ||
| 245 | written into. It needs to be at least 14 bytes long. This function | ||
| 246 | is thread safe, unlike the normal crypt. | ||
| 247 | |||
| 248 | DES_crypt() is a faster replacement for the normal system crypt(). | ||
| 249 | This function calls DES_fcrypt() with a static array passed as the | ||
| 250 | third parameter. This emulates the normal non-thread safe semantics | ||
| 251 | of crypt(3). | ||
| 252 | |||
| 253 | DES_enc_write() writes I<len> bytes to file descriptor I<fd> from | ||
| 254 | buffer I<buf>. The data is encrypted via I<pcbc_encrypt> (default) | ||
| 255 | using I<sched> for the key and I<iv> as a starting vector. The actual | ||
| 256 | data send down I<fd> consists of 4 bytes (in network byte order) | ||
| 257 | containing the length of the following encrypted data. The encrypted | ||
| 258 | data then follows, padded with random data out to a multiple of 8 | ||
| 259 | bytes. | ||
| 260 | |||
| 261 | DES_enc_read() is used to read I<len> bytes from file descriptor | ||
| 262 | I<fd> into buffer I<buf>. The data being read from I<fd> is assumed to | ||
| 263 | have come from DES_enc_write() and is decrypted using I<sched> for | ||
| 264 | the key schedule and I<iv> for the initial vector. | ||
| 265 | |||
| 266 | B<Warning:> The data format used by DES_enc_write() and DES_enc_read() | ||
| 267 | has a cryptographic weakness: When asked to write more than MAXWRITE | ||
| 268 | bytes, DES_enc_write() will split the data into several chunks that | ||
| 269 | are all encrypted using the same IV. So don't use these functions | ||
| 270 | unless you are sure you know what you do (in which case you might not | ||
| 271 | want to use them anyway). They cannot handle non-blocking sockets. | ||
| 272 | DES_enc_read() uses an internal state and thus cannot be used on | ||
| 273 | multiple files. | ||
| 274 | |||
| 275 | I<DES_rw_mode> is used to specify the encryption mode to use with | ||
| 276 | DES_enc_read() and DES_end_write(). If set to I<DES_PCBC_MODE> (the | ||
| 277 | default), DES_pcbc_encrypt is used. If set to I<DES_CBC_MODE> | ||
| 278 | DES_cbc_encrypt is used. | ||
| 279 | |||
| 280 | =head1 NOTES | ||
| 281 | |||
| 282 | Single-key DES is insecure due to its short key size. ECB mode is | ||
| 283 | not suitable for most applications. | ||
| 284 | |||
| 285 | The L<evp(3)|evp(3)> library provides higher-level encryption functions. | ||
| 286 | |||
| 287 | =head1 BUGS | ||
| 288 | |||
| 289 | DES_cbc_encrypt() does not modify B<ivec>; use DES_ncbc_encrypt() | ||
| 290 | instead. | ||
| 291 | |||
| 292 | DES_cfb_encrypt() and DES_ofb_encrypt() operates on input of 8 bits. | ||
| 293 | What this means is that if you set numbits to 12, and length to 2, the | ||
| 294 | first 12 bits will come from the 1st input byte and the low half of | ||
| 295 | the second input byte. The second 12 bits will have the low 8 bits | ||
| 296 | taken from the 3rd input byte and the top 4 bits taken from the 4th | ||
| 297 | input byte. The same holds for output. This function has been | ||
| 298 | implemented this way because most people will be using a multiple of 8 | ||
| 299 | and because once you get into pulling bytes input bytes apart things | ||
| 300 | get ugly! | ||
| 301 | |||
| 302 | DES_string_to_key() is available for backward compatibility with the | ||
| 303 | MIT library. New applications should use a cryptographic hash function. | ||
| 304 | The same applies for DES_string_to_2key(). | ||
| 305 | |||
| 306 | =head1 CONFORMING TO | ||
| 307 | |||
| 308 | ANSI X3.106 | ||
| 309 | |||
| 310 | The B<des> library was initially written to be source code compatible with | ||
| 311 | the MIT Kerberos library. | ||
| 312 | |||
| 313 | =head1 SEE ALSO | ||
| 314 | |||
| 315 | crypt(3), L<evp(3)|evp(3)>, L<rand(3)|rand(3)> | ||
| 316 | |||
| 317 | =head1 HISTORY | ||
| 318 | |||
| 319 | In OpenSSL 0.9.7, all des_ functions were renamed to DES_ to avoid | ||
| 320 | clashes with older versions of libdes. | ||
| 321 | |||
| 322 | DES_set_key_checked() and DES_set_key_unchecked() were added in | ||
| 323 | OpenSSL 0.9.5. | ||
| 324 | |||
| 325 | des_generate_random_block(), des_init_random_number_generator(), | ||
| 326 | des_new_random_key(), des_set_random_generator_seed() and | ||
| 327 | des_set_sequence_number() and des_rand_data() are used in newer | ||
| 328 | versions of Kerberos but are not implemented here. | ||
| 329 | |||
| 330 | DES_random_key() generated cryptographically weak random data in | ||
| 331 | SSLeay and in OpenSSL prior version 0.9.5, as well as in the original | ||
| 332 | MIT library. | ||
| 333 | |||
| 334 | =head1 AUTHOR | ||
| 335 | |||
| 336 | Eric Young (eay@cryptsoft.com). Modified for the OpenSSL project | ||
| 337 | (http://www.openssl.org). | ||
| 338 | |||
| 339 | =cut | ||
diff --git a/src/lib/libcrypto/doc/DH_generate_key.pod b/src/lib/libcrypto/doc/DH_generate_key.pod deleted file mode 100644 index 148e13762b..0000000000 --- a/src/lib/libcrypto/doc/DH_generate_key.pod +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | #include <openssl/dh.h> | ||
| 10 | |||
| 11 | int DH_generate_key(DH *dh); | ||
| 12 | |||
| 13 | int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | DH_generate_key() performs the first step of a Diffie-Hellman key | ||
| 18 | exchange by generating private and public DH values. By calling | ||
| 19 | DH_compute_key(), these are combined with the other party's public | ||
| 20 | value to compute the shared key. | ||
| 21 | |||
| 22 | DH_generate_key() expects B<dh> to contain the shared parameters | ||
| 23 | B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value | ||
| 24 | unless B<dh-E<gt>priv_key> is already set, and computes the | ||
| 25 | corresponding public value B<dh-E<gt>pub_key>, which can then be | ||
| 26 | published. | ||
| 27 | |||
| 28 | DH_compute_key() computes the shared secret from the private DH value | ||
| 29 | in B<dh> and the other party's public value in B<pub_key> and stores | ||
| 30 | it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory. | ||
| 31 | |||
| 32 | =head1 RETURN VALUES | ||
| 33 | |||
| 34 | DH_generate_key() returns 1 on success, 0 otherwise. | ||
| 35 | |||
| 36 | DH_compute_key() returns the size of the shared secret on success, -1 | ||
| 37 | on error. | ||
| 38 | |||
| 39 | The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. | ||
| 40 | |||
| 41 | =head1 SEE ALSO | ||
| 42 | |||
| 43 | L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, | ||
| 44 | L<DH_size(3)|DH_size(3)> | ||
| 45 | |||
| 46 | =head1 HISTORY | ||
| 47 | |||
| 48 | DH_generate_key() and DH_compute_key() are available in all versions | ||
| 49 | of SSLeay and OpenSSL. | ||
| 50 | |||
| 51 | =cut | ||
diff --git a/src/lib/libcrypto/doc/DH_generate_parameters.pod b/src/lib/libcrypto/doc/DH_generate_parameters.pod deleted file mode 100644 index bd0782cb0c..0000000000 --- a/src/lib/libcrypto/doc/DH_generate_parameters.pod +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DH_generate_parameters_ex, DH_generate_parameters, | ||
| 6 | DH_check - generate and check Diffie-Hellman parameters | ||
| 7 | |||
| 8 | =head1 SYNOPSIS | ||
| 9 | |||
| 10 | #include <openssl/dh.h> | ||
| 11 | |||
| 12 | int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb); | ||
| 13 | |||
| 14 | int DH_check(DH *dh, int *codes); | ||
| 15 | |||
| 16 | Deprecated: | ||
| 17 | |||
| 18 | DH *DH_generate_parameters(int prime_len, int generator, | ||
| 19 | void (*callback)(int, int, void *), void *cb_arg); | ||
| 20 | |||
| 21 | =head1 DESCRIPTION | ||
| 22 | |||
| 23 | DH_generate_parameters_ex() generates Diffie-Hellman parameters that can | ||
| 24 | be shared among a group of users, and stores them in the provided B<DH> | ||
| 25 | structure. | ||
| 26 | |||
| 27 | B<prime_len> is the length in bits of the safe prime to be generated. | ||
| 28 | B<generator> is a small number E<gt> 1, typically 2 or 5. | ||
| 29 | |||
| 30 | A callback function may be used to provide feedback about the progress | ||
| 31 | of the key generation. If B<cb> is not B<NULL>, it will be | ||
| 32 | called as described in L<BN_generate_prime(3)|BN_generate_prime(3)> while a random prime number is | ||
| 33 | generated, and when a prime has been found, B<BN_GENCB_call(cb, 3, 0)> is | ||
| 34 | called. See L<BN_generate_prime(3)|BN_generate_prime(3)> for information on | ||
| 35 | the BN_GENCB_call() function. | ||
| 36 | |||
| 37 | DH_check() validates Diffie-Hellman parameters. It checks that B<p> is | ||
| 38 | a safe prime, and that B<g> is a suitable generator. In the case of an | ||
| 39 | error, the bit flags DH_CHECK_P_NOT_SAFE_PRIME or | ||
| 40 | DH_NOT_SUITABLE_GENERATOR are set in B<*codes>. | ||
| 41 | DH_UNABLE_TO_CHECK_GENERATOR is set if the generator cannot be | ||
| 42 | checked, i.e. it does not equal 2 or 5. | ||
| 43 | |||
| 44 | =head1 RETURN VALUES | ||
| 45 | |||
| 46 | DH_generate_parameters_ex() and DH_check() return 1 if the check could be | ||
| 47 | performed, 0 otherwise. | ||
| 48 | |||
| 49 | DH_generate_parameters() (deprecated) returns a pointer to the DH structure, or | ||
| 50 | NULL if the parameter generation fails. | ||
| 51 | |||
| 52 | The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. | ||
| 53 | |||
| 54 | =head1 NOTES | ||
| 55 | |||
| 56 | DH_generate_parameters_ex() and DH_generate_parameters() may run for several | ||
| 57 | hours before finding a suitable prime. | ||
| 58 | |||
| 59 | The parameters generated by DH_generate_parameters_ex() and DH_generate_parameters() | ||
| 60 | are not to be used in signature schemes. | ||
| 61 | |||
| 62 | =head1 BUGS | ||
| 63 | |||
| 64 | If B<generator> is not 2 or 5, B<dh-E<gt>g>=B<generator> is not | ||
| 65 | a usable generator. | ||
| 66 | |||
| 67 | =head1 SEE ALSO | ||
| 68 | |||
| 69 | L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, | ||
| 70 | L<DH_free(3)|DH_free(3)> | ||
| 71 | |||
| 72 | =head1 HISTORY | ||
| 73 | |||
| 74 | DH_check() is available in all versions of SSLeay and OpenSSL. | ||
| 75 | The B<cb_arg> argument to DH_generate_parameters() was added in SSLeay 0.9.0. | ||
| 76 | |||
| 77 | In versions before OpenSSL 0.9.5, DH_CHECK_P_NOT_STRONG_PRIME is used | ||
| 78 | instead of DH_CHECK_P_NOT_SAFE_PRIME. | ||
| 79 | |||
| 80 | =cut | ||
diff --git a/src/lib/libcrypto/doc/DH_get_ex_new_index.pod b/src/lib/libcrypto/doc/DH_get_ex_new_index.pod deleted file mode 100644 index 934ec094bb..0000000000 --- a/src/lib/libcrypto/doc/DH_get_ex_new_index.pod +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DH_get_ex_new_index, DH_set_ex_data, DH_get_ex_data - add application specific | ||
| 6 | data to DH structures | ||
| 7 | |||
| 8 | =head1 SYNOPSIS | ||
| 9 | |||
| 10 | #include <openssl/dh.h> | ||
| 11 | |||
| 12 | int DH_get_ex_new_index(long argl, void *argp, | ||
| 13 | CRYPTO_EX_new *new_func, | ||
| 14 | CRYPTO_EX_dup *dup_func, | ||
| 15 | CRYPTO_EX_free *free_func); | ||
| 16 | |||
| 17 | int DH_set_ex_data(DH *d, int idx, void *arg); | ||
| 18 | |||
| 19 | char *DH_get_ex_data(DH *d, int idx); | ||
| 20 | |||
| 21 | =head1 DESCRIPTION | ||
| 22 | |||
| 23 | These functions handle application specific data in DH | ||
| 24 | structures. Their usage is identical to that of | ||
| 25 | RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data() | ||
| 26 | as described in L<RSA_get_ex_new_index(3)>. | ||
| 27 | |||
| 28 | =head1 SEE ALSO | ||
| 29 | |||
| 30 | L<RSA_get_ex_new_index(3)|RSA_get_ex_new_index(3)>, L<dh(3)|dh(3)> | ||
| 31 | |||
| 32 | =head1 HISTORY | ||
| 33 | |||
| 34 | DH_get_ex_new_index(), DH_set_ex_data() and DH_get_ex_data() are | ||
| 35 | available since OpenSSL 0.9.5. | ||
| 36 | |||
| 37 | =cut | ||
diff --git a/src/lib/libcrypto/doc/DH_new.pod b/src/lib/libcrypto/doc/DH_new.pod deleted file mode 100644 index 0fdb7b9680..0000000000 --- a/src/lib/libcrypto/doc/DH_new.pod +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DH_new, DH_free - allocate and free DH objects | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | #include <openssl/dh.h> | ||
| 10 | |||
| 11 | DH* DH_new(void); | ||
| 12 | |||
| 13 | void DH_free(DH *dh); | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | DH_new() allocates and initializes a B<DH> structure. | ||
| 18 | |||
| 19 | DH_free() frees the B<DH> structure and its components. The values are | ||
| 20 | erased before the memory is returned to the system. | ||
| 21 | |||
| 22 | =head1 RETURN VALUES | ||
| 23 | |||
| 24 | If the allocation fails, DH_new() returns B<NULL> and sets an error code that | ||
| 25 | can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. Otherwise it returns a | ||
| 26 | pointer to the newly allocated structure. | ||
| 27 | |||
| 28 | =head1 SEE ALSO | ||
| 29 | |||
| 30 | L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, | ||
| 31 | L<DH_generate_parameters(3)|DH_generate_parameters(3)>, | ||
| 32 | L<DH_generate_key(3)|DH_generate_key(3)> | ||
| 33 | |||
| 34 | =head1 HISTORY | ||
| 35 | |||
| 36 | DH_new() and DH_free() are available in all versions of SSLeay and OpenSSL. | ||
| 37 | |||
| 38 | =cut | ||
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod deleted file mode 100644 index d82fe7377a..0000000000 --- a/src/lib/libcrypto/doc/DH_set_method.pod +++ /dev/null | |||
| @@ -1,129 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DH_set_default_method, DH_get_default_method, | ||
| 6 | DH_set_method, DH_new_method, DH_OpenSSL, | ||
| 7 | DH_set_default_openssl_method, DH_get_default_openssl_method | ||
| 8 | - select DH method | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | #include <openssl/dh.h> | ||
| 13 | #include <openssl/engine.h> | ||
| 14 | |||
| 15 | void DH_set_default_method(const DH_METHOD *meth); | ||
| 16 | |||
| 17 | const DH_METHOD *DH_get_default_method(void); | ||
| 18 | |||
| 19 | int DH_set_method(DH *dh, const DH_METHOD *meth); | ||
| 20 | |||
| 21 | DH *DH_new_method(ENGINE *engine); | ||
| 22 | |||
| 23 | const DH_METHOD *DH_OpenSSL(void); | ||
| 24 | |||
| 25 | =head1 DESCRIPTION | ||
| 26 | |||
| 27 | A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman | ||
| 28 | operations. By modifying the method, alternative implementations | ||
| 29 | such as hardware accelerators may be used. IMPORTANT: See the NOTES section for | ||
| 30 | important information about how these DH API functions are affected by the use | ||
| 31 | of B<ENGINE> API calls. | ||
| 32 | |||
| 33 | Initially, the default DH_METHOD is the OpenSSL internal implementation, as | ||
| 34 | returned by DH_OpenSSL(). | ||
| 35 | |||
| 36 | DH_set_default_method() makes B<meth> the default method for all DH | ||
| 37 | structures created later. B<NB>: This is true only whilst no ENGINE has been set | ||
| 38 | as a default for DH, so this function is no longer recommended. | ||
| 39 | |||
| 40 | DH_get_default_method() returns a pointer to the current default DH_METHOD. | ||
| 41 | However, the meaningfulness of this result is dependent on whether the ENGINE | ||
| 42 | API is being used, so this function is no longer recommended. | ||
| 43 | |||
| 44 | DH_set_method() selects B<meth> to perform all operations using the key B<dh>. | ||
| 45 | This will replace the DH_METHOD used by the DH key and if the previous method | ||
| 46 | was supplied by an ENGINE, the handle to that ENGINE will be released during the | ||
| 47 | change. It is possible to have DH keys that only work with certain DH_METHOD | ||
| 48 | implementations (eg. from an ENGINE module that supports embedded | ||
| 49 | hardware-protected keys), and in such cases attempting to change the DH_METHOD | ||
| 50 | for the key can have unexpected results. | ||
| 51 | |||
| 52 | DH_new_method() allocates and initializes a DH structure so that B<engine> will | ||
| 53 | be used for the DH operations. If B<engine> is NULL, the default ENGINE for DH | ||
| 54 | operations is used, and if no default ENGINE is set, the DH_METHOD controlled by | ||
| 55 | DH_set_default_method() is used. | ||
| 56 | |||
| 57 | =head1 THE DH_METHOD STRUCTURE | ||
| 58 | |||
| 59 | typedef struct dh_meth_st | ||
| 60 | { | ||
| 61 | /* name of the implementation */ | ||
| 62 | const char *name; | ||
| 63 | |||
| 64 | /* generate private and public DH values for key agreement */ | ||
| 65 | int (*generate_key)(DH *dh); | ||
| 66 | |||
| 67 | /* compute shared secret */ | ||
| 68 | int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh); | ||
| 69 | |||
| 70 | /* compute r = a ^ p mod m (May be NULL for some implementations) */ | ||
| 71 | int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, | ||
| 72 | const BIGNUM *m, BN_CTX *ctx, | ||
| 73 | BN_MONT_CTX *m_ctx); | ||
| 74 | |||
| 75 | /* called at DH_new */ | ||
| 76 | int (*init)(DH *dh); | ||
| 77 | |||
| 78 | /* called at DH_free */ | ||
| 79 | int (*finish)(DH *dh); | ||
| 80 | |||
| 81 | int flags; | ||
| 82 | |||
| 83 | char *app_data; /* ?? */ | ||
| 84 | |||
| 85 | } DH_METHOD; | ||
| 86 | |||
| 87 | =head1 RETURN VALUES | ||
| 88 | |||
| 89 | DH_OpenSSL() and DH_get_default_method() return pointers to the respective | ||
| 90 | B<DH_METHOD>s. | ||
| 91 | |||
| 92 | DH_set_method() returns non-zero if the provided B<meth> was successfully set as | ||
| 93 | the method for B<dh> (including unloading the ENGINE handle if the previous | ||
| 94 | method was supplied by an ENGINE). | ||
| 95 | |||
| 96 | DH_new_method() returns NULL and sets an error code that can be obtained by | ||
| 97 | L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it | ||
| 98 | returns a pointer to the newly allocated structure. | ||
| 99 | |||
| 100 | =head1 NOTES | ||
| 101 | |||
| 102 | As of version 0.9.7, DH_METHOD implementations are grouped together with other | ||
| 103 | algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a | ||
| 104 | default ENGINE is specified for DH functionality using an ENGINE API function, | ||
| 105 | that will override any DH defaults set using the DH API (ie. | ||
| 106 | DH_set_default_method()). For this reason, the ENGINE API is the recommended way | ||
| 107 | to control default implementations for use in DH and other cryptographic | ||
| 108 | algorithms. | ||
| 109 | |||
| 110 | =head1 SEE ALSO | ||
| 111 | |||
| 112 | L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)> | ||
| 113 | |||
| 114 | =head1 HISTORY | ||
| 115 | |||
| 116 | DH_set_default_method(), DH_get_default_method(), DH_set_method(), | ||
| 117 | DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4. | ||
| 118 | |||
| 119 | DH_set_default_openssl_method() and DH_get_default_openssl_method() replaced | ||
| 120 | DH_set_default_method() and DH_get_default_method() respectively, and | ||
| 121 | DH_set_method() and DH_new_method() were altered to use B<ENGINE>s rather than | ||
| 122 | B<DH_METHOD>s during development of the engine version of OpenSSL 0.9.6. For | ||
| 123 | 0.9.7, the handling of defaults in the ENGINE API was restructured so that this | ||
| 124 | change was reversed, and behaviour of the other functions resembled more closely | ||
| 125 | the previous behaviour. The behaviour of defaults in the ENGINE API now | ||
| 126 | transparently overrides the behaviour of defaults in the DH API without | ||
| 127 | requiring changing these function prototypes. | ||
| 128 | |||
| 129 | =cut | ||
diff --git a/src/lib/libcrypto/doc/DH_size.pod b/src/lib/libcrypto/doc/DH_size.pod deleted file mode 100644 index 97f26fda78..0000000000 --- a/src/lib/libcrypto/doc/DH_size.pod +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | =pod | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | DH_size - get Diffie-Hellman prime size | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | #include <openssl/dh.h> | ||
| 10 | |||
| 11 | int DH_size(DH *dh); | ||
| 12 | |||
| 13 | =head1 DESCRIPTION | ||
| 14 | |||
| 15 | This function returns the Diffie-Hellman size in bytes. It can be used | ||
| 16 | to determine how much memory must be allocated for the shared secret | ||
| 17 | computed by DH_compute_key(). | ||
| 18 | |||
| 19 | B<dh-E<gt>p> must not be B<NULL>. | ||
| 20 | |||
| 21 | =head1 RETURN VALUE | ||
| 22 | |||
| 23 | The size in bytes. | ||
| 24 | |||
| 25 | =head1 SEE ALSO | ||
| 26 | |||
| 27 | L<dh(3)|dh(3)>, L<DH_generate_key(3)|DH_generate_key(3)> | ||
| 28 | |||
| 29 | =head1 HISTORY | ||
| 30 | |||
| 31 | DH_size() is available in all versions of SSLeay and OpenSSL. | ||
| 32 | |||
| 33 | =cut | ||
diff --git a/src/lib/libcrypto/man/DES_set_key.3 b/src/lib/libcrypto/man/DES_set_key.3 new file mode 100644 index 0000000000..9c33bf29e6 --- /dev/null +++ b/src/lib/libcrypto/man/DES_set_key.3 | |||
| @@ -0,0 +1,697 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DES_SET_KEY 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DES_random_key , | ||
| 6 | .Nm DES_set_key , | ||
| 7 | .Nm DES_key_sched , | ||
| 8 | .Nm DES_set_key_checked , | ||
| 9 | .Nm DES_set_key_unchecked , | ||
| 10 | .Nm DES_set_odd_parity , | ||
| 11 | .Nm DES_is_weak_key , | ||
| 12 | .Nm DES_ecb_encrypt , | ||
| 13 | .Nm DES_ecb2_encrypt , | ||
| 14 | .Nm DES_ecb3_encrypt , | ||
| 15 | .Nm DES_ncbc_encrypt , | ||
| 16 | .Nm DES_cfb_encrypt , | ||
| 17 | .Nm DES_ofb_encrypt , | ||
| 18 | .Nm DES_pcbc_encrypt , | ||
| 19 | .Nm DES_cfb64_encrypt , | ||
| 20 | .Nm DES_ofb64_encrypt , | ||
| 21 | .Nm DES_xcbc_encrypt , | ||
| 22 | .Nm DES_ede2_cbc_encrypt , | ||
| 23 | .Nm DES_ede2_cfb64_encrypt , | ||
| 24 | .Nm DES_ede2_ofb64_encrypt , | ||
| 25 | .Nm DES_ede3_cbc_encrypt , | ||
| 26 | .Nm DES_ede3_cbcm_encrypt , | ||
| 27 | .Nm DES_ede3_cfb64_encrypt , | ||
| 28 | .Nm DES_ede3_ofb64_encrypt , | ||
| 29 | .Nm DES_cbc_cksum , | ||
| 30 | .Nm DES_quad_cksum , | ||
| 31 | .Nm DES_string_to_key , | ||
| 32 | .Nm DES_string_to_2keys , | ||
| 33 | .Nm DES_fcrypt , | ||
| 34 | .Nm DES_crypt , | ||
| 35 | .Nm DES_enc_read , | ||
| 36 | .Nm DES_enc_write | ||
| 37 | .Nd DES encryption | ||
| 38 | .Sh SYNOPSIS | ||
| 39 | .In openssl/des.h | ||
| 40 | .Ft void | ||
| 41 | .Fo DES_random_key | ||
| 42 | .Fa "DES_cblock *ret" | ||
| 43 | .Fc | ||
| 44 | .Ft int | ||
| 45 | .Fo DES_set_key | ||
| 46 | .Fa "const_DES_cblock *key" | ||
| 47 | .Fa "DES_key_schedule *schedule" | ||
| 48 | .Fc | ||
| 49 | .Ft int | ||
| 50 | .Fo DES_key_sched | ||
| 51 | .Fa "const_DES_cblock *key" | ||
| 52 | .Fa "DES_key_schedule *schedule" | ||
| 53 | .Fc | ||
| 54 | .Ft int | ||
| 55 | .Fo DES_set_key_checked | ||
| 56 | .Fa "const_DES_cblock *key" | ||
| 57 | .Fa "DES_key_schedule *schedule" | ||
| 58 | .Fc | ||
| 59 | .Ft void | ||
| 60 | .Fo DES_set_key_unchecked | ||
| 61 | .Fa "const_DES_cblock *key" | ||
| 62 | .Fa "DES_key_schedule *schedule" | ||
| 63 | .Fc | ||
| 64 | .Ft void | ||
| 65 | .Fo DES_set_odd_parity | ||
| 66 | .Fa "DES_cblock *key" | ||
| 67 | .Fc | ||
| 68 | .Ft int | ||
| 69 | .Fo DES_is_weak_key | ||
| 70 | .Fa "const_DES_cblock *key" | ||
| 71 | .Fc | ||
| 72 | .Ft void | ||
| 73 | .Fo DES_ecb_encrypt | ||
| 74 | .Fa "const_DES_cblock *input" | ||
| 75 | .Fa "DES_cblock *output" | ||
| 76 | .Fa "DES_key_schedule *ks" | ||
| 77 | .Fa "int enc" | ||
| 78 | .Fc | ||
| 79 | .Ft void | ||
| 80 | .Fo DES_ecb2_encrypt | ||
| 81 | .Fa "const_DES_cblock *input" | ||
| 82 | .Fa "DES_cblock *output" | ||
| 83 | .Fa "DES_key_schedule *ks1" | ||
| 84 | .Fa "DES_key_schedule *ks2" | ||
| 85 | .Fa "int enc" | ||
| 86 | .Fc | ||
| 87 | .Ft void | ||
| 88 | .Fo DES_ecb3_encrypt | ||
| 89 | .Fa "const_DES_cblock *input" | ||
| 90 | .Fa "DES_cblock *output" | ||
| 91 | .Fa "DES_key_schedule *ks1" | ||
| 92 | .Fa "DES_key_schedule *ks2" | ||
| 93 | .Fa "DES_key_schedule *ks3" | ||
| 94 | .Fa "int enc" | ||
| 95 | .Fc | ||
| 96 | .Ft void | ||
| 97 | .Fo DES_ncbc_encrypt | ||
| 98 | .Fa "const unsigned char *input" | ||
| 99 | .Fa "unsigned char *output" | ||
| 100 | .Fa "long length" | ||
| 101 | .Fa "DES_key_schedule *schedule" | ||
| 102 | .Fa "DES_cblock *ivec" | ||
| 103 | .Fa "int enc" | ||
| 104 | .Fc | ||
| 105 | .Ft void | ||
| 106 | .Fo DES_cfb_encrypt | ||
| 107 | .Fa "const unsigned char *in" | ||
| 108 | .Fa "unsigned char *out" | ||
| 109 | .Fa "int numbits" | ||
| 110 | .Fa "long length" | ||
| 111 | .Fa "DES_key_schedule *schedule" | ||
| 112 | .Fa "DES_cblock *ivec" | ||
| 113 | .Fa "int enc" | ||
| 114 | .Fc | ||
| 115 | .Ft void | ||
| 116 | .Fo DES_ofb_encrypt | ||
| 117 | .Fa "const unsigned char *in" | ||
| 118 | .Fa "unsigned char *out" | ||
| 119 | .Fa "int numbits" | ||
| 120 | .Fa "long length" | ||
| 121 | .Fa "DES_key_schedule *schedule" | ||
| 122 | .Fa "DES_cblock *ivec" | ||
| 123 | .Fc | ||
| 124 | .Ft void | ||
| 125 | .Fo DES_pcbc_encrypt | ||
| 126 | .Fa "const unsigned char *input" | ||
| 127 | .Fa "unsigned char *output" | ||
| 128 | .Fa "long length" | ||
| 129 | .Fa "DES_key_schedule *schedule" | ||
| 130 | .Fa "DES_cblock *ivec" | ||
| 131 | .Fa "int enc" | ||
| 132 | .Fc | ||
| 133 | .Ft void | ||
| 134 | .Fo DES_cfb64_encrypt | ||
| 135 | .Fa "const unsigned char *in" | ||
| 136 | .Fa "unsigned char *out" | ||
| 137 | .Fa "long length" | ||
| 138 | .Fa "DES_key_schedule *schedule" | ||
| 139 | .Fa "DES_cblock *ivec" | ||
| 140 | .Fa "int *num" | ||
| 141 | .Fa "int enc" | ||
| 142 | .Fc | ||
| 143 | .Ft void | ||
| 144 | .Fo DES_ofb64_encrypt | ||
| 145 | .Fa "const unsigned char *in" | ||
| 146 | .Fa "unsigned char *out" | ||
| 147 | .Fa "long length" | ||
| 148 | .Fa "DES_key_schedule *schedule" | ||
| 149 | .Fa "DES_cblock *ivec" | ||
| 150 | .Fa "int *num" | ||
| 151 | .Fc | ||
| 152 | .Ft void | ||
| 153 | .Fo DES_xcbc_encrypt | ||
| 154 | .Fa "const unsigned char *input" | ||
| 155 | .Fa "unsigned char *output" | ||
| 156 | .Fa "long length" | ||
| 157 | .Fa "DES_key_schedule *schedule" | ||
| 158 | .Fa "DES_cblock *ivec" | ||
| 159 | .Fa "const_DES_cblock *inw" | ||
| 160 | .Fa "const_DES_cblock *outw" | ||
| 161 | .Fa "int enc" | ||
| 162 | .Fc | ||
| 163 | .Ft void | ||
| 164 | .Fo DES_ede2_cbc_encrypt | ||
| 165 | .Fa "const unsigned char *input" | ||
| 166 | .Fa "unsigned char *output" | ||
| 167 | .Fa "long length" | ||
| 168 | .Fa "DES_key_schedule *ks1" | ||
| 169 | .Fa "DES_key_schedule *ks2" | ||
| 170 | .Fa "DES_cblock *ivec" | ||
| 171 | .Fa "int enc" | ||
| 172 | .Fc | ||
| 173 | .Ft void | ||
| 174 | .Fo DES_ede2_cfb64_encrypt | ||
| 175 | .Fa "const unsigned char *in" | ||
| 176 | .Fa "unsigned char *out" | ||
| 177 | .Fa "long length" | ||
| 178 | .Fa "DES_key_schedule *ks1" | ||
| 179 | .Fa "DES_key_schedule *ks2" | ||
| 180 | .Fa "DES_cblock *ivec" | ||
| 181 | .Fa "int *num" | ||
| 182 | .Fa "int enc" | ||
| 183 | .Fc | ||
| 184 | .Ft void | ||
| 185 | .Fo DES_ede2_ofb64_encrypt | ||
| 186 | .Fa "const unsigned char *in" | ||
| 187 | .Fa "unsigned char *out" | ||
| 188 | .Fa "long length" | ||
| 189 | .Fa "DES_key_schedule *ks1" | ||
| 190 | .Fa "DES_key_schedule *ks2" | ||
| 191 | .Fa "DES_cblock *ivec" | ||
| 192 | .Fa "int *num" | ||
| 193 | .Fc | ||
| 194 | .Ft void | ||
| 195 | .Fo DES_ede3_cbc_encrypt | ||
| 196 | .Fa "const unsigned char *input" | ||
| 197 | .Fa "unsigned char *output" | ||
| 198 | .Fa "long length" | ||
| 199 | .Fa "DES_key_schedule *ks1" | ||
| 200 | .Fa "DES_key_schedule *ks2" | ||
| 201 | .Fa "DES_key_schedule *ks3" | ||
| 202 | .Fa "DES_cblock *ivec" | ||
| 203 | .Fa "int enc" | ||
| 204 | .Fc | ||
| 205 | .Ft void | ||
| 206 | .Fo DES_ede3_cbcm_encrypt | ||
| 207 | .Fa "const unsigned char *in" | ||
| 208 | .Fa "unsigned char *out" | ||
| 209 | .Fa "long length" | ||
| 210 | .Fa "DES_key_schedule *ks1" | ||
| 211 | .Fa "DES_key_schedule *ks2" | ||
| 212 | .Fa "DES_key_schedule *ks3" | ||
| 213 | .Fa "DES_cblock *ivec1" | ||
| 214 | .Fa "DES_cblock *ivec2" | ||
| 215 | .Fa "int enc" | ||
| 216 | .Fc | ||
| 217 | .Ft void | ||
| 218 | .Fo DES_ede3_cfb64_encrypt | ||
| 219 | .Fa "const unsigned char *in" | ||
| 220 | .Fa "unsigned char *out" | ||
| 221 | .Fa "long length" | ||
| 222 | .Fa "DES_key_schedule *ks1" | ||
| 223 | .Fa "DES_key_schedule *ks2" | ||
| 224 | .Fa "DES_key_schedule *ks3" | ||
| 225 | .Fa "DES_cblock *ivec" | ||
| 226 | .Fa "int *num" | ||
| 227 | .Fa "int enc" | ||
| 228 | .Fc | ||
| 229 | .Ft void | ||
| 230 | .Fo DES_ede3_ofb64_encrypt | ||
| 231 | .Fa "const unsigned char *in" | ||
| 232 | .Fa "unsigned char *out" | ||
| 233 | .Fa "long length" | ||
| 234 | .Fa "DES_key_schedule *ks1" | ||
| 235 | .Fa "DES_key_schedule *ks2" | ||
| 236 | .Fa "DES_key_schedule *ks3" | ||
| 237 | .Fa "DES_cblock *ivec" | ||
| 238 | .Fa "int *num" | ||
| 239 | .Fc | ||
| 240 | .Ft DES_LONG | ||
| 241 | .Fo DES_cbc_cksum | ||
| 242 | .Fa "const unsigned char *input" | ||
| 243 | .Fa "DES_cblock *output" | ||
| 244 | .Fa "long length" | ||
| 245 | .Fa "DES_key_schedule *schedule" | ||
| 246 | .Fa "const_DES_cblock *ivec" | ||
| 247 | .Fc | ||
| 248 | .Ft DES_LONG | ||
| 249 | .Fo DES_quad_cksum | ||
| 250 | .Fa "const unsigned char *input" | ||
| 251 | .Fa "DES_cblock output[]" | ||
| 252 | .Fa "long length" | ||
| 253 | .Fa "int out_count" | ||
| 254 | .Fa "DES_cblock *seed" | ||
| 255 | .Fc | ||
| 256 | .Ft void | ||
| 257 | .Fo DES_string_to_key | ||
| 258 | .Fa "const char *str" | ||
| 259 | .Fa "DES_cblock *key" | ||
| 260 | .Fc | ||
| 261 | .Ft void | ||
| 262 | .Fo DES_string_to_2keys | ||
| 263 | .Fa "const char *str" | ||
| 264 | .Fa "DES_cblock *key1" | ||
| 265 | .Fa "DES_cblock *key2" | ||
| 266 | .Fc | ||
| 267 | .Ft char * | ||
| 268 | .Fo DES_fcrypt | ||
| 269 | .Fa "const char *buf" | ||
| 270 | .Fa "const char *salt" | ||
| 271 | .Fa "char *ret" | ||
| 272 | .Fc | ||
| 273 | .Ft char * | ||
| 274 | .Fo DES_crypt | ||
| 275 | .Fa "const char *buf" | ||
| 276 | .Fa "const char *salt" | ||
| 277 | .Fc | ||
| 278 | .Ft int | ||
| 279 | .Fo DES_enc_read | ||
| 280 | .Fa "int fd" | ||
| 281 | .Fa "void *buf" | ||
| 282 | .Fa "int len" | ||
| 283 | .Fa "DES_key_schedule *sched" | ||
| 284 | .Fa "DES_cblock *iv" | ||
| 285 | .Fc | ||
| 286 | .Ft int | ||
| 287 | .Fo DES_enc_write | ||
| 288 | .Fa "int fd" | ||
| 289 | .Fa "const void *buf" | ||
| 290 | .Fa "int len" | ||
| 291 | .Fa "DES_key_schedule *sched" | ||
| 292 | .Fa "DES_cblock *iv" | ||
| 293 | .Fc | ||
| 294 | .Sh DESCRIPTION | ||
| 295 | This library contains a fast implementation of the DES encryption | ||
| 296 | algorithm. | ||
| 297 | .Pp | ||
| 298 | There are two phases to the use of DES encryption. | ||
| 299 | The first is the generation of a | ||
| 300 | .Vt DES_key_schedule | ||
| 301 | from a key, the second is the actual encryption. | ||
| 302 | A DES key is of type | ||
| 303 | .Vt DES_cblock . | ||
| 304 | This type is consists of 8 bytes with odd parity. | ||
| 305 | The least significant bit in each byte is the parity bit. | ||
| 306 | The key schedule is an expanded form of the key; it is used to speed the | ||
| 307 | encryption process. | ||
| 308 | .Pp | ||
| 309 | .Fn DES_random_key | ||
| 310 | generates a random key in odd parity. | ||
| 311 | .Pp | ||
| 312 | Before a DES key can be used, it must be converted into the architecture | ||
| 313 | dependent | ||
| 314 | .Vt DES_key_schedule | ||
| 315 | via the | ||
| 316 | .Fn DES_set_key_checked | ||
| 317 | or | ||
| 318 | .Fn DES_set_key_unchecked | ||
| 319 | function. | ||
| 320 | .Pp | ||
| 321 | .Fn DES_set_key_checked | ||
| 322 | will check that the key passed is of odd parity and is not a week or | ||
| 323 | semi-weak key. | ||
| 324 | If the parity is wrong, then -1 is returned. | ||
| 325 | If the key is a weak key, then -2 is returned. | ||
| 326 | If an error is returned, the key schedule is not generated. | ||
| 327 | .Pp | ||
| 328 | .Fn DES_set_key | ||
| 329 | works like | ||
| 330 | .Fn DES_set_key_checked | ||
| 331 | if the | ||
| 332 | .Em DES_check_key | ||
| 333 | flag is non-zero, otherwise like | ||
| 334 | .Fn DES_set_key_unchecked . | ||
| 335 | These functions are available for compatibility; it is recommended to | ||
| 336 | use a function that does not depend on a global variable. | ||
| 337 | .Pp | ||
| 338 | .Fn DES_set_odd_parity | ||
| 339 | sets the parity of the passed | ||
| 340 | .Fa key | ||
| 341 | to odd. | ||
| 342 | .Pp | ||
| 343 | .Fn DES_is_weak_key | ||
| 344 | returns 1 is the passed key is a weak key, 0 if it is ok. | ||
| 345 | .Pp | ||
| 346 | The following routines mostly operate on an input and output stream of | ||
| 347 | .Vt DES_cblock Ns s. | ||
| 348 | .Pp | ||
| 349 | .Fn DES_ecb_encrypt | ||
| 350 | is the basic DES encryption routine that encrypts or decrypts a single | ||
| 351 | 8-byte | ||
| 352 | .Vt DES_cblock | ||
| 353 | in electronic code book (ECB) mode. | ||
| 354 | It always transforms the input data, pointed to by | ||
| 355 | .Fa input , | ||
| 356 | into the output data, pointed to by the | ||
| 357 | .Fa output | ||
| 358 | argument. | ||
| 359 | If the | ||
| 360 | .Fa enc | ||
| 361 | argument is non-zero | ||
| 362 | .Pq Dv DES_ENCRYPT , | ||
| 363 | the | ||
| 364 | .Fa input | ||
| 365 | (cleartext) is encrypted in to the | ||
| 366 | .Fa output | ||
| 367 | (ciphertext) using the key_schedule specified by the | ||
| 368 | .Fa schedule | ||
| 369 | argument, previously set via | ||
| 370 | .Fn DES_set_key . | ||
| 371 | If | ||
| 372 | .Fa enc | ||
| 373 | is zero | ||
| 374 | .Pq Dv DES_DECRYPT , | ||
| 375 | the | ||
| 376 | .Fa input | ||
| 377 | (now ciphertext) is decrypted into the | ||
| 378 | .Fa output | ||
| 379 | (now cleartext). | ||
| 380 | Input and output may overlap. | ||
| 381 | .Fn DES_ecb_encrypt | ||
| 382 | does not return a value. | ||
| 383 | .Pp | ||
| 384 | .Fn DES_ecb3_encrypt | ||
| 385 | encrypts/decrypts the | ||
| 386 | .Fa input | ||
| 387 | block by using three-key Triple-DES encryption in ECB mode. | ||
| 388 | This involves encrypting the input with | ||
| 389 | .Fa ks1 , | ||
| 390 | decrypting with the key schedule | ||
| 391 | .Fa ks2 , | ||
| 392 | and then encrypting with | ||
| 393 | .Fa ks3 . | ||
| 394 | This routine greatly reduces the chances of brute force breaking of DES | ||
| 395 | and has the advantage of if | ||
| 396 | .Fa ks1 , | ||
| 397 | .Fa ks2 , | ||
| 398 | and | ||
| 399 | .Fa ks3 | ||
| 400 | are the same, it is equivalent to just encryption using ECB mode and | ||
| 401 | .Fa ks1 | ||
| 402 | as the key. | ||
| 403 | .Pp | ||
| 404 | The macro | ||
| 405 | .Fn DES_ecb2_encrypt | ||
| 406 | is provided to perform two-key Triple-DES encryption by using | ||
| 407 | .Fa ks1 | ||
| 408 | for the final encryption. | ||
| 409 | .Pp | ||
| 410 | .Fn DES_ncbc_encrypt | ||
| 411 | encrypts/decrypts using the cipher-block-chaining (CBC) mode of DES. | ||
| 412 | If the | ||
| 413 | .Fa enc | ||
| 414 | argument is non-zero, the routine cipher-block-chain encrypts the | ||
| 415 | cleartext data pointed to by the | ||
| 416 | .Fa input | ||
| 417 | argument into the ciphertext pointed to by the | ||
| 418 | .Fa output | ||
| 419 | argument, using the key schedule provided by the | ||
| 420 | .Fa schedule | ||
| 421 | argument, and initialization vector provided by the | ||
| 422 | .Fa ivec | ||
| 423 | argument. | ||
| 424 | If the | ||
| 425 | .Fa length | ||
| 426 | argument is not an integral multiple of eight bytes, the last block is | ||
| 427 | copied to a temporary area and zero filled. | ||
| 428 | The output is always an integral multiple of eight bytes. | ||
| 429 | .Pp | ||
| 430 | .Fn DES_xcbc_encrypt | ||
| 431 | is RSA's DESX mode of DES. | ||
| 432 | It uses | ||
| 433 | .Fa inw | ||
| 434 | and | ||
| 435 | .Fa outw | ||
| 436 | to 'whiten' the encryption. | ||
| 437 | .Fa inw | ||
| 438 | and | ||
| 439 | .Fa outw | ||
| 440 | are secret (unlike the iv) and are as such, part of the key. | ||
| 441 | So the key is sort of 24 bytes. | ||
| 442 | This is much better than CBC DES. | ||
| 443 | .Pp | ||
| 444 | .Fn DES_ede3_cbc_encrypt | ||
| 445 | implements outer triple CBC DES encryption with three keys. | ||
| 446 | This means that each DES operation inside the CBC mode is really an | ||
| 447 | .Qq Li C=E(ks3,D(ks2,E(ks1,M))) . | ||
| 448 | This mode is used by SSL. | ||
| 449 | .Pp | ||
| 450 | The | ||
| 451 | .Fn DES_ede2_cbc_encrypt | ||
| 452 | macro implements two-key Triple-DES by reusing | ||
| 453 | .Fa ks1 | ||
| 454 | for the final encryption. | ||
| 455 | .Qq Li C=E(ks1,D(ks2,E(ks1,M))) . | ||
| 456 | This form of Triple-DES is used by the RSAREF library. | ||
| 457 | .Pp | ||
| 458 | .Fn DES_pcbc_encrypt | ||
| 459 | encrypt/decrypts using the propagating cipher block chaining mode used | ||
| 460 | by Kerberos v4. | ||
| 461 | Its parameters are the same as | ||
| 462 | .Fn DES_ncbc_encrypt . | ||
| 463 | .Pp | ||
| 464 | .Fn DES_cfb_encrypt | ||
| 465 | encrypt/decrypts using cipher feedback mode. | ||
| 466 | This method takes an array of characters as input and outputs and array | ||
| 467 | of characters. | ||
| 468 | It does not require any padding to 8 character groups. | ||
| 469 | Note: the | ||
| 470 | .Fa ivec | ||
| 471 | variable is changed and the new changed value needs to be passed to the | ||
| 472 | next call to this function. | ||
| 473 | Since this function runs a complete DES ECB encryption per | ||
| 474 | .Fa numbits , | ||
| 475 | this function is only suggested for use when sending small numbers of | ||
| 476 | characters. | ||
| 477 | .Pp | ||
| 478 | .Fn DES_cfb64_encrypt | ||
| 479 | implements CFB mode of DES with 64bit feedback. | ||
| 480 | Why is this useful you ask? | ||
| 481 | Because this routine will allow you to encrypt an arbitrary number of | ||
| 482 | bytes, no 8 byte padding. | ||
| 483 | Each call to this routine will encrypt the input bytes to output and | ||
| 484 | then update ivec and num. | ||
| 485 | num contains 'how far' we are though ivec. | ||
| 486 | If this does not make much sense, read more about cfb mode of DES :-). | ||
| 487 | .Pp | ||
| 488 | .Fn DES_ede3_cfb64_encrypt | ||
| 489 | and | ||
| 490 | .Fn DES_ede2_cfb64_encrypt | ||
| 491 | is the same as | ||
| 492 | .Fn DES_cfb64_encrypt | ||
| 493 | except that Triple-DES is used. | ||
| 494 | .Pp | ||
| 495 | .Fn DES_ofb_encrypt | ||
| 496 | encrypts using output feedback mode. | ||
| 497 | This method takes an array of characters as input and outputs and array | ||
| 498 | of characters. | ||
| 499 | It does not require any padding to 8 character groups. | ||
| 500 | Note: the | ||
| 501 | .Fa ivec | ||
| 502 | variable is changed and the new changed value needs to be passed to the | ||
| 503 | next call to this function. | ||
| 504 | Since this function runs a complete DES ECB encryption per numbits, this | ||
| 505 | function is only suggested for use when sending small numbers of | ||
| 506 | characters. | ||
| 507 | .Pp | ||
| 508 | .Fn DES_ofb64_encrypt | ||
| 509 | is the same as | ||
| 510 | .Fn DES_cfb64_encrypt | ||
| 511 | using Output Feed Back mode. | ||
| 512 | .Pp | ||
| 513 | .Fn DES_ede3_ofb64_encrypt | ||
| 514 | and | ||
| 515 | .Fn DES_ede2_ofb64_encrypt | ||
| 516 | is the same as | ||
| 517 | .Fn DES_ofb64_encrypt , | ||
| 518 | using Triple-DES. | ||
| 519 | .Pp | ||
| 520 | The following functions are included in the DES library for | ||
| 521 | compatibility with the MIT Kerberos library. | ||
| 522 | .Pp | ||
| 523 | .Fn DES_cbc_cksum | ||
| 524 | produces an 8 byte checksum based on the input stream (via CBC | ||
| 525 | encryption). | ||
| 526 | The last 4 bytes of the checksum are returned and the complete 8 bytes | ||
| 527 | are placed in | ||
| 528 | .Fa output . | ||
| 529 | This function is used by Kerberos v4. | ||
| 530 | Other applications should use | ||
| 531 | .Xr EVP_DigestInit 3 | ||
| 532 | etc. instead. | ||
| 533 | .Pp | ||
| 534 | .Fn DES_quad_cksum | ||
| 535 | is a Kerberos v4 function. | ||
| 536 | It returns a 4 byte checksum from the input bytes. | ||
| 537 | The algorithm can be iterated over the input, depending on | ||
| 538 | .Fa out_count , | ||
| 539 | 1, 2, 3 or 4 times. | ||
| 540 | If | ||
| 541 | .Fa output | ||
| 542 | is | ||
| 543 | .Pf non- Dv NULL , | ||
| 544 | the 8 bytes generated by each pass are written into | ||
| 545 | .Fa output . | ||
| 546 | .Pp | ||
| 547 | The following are DES-based transformations: | ||
| 548 | .Pp | ||
| 549 | .Fn DES_fcrypt | ||
| 550 | is a fast version of the Unix | ||
| 551 | .Xr crypt 3 | ||
| 552 | function. | ||
| 553 | This version takes only a small amount of space relative to other | ||
| 554 | fast crypt implementations. | ||
| 555 | This is different to the normal crypt in that the third parameter is the | ||
| 556 | buffer that the return value is written into. | ||
| 557 | It needs to be at least 14 bytes long. | ||
| 558 | This function is thread safe, unlike the normal crypt. | ||
| 559 | .Pp | ||
| 560 | .Fn DES_crypt | ||
| 561 | is a faster replacement for the normal system | ||
| 562 | .Xr crypt 3 . | ||
| 563 | This function calls | ||
| 564 | .Fn DES_fcrypt | ||
| 565 | with a static array passed as the third parameter. | ||
| 566 | This emulates the normal non-thread safe semantics of | ||
| 567 | .Xr crypt 3 . | ||
| 568 | .Pp | ||
| 569 | .Fn DES_enc_write | ||
| 570 | writes | ||
| 571 | .Fa len | ||
| 572 | bytes to file descriptor | ||
| 573 | .Fa fd | ||
| 574 | from buffer | ||
| 575 | .Fa buf . | ||
| 576 | The data is encrypted via | ||
| 577 | .Em pcbc_encrypt | ||
| 578 | (default) using | ||
| 579 | .Fa sched | ||
| 580 | for the key and | ||
| 581 | .Fa iv | ||
| 582 | as a starting vector. | ||
| 583 | The actual data send down | ||
| 584 | .Fa fd | ||
| 585 | consists of 4 bytes (in network byte order) containing the length of the | ||
| 586 | following encrypted data. | ||
| 587 | The encrypted data then follows, padded with random data out to a | ||
| 588 | multiple of 8 bytes. | ||
| 589 | .Pp | ||
| 590 | .Fn DES_enc_read | ||
| 591 | is used to read | ||
| 592 | .Fa len | ||
| 593 | bytes from file descriptor | ||
| 594 | .Fa fd | ||
| 595 | into buffer | ||
| 596 | .Fa buf . | ||
| 597 | The data being read from | ||
| 598 | .Fa fd | ||
| 599 | is assumed to have come from | ||
| 600 | .Fn DES_enc_write | ||
| 601 | and is decrypted using | ||
| 602 | .Fa sched | ||
| 603 | for the key schedule and | ||
| 604 | .Fa iv | ||
| 605 | for the initial vector. | ||
| 606 | .Pp | ||
| 607 | .Sy Warning: | ||
| 608 | The data format used by | ||
| 609 | .Fn DES_enc_write | ||
| 610 | and | ||
| 611 | .Fn DES_enc_read | ||
| 612 | has a cryptographic weakness: When asked to write more than | ||
| 613 | .Dv MAXWRITE | ||
| 614 | bytes, | ||
| 615 | .Fn DES_enc_write | ||
| 616 | will split the data into several chunks that are all encrypted using the | ||
| 617 | same IV. | ||
| 618 | So don't use these functions unless you are sure you know what | ||
| 619 | you do (in which case you might not want to use them anyway). | ||
| 620 | They cannot handle non-blocking sockets. | ||
| 621 | .Fn DES_enc_read | ||
| 622 | uses an internal state and thus cannot be used on multiple files. | ||
| 623 | .Pp | ||
| 624 | .Em DES_rw_mode | ||
| 625 | is used to specify the encryption mode to use with | ||
| 626 | .Fn DES_enc_read . | ||
| 627 | If set to | ||
| 628 | .Dv DES_PCBC_MODE | ||
| 629 | (the default), DES_pcbc_encrypt is used. | ||
| 630 | If set to | ||
| 631 | .Dv DES_CBC_MODE | ||
| 632 | DES_cbc_encrypt is used. | ||
| 633 | .Sh SEE ALSO | ||
| 634 | .Xr crypt 3 , | ||
| 635 | .Xr rand 3 | ||
| 636 | .Pp | ||
| 637 | The | ||
| 638 | .Xr evp 3 | ||
| 639 | library provides higher-level encryption functions. | ||
| 640 | .Sh STANDARDS | ||
| 641 | ANSI X3.106 | ||
| 642 | .Pp | ||
| 643 | The DES library was initially written to be source code compatible | ||
| 644 | with the MIT Kerberos library. | ||
| 645 | .Sh HISTORY | ||
| 646 | In OpenSSL 0.9.7, all des_ functions were renamed to DES_ to avoid | ||
| 647 | clashes with older versions of libdes. | ||
| 648 | .Pp | ||
| 649 | .Fn DES_set_key_checked | ||
| 650 | and | ||
| 651 | .Fn DES_set_key_unchecked | ||
| 652 | were added in OpenSSL 0.9.5. | ||
| 653 | .Pp | ||
| 654 | .Fn des_generate_random_block , | ||
| 655 | .Fn des_init_random_number_generator , | ||
| 656 | .Fn des_new_random_key , | ||
| 657 | .Fn des_set_random_generator_seed , | ||
| 658 | .Xr des_set_sequence_number , | ||
| 659 | and | ||
| 660 | .Fn des_rand_data 3 | ||
| 661 | are used in newer versions of Kerberos but are not implemented here. | ||
| 662 | .Pp | ||
| 663 | .Fn DES_random_key | ||
| 664 | generated cryptographically weak random data in SSLeay and in OpenSSL | ||
| 665 | prior version 0.9.5, as well as in the original MIT library. | ||
| 666 | .Sh AUTHORS | ||
| 667 | .An Eric Young Aq Mt eay@cryptsoft.com | ||
| 668 | .Sh CAVEATS | ||
| 669 | Single-key DES is insecure due to its short key size. | ||
| 670 | ECB mode is not suitable for most applications. | ||
| 671 | .Sh BUGS | ||
| 672 | .Xr DES_cbc_encrypt 3 | ||
| 673 | does not modify | ||
| 674 | .Fa ivec ; | ||
| 675 | use | ||
| 676 | .Fn DES_ncbc_encrypt | ||
| 677 | instead. | ||
| 678 | .Pp | ||
| 679 | .Fn DES_cfb_encrypt | ||
| 680 | and | ||
| 681 | .Fn DES_ofb_encrypt | ||
| 682 | operates on input of 8 bits. | ||
| 683 | What this means is that if you set numbits to 12, and length to 2, the | ||
| 684 | first 12 bits will come from the 1st input byte and the low half of the | ||
| 685 | second input byte. | ||
| 686 | The second 12 bits will have the low 8 bits taken from the 3rd input | ||
| 687 | byte and the top 4 bits taken from the 4th input byte. | ||
| 688 | The same holds for output. | ||
| 689 | This function has been implemented this way because most people will be | ||
| 690 | using a multiple of 8 and because once you get into pulling bytes input | ||
| 691 | bytes apart things get ugly! | ||
| 692 | .Pp | ||
| 693 | .Fn DES_string_to_key | ||
| 694 | is available for backward compatibility with the MIT library. | ||
| 695 | New applications should use a cryptographic hash function. | ||
| 696 | The same applies for | ||
| 697 | .Fn DES_string_to_2key . | ||
diff --git a/src/lib/libcrypto/man/DH_generate_key.3 b/src/lib/libcrypto/man/DH_generate_key.3 new file mode 100644 index 0000000000..6e2edbadb3 --- /dev/null +++ b/src/lib/libcrypto/man/DH_generate_key.3 | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DH_GENERATE_KEY 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DH_generate_key , | ||
| 6 | .Nm DH_compute_key | ||
| 7 | .Nd perform Diffie-Hellman key exchange | ||
| 8 | .Sh SYNOPSIS | ||
| 9 | .In openssl/dh.h | ||
| 10 | .Ft int | ||
| 11 | .Fo DH_generate_key | ||
| 12 | .Fa "DH *dh" | ||
| 13 | .Fc | ||
| 14 | .Ft int | ||
| 15 | .Fo DH_compute_key | ||
| 16 | .Fa "unsigned char *key" | ||
| 17 | .Fa "BIGNUM *pub_key" | ||
| 18 | .Fa "DH *dh" | ||
| 19 | .Fc | ||
| 20 | .Sh DESCRIPTION | ||
| 21 | .Fn DH_generate_key | ||
| 22 | performs the first step of a Diffie-Hellman key exchange by generating | ||
| 23 | private and public DH values. | ||
| 24 | By calling | ||
| 25 | .Fn DH_compute_key , | ||
| 26 | these are combined with the other party's public value to compute the | ||
| 27 | shared key. | ||
| 28 | .Pp | ||
| 29 | .Fn DH_generate_key | ||
| 30 | expects | ||
| 31 | .Fa dh | ||
| 32 | to contain the shared parameters | ||
| 33 | .Sy dh->p | ||
| 34 | and | ||
| 35 | .Sy dh->g . | ||
| 36 | It generates a random private DH value unless | ||
| 37 | .Sy dh->priv_key | ||
| 38 | is already set, and computes the corresponding public value | ||
| 39 | .Sy dh->pub_key , | ||
| 40 | which can then be published. | ||
| 41 | .Pp | ||
| 42 | .Fn DH_compute_key | ||
| 43 | computes the shared secret from the private DH value in | ||
| 44 | .Fa dh | ||
| 45 | and the other party's public value in | ||
| 46 | .Fa pub_key | ||
| 47 | and stores it in | ||
| 48 | .Fa key . | ||
| 49 | .Fa key | ||
| 50 | must point to | ||
| 51 | .Fn DH_size dh | ||
| 52 | bytes of memory. | ||
| 53 | .Sh RETURN VALUES | ||
| 54 | .Fn DH_generate_key | ||
| 55 | returns 1 on success, 0 otherwise. | ||
| 56 | .Pp | ||
| 57 | .Fn DH_compute_key | ||
| 58 | returns the size of the shared secret on success, -1 on error. | ||
| 59 | .Pp | ||
| 60 | The error codes can be obtained by | ||
| 61 | .Xr ERR_get_error 3 . | ||
| 62 | .Sh SEE ALSO | ||
| 63 | .Xr dh 3 , | ||
| 64 | .Xr DH_size 3 , | ||
| 65 | .Xr ERR_get_error 3 , | ||
| 66 | .Xr rand 3 | ||
| 67 | .Sh HISTORY | ||
| 68 | .Fn DH_generate_key | ||
| 69 | and | ||
| 70 | .Fn DH_compute_key | ||
| 71 | are available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/DH_generate_parameters.3 b/src/lib/libcrypto/man/DH_generate_parameters.3 new file mode 100644 index 0000000000..431ffd634c --- /dev/null +++ b/src/lib/libcrypto/man/DH_generate_parameters.3 | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DH_GENERATE_PARAMETERS 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DH_generate_parameters_ex , | ||
| 6 | .Nm DH_generate_parameters , | ||
| 7 | .Nm DH_check | ||
| 8 | .Nd generate and check Diffie-Hellman parameters | ||
| 9 | .Sh SYNOPSIS | ||
| 10 | .In openssl/dh.h | ||
| 11 | .Ft int | ||
| 12 | .Fo DH_generate_parameters_ex | ||
| 13 | .Fa "DH *dh" | ||
| 14 | .Fa "int prime_len" | ||
| 15 | .Fa "int generator" | ||
| 16 | .Fa "BN_GENCB *cb" | ||
| 17 | .Fc | ||
| 18 | .Ft int | ||
| 19 | .Fo DH_check | ||
| 20 | .Fa "DH *dh" | ||
| 21 | .Fa "int *codes" | ||
| 22 | .Fc | ||
| 23 | .Pp | ||
| 24 | Deprecated: | ||
| 25 | .Pp | ||
| 26 | .Ft DH * | ||
| 27 | .Fo DH_generate_parameters | ||
| 28 | .Fa "int prime_len" | ||
| 29 | .Fa "int generator" | ||
| 30 | .Fa "void (*callback)(int" | ||
| 31 | .Fa int | ||
| 32 | .Fa "void *)" | ||
| 33 | .Fa "void *cb_arg" | ||
| 34 | .Fc | ||
| 35 | .Sh DESCRIPTION | ||
| 36 | .Fn DH_generate_parameters_ex | ||
| 37 | generates Diffie-Hellman parameters that can be shared among a group of | ||
| 38 | users, and stores them in the provided | ||
| 39 | .Vt DH | ||
| 40 | structure. | ||
| 41 | .Pp | ||
| 42 | .Fa prime_len | ||
| 43 | is the length in bits of the safe prime to be generated. | ||
| 44 | .Fa generator | ||
| 45 | is a small number > 1, typically 2 or 5. | ||
| 46 | .Pp | ||
| 47 | A callback function may be used to provide feedback about the progress | ||
| 48 | of the key generation. | ||
| 49 | If | ||
| 50 | .Fa cb | ||
| 51 | is not | ||
| 52 | .Dv NULL , | ||
| 53 | it will be called as described in | ||
| 54 | .Xr BN_generate_prime 3 | ||
| 55 | while a random prime number is generated, and when a prime has been | ||
| 56 | found, | ||
| 57 | .Fn BN_GENCB_call cb 3 0 | ||
| 58 | is called; see | ||
| 59 | .Xr BN_GENCB_call 3 . | ||
| 60 | .Pp | ||
| 61 | .Fn DH_check | ||
| 62 | validates Diffie-Hellman parameters. | ||
| 63 | It checks that | ||
| 64 | .Fa dh->p | ||
| 65 | is a safe prime, and that | ||
| 66 | .Fa dh->g | ||
| 67 | is a suitable generator. | ||
| 68 | In the case of an error, the bit flags | ||
| 69 | .Dv DH_CHECK_P_NOT_SAFE_PRIME | ||
| 70 | or | ||
| 71 | .Dv DH_NOT_SUITABLE_GENERATOR | ||
| 72 | are set in | ||
| 73 | .Pf * Fa codes . | ||
| 74 | .Dv DH_UNABLE_TO_CHECK_GENERATOR | ||
| 75 | is set if the generator cannot be checked, i.e. if it does not equal 2 or 5. | ||
| 76 | .Sh RETURN VALUES | ||
| 77 | .Fn DH_generate_parameters_ex | ||
| 78 | and | ||
| 79 | .Fn DH_check | ||
| 80 | return 1 if the check could be performed, 0 otherwise. | ||
| 81 | .Pp | ||
| 82 | .Fn DH_generate_parameters | ||
| 83 | (deprecated) returns a pointer to the | ||
| 84 | .Vt DH | ||
| 85 | structure, or | ||
| 86 | .Dv NULL | ||
| 87 | if the parameter generation fails. | ||
| 88 | .Pp | ||
| 89 | The error codes can be obtained by | ||
| 90 | .Xr ERR_get_error 3 . | ||
| 91 | .Sh SEE ALSO | ||
| 92 | .Xr dh 3 , | ||
| 93 | .Xr DH_free 3 , | ||
| 94 | .Xr ERR_get_error 3 , | ||
| 95 | .Xr rand 3 | ||
| 96 | .Sh HISTORY | ||
| 97 | .Fn DH_check | ||
| 98 | is available in all versions of SSLeay and OpenSSL. | ||
| 99 | The | ||
| 100 | .Fa cb_arg | ||
| 101 | argument to | ||
| 102 | .Fn DH_generate_parameters | ||
| 103 | was added in SSLeay 0.9.0. | ||
| 104 | .Pp | ||
| 105 | In versions before OpenSSL 0.9.5, | ||
| 106 | .Dv DH_CHECK_P_NOT_STRONG_PRIME | ||
| 107 | is used instead of | ||
| 108 | .Dv DH_CHECK_P_NOT_SAFE_PRIME . | ||
| 109 | .Sh CAVEATS | ||
| 110 | .Fn DH_generate_parameters_ex | ||
| 111 | and | ||
| 112 | .Fn DH_generate_parameters | ||
| 113 | may run for several hours before finding a suitable prime. | ||
| 114 | .Pp | ||
| 115 | The parameters generated by | ||
| 116 | .Fn DH_generate_parameters_ex | ||
| 117 | and | ||
| 118 | .Fn DH_generate_parameters | ||
| 119 | are not to be used in signature schemes. | ||
| 120 | .Sh BUGS | ||
| 121 | If | ||
| 122 | .Fa generator | ||
| 123 | is not 2 or 5, | ||
| 124 | .Fa dh->g Ns = Ns Fa generator | ||
| 125 | is not a usable generator. | ||
diff --git a/src/lib/libcrypto/man/DH_get_ex_new_index.3 b/src/lib/libcrypto/man/DH_get_ex_new_index.3 new file mode 100644 index 0000000000..c93efa73d6 --- /dev/null +++ b/src/lib/libcrypto/man/DH_get_ex_new_index.3 | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DH_GET_EX_NEW_INDEX 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DH_get_ex_new_index , | ||
| 6 | .Nm DH_set_ex_data , | ||
| 7 | .Nm DH_get_ex_data | ||
| 8 | .Nd add application specific data to DH structures | ||
| 9 | .Sh SYNOPSIS | ||
| 10 | .In openssl/dh.h | ||
| 11 | .Ft int | ||
| 12 | .Fo DH_get_ex_new_index | ||
| 13 | .Fa "long argl" | ||
| 14 | .Fa "void *argp" | ||
| 15 | .Fa "CRYPTO_EX_new *new_func" | ||
| 16 | .Fa "CRYPTO_EX_dup *dup_func" | ||
| 17 | .Fa "CRYPTO_EX_free *free_func" | ||
| 18 | .Fc | ||
| 19 | .Ft int | ||
| 20 | .Fo DH_set_ex_data | ||
| 21 | .Fa "DH *d" | ||
| 22 | .Fa "int idx" | ||
| 23 | .Fa "void *arg" | ||
| 24 | .Fc | ||
| 25 | .Ft char * | ||
| 26 | .Fo DH_get_ex_data | ||
| 27 | .Fa "DH *d" | ||
| 28 | .Fa "int idx" | ||
| 29 | .Fc | ||
| 30 | .Sh DESCRIPTION | ||
| 31 | These functions handle application specific data in | ||
| 32 | .Vt DH | ||
| 33 | structures. | ||
| 34 | Their usage is identical to that of | ||
| 35 | .Xr RSA_get_ex_new_index 3 , | ||
| 36 | .Xr RSA_set_ex_data 3 , | ||
| 37 | and | ||
| 38 | .Xr RSA_get_ex_data 3 . | ||
| 39 | .Sh SEE ALSO | ||
| 40 | .Xr dh 3 , | ||
| 41 | .Xr RSA_get_ex_new_index 3 | ||
| 42 | .Sh HISTORY | ||
| 43 | .Fn DH_get_ex_new_index , | ||
| 44 | .Fn DH_set_ex_data , | ||
| 45 | and | ||
| 46 | .Fn DH_get_ex_data | ||
| 47 | are available since OpenSSL 0.9.5. | ||
diff --git a/src/lib/libcrypto/man/DH_new.3 b/src/lib/libcrypto/man/DH_new.3 new file mode 100644 index 0000000000..46b1570765 --- /dev/null +++ b/src/lib/libcrypto/man/DH_new.3 | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DH_NEW 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DH_new , | ||
| 6 | .Nm DH_free | ||
| 7 | .Nd allocate and free DH objects | ||
| 8 | .Sh SYNOPSIS | ||
| 9 | .In openssl/dh.h | ||
| 10 | .Ft DH* | ||
| 11 | .Fn DH_new void | ||
| 12 | .Ft void | ||
| 13 | .Fo DH_free | ||
| 14 | .Fa "DH *dh" | ||
| 15 | .Fc | ||
| 16 | .Sh DESCRIPTION | ||
| 17 | .Fn DH_new | ||
| 18 | allocates and initializes a | ||
| 19 | .Vt DH | ||
| 20 | structure. | ||
| 21 | .Pp | ||
| 22 | .Fn DH_free | ||
| 23 | frees the | ||
| 24 | .Vt DH | ||
| 25 | structure and its components. | ||
| 26 | The values are erased before the memory is returned to the system. | ||
| 27 | .Sh RETURN VALUES | ||
| 28 | If the allocation fails, | ||
| 29 | .Fn DH_new | ||
| 30 | returns | ||
| 31 | .Dv NULL | ||
| 32 | and sets an error code that can be obtained by | ||
| 33 | .Xr ERR_get_error 3 . | ||
| 34 | Otherwise it returns a pointer to the newly allocated structure. | ||
| 35 | .Sh SEE ALSO | ||
| 36 | .Xr dh 3 , | ||
| 37 | .Xr DH_generate_key 3 , | ||
| 38 | .Xr DH_generate_parameters 3 , | ||
| 39 | .Xr ERR_get_error 3 | ||
| 40 | .Sh HISTORY | ||
| 41 | .Fn DH_new | ||
| 42 | and | ||
| 43 | .Fn DH_free | ||
| 44 | are available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/DH_set_method.3 b/src/lib/libcrypto/man/DH_set_method.3 new file mode 100644 index 0000000000..86dae1728c --- /dev/null +++ b/src/lib/libcrypto/man/DH_set_method.3 | |||
| @@ -0,0 +1,223 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DH_SET_METHOD 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DH_set_default_method , | ||
| 6 | .Nm DH_get_default_method , | ||
| 7 | .Nm DH_set_method , | ||
| 8 | .Nm DH_new_method , | ||
| 9 | .Nm DH_OpenSSL , | ||
| 10 | .Nm DH_set_default_openssl_method , | ||
| 11 | .Nm DH_get_default_openssl_method | ||
| 12 | .Nd select DH method | ||
| 13 | .Sh SYNOPSIS | ||
| 14 | .In openssl/dh.h | ||
| 15 | .In openssl/engine.h | ||
| 16 | .Ft void | ||
| 17 | .Fo DH_set_default_method | ||
| 18 | .Fa "const DH_METHOD *meth" | ||
| 19 | .Fc | ||
| 20 | .Ft const DH_METHOD * | ||
| 21 | .Fo DH_get_default_method | ||
| 22 | .Fa void | ||
| 23 | .Fc | ||
| 24 | .Ft int | ||
| 25 | .Fo DH_set_method | ||
| 26 | .Fa "DH *dh" | ||
| 27 | .Fa "const DH_METHOD *meth" | ||
| 28 | .Fc | ||
| 29 | .Ft DH * | ||
| 30 | .Fo DH_new_method | ||
| 31 | .Fa "ENGINE *engine" | ||
| 32 | .Fc | ||
| 33 | .Ft const DH_METHOD * | ||
| 34 | .Fo DH_OpenSSL | ||
| 35 | .Fa void | ||
| 36 | .Fc | ||
| 37 | .Sh DESCRIPTION | ||
| 38 | A | ||
| 39 | .Vt DH_METHOD | ||
| 40 | specifies the functions that OpenSSL uses for Diffie-Hellman operations. | ||
| 41 | By modifying the method, alternative implementations such as hardware | ||
| 42 | accelerators may be used. | ||
| 43 | See the | ||
| 44 | .Sx CAVEATS | ||
| 45 | section for how these DH API functions are affected by the use of | ||
| 46 | .Xr engine 3 | ||
| 47 | API calls. | ||
| 48 | .Pp | ||
| 49 | Initially, the default | ||
| 50 | .Vt DH_METHOD | ||
| 51 | is the OpenSSL internal implementation as returned by | ||
| 52 | .Fn DH_OpenSSL . | ||
| 53 | .Pp | ||
| 54 | .Fn DH_set_default_method | ||
| 55 | makes | ||
| 56 | .Fa meth | ||
| 57 | the default method for all | ||
| 58 | .Vt DH | ||
| 59 | structures created later. | ||
| 60 | .Sy NB : | ||
| 61 | This is true only whilst no | ||
| 62 | .Vt ENGINE | ||
| 63 | has been set as a default for DH, so this function is no longer | ||
| 64 | recommended. | ||
| 65 | .Pp | ||
| 66 | .Fn DH_get_default_method | ||
| 67 | returns a pointer to the current default | ||
| 68 | .Vt DH_METHOD . | ||
| 69 | However, the meaningfulness of this result is dependent on whether the | ||
| 70 | .Xr engine 3 | ||
| 71 | API is being used, so this function is no longer recommended. | ||
| 72 | .Pp | ||
| 73 | .Fn DH_set_method | ||
| 74 | selects | ||
| 75 | .Fa meth | ||
| 76 | to perform all operations using the key | ||
| 77 | .Fa dh . | ||
| 78 | This will replace the | ||
| 79 | .Vt DH_METHOD | ||
| 80 | used by the | ||
| 81 | .Fa dh | ||
| 82 | key and if the previous method was supplied by an | ||
| 83 | .Vt ENGINE , | ||
| 84 | the handle to that | ||
| 85 | .Vt ENGINE | ||
| 86 | will be released during the change. | ||
| 87 | It is possible to have | ||
| 88 | .Vt DH | ||
| 89 | keys that only work with certain | ||
| 90 | .Vt DH_METHOD | ||
| 91 | implementations (eg. from an | ||
| 92 | .Vt ENGINE | ||
| 93 | module that supports embedded hardware-protected keys), | ||
| 94 | and in such cases attempting to change the | ||
| 95 | .Vt DH_METHOD | ||
| 96 | for the key can have unexpected results. | ||
| 97 | .Pp | ||
| 98 | .Fn DH_new_method | ||
| 99 | allocates and initializes a | ||
| 100 | .Vt DH | ||
| 101 | structure so that | ||
| 102 | .Fa engine | ||
| 103 | will be used for the DH operations. | ||
| 104 | If | ||
| 105 | .Fa engine | ||
| 106 | is | ||
| 107 | .Dv NULL , | ||
| 108 | the default | ||
| 109 | .Vt ENGINE | ||
| 110 | for DH operations is used, and if no default | ||
| 111 | .Vt ENGINE | ||
| 112 | is set, the | ||
| 113 | .Vt DH_METHOD | ||
| 114 | controlled by | ||
| 115 | .Fn DH_set_default_method | ||
| 116 | is used. | ||
| 117 | .Sh THE DH_METHOD STRUCTURE | ||
| 118 | .Bd -literal | ||
| 119 | typedef struct dh_meth_st | ||
| 120 | { | ||
| 121 | /* name of the implementation */ | ||
| 122 | const char *name; | ||
| 123 | |||
| 124 | /* generate private and public DH values for key agreement */ | ||
| 125 | int (*generate_key)(DH *dh); | ||
| 126 | |||
| 127 | /* compute shared secret */ | ||
| 128 | int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh); | ||
| 129 | |||
| 130 | /* compute r = a ^ p mod m (May be NULL for some implementations) */ | ||
| 131 | int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, | ||
| 132 | const BIGNUM *m, BN_CTX *ctx, | ||
| 133 | BN_MONT_CTX *m_ctx); | ||
| 134 | |||
| 135 | /* called at DH_new */ | ||
| 136 | int (*init)(DH *dh); | ||
| 137 | |||
| 138 | /* called at DH_free */ | ||
| 139 | int (*finish)(DH *dh); | ||
| 140 | |||
| 141 | int flags; | ||
| 142 | |||
| 143 | char *app_data; /* ?? */ | ||
| 144 | |||
| 145 | } DH_METHOD; | ||
| 146 | .Ed | ||
| 147 | .Sh RETURN VALUES | ||
| 148 | .Fn DH_OpenSSL | ||
| 149 | and | ||
| 150 | .Fn DH_get_default_method | ||
| 151 | return pointers to the respective | ||
| 152 | .Sy DH_METHOD Ns s. | ||
| 153 | .Pp | ||
| 154 | .Fn DH_set_method | ||
| 155 | returns non-zero if the provided | ||
| 156 | .Fa meth | ||
| 157 | was successfully set as the method for | ||
| 158 | .Fa dh | ||
| 159 | (including unloading the | ||
| 160 | .Vt ENGINE | ||
| 161 | handle if the previous method was supplied by an | ||
| 162 | .Vt ENGINE ) . | ||
| 163 | .Pp | ||
| 164 | .Fn DH_new_method | ||
| 165 | returns | ||
| 166 | .Dv NULL | ||
| 167 | and sets an error code that can be obtained by | ||
| 168 | .Xr ERR_get_error 3 | ||
| 169 | if the allocation fails. | ||
| 170 | Otherwise it returns a pointer to the newly allocated structure. | ||
| 171 | .Sh SEE ALSO | ||
| 172 | .Xr dh 3 , | ||
| 173 | .Xr DH_new 3 | ||
| 174 | .Sh HISTORY | ||
| 175 | .Fn DH_set_default_method , | ||
| 176 | .Fn DH_get_default_method , | ||
| 177 | .Fn DH_set_method , | ||
| 178 | .Fn DH_new_method | ||
| 179 | and | ||
| 180 | .Fn DH_OpenSSL | ||
| 181 | were added in OpenSSL 0.9.4. | ||
| 182 | .Pp | ||
| 183 | .Fn DH_set_default_openssl_method | ||
| 184 | and | ||
| 185 | .Fn DH_get_default_openssl_method | ||
| 186 | replaced | ||
| 187 | .Fn DH_set_default_method | ||
| 188 | and | ||
| 189 | .Fn DH_get_default_method | ||
| 190 | respectively, and | ||
| 191 | .Fn DH_set_method | ||
| 192 | and | ||
| 193 | .Fn DH_new_method | ||
| 194 | were altered to use | ||
| 195 | .Vt ENGINE Ns s | ||
| 196 | rather than | ||
| 197 | .Vt DH_METHOD Ns s | ||
| 198 | during development of the engine version of OpenSSL 0.9.6. | ||
| 199 | For 0.9.7, the handling of defaults in the | ||
| 200 | .Xr engine 3 | ||
| 201 | API was restructured so that this change was reversed, and behaviour | ||
| 202 | of the other functions resembled more closely the previous behaviour. | ||
| 203 | The behaviour of defaults in the | ||
| 204 | .Xr engine 3 | ||
| 205 | API now transparently overrides the behaviour of defaults in the | ||
| 206 | DH API without requiring changing these function prototypes. | ||
| 207 | .Sh CAVEATS | ||
| 208 | As of version 0.9.7, | ||
| 209 | .Vt DH_METHOD | ||
| 210 | implementations are grouped together with other algorithmic APIs | ||
| 211 | (eg. RSA_METHOD, EVP_CIPHER, etc) in | ||
| 212 | .Vt ENGINE | ||
| 213 | modules. | ||
| 214 | If a default | ||
| 215 | .Vt ENGINE | ||
| 216 | is specified for DH functionality using an | ||
| 217 | .Xr engine 3 | ||
| 218 | API function, that will override any DH defaults set using the DH API | ||
| 219 | .Pq ie. Fn DH_set_default_method . | ||
| 220 | For this reason, the | ||
| 221 | .Xr engine 3 | ||
| 222 | API is the recommended way to control default implementations | ||
| 223 | for use in DH and other cryptographic algorithms. | ||
diff --git a/src/lib/libcrypto/man/DH_size.3 b/src/lib/libcrypto/man/DH_size.3 new file mode 100644 index 0000000000..3675f7b12b --- /dev/null +++ b/src/lib/libcrypto/man/DH_size.3 | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | .Dd $Mdocdate: November 2 2016 $ | ||
| 2 | .Dt DH_SIZE 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm DH_size | ||
| 6 | .Nd get Diffie-Hellman prime size | ||
| 7 | .Sh SYNOPSIS | ||
| 8 | .In openssl/dh.h | ||
| 9 | .Ft int | ||
| 10 | .Fo DH_size | ||
| 11 | .Fa "DH *dh" | ||
| 12 | .Fc | ||
| 13 | .Sh DESCRIPTION | ||
| 14 | This function returns the Diffie-Hellman size in bytes. | ||
| 15 | It can be used to determine how much memory must be allocated for the | ||
| 16 | shared secret computed by | ||
| 17 | .Xr DH_compute_key 3 . | ||
| 18 | .Pp | ||
| 19 | .Fa dh->p | ||
| 20 | must not be | ||
| 21 | .Dv NULL . | ||
| 22 | .Sh RETURN VALUE | ||
| 23 | The size in bytes. | ||
| 24 | .Sh SEE ALSO | ||
| 25 | .Xr dh 3 , | ||
| 26 | .Xr DH_generate_key 3 | ||
| 27 | .Sh HISTORY | ||
| 28 | .Fn DH_size | ||
| 29 | is available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 1dfcf8700d..a40bb39167 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.34 2016/09/05 10:43:42 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.35 2016/11/02 09:11:53 schwarze Exp $ |
| 2 | 2 | ||
| 3 | .include <bsd.own.mk> # for NOMAN | 3 | .include <bsd.own.mk> # for NOMAN |
| 4 | 4 | ||
| @@ -56,6 +56,13 @@ MAN= \ | |||
| 56 | CONF_modules_load_file.3 \ | 56 | CONF_modules_load_file.3 \ |
| 57 | CRYPTO_set_ex_data.3 \ | 57 | CRYPTO_set_ex_data.3 \ |
| 58 | CRYPTO_set_locking_callback.3 \ | 58 | CRYPTO_set_locking_callback.3 \ |
| 59 | DES_set_key.3 \ | ||
| 60 | DH_generate_key.3 \ | ||
| 61 | DH_generate_parameters.3 \ | ||
| 62 | DH_get_ex_new_index.3 \ | ||
| 63 | DH_new.3 \ | ||
| 64 | DH_set_method.3 \ | ||
| 65 | DH_size.3 \ | ||
| 59 | ECDSA_SIG_new.3 \ | 66 | ECDSA_SIG_new.3 \ |
| 60 | EVP_AEAD_CTX_init.3 \ | 67 | EVP_AEAD_CTX_init.3 \ |
| 61 | UI_new.3 \ | 68 | UI_new.3 \ |
| @@ -66,13 +73,6 @@ MAN= \ | |||
| 66 | lh_new.3 \ | 73 | lh_new.3 \ |
| 67 | 74 | ||
| 68 | GENMAN= \ | 75 | GENMAN= \ |
| 69 | DES_set_key.3 \ | ||
| 70 | DH_generate_key.3 \ | ||
| 71 | DH_generate_parameters.3 \ | ||
| 72 | DH_get_ex_new_index.3 \ | ||
| 73 | DH_new.3 \ | ||
| 74 | DH_set_method.3 \ | ||
| 75 | DH_size.3 \ | ||
| 76 | DSA_SIG_new.3 \ | 76 | DSA_SIG_new.3 \ |
| 77 | DSA_do_sign.3 \ | 77 | DSA_do_sign.3 \ |
| 78 | DSA_dup_DH.3 \ | 78 | DSA_dup_DH.3 \ |
