diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/man/EVP_EncryptInit.3 | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/lib/libcrypto/man/EVP_EncryptInit.3 b/src/lib/libcrypto/man/EVP_EncryptInit.3 index e786468550..3757bfc815 100644 --- a/src/lib/libcrypto/man/EVP_EncryptInit.3 +++ b/src/lib/libcrypto/man/EVP_EncryptInit.3 | |||
@@ -1,6 +1,6 @@ | |||
1 | .\" $OpenBSD: EVP_EncryptInit.3,v 1.2 2016/11/06 15:52:50 jmc Exp $ | 1 | .\" $OpenBSD: EVP_EncryptInit.3,v 1.3 2016/11/21 22:19:15 jmc Exp $ |
2 | .\" | 2 | .\" |
3 | .Dd $Mdocdate: November 6 2016 $ | 3 | .Dd $Mdocdate: November 21 2016 $ |
4 | .Dt EVP_ENCRYPTINIT 3 | 4 | .Dt EVP_ENCRYPTINIT 3 |
5 | .Os | 5 | .Os |
6 | .Sh NAME | 6 | .Sh NAME |
@@ -14,15 +14,16 @@ | |||
14 | .Nm EVP_CipherInit_ex , | 14 | .Nm EVP_CipherInit_ex , |
15 | .Nm EVP_CipherUpdate , | 15 | .Nm EVP_CipherUpdate , |
16 | .Nm EVP_CipherFinal_ex , | 16 | .Nm EVP_CipherFinal_ex , |
17 | .Nm EVP_CIPHER_CTX_set_key_length , | ||
18 | .Nm EVP_CIPHER_CTX_ctrl , | ||
19 | .Nm EVP_CIPHER_CTX_cleanup , | ||
20 | .Nm EVP_EncryptInit , | 17 | .Nm EVP_EncryptInit , |
21 | .Nm EVP_EncryptFinal , | 18 | .Nm EVP_EncryptFinal , |
22 | .Nm EVP_DecryptInit , | 19 | .Nm EVP_DecryptInit , |
23 | .Nm EVP_DecryptFinal , | 20 | .Nm EVP_DecryptFinal , |
24 | .Nm EVP_CipherInit , | 21 | .Nm EVP_CipherInit , |
25 | .Nm EVP_CipherFinal , | 22 | .Nm EVP_CipherFinal , |
23 | .Nm EVP_CIPHER_CTX_set_padding , | ||
24 | .Nm EVP_CIPHER_CTX_set_key_length , | ||
25 | .Nm EVP_CIPHER_CTX_ctrl , | ||
26 | .Nm EVP_CIPHER_CTX_cleanup , | ||
26 | .Nm EVP_get_cipherbyname , | 27 | .Nm EVP_get_cipherbyname , |
27 | .Nm EVP_get_cipherbynid , | 28 | .Nm EVP_get_cipherbynid , |
28 | .Nm EVP_get_cipherbyobj , | 29 | .Nm EVP_get_cipherbyobj , |
@@ -45,7 +46,6 @@ | |||
45 | .Nm EVP_CIPHER_CTX_mode , | 46 | .Nm EVP_CIPHER_CTX_mode , |
46 | .Nm EVP_CIPHER_param_to_asn1 , | 47 | .Nm EVP_CIPHER_param_to_asn1 , |
47 | .Nm EVP_CIPHER_asn1_to_param , | 48 | .Nm EVP_CIPHER_asn1_to_param , |
48 | .Nm EVP_CIPHER_CTX_set_padding , | ||
49 | .Nm EVP_enc_null , | 49 | .Nm EVP_enc_null , |
50 | .Nm EVP_des_cbc , | 50 | .Nm EVP_des_cbc , |
51 | .Nm EVP_des_ecb , | 51 | .Nm EVP_des_ecb , |
@@ -291,7 +291,8 @@ then the default implementation is used. | |||
291 | .Fa key | 291 | .Fa key |
292 | is the symmetric key to use and | 292 | is the symmetric key to use and |
293 | .Fa iv | 293 | .Fa iv |
294 | is the IV to use (if necessary), the actual number of bytes used for the | 294 | is the IV to use (if necessary). |
295 | The actual number of bytes used for the | ||
295 | key and IV depends on the cipher. | 296 | key and IV depends on the cipher. |
296 | It is possible to set all parameters to | 297 | It is possible to set all parameters to |
297 | .Dv NULL | 298 | .Dv NULL |
@@ -375,7 +376,7 @@ being supplied in a previous call). | |||
375 | .Pp | 376 | .Pp |
376 | .Fn EVP_CIPHER_CTX_cleanup | 377 | .Fn EVP_CIPHER_CTX_cleanup |
377 | clears all information from a cipher context and free up any allocated | 378 | clears all information from a cipher context and free up any allocated |
378 | memory associate with it. | 379 | memory associated with it. |
379 | It should be called after all operations using a cipher are complete so | 380 | It should be called after all operations using a cipher are complete so |
380 | sensitive information does not remain in memory. | 381 | sensitive information does not remain in memory. |
381 | .Pp | 382 | .Pp |
@@ -490,10 +491,10 @@ and | |||
490 | .Fn EVP_CIPHER_CTX_type | 491 | .Fn EVP_CIPHER_CTX_type |
491 | return the type of the passed cipher or context. | 492 | return the type of the passed cipher or context. |
492 | This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it | 493 | This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it |
493 | ignores the cipher parameters and 40 bit RC2 and 128 bit RC2 have the | 494 | ignores the cipher parameters and 40-bit RC2 and 128-bit RC2 have the |
494 | same NID. | 495 | same NID. |
495 | If the cipher does not have an object identifier or does not | 496 | If the cipher does not have an object identifier or does not |
496 | have ASN1 support this function will return | 497 | have ASN.1 support this function will return |
497 | .Dv NID_undef . | 498 | .Dv NID_undef . |
498 | .Pp | 499 | .Pp |
499 | .Fn EVP_CIPHER_CTX_cipher | 500 | .Fn EVP_CIPHER_CTX_cipher |
@@ -521,13 +522,14 @@ sets the AlgorithmIdentifier "parameter" based on the passed cipher. | |||
521 | This will typically include any parameters and an IV. | 522 | This will typically include any parameters and an IV. |
522 | The cipher IV (if any) must be set when this call is made. | 523 | The cipher IV (if any) must be set when this call is made. |
523 | This call should be made before the cipher is actually "used" (before any | 524 | This call should be made before the cipher is actually "used" (before any |
524 | .Fn EVP_EncryptUpdate , | 525 | .Fn EVP_EncryptUpdate |
526 | or | ||
525 | .Fn EVP_DecryptUpdate | 527 | .Fn EVP_DecryptUpdate |
526 | calls for example). | 528 | calls, for example). |
527 | This function may fail if the cipher does not have any ASN1 support. | 529 | This function may fail if the cipher does not have any ASN.1 support. |
528 | .Pp | 530 | .Pp |
529 | .Fn EVP_CIPHER_asn1_to_param | 531 | .Fn EVP_CIPHER_asn1_to_param |
530 | sets the cipher parameters based on an ASN1 AlgorithmIdentifier | 532 | sets the cipher parameters based on an ASN.1 AlgorithmIdentifier |
531 | "parameter". | 533 | "parameter". |
532 | The precise effect depends on the cipher. | 534 | The precise effect depends on the cipher. |
533 | In the case of RC2, for example, it will set the IV and effective | 535 | In the case of RC2, for example, it will set the IV and effective |
@@ -544,7 +546,7 @@ will be called and finally | |||
544 | again with all parameters except the key set to | 546 | again with all parameters except the key set to |
545 | .Dv NULL . | 547 | .Dv NULL . |
546 | It is possible for this function to fail if the cipher does not | 548 | It is possible for this function to fail if the cipher does not |
547 | have any ASN1 support or the parameters cannot be set (for example | 549 | have any ASN.1 support or the parameters cannot be set (for example |
548 | the RC2 effective key length is not supported). | 550 | the RC2 effective key length is not supported). |
549 | .Pp | 551 | .Pp |
550 | .Fn EVP_CIPHER_CTX_ctrl | 552 | .Fn EVP_CIPHER_CTX_ctrl |
@@ -720,7 +722,7 @@ DESX algorithm in CBC mode. | |||
720 | RC4 stream cipher. | 722 | RC4 stream cipher. |
721 | This is a variable key length cipher with default key length 128 bits. | 723 | This is a variable key length cipher with default key length 128 bits. |
722 | .It Fn EVP_rc4_40 void | 724 | .It Fn EVP_rc4_40 void |
723 | RC4 stream cipher with 40 bit key length. | 725 | RC4 stream cipher with 40-bit key length. |
724 | This is obsolete and new code should use | 726 | This is obsolete and new code should use |
725 | .Fn EVP_rc4 | 727 | .Fn EVP_rc4 |
726 | and the | 728 | and the |
@@ -785,31 +787,31 @@ By default the key length is set to 128 bits and 12 rounds. | |||
785 | .El | 787 | .El |
786 | .Sh EXAMPLES | 788 | .Sh EXAMPLES |
787 | Get the number of rounds used in RC5: | 789 | Get the number of rounds used in RC5: |
788 | .Bd -literal | 790 | .Bd -literal -offset indent |
789 | int nrounds; | 791 | int nrounds; |
790 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds); | 792 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds); |
791 | .Ed | 793 | .Ed |
792 | .Pp | 794 | .Pp |
793 | Get the RC2 effective key length: | 795 | Get the RC2 effective key length: |
794 | .Bd -literal | 796 | .Bd -literal -offset indent |
795 | int key_bits; | 797 | int key_bits; |
796 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits); | 798 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits); |
797 | .Ed | 799 | .Ed |
798 | .Pp | 800 | .Pp |
799 | Set the number of rounds used in RC5: | 801 | Set the number of rounds used in RC5: |
800 | .Bd -literal | 802 | .Bd -literal -offset indent |
801 | int nrounds; | 803 | int nrounds; |
802 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL); | 804 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL); |
803 | .Ed | 805 | .Ed |
804 | .Pp | 806 | .Pp |
805 | Set the effective key length used in RC2: | 807 | Set the effective key length used in RC2: |
806 | .Bd -literal | 808 | .Bd -literal -offset indent |
807 | int key_bits; | 809 | int key_bits; |
808 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); | 810 | EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); |
809 | .Ed | 811 | .Ed |
810 | .Pp | 812 | .Pp |
811 | Encrypt a string using blowfish: | 813 | Encrypt a string using blowfish: |
812 | .Bd -literal | 814 | .Bd -literal -offset 3n |
813 | int | 815 | int |
814 | do_crypt(char *outfile) | 816 | do_crypt(char *outfile) |
815 | { | 817 | { |
@@ -858,13 +860,13 @@ do_crypt(char *outfile) | |||
858 | The ciphertext from the above example can be decrypted using the | 860 | The ciphertext from the above example can be decrypted using the |
859 | .Xr openssl 1 | 861 | .Xr openssl 1 |
860 | utility with the command line: | 862 | utility with the command line: |
861 | .Bd -literal | 863 | .Bd -literal -offset indent |
862 | openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F \e | 864 | openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F \e |
863 | -iv 0102030405060708 -d | 865 | -iv 0102030405060708 -d |
864 | .Ed | 866 | .Ed |
865 | .Pp | 867 | .Pp |
866 | General encryption, decryption function example using FILE I/O and RC2 | 868 | General encryption, decryption function example using FILE I/O and RC2 |
867 | with an 80 bit key: | 869 | with an 80-bit key: |
868 | .Bd -literal | 870 | .Bd -literal |
869 | int | 871 | int |
870 | do_crypt(FILE *in, FILE *out, int do_encrypt) | 872 | do_crypt(FILE *in, FILE *out, int do_encrypt) |
@@ -937,6 +939,6 @@ as a fixed unsigned char array containing | |||
937 | .Dv EVP_MAX_KEY_LENGTH | 939 | .Dv EVP_MAX_KEY_LENGTH |
938 | bytes. | 940 | bytes. |
939 | .Pp | 941 | .Pp |
940 | The ASN1 code is incomplete (and sometimes inaccurate) it has only been | 942 | The ASN.1 code is incomplete (and sometimes inaccurate). |
941 | tested for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC | 943 | It has only been tested for certain common S/MIME ciphers |
942 | mode. | 944 | (RC2, DES, triple DES) in CBC mode. |