summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EVP_EncryptInit.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/man/EVP_EncryptInit.354
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
292is the symmetric key to use and 292is the symmetric key to use and
293.Fa iv 293.Fa iv
294is the IV to use (if necessary), the actual number of bytes used for the 294is the IV to use (if necessary).
295The actual number of bytes used for the
295key and IV depends on the cipher. 296key and IV depends on the cipher.
296It is possible to set all parameters to 297It 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
377clears all information from a cipher context and free up any allocated 378clears all information from a cipher context and free up any allocated
378memory associate with it. 379memory associated with it.
379It should be called after all operations using a cipher are complete so 380It should be called after all operations using a cipher are complete so
380sensitive information does not remain in memory. 381sensitive 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
491return the type of the passed cipher or context. 492return the type of the passed cipher or context.
492This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it 493This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it
493ignores the cipher parameters and 40 bit RC2 and 128 bit RC2 have the 494ignores the cipher parameters and 40-bit RC2 and 128-bit RC2 have the
494same NID. 495same NID.
495If the cipher does not have an object identifier or does not 496If the cipher does not have an object identifier or does not
496have ASN1 support this function will return 497have 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.
521This will typically include any parameters and an IV. 522This will typically include any parameters and an IV.
522The cipher IV (if any) must be set when this call is made. 523The cipher IV (if any) must be set when this call is made.
523This call should be made before the cipher is actually "used" (before any 524This call should be made before the cipher is actually "used" (before any
524.Fn EVP_EncryptUpdate , 525.Fn EVP_EncryptUpdate
526or
525.Fn EVP_DecryptUpdate 527.Fn EVP_DecryptUpdate
526calls for example). 528calls, for example).
527This function may fail if the cipher does not have any ASN1 support. 529This 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
530sets the cipher parameters based on an ASN1 AlgorithmIdentifier 532sets the cipher parameters based on an ASN.1 AlgorithmIdentifier
531"parameter". 533"parameter".
532The precise effect depends on the cipher. 534The precise effect depends on the cipher.
533In the case of RC2, for example, it will set the IV and effective 535In the case of RC2, for example, it will set the IV and effective
@@ -544,7 +546,7 @@ will be called and finally
544again with all parameters except the key set to 546again with all parameters except the key set to
545.Dv NULL . 547.Dv NULL .
546It is possible for this function to fail if the cipher does not 548It is possible for this function to fail if the cipher does not
547have any ASN1 support or the parameters cannot be set (for example 549have any ASN.1 support or the parameters cannot be set (for example
548the RC2 effective key length is not supported). 550the 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.
720RC4 stream cipher. 722RC4 stream cipher.
721This is a variable key length cipher with default key length 128 bits. 723This 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
723RC4 stream cipher with 40 bit key length. 725RC4 stream cipher with 40-bit key length.
724This is obsolete and new code should use 726This is obsolete and new code should use
725.Fn EVP_rc4 727.Fn EVP_rc4
726and the 728and 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
787Get the number of rounds used in RC5: 789Get the number of rounds used in RC5:
788.Bd -literal 790.Bd -literal -offset indent
789int nrounds; 791int nrounds;
790EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds); 792EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds);
791.Ed 793.Ed
792.Pp 794.Pp
793Get the RC2 effective key length: 795Get the RC2 effective key length:
794.Bd -literal 796.Bd -literal -offset indent
795int key_bits; 797int key_bits;
796EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits); 798EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits);
797.Ed 799.Ed
798.Pp 800.Pp
799Set the number of rounds used in RC5: 801Set the number of rounds used in RC5:
800.Bd -literal 802.Bd -literal -offset indent
801int nrounds; 803int nrounds;
802EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL); 804EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL);
803.Ed 805.Ed
804.Pp 806.Pp
805Set the effective key length used in RC2: 807Set the effective key length used in RC2:
806.Bd -literal 808.Bd -literal -offset indent
807int key_bits; 809int key_bits;
808EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); 810EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
809.Ed 811.Ed
810.Pp 812.Pp
811Encrypt a string using blowfish: 813Encrypt a string using blowfish:
812.Bd -literal 814.Bd -literal -offset 3n
813int 815int
814do_crypt(char *outfile) 816do_crypt(char *outfile)
815{ 817{
@@ -858,13 +860,13 @@ do_crypt(char *outfile)
858The ciphertext from the above example can be decrypted using the 860The ciphertext from the above example can be decrypted using the
859.Xr openssl 1 861.Xr openssl 1
860utility with the command line: 862utility with the command line:
861.Bd -literal 863.Bd -literal -offset indent
862openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F \e 864openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F \e
863 -iv 0102030405060708 -d 865 -iv 0102030405060708 -d
864.Ed 866.Ed
865.Pp 867.Pp
866General encryption, decryption function example using FILE I/O and RC2 868General encryption, decryption function example using FILE I/O and RC2
867with an 80 bit key: 869with an 80-bit key:
868.Bd -literal 870.Bd -literal
869int 871int
870do_crypt(FILE *in, FILE *out, int do_encrypt) 872do_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
938bytes. 940bytes.
939.Pp 941.Pp
940The ASN1 code is incomplete (and sometimes inaccurate) it has only been 942The ASN.1 code is incomplete (and sometimes inaccurate).
941tested for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC 943It has only been tested for certain common S/MIME ciphers
942mode. 944(RC2, DES, triple DES) in CBC mode.