summaryrefslogtreecommitdiffstats
path: root/crypto/pem
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2005-03-31 09:26:39 +0000
committerBen Laurie <ben@openssl.org>2005-03-31 09:26:39 +0000
commit41a15c4f0f2535591ba9f258cf76119f86477c43 (patch)
tree6aca3f255f97dc3e9bd18884beeddf7de26fa122 /crypto/pem
parentfea4280a8b1a37bfe1ae6ffaede58722ad71afa1 (diff)
Give everything prototypes (well, everything that's actually used).
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pem.h85
-rw-r--r--crypto/pem/pem_all.c12
-rw-r--r--crypto/pem/pem_info.c17
-rw-r--r--crypto/pem/pem_lib.c19
-rw-r--r--crypto/pem/pem_oth.c8
5 files changed, 90 insertions, 51 deletions
diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h
index ce5b75c315..9a5fa03e2a 100644
--- a/crypto/pem/pem.h
+++ b/crypto/pem/pem.h
@@ -220,15 +220,19 @@ typedef struct pem_ctx_st
#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
{ \
-return((type *)PEM_ASN1_read((char *(*)())d2i_##asn1, str,fp,(char **)x,\
- cb,u)); \
+return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))PEM_ASN1_read)(d2i_##asn1, str,fp,x,cb,u)); \
} \
#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x) \
{ \
-return(PEM_ASN1_write((int (*)())i2d_##asn1,str,fp, (char *)x, \
- NULL,NULL,0,NULL,NULL)); \
+return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write)(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
+}
+
+#define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
+int PEM_write_##name(FILE *fp, type *x) \
+{ \
+return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write)(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
}
#define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
@@ -236,8 +240,15 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
unsigned char *kstr, int klen, pem_password_cb *cb, \
void *u) \
{ \
- return(PEM_ASN1_write((int (*)())i2d_##asn1,str,fp, \
- (char *)x,enc,kstr,klen,cb,u)); \
+ return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write)(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
+ }
+
+#define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
+int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, \
+ void *u) \
+ { \
+ return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write)(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
}
#endif
@@ -245,33 +256,51 @@ int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
{ \
-return((type *)PEM_ASN1_read_bio((char *(*)())d2i_##asn1, str,bp,\
- (char **)x,cb,u)); \
+return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))PEM_ASN1_read_bio)(d2i_##asn1, str,bp,x,cb,u)); \
}
#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x) \
{ \
-return(PEM_ASN1_write_bio((int (*)())i2d_##asn1,str,bp, (char *)x, \
- NULL,NULL,0,NULL,NULL)); \
+return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
+}
+
+#define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
+int PEM_write_bio_##name(BIO *bp, type *x) \
+{ \
+return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
}
#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
{ \
- return(PEM_ASN1_write_bio((int (*)())i2d_##asn1,str,bp, \
- (char *)x,enc,kstr,klen,cb,u)); \
+ return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
+ }
+
+#define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
+int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
+ unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
+ { \
+ return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
}
#define IMPLEMENT_PEM_write(name, type, str, asn1) \
IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
IMPLEMENT_PEM_write_fp(name, type, str, asn1)
+#define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)
+
#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)
+#define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)
+
#define IMPLEMENT_PEM_read(name, type, str, asn1) \
IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
IMPLEMENT_PEM_read_fp(name, type, str, asn1)
@@ -280,6 +309,10 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
IMPLEMENT_PEM_read(name, type, str, asn1) \
IMPLEMENT_PEM_write(name, type, str, asn1)
+#define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
+ IMPLEMENT_PEM_read(name, type, str, asn1) \
+ IMPLEMENT_PEM_write_const(name, type, str, asn1)
+
#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
IMPLEMENT_PEM_read(name, type, str, asn1) \
IMPLEMENT_PEM_write_cb(name, type, str, asn1)
@@ -410,9 +443,6 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
(char *(*)())d2i_NETSCAPE_CERT_SEQUENCE,PEM_STRING_X509,fp,\
(char **)x,cb,u)
-#define PEM_write_bio_SSL_SESSION(bp,x) \
- PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
- PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL,NULL)
#define PEM_write_bio_X509(bp,x) \
PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
(char *)x, NULL,NULL,0,NULL,NULL)
@@ -451,8 +481,6 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
PEM_STRING_X509,bp, \
(char *)x, NULL,NULL,0,NULL,NULL)
-#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read_bio( \
- (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb,u)
#define PEM_read_bio_X509(bp,x,cb,u) (X509 *)PEM_ASN1_read_bio( \
(char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb,u)
#define PEM_read_bio_X509_REQ(bp,x,cb,u) (X509_REQ *)PEM_ASN1_read_bio( \
@@ -501,11 +529,17 @@ int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
long len);
int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
pem_password_cb *cb, void *u);
-char * PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x,
- pem_password_cb *cb, void *u);
-int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x,
+void * PEM_ASN1_read_bio(void *(*d2i)(void **,const unsigned char **,long),
+ const char *name,BIO *bp,void **x,
+ pem_password_cb *cb, void *u);
+#define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
+((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))PEM_ASN1_read_bio)(d2i,name,bp,x,cb,u)
+int PEM_ASN1_write_bio(int (*i2d)(void *,unsigned char **),const char *name,BIO *bp,char *x,
const EVP_CIPHER *enc,unsigned char *kstr,int klen,
pem_password_cb *cb, void *u);
+#define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
+ ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))PEM_ASN1_write_bio)(i2d,name,bp,x,enc,kstr,klen,cb,u)
+
STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
@@ -515,11 +549,12 @@ int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
int PEM_read(FILE *fp, char **name, char **header,
unsigned char **data,long *len);
int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
-char * PEM_ASN1_read(char *(*d2i)(),const char *name,FILE *fp,char **x,
- pem_password_cb *cb, void *u);
-int PEM_ASN1_write(int (*i2d)(),const char *name,FILE *fp,char *x,
- const EVP_CIPHER *enc,unsigned char *kstr,int klen,
- pem_password_cb *callback, void *u);
+void * PEM_ASN1_read(void *(*d2i)(void **,const unsigned char **,long),
+ const char *name,FILE *fp,void **x,pem_password_cb *cb,
+ void *u);
+int PEM_ASN1_write(int (*i2d)(void *,unsigned char **),const char *name,FILE *fp,
+ char *x,const EVP_CIPHER *enc,unsigned char *kstr,
+ int klen,pem_password_cb *callback, void *u);
STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
pem_password_cb *cb, void *u);
#endif
diff --git a/crypto/pem/pem_all.c b/crypto/pem/pem_all.c
index a4357d591c..a9ac52de02 100644
--- a/crypto/pem/pem_all.c
+++ b/crypto/pem/pem_all.c
@@ -188,8 +188,8 @@ RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb,
#endif
-IMPLEMENT_PEM_write_cb(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
-IMPLEMENT_PEM_rw(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
+IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey)
+IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey)
IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
#endif
@@ -218,7 +218,7 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb,
return pkey_get_dsa(pktmp, dsa);
}
-IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
+IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
#ifndef OPENSSL_NO_FP_API
@@ -233,7 +233,7 @@ DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb,
#endif
-IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams)
+IMPLEMENT_PEM_rw_const(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams)
#endif
@@ -262,7 +262,7 @@ EC_KEY *PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb,
return pkey_get_eckey(pktmp, key);
}
-IMPLEMENT_PEM_rw(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters)
+IMPLEMENT_PEM_rw_const(ECPKParameters, EC_GROUP, PEM_STRING_ECPARAMETERS, ECPKParameters)
IMPLEMENT_PEM_write_cb(ECPrivateKey, EC_KEY, PEM_STRING_ECPRIVATEKEY, ECPrivateKey)
@@ -284,7 +284,7 @@ EC_KEY *PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb,
#ifndef OPENSSL_NO_DH
-IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
+IMPLEMENT_PEM_rw_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
#endif
diff --git a/crypto/pem/pem_info.c b/crypto/pem/pem_info.c
index 7eba3b26c1..b9e2ab51f3 100644
--- a/crypto/pem/pem_info.c
+++ b/crypto/pem/pem_info.c
@@ -88,12 +88,13 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe
{
X509_INFO *xi=NULL;
char *name=NULL,*header=NULL,**pp;
- unsigned char *data=NULL,*p;
+ unsigned char *data=NULL;
+ const unsigned char *p;
long len,error=0;
int ok=0;
STACK_OF(X509_INFO) *ret=NULL;
unsigned int i,raw;
- char *(*d2i)();
+ char *(*d2i)(void *,const unsigned char **,long);
if (sk == NULL)
{
@@ -125,7 +126,7 @@ start:
if ( (strcmp(name,PEM_STRING_X509) == 0) ||
(strcmp(name,PEM_STRING_X509_OLD) == 0))
{
- d2i=(char *(*)())d2i_X509;
+ (D2I_OF(X509))d2i=d2i_X509;
if (xi->x509 != NULL)
{
if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -136,7 +137,7 @@ start:
}
else if ((strcmp(name,PEM_STRING_X509_TRUSTED) == 0))
{
- d2i=(char *(*)())d2i_X509_AUX;
+ (D2I_OF(X509))d2i=d2i_X509_AUX;
if (xi->x509 != NULL)
{
if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -147,7 +148,7 @@ start:
}
else if (strcmp(name,PEM_STRING_X509_CRL) == 0)
{
- d2i=(char *(*)())d2i_X509_CRL;
+ (D2I_OF(X509_CRL))d2i=d2i_X509_CRL;
if (xi->crl != NULL)
{
if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -160,7 +161,7 @@ start:
#ifndef OPENSSL_NO_RSA
if (strcmp(name,PEM_STRING_RSA) == 0)
{
- d2i=(char *(*)())d2i_RSAPrivateKey;
+ (D2I_OF(RSA))d2i=d2i_RSAPrivateKey;
if (xi->x_pkey != NULL)
{
if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -184,7 +185,7 @@ start:
#ifndef OPENSSL_NO_DSA
if (strcmp(name,PEM_STRING_DSA) == 0)
{
- d2i=(char *(*)())d2i_DSAPrivateKey;
+ (D2I_OF(RSA))d2i=d2i_DSAPrivateKey;
if (xi->x_pkey != NULL)
{
if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -208,7 +209,7 @@ start:
#ifndef OPENSSL_NO_EC
if (strcmp(name,PEM_STRING_ECPRIVATEKEY) == 0)
{
- d2i=(char *(*)())d2i_ECPrivateKey;
+ (D2I_OF(EC_KEY))d2i=d2i_ECPrivateKey;
if (xi->x_pkey != NULL)
{
if (!sk_X509_INFO_push(ret,xi)) goto err;
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index ae0a87e978..6e1bb4a62a 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -158,11 +158,12 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str)
}
#ifndef OPENSSL_NO_FP_API
-char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x,
- pem_password_cb *cb, void *u)
+void *PEM_ASN1_read(void *(*d2i)(void **,const unsigned char **,long),
+ const char *name, FILE *fp,void **x,pem_password_cb *cb,
+ void *u)
{
BIO *b;
- char *ret;
+ void *ret;
if ((b=BIO_new(BIO_s_file())) == NULL)
{
@@ -260,9 +261,9 @@ err:
}
#ifndef OPENSSL_NO_FP_API
-int PEM_ASN1_write(int (*i2d)(), const char *name, FILE *fp, char *x,
- const EVP_CIPHER *enc, unsigned char *kstr, int klen,
- pem_password_cb *callback, void *u)
+int PEM_ASN1_write(int (*i2d)(void *,unsigned char **), const char *name, FILE *fp,
+ char *x, const EVP_CIPHER *enc, unsigned char *kstr,
+ int klen, pem_password_cb *callback, void *u)
{
BIO *b;
int ret;
@@ -279,9 +280,9 @@ int PEM_ASN1_write(int (*i2d)(), const char *name, FILE *fp, char *x,
}
#endif
-int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
- const EVP_CIPHER *enc, unsigned char *kstr, int klen,
- pem_password_cb *callback, void *u)
+int PEM_ASN1_write_bio(int (*i2d)(void *,unsigned char **), const char *name, BIO *bp,
+ char *x, const EVP_CIPHER *enc, unsigned char *kstr,
+ int klen, pem_password_cb *callback, void *u)
{
EVP_CIPHER_CTX ctx;
int dsize=0,i,j,ret=0;
diff --git a/crypto/pem/pem_oth.c b/crypto/pem/pem_oth.c
index 8d9064ea7c..a5e9204590 100644
--- a/crypto/pem/pem_oth.c
+++ b/crypto/pem/pem_oth.c
@@ -67,10 +67,12 @@
/* Handle 'other' PEMs: not private keys */
-char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
- pem_password_cb *cb, void *u)
+void *PEM_ASN1_read_bio(void *(*d2i)(void **,const unsigned char **,long),
+ const char *name, BIO *bp, void **x,
+ pem_password_cb *cb, void *u)
{
- unsigned char *p=NULL,*data=NULL;
+ const unsigned char *p=NULL;
+ unsigned char *data=NULL;
long len;
char *ret=NULL;