summaryrefslogtreecommitdiff
path: root/lib/libcrypto/pem
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2016-09-04 16:10:39 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2016-09-04 16:10:39 +0000
commit4069d02e14d279fbf9e945c85a1342d8b88eb650 (patch)
tree9ffe109fd7eabc0c48f4e60d310696e9f76354e4 /lib/libcrypto/pem
parentd9123b7946dc99b122c27b2c0cf255dac6a0051d (diff)
Sort and group functions.
Diffstat (limited to 'lib/libcrypto/pem')
-rw-r--r--lib/libcrypto/pem/pem_all.c343
-rw-r--r--lib/libcrypto/pem/pem_pk8.c44
-rw-r--r--lib/libcrypto/pem/pem_x509.c24
-rw-r--r--lib/libcrypto/pem/pem_xaux.c42
4 files changed, 215 insertions, 238 deletions
diff --git a/lib/libcrypto/pem/pem_all.c b/lib/libcrypto/pem/pem_all.c
index befa37c6544..f5211f29a67 100644
--- a/lib/libcrypto/pem/pem_all.c
+++ b/lib/libcrypto/pem/pem_all.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pem_all.c,v 1.16 2016/09/04 15:53:03 jsing Exp $ */
+/* $OpenBSD: pem_all.c,v 1.17 2016/09/04 16:10:38 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -142,16 +142,23 @@ static EC_KEY *pkey_get_eckey(EVP_PKEY *key, EC_KEY **eckey);
X509_REQ *
-PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x, pem_password_cb *cb, void *u)
+PEM_read_X509_REQ(FILE *fp, X509_REQ **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509_REQ, PEM_STRING_X509_REQ, bp,
+ return PEM_ASN1_read((d2i_of_void *)d2i_X509_REQ, PEM_STRING_X509_REQ, fp,
(void **)x, cb, u);
}
+int
+PEM_write_X509_REQ(FILE *fp, X509_REQ *x)
+{
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509_REQ, PEM_STRING_X509_REQ, fp,
+ x, NULL, NULL, 0, NULL, NULL);
+}
+
X509_REQ *
-PEM_read_X509_REQ(FILE *fp, X509_REQ **x, pem_password_cb *cb, void *u)
+PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read((d2i_of_void *)d2i_X509_REQ, PEM_STRING_X509_REQ, fp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509_REQ, PEM_STRING_X509_REQ, bp,
(void **)x, cb, u);
}
@@ -163,13 +170,12 @@ PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x)
}
int
-PEM_write_X509_REQ(FILE *fp, X509_REQ *x)
+PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509_REQ, PEM_STRING_X509_REQ, fp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509_REQ, PEM_STRING_X509_REQ_OLD, fp,
x, NULL, NULL, 0, NULL, NULL);
}
-
int
PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x)
{
@@ -177,14 +183,20 @@ PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x)
x, NULL, NULL, 0, NULL, NULL);
}
+X509_CRL *
+PEM_read_X509_CRL(FILE *fp, X509_CRL **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read((d2i_of_void *)d2i_X509_CRL, PEM_STRING_X509_CRL, fp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x)
+PEM_write_X509_CRL(FILE *fp, X509_CRL *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509_REQ, PEM_STRING_X509_REQ_OLD, fp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509_CRL, PEM_STRING_X509_CRL, fp,
x, NULL, NULL, 0, NULL, NULL);
}
-
X509_CRL *
PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x, pem_password_cb *cb, void *u)
{
@@ -192,13 +204,6 @@ PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x, pem_password_cb *cb, void *u)
(void **)x, cb, u);
}
-X509_CRL *
-PEM_read_X509_CRL(FILE *fp, X509_CRL **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read((d2i_of_void *)d2i_X509_CRL, PEM_STRING_X509_CRL, fp,
- (void **)x, cb, u);
-}
-
int
PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x)
{
@@ -206,14 +211,20 @@ PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x)
x, NULL, NULL, 0, NULL, NULL);
}
+PKCS7 *
+PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read((d2i_of_void *)d2i_PKCS7, PEM_STRING_PKCS7, fp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_X509_CRL(FILE *fp, X509_CRL *x)
+PEM_write_PKCS7(FILE *fp, PKCS7 *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509_CRL, PEM_STRING_X509_CRL, fp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_PKCS7, PEM_STRING_PKCS7, fp,
x, NULL, NULL, 0, NULL, NULL);
}
-
PKCS7 *
PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u)
{
@@ -221,13 +232,6 @@ PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u)
(void **)x, cb, u);
}
-PKCS7 *
-PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read((d2i_of_void *)d2i_PKCS7, PEM_STRING_PKCS7, fp,
- (void **)x, cb, u);
-}
-
int
PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x)
{
@@ -236,24 +240,23 @@ PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x)
}
int
-PEM_write_PKCS7(FILE *fp, PKCS7 *x)
+PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_PKCS7, PEM_STRING_PKCS7, fp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, fp,
x, NULL, NULL, 0, NULL, NULL);
}
-
NETSCAPE_CERT_SEQUENCE *
-PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE **x, pem_password_cb *cb, void *u)
+PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, bp,
+ return PEM_ASN1_read((d2i_of_void *)d2i_NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, fp,
(void **)x, cb, u);
}
NETSCAPE_CERT_SEQUENCE *
-PEM_read_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE **x, pem_password_cb *cb, void *u)
+PEM_read_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read((d2i_of_void *)d2i_NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, fp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, bp,
(void **)x, cb, u);
}
@@ -264,14 +267,6 @@ PEM_write_bio_NETSCAPE_CERT_SEQUENCE(BIO *bp, NETSCAPE_CERT_SEQUENCE *x)
x, NULL, NULL, 0, NULL, NULL);
}
-int
-PEM_write_NETSCAPE_CERT_SEQUENCE(FILE *fp, NETSCAPE_CERT_SEQUENCE *x)
-{
- return PEM_ASN1_write((i2d_of_void *)i2d_NETSCAPE_CERT_SEQUENCE, PEM_STRING_X509, fp,
- x, NULL, NULL, 0, NULL, NULL);
-}
-
-
#ifndef OPENSSL_NO_RSA
/* We treat RSA or DSA private keys as a special case.
@@ -301,26 +296,31 @@ pkey_get_rsa(EVP_PKEY *key, RSA **rsa)
}
RSA *
-PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb, void *u)
+PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
- pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
+ pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
return pkey_get_rsa(pktmp, rsa);
}
+int
+PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
+ unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_write((i2d_of_void *)i2d_RSAPrivateKey, PEM_STRING_RSA, fp,
+ x, enc, kstr, klen, cb, u);
+}
RSA *
-PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, void *u)
+PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
- pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
+ pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
return pkey_get_rsa(pktmp, rsa);
}
-
-
int
PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x,
const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb,
@@ -330,22 +330,6 @@ PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x,
x, enc, kstr, klen, cb, u);
}
-int
-PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
- unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_write((i2d_of_void *)i2d_RSAPrivateKey, PEM_STRING_RSA, fp,
- x, enc, kstr, klen, cb, u);
-}
-
-
-RSA *
-PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_RSAPublicKey, PEM_STRING_RSA_PUBLIC, bp,
- (void **)x, cb, u);
-}
-
RSA *
PEM_read_RSAPublicKey(FILE *fp, RSA **x, pem_password_cb *cb, void *u)
{
@@ -354,13 +338,6 @@ PEM_read_RSAPublicKey(FILE *fp, RSA **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_RSAPublicKey(BIO *bp, const RSA *x)
-{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_RSAPublicKey, PEM_STRING_RSA_PUBLIC, bp,
- (void *)x, NULL, NULL, 0, NULL, NULL);
-}
-
-int
PEM_write_RSAPublicKey(FILE *fp, const RSA *x)
{
return PEM_ASN1_write((i2d_of_void *)i2d_RSAPublicKey, PEM_STRING_RSA_PUBLIC, fp,
@@ -368,12 +345,19 @@ PEM_write_RSAPublicKey(FILE *fp, const RSA *x)
}
RSA *
-PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x, pem_password_cb *cb, void *u)
+PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_RSA_PUBKEY, PEM_STRING_PUBLIC, bp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_RSAPublicKey, PEM_STRING_RSA_PUBLIC, bp,
(void **)x, cb, u);
}
+int
+PEM_write_bio_RSAPublicKey(BIO *bp, const RSA *x)
+{
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_RSAPublicKey, PEM_STRING_RSA_PUBLIC, bp,
+ (void *)x, NULL, NULL, 0, NULL, NULL);
+}
+
RSA *
PEM_read_RSA_PUBKEY(FILE *fp, RSA **x, pem_password_cb *cb, void *u)
{
@@ -382,16 +366,23 @@ PEM_read_RSA_PUBKEY(FILE *fp, RSA **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x)
+PEM_write_RSA_PUBKEY(FILE *fp, RSA *x)
{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_RSA_PUBKEY, PEM_STRING_PUBLIC, bp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_RSA_PUBKEY, PEM_STRING_PUBLIC, fp,
x, NULL, NULL, 0, NULL, NULL);
}
+RSA *
+PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_RSA_PUBKEY, PEM_STRING_PUBLIC, bp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_RSA_PUBKEY(FILE *fp, RSA *x)
+PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_RSA_PUBKEY, PEM_STRING_PUBLIC, fp,
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_RSA_PUBKEY, PEM_STRING_PUBLIC, bp,
x, NULL, NULL, 0, NULL, NULL);
}
@@ -418,24 +409,14 @@ pkey_get_dsa(EVP_PKEY *key, DSA **dsa)
}
DSA *
-PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, void *u)
+PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, void *u)
{
EVP_PKEY *pktmp;
- pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
+ pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
}
-
-int
-PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x,
- const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb,
- void *u)
-{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_DSAPrivateKey, PEM_STRING_DSA, bp,
- x, enc, kstr, klen, cb, u);
-}
-
int
PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
unsigned char *kstr, int klen, pem_password_cb *cb, void *u)
@@ -444,12 +425,22 @@ PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
x, enc, kstr, klen, cb, u);
}
-
DSA *
-PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x, pem_password_cb *cb, void *u)
+PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_DSA_PUBKEY, PEM_STRING_PUBLIC, bp,
- (void **)x, cb, u);
+ EVP_PKEY *pktmp;
+
+ pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
+ return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
+}
+
+int
+PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x,
+ const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb,
+ void *u)
+{
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_DSAPrivateKey, PEM_STRING_DSA, bp,
+ x, enc, kstr, klen, cb, u);
}
DSA *
@@ -460,35 +451,23 @@ PEM_read_DSA_PUBKEY(FILE *fp, DSA **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x)
-{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_DSA_PUBKEY, PEM_STRING_PUBLIC, bp,
- x, NULL, NULL, 0, NULL, NULL);
-}
-
-int
PEM_write_DSA_PUBKEY(FILE *fp, DSA *x)
{
return PEM_ASN1_write((i2d_of_void *)i2d_DSA_PUBKEY, PEM_STRING_PUBLIC, fp,
x, NULL, NULL, 0, NULL, NULL);
}
-
-DSA *
-PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, void *u)
+int
+PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x)
{
- EVP_PKEY *pktmp;
-
- pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
- return pkey_get_dsa(pktmp, dsa); /* will free pktmp */
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_DSA_PUBKEY, PEM_STRING_PUBLIC, bp,
+ x, NULL, NULL, 0, NULL, NULL);
}
-
-
DSA *
-PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u)
+PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_DSAparams, PEM_STRING_DSAPARAMS, bp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_DSA_PUBKEY, PEM_STRING_PUBLIC, bp,
(void **)x, cb, u);
}
@@ -500,16 +479,23 @@ PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_DSAparams(BIO *bp, const DSA *x)
+PEM_write_DSAparams(FILE *fp, const DSA *x)
{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_DSAparams, PEM_STRING_DSAPARAMS, bp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_DSAparams, PEM_STRING_DSAPARAMS, fp,
(void *)x, NULL, NULL, 0, NULL, NULL);
}
+DSA *
+PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_DSAparams, PEM_STRING_DSAPARAMS, bp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_DSAparams(FILE *fp, const DSA *x)
+PEM_write_bio_DSAparams(BIO *bp, const DSA *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_DSAparams, PEM_STRING_DSAPARAMS, fp,
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_DSAparams, PEM_STRING_DSAPARAMS, bp,
(void *)x, NULL, NULL, 0, NULL, NULL);
}
@@ -535,26 +521,24 @@ pkey_get_eckey(EVP_PKEY *key, EC_KEY **eckey)
return dtmp;
}
-EC_KEY *
-PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb, void *u)
+EC_GROUP *
+PEM_read_ECPKParameters(FILE *fp, EC_GROUP **x, pem_password_cb *cb, void *u)
{
- EVP_PKEY *pktmp;
- pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
- return pkey_get_eckey(pktmp, key); /* will free pktmp */
+ return PEM_ASN1_read((d2i_of_void *)d2i_ECPKParameters, PEM_STRING_ECPARAMETERS, fp,
+ (void **)x, cb, u);
}
-
-EC_GROUP *
-PEM_read_bio_ECPKParameters(BIO *bp, EC_GROUP **x, pem_password_cb *cb, void *u)
+int
+PEM_write_ECPKParameters(FILE *fp, const EC_GROUP *x)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_ECPKParameters, PEM_STRING_ECPARAMETERS, bp,
- (void **)x, cb, u);
+ return PEM_ASN1_write((i2d_of_void *)i2d_ECPKParameters, PEM_STRING_ECPARAMETERS, fp,
+ (void *)x, NULL, NULL, 0, NULL, NULL);
}
EC_GROUP *
-PEM_read_ECPKParameters(FILE *fp, EC_GROUP **x, pem_password_cb *cb, void *u)
+PEM_read_bio_ECPKParameters(BIO *bp, EC_GROUP **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read((d2i_of_void *)d2i_ECPKParameters, PEM_STRING_ECPARAMETERS, fp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_ECPKParameters, PEM_STRING_ECPARAMETERS, bp,
(void **)x, cb, u);
}
@@ -565,21 +549,13 @@ PEM_write_bio_ECPKParameters(BIO *bp, const EC_GROUP *x)
(void *)x, NULL, NULL, 0, NULL, NULL);
}
-int
-PEM_write_ECPKParameters(FILE *fp, const EC_GROUP *x)
+EC_KEY *
+PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_ECPKParameters, PEM_STRING_ECPARAMETERS, fp,
- (void *)x, NULL, NULL, 0, NULL, NULL);
-}
-
+ EVP_PKEY *pktmp;
-int
-PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x,
- const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb,
- void *u)
-{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_ECPrivateKey, PEM_STRING_ECPRIVATEKEY, bp,
- x, enc, kstr, klen, cb, u);
+ pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
+ return pkey_get_eckey(pktmp, eckey); /* will free pktmp */
}
int
@@ -590,12 +566,21 @@ PEM_write_ECPrivateKey(FILE *fp, EC_KEY *x, const EVP_CIPHER *enc,
x, enc, kstr, klen, cb, u);
}
-
EC_KEY *
-PEM_read_bio_EC_PUBKEY(BIO *bp, EC_KEY **x, pem_password_cb *cb, void *u)
+PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_EC_PUBKEY, PEM_STRING_PUBLIC, bp,
- (void **)x, cb, u);
+ EVP_PKEY *pktmp;
+ pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u);
+ return pkey_get_eckey(pktmp, key); /* will free pktmp */
+}
+
+int
+PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x,
+ const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb,
+ void *u)
+{
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_ECPrivateKey, PEM_STRING_ECPRIVATEKEY, bp,
+ x, enc, kstr, klen, cb, u);
}
EC_KEY *
@@ -606,42 +591,30 @@ PEM_read_EC_PUBKEY(FILE *fp, EC_KEY **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_EC_PUBKEY(BIO *bp, EC_KEY *x)
-{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_EC_PUBKEY, PEM_STRING_PUBLIC, bp,
- x, NULL, NULL, 0, NULL, NULL);
-}
-
-int
PEM_write_EC_PUBKEY(FILE *fp, EC_KEY *x)
{
return PEM_ASN1_write((i2d_of_void *)i2d_EC_PUBKEY, PEM_STRING_PUBLIC, fp,
x, NULL, NULL, 0, NULL, NULL);
}
-
EC_KEY *
-PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, void *u)
+PEM_read_bio_EC_PUBKEY(BIO *bp, EC_KEY **x, pem_password_cb *cb, void *u)
{
- EVP_PKEY *pktmp;
-
- pktmp = PEM_read_PrivateKey(fp, NULL, cb, u);
- return pkey_get_eckey(pktmp, eckey); /* will free pktmp */
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_EC_PUBKEY, PEM_STRING_PUBLIC, bp,
+ (void **)x, cb, u);
}
+int
+PEM_write_bio_EC_PUBKEY(BIO *bp, EC_KEY *x)
+{
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_EC_PUBKEY, PEM_STRING_PUBLIC, bp,
+ x, NULL, NULL, 0, NULL, NULL);
+}
#endif
#ifndef OPENSSL_NO_DH
-
-DH *
-PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_DHparams, PEM_STRING_DHPARAMS, bp,
- (void **)x, cb, u);
-}
-
DH *
PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u)
{
@@ -650,29 +623,28 @@ PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_DHparams(BIO *bp, const DH *x)
+PEM_write_DHparams(FILE *fp, const DH *x)
{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_DHparams, PEM_STRING_DHPARAMS, bp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_DHparams, PEM_STRING_DHPARAMS, fp,
(void *)x, NULL, NULL, 0, NULL, NULL);
}
+DH *
+PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_DHparams, PEM_STRING_DHPARAMS, bp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_DHparams(FILE *fp, const DH *x)
+PEM_write_bio_DHparams(BIO *bp, const DH *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_DHparams, PEM_STRING_DHPARAMS, fp,
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_DHparams, PEM_STRING_DHPARAMS, bp,
(void *)x, NULL, NULL, 0, NULL, NULL);
}
#endif
-
-EVP_PKEY *
-PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_PUBKEY, PEM_STRING_PUBLIC, bp,
- (void **)x, cb, u);
-}
-
EVP_PKEY *
PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
{
@@ -681,15 +653,22 @@ PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x)
+PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x)
{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_PUBKEY, PEM_STRING_PUBLIC, bp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_PUBKEY, PEM_STRING_PUBLIC, fp,
x, NULL, NULL, 0, NULL, NULL);
}
+EVP_PKEY *
+PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_PUBKEY, PEM_STRING_PUBLIC, bp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x)
+PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_PUBKEY, PEM_STRING_PUBLIC, fp,
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_PUBKEY, PEM_STRING_PUBLIC, bp,
x, NULL, NULL, 0, NULL, NULL);
}
diff --git a/lib/libcrypto/pem/pem_pk8.c b/lib/libcrypto/pem/pem_pk8.c
index 50aafb7655f..4b3578f9716 100644
--- a/lib/libcrypto/pem/pem_pk8.c
+++ b/lib/libcrypto/pem/pem_pk8.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pem_pk8.c,v 1.11 2016/09/04 15:53:03 jsing Exp $ */
+/* $OpenBSD: pem_pk8.c,v 1.12 2016/09/04 16:10:38 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -250,19 +250,24 @@ d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
return ret;
}
-
-
X509_SIG *
-PEM_read_bio_PKCS8(BIO *bp, X509_SIG **x, pem_password_cb *cb, void *u)
+PEM_read_PKCS8(FILE *fp, X509_SIG **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509_SIG, PEM_STRING_PKCS8, bp,
+ return PEM_ASN1_read((d2i_of_void *)d2i_X509_SIG, PEM_STRING_PKCS8, fp,
(void **)x, cb, u);
}
+int
+PEM_write_PKCS8(FILE *fp, X509_SIG *x)
+{
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509_SIG, PEM_STRING_PKCS8, fp,
+ x, NULL, NULL, 0, NULL, NULL);
+}
+
X509_SIG *
-PEM_read_PKCS8(FILE *fp, X509_SIG **x, pem_password_cb *cb, void *u)
+PEM_read_bio_PKCS8(BIO *bp, X509_SIG **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read((d2i_of_void *)d2i_X509_SIG, PEM_STRING_PKCS8, fp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509_SIG, PEM_STRING_PKCS8, bp,
(void **)x, cb, u);
}
@@ -273,10 +278,17 @@ PEM_write_bio_PKCS8(BIO *bp, X509_SIG *x)
x, NULL, NULL, 0, NULL, NULL);
}
+PKCS8_PRIV_KEY_INFO *
+PEM_read_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read((d2i_of_void *)d2i_PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, fp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_PKCS8(FILE *fp, X509_SIG *x)
+PEM_write_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509_SIG, PEM_STRING_PKCS8, fp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, fp,
x, NULL, NULL, 0, NULL, NULL);
}
@@ -287,23 +299,9 @@ PEM_read_bio_PKCS8_PRIV_KEY_INFO(BIO *bp, PKCS8_PRIV_KEY_INFO **x, pem_password_
(void **)x, cb, u);
}
-PKCS8_PRIV_KEY_INFO *
-PEM_read_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read((d2i_of_void *)d2i_PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, fp,
- (void **)x, cb, u);
-}
-
int
PEM_write_bio_PKCS8_PRIV_KEY_INFO(BIO *bp, PKCS8_PRIV_KEY_INFO *x)
{
return PEM_ASN1_write_bio((i2d_of_void *)i2d_PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, bp,
x, NULL, NULL, 0, NULL, NULL);
}
-
-int
-PEM_write_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO *x)
-{
- return PEM_ASN1_write((i2d_of_void *)i2d_PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, fp,
- x, NULL, NULL, 0, NULL, NULL);
-}
diff --git a/lib/libcrypto/pem/pem_x509.c b/lib/libcrypto/pem/pem_x509.c
index 350c48ba9a3..f440a9f0aa3 100644
--- a/lib/libcrypto/pem/pem_x509.c
+++ b/lib/libcrypto/pem/pem_x509.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pem_x509.c,v 1.7 2016/09/04 15:53:03 jsing Exp $ */
+/* $OpenBSD: pem_x509.c,v 1.8 2016/09/04 16:10:38 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2001.
*/
@@ -66,13 +66,6 @@
X509 *
-PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509, PEM_STRING_X509, bp,
- (void **)x, cb, u);
-}
-
-X509 *
PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u)
{
return PEM_ASN1_read((d2i_of_void *)d2i_X509, PEM_STRING_X509, fp,
@@ -80,15 +73,22 @@ PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u)
}
int
-PEM_write_bio_X509(BIO *bp, X509 *x)
+PEM_write_X509(FILE *fp, X509 *x)
{
- return PEM_ASN1_write_bio((i2d_of_void *)i2d_X509, PEM_STRING_X509, bp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509, PEM_STRING_X509, fp,
x, NULL, NULL, 0, NULL, NULL);
}
+X509 *
+PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509, PEM_STRING_X509, bp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_X509(FILE *fp, X509 *x)
+PEM_write_bio_X509(BIO *bp, X509 *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509, PEM_STRING_X509, fp,
+ return PEM_ASN1_write_bio((i2d_of_void *)i2d_X509, PEM_STRING_X509, bp,
x, NULL, NULL, 0, NULL, NULL);
}
diff --git a/lib/libcrypto/pem/pem_xaux.c b/lib/libcrypto/pem/pem_xaux.c
index f5dfb8476c0..0dd81523b58 100644
--- a/lib/libcrypto/pem/pem_xaux.c
+++ b/lib/libcrypto/pem/pem_xaux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pem_xaux.c,v 1.8 2016/09/04 15:53:03 jsing Exp $ */
+/* $OpenBSD: pem_xaux.c,v 1.9 2016/09/04 16:10:38 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2001.
*/
@@ -66,16 +66,23 @@
X509 *
-PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
+PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509_AUX, PEM_STRING_X509_TRUSTED, bp,
+ return PEM_ASN1_read((d2i_of_void *)d2i_X509_AUX, PEM_STRING_X509_TRUSTED, fp,
(void **)x, cb, u);
}
+int
+PEM_write_X509_AUX(FILE *fp, X509 *x)
+{
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509_AUX, PEM_STRING_X509_TRUSTED, fp,
+ x, NULL, NULL, 0, NULL, NULL);
+}
+
X509 *
-PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u)
+PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
{
- return PEM_ASN1_read((d2i_of_void *)d2i_X509_AUX, PEM_STRING_X509_TRUSTED, fp,
+ return PEM_ASN1_read_bio((d2i_of_void *)d2i_X509_AUX, PEM_STRING_X509_TRUSTED, bp,
(void **)x, cb, u);
}
@@ -86,10 +93,17 @@ PEM_write_bio_X509_AUX(BIO *bp, X509 *x)
x, NULL, NULL, 0, NULL, NULL);
}
+X509_CERT_PAIR *
+PEM_read_X509_CERT_PAIR(FILE *fp, X509_CERT_PAIR **x, pem_password_cb *cb, void *u)
+{
+ return PEM_ASN1_read((d2i_of_void *)d2i_X509_CERT_PAIR, PEM_STRING_X509_PAIR, fp,
+ (void **)x, cb, u);
+}
+
int
-PEM_write_X509_AUX(FILE *fp, X509 *x)
+PEM_write_X509_CERT_PAIR(FILE *fp, X509_CERT_PAIR *x)
{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509_AUX, PEM_STRING_X509_TRUSTED, fp,
+ return PEM_ASN1_write((i2d_of_void *)i2d_X509_CERT_PAIR, PEM_STRING_X509_PAIR, fp,
x, NULL, NULL, 0, NULL, NULL);
}
@@ -100,23 +114,9 @@ PEM_read_bio_X509_CERT_PAIR(BIO *bp, X509_CERT_PAIR **x, pem_password_cb *cb, vo
(void **)x, cb, u);
}
-X509_CERT_PAIR *
-PEM_read_X509_CERT_PAIR(FILE *fp, X509_CERT_PAIR **x, pem_password_cb *cb, void *u)
-{
- return PEM_ASN1_read((d2i_of_void *)d2i_X509_CERT_PAIR, PEM_STRING_X509_PAIR, fp,
- (void **)x, cb, u);
-}
-
int
PEM_write_bio_X509_CERT_PAIR(BIO *bp, X509_CERT_PAIR *x)
{
return PEM_ASN1_write_bio((i2d_of_void *)i2d_X509_CERT_PAIR, PEM_STRING_X509_PAIR, bp,
x, NULL, NULL, 0, NULL, NULL);
}
-
-int
-PEM_write_X509_CERT_PAIR(FILE *fp, X509_CERT_PAIR *x)
-{
- return PEM_ASN1_write((i2d_of_void *)i2d_X509_CERT_PAIR, PEM_STRING_X509_PAIR, fp,
- x, NULL, NULL, 0, NULL, NULL);
-}