📄 des.pod
字号:
DES_ede3_cbc_encrypt() implements outer triple CBC DES encryption withthree keys. This means that each DES operation inside the CBC mode isreally an C<C=E(ks3,D(ks2,E(ks1,M)))>. This mode is used by SSL.The DES_ede2_cbc_encrypt() macro implements two-key Triple-DES byreusing I<ks1> for the final encryption. C<C=E(ks1,D(ks2,E(ks1,M)))>.This form of Triple-DES is used by the RSAREF library.DES_pcbc_encrypt() encrypt/decrypts using the propagating cipher blockchaining mode used by Kerberos v4. Its parameters are the same asDES_ncbc_encrypt().DES_cfb_encrypt() encrypt/decrypts using cipher feedback mode. Thismethod takes an array of characters as input and outputs and array ofcharacters. It does not require any padding to 8 character groups.Note: the I<ivec> variable is changed and the new changed value needs tobe passed to the next call to this function. Since this function runsa complete DES ECB encryption per I<numbits>, this function is onlysuggested for use when sending small numbers of characters.DES_cfb64_encrypt()implements CFB mode of DES with 64bit feedback. Why is thisuseful you ask? Because this routine will allow you to encrypt anarbitrary number of bytes, no 8 byte padding. Each call to thisroutine will encrypt the input bytes to output and then update ivecand num. num contains 'how far' we are though ivec. If this doesnot make much sense, read more about cfb mode of DES :-).DES_ede3_cfb64_encrypt() and DES_ede2_cfb64_encrypt() is the same asDES_cfb64_encrypt() except that Triple-DES is used.DES_ofb_encrypt() encrypts using output feedback mode. This methodtakes an array of characters as input and outputs and array ofcharacters. It does not require any padding to 8 character groups.Note: the I<ivec> variable is changed and the new changed value needs tobe passed to the next call to this function. Since this function runsa complete DES ECB encryption per numbits, this function is onlysuggested for use when sending small numbers of characters.DES_ofb64_encrypt() is the same as DES_cfb64_encrypt() using OutputFeed Back mode.DES_ede3_ofb64_encrypt() and DES_ede2_ofb64_encrypt() is the same asDES_ofb64_encrypt(), using Triple-DES.The following functions are included in the DES library forcompatibility with the MIT Kerberos library.DES_cbc_cksum() produces an 8 byte checksum based on the input stream(via CBC encryption). The last 4 bytes of the checksum are returnedand the complete 8 bytes are placed in I<output>. This function isused by Kerberos v4. Other applications should useL<EVP_DigestInit(3)|EVP_DigestInit(3)> etc. instead.DES_quad_cksum() is a Kerberos v4 function. It returns a 4 bytechecksum from the input bytes. The algorithm can be iterated over theinput, depending on I<out_count>, 1, 2, 3 or 4 times. If I<output> isnon-NULL, the 8 bytes generated by each pass are written intoI<output>.The following are DES-based transformations:DES_fcrypt() is a fast version of the Unix crypt(3) function. Thisversion takes only a small amount of space relative to other fastcrypt() implementations. This is different to the normal crypt inthat the third parameter is the buffer that the return value iswritten into. It needs to be at least 14 bytes long. This functionis thread safe, unlike the normal crypt.DES_crypt() is a faster replacement for the normal system crypt().This function calls DES_fcrypt() with a static array passed as thethird parameter. This emulates the normal non-thread safe semanticsof crypt(3).DES_enc_write() writes I<len> bytes to file descriptor I<fd> frombuffer I<buf>. The data is encrypted via I<pcbc_encrypt> (default)using I<sched> for the key and I<iv> as a starting vector. The actualdata send down I<fd> consists of 4 bytes (in network byte order)containing the length of the following encrypted data. The encrypteddata then follows, padded with random data out to a multiple of 8bytes.DES_enc_read() is used to read I<len> bytes from file descriptorI<fd> into buffer I<buf>. The data being read from I<fd> is assumed tohave come from DES_enc_write() and is decrypted using I<sched> forthe key schedule and I<iv> for the initial vector.B<Warning:> The data format used by DES_enc_write() and DES_enc_read()has a cryptographic weakness: When asked to write more than MAXWRITEbytes, DES_enc_write() will split the data into several chunks thatare all encrypted using the same IV. So don't use these functionsunless you are sure you know what you do (in which case you might notwant to use them anyway). They cannot handle non-blocking sockets.DES_enc_read() uses an internal state and thus cannot be used onmultiple files.I<DES_rw_mode> is used to specify the encryption mode to use withDES_enc_read() and DES_end_write(). If set to I<DES_PCBC_MODE> (thedefault), DES_pcbc_encrypt is used. If set to I<DES_CBC_MODE>DES_cbc_encrypt is used.=head1 NOTESSingle-key DES is insecure due to its short key size. ECB mode isnot suitable for most applications; see L<des_modes(7)|des_modes(7)>.The L<evp(3)|evp(3)> library provides higher-level encryption functions.=head1 BUGSDES_3cbc_encrypt() is flawed and must not be used in applications.DES_cbc_encrypt() does not modify B<ivec>; use DES_ncbc_encrypt()instead.DES_cfb_encrypt() and DES_ofb_encrypt() operates on input of 8 bits.What this means is that if you set numbits to 12, and length to 2, thefirst 12 bits will come from the 1st input byte and the low half ofthe second input byte. The second 12 bits will have the low 8 bitstaken from the 3rd input byte and the top 4 bits taken from the 4thinput byte. The same holds for output. This function has beenimplemented this way because most people will be using a multiple of 8and because once you get into pulling bytes input bytes apart thingsget ugly!DES_string_to_key() is available for backward compatibility with theMIT library. New applications should use a cryptographic hash function.The same applies for DES_string_to_2key().=head1 CONFORMING TOANSI X3.106The B<des> library was written to be source code compatible withthe MIT Kerberos library.=head1 SEE ALSOcrypt(3), L<des_modes(7)|des_modes(7)>, L<evp(3)|evp(3)>, L<rand(3)|rand(3)>=head1 HISTORYIn OpenSSL 0.9.7, all des_ functions were renamed to DES_ to avoidclashes with older versions of libdes. Compatibility des_ functionsare provided for a short while, as well as crypt().Declarations for these are in <openssl/des_old.h>. There is no DES_variant for des_random_seed().This will happen to other functionsas well if they are deemed redundant (des_random_seed() just callsRAND_seed() and is present for backward compatibility only), buggy oralready scheduled for removal.des_cbc_cksum(), des_cbc_encrypt(), des_ecb_encrypt(),des_is_weak_key(), des_key_sched(), des_pcbc_encrypt(),des_quad_cksum(), des_random_key() and des_string_to_key()are available in the MIT Kerberos library;des_check_key_parity(), des_fixup_key_parity() and des_is_weak_key()are available in newer versions of that library.des_set_key_checked() and des_set_key_unchecked() were added inOpenSSL 0.9.5.des_generate_random_block(), des_init_random_number_generator(),des_new_random_key(), des_set_random_generator_seed() anddes_set_sequence_number() and des_rand_data() are used in newerversions of Kerberos but are not implemented here.des_random_key() generated cryptographically weak random data inSSLeay and in OpenSSL prior version 0.9.5, as well as in the originalMIT library.=head1 AUTHOREric Young (eay@cryptsoft.com). Modified for the OpenSSL project(http://www.openssl.org).=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -