summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3')
-rw-r--r--src/lib/libcrypto/man/PEM_read_bio_PrivateKey.348
1 files changed, 23 insertions, 25 deletions
diff --git a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3 b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
index 8532ef1b27..1ffafd69ed 100644
--- a/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
+++ b/src/lib/libcrypto/man/PEM_read_bio_PrivateKey.3
@@ -1,10 +1,9 @@
1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.2 2016/11/06 15:52:50 jmc Exp $ 1.\" $OpenBSD: PEM_read_bio_PrivateKey.3,v 1.3 2016/11/24 19:45:16 jmc Exp $
2.\" 2.\"
3.Dd $Mdocdate: November 6 2016 $ 3.Dd $Mdocdate: November 24 2016 $
4.Dt PEM_READ_BIO_PRIVATEKEY 3 4.Dt PEM_READ_BIO_PRIVATEKEY 3
5.Os 5.Os
6.Sh NAME 6.Sh NAME
7.Nm PEM ,
8.Nm PEM_read_bio_PrivateKey , 7.Nm PEM_read_bio_PrivateKey ,
9.Nm PEM_read_PrivateKey , 8.Nm PEM_read_PrivateKey ,
10.Nm PEM_write_bio_PrivateKey , 9.Nm PEM_write_bio_PrivateKey ,
@@ -516,7 +515,7 @@
516.Fc 515.Fc
517.Sh DESCRIPTION 516.Sh DESCRIPTION
518The PEM functions read or write structures in PEM format. 517The PEM functions read or write structures in PEM format.
519In this sense PEM format is simply base64 encoded data surrounded by 518In this sense PEM format is simply base64-encoded data surrounded by
520header lines. 519header lines.
521.Pp 520.Pp
522For more details about the meaning of arguments see the 521For more details about the meaning of arguments see the
@@ -542,7 +541,7 @@ structure.
542The write routines use "traditional" private key format and can handle 541The write routines use "traditional" private key format and can handle
543both RSA and DSA private keys. 542both RSA and DSA private keys.
544The read functions can additionally transparently handle PKCS#8 format 543The read functions can additionally transparently handle PKCS#8 format
545encrypted and unencrypted keys, too. 544encrypted and unencrypted keys too.
546.Pp 545.Pp
547.Fn PEM_write_bio_PKCS8PrivateKey 546.Fn PEM_write_bio_PKCS8PrivateKey
548and 547and
@@ -570,8 +569,7 @@ also write out a private key as a PKCS#8 EncryptedPrivateKeyInfo.
570However they use PKCS#5 v1.5 or PKCS#12 encryption algorithms instead. 569However they use PKCS#5 v1.5 or PKCS#12 encryption algorithms instead.
571The algorithm to use is specified in the 570The algorithm to use is specified in the
572.Fa nid 571.Fa nid
573parameter and should be the NID of the corresponding OBJECT IDENTIFIER 572parameter and should be the NID of the corresponding OBJECT IDENTIFIER.
574(see NOTES section).
575.Pp 573.Pp
576The 574The
577.Sy PUBKEY 575.Sy PUBKEY
@@ -754,7 +752,7 @@ if an error occurred.
754.Pp 752.Pp
755The PEM functions which write private keys take an 753The PEM functions which write private keys take an
756.Fa enc 754.Fa enc
757parameter which specifies the encryption algorithm to use. 755parameter, which specifies the encryption algorithm to use.
758Encryption is done at the PEM level. 756Encryption is done at the PEM level.
759If this parameter is set to 757If this parameter is set to
760.Dv NULL , 758.Dv NULL ,
@@ -779,7 +777,7 @@ is ignored.
779.Pp 777.Pp
780If the 778If the
781.Fa cb 779.Fa cb
782parameters is set to 780parameter is set to
783.Dv NULL 781.Dv NULL
784and the 782and the
785.Fa u 783.Fa u
@@ -795,7 +793,7 @@ and
795.Fa u 793.Fa u
796are 794are
797.Dv NULL , 795.Dv NULL ,
798then the default callback routine is used which will typically 796then the default callback routine is used, which will typically
799prompt for the passphrase on the current terminal with echoing 797prompt for the passphrase on the current terminal with echoing
800turned off. 798turned off.
801.Pp 799.Pp
@@ -835,7 +833,7 @@ or 0 if an error occurred.
835.Ss PEM encryption format 833.Ss PEM encryption format
836This old 834This old
837.Sy PrivateKey 835.Sy PrivateKey
838routines use a non standard technique for encryption. 836routines use a non-standard technique for encryption.
839.Pp 837.Pp
840The private key (or other data) takes the following form: 838The private key (or other data) takes the following form:
841.Bd -literal -offset indent 839.Bd -literal -offset indent
@@ -852,9 +850,9 @@ The line beginning with
852contains two comma separated pieces of information: 850contains two comma separated pieces of information:
853the encryption algorithm name as used by 851the encryption algorithm name as used by
854.Xr EVP_get_cipherbyname 3 852.Xr EVP_get_cipherbyname 3
855and an 8 byte salt encoded as a set of hexadecimal digits. 853and an 8-byte salt encoded as a set of hexadecimal digits.
856.Pp 854.Pp
857After this is the base64 encoded encrypted data. 855After this is the base64-encoded encrypted data.
858.Pp 856.Pp
859The encryption key is determined using 857The encryption key is determined using
860.Xr EVP_BytesToKey 3 , 858.Xr EVP_BytesToKey 3 ,
@@ -874,7 +872,7 @@ applications most of them are set to 0 or
874.Pp 872.Pp
875Read a certificate in PEM format from a 873Read a certificate in PEM format from a
876.Vt BIO : 874.Vt BIO :
877.Bd -literal 875.Bd -literal -offset indent
878X509 *x; 876X509 *x;
879x = PEM_read_bio_X509(bp, NULL, 0, NULL); 877x = PEM_read_bio_X509(bp, NULL, 0, NULL);
880if (x == NULL) { 878if (x == NULL) {
@@ -883,7 +881,7 @@ if (x == NULL) {
883.Ed 881.Ed
884.Pp 882.Pp
885Alternative method: 883Alternative method:
886.Bd -literal 884.Bd -literal -offset indent
887X509 *x = NULL; 885X509 *x = NULL;
888if (!PEM_read_bio_X509(bp, &x, 0, NULL)) { 886if (!PEM_read_bio_X509(bp, &x, 0, NULL)) {
889 /* Error */ 887 /* Error */
@@ -892,7 +890,7 @@ if (!PEM_read_bio_X509(bp, &x, 0, NULL)) {
892.Pp 890.Pp
893Write a certificate to a 891Write a certificate to a
894.Vt BIO : 892.Vt BIO :
895.Bd -literal 893.Bd -literal -offset indent
896if (!PEM_write_bio_X509(bp, x)) { 894if (!PEM_write_bio_X509(bp, x)) {
897 /* Error */ 895 /* Error */
898} 896}
@@ -900,7 +898,7 @@ if (!PEM_write_bio_X509(bp, x)) {
900.Pp 898.Pp
901Write an unencrypted private key to a 899Write an unencrypted private key to a
902.Vt FILE : 900.Vt FILE :
903.Bd -literal 901.Bd -literal -offset indent
904if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) { 902if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) {
905 /* Error */ 903 /* Error */
906} 904}
@@ -908,8 +906,8 @@ if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) {
908.Pp 906.Pp
909Write a private key (using traditional format) to a 907Write a private key (using traditional format) to a
910.Vt BIO 908.Vt BIO
911using triple DES encryption, the pass phrase is prompted for: 909using triple DES encryption; the pass phrase is prompted for:
912.Bd -literal 910.Bd -literal -offset indent
913if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), 911if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(),
914 NULL, 0, 0, NULL)) { 912 NULL, 0, 0, NULL)) {
915 /* Error */ 913 /* Error */
@@ -919,7 +917,7 @@ if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(),
919Write a private key (using PKCS#8 format) to a 917Write a private key (using PKCS#8 format) to a
920.Vt BIO 918.Vt BIO
921using triple DES encryption, using the pass phrase "hello": 919using triple DES encryption, using the pass phrase "hello":
922.Bd -literal 920.Bd -literal -offset indent
923if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(), 921if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(),
924 NULL, 0, 0, "hello")) { 922 NULL, 0, 0, "hello")) {
925 /* Error */ 923 /* Error */
@@ -929,7 +927,7 @@ if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(),
929Read a private key from a 927Read a private key from a
930.Vt BIO 928.Vt BIO
931using the pass phrase "hello": 929using the pass phrase "hello":
932.Bd -literal 930.Bd -literal -offset indent
933key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello"); 931key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello");
934if (key == NULL) { 932if (key == NULL) {
935 /* Error */ 933 /* Error */
@@ -939,7 +937,7 @@ if (key == NULL) {
939Read a private key from a 937Read a private key from a
940.Vt BIO 938.Vt BIO
941using a pass phrase callback: 939using a pass phrase callback:
942.Bd -literal 940.Bd -literal -offset indent
943key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key"); 941key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key");
944if (key == NULL) { 942if (key == NULL) {
945 /* Error */ 943 /* Error */
@@ -947,7 +945,7 @@ if (key == NULL) {
947.Ed 945.Ed
948.Pp 946.Pp
949Skeleton pass phrase callback: 947Skeleton pass phrase callback:
950.Bd -literal 948.Bd -literal -offset indent
951int 949int
952pass_cb(char *buf, int size, int rwflag, void *u) 950pass_cb(char *buf, int size, int rwflag, void *u)
953{ 951{
@@ -973,13 +971,13 @@ pass_cb(char *buf, int size, int rwflag, void *u)
973.Sh CAVEATS 971.Sh CAVEATS
974A frequent cause of problems is attempting to use the PEM routines like 972A frequent cause of problems is attempting to use the PEM routines like
975this: 973this:
976.Bd -literal 974.Bd -literal -offset indent
977X509 *x; 975X509 *x;
978PEM_read_bio_X509(bp, &x, 0, NULL); 976PEM_read_bio_X509(bp, &x, 0, NULL);
979.Ed 977.Ed
980.Pp 978.Pp
981This is a bug because an attempt will be made to reuse the data at 979This is a bug because an attempt will be made to reuse the data at
982.Fa x 980.Fa x ,
983which is an uninitialised pointer. 981which is an uninitialised pointer.
984.Sh BUGS 982.Sh BUGS
985The PEM read routines in some versions of OpenSSL will not correctly 983The PEM read routines in some versions of OpenSSL will not correctly