提交 78d3b819 编写于 作者: D Dr. Stephen Henson

Replace the old ASN1_dup() with ASN1_item_dup() and

zap some evil function pointers casts along the way...
上级 200b24e3
......@@ -8,7 +8,7 @@
it complain about algorithm deselection that isn't recognised.
[Richard Levitte]
*) New ASN1 functions to handle sign, verify, digest, pack and
*) New ASN1 functions to handle dup, sign, verify, digest, pack and
unpack operations in terms of ASN1_ITEM. Modify existing wrappers
to use new functions. Add NO_ASN1_OLD which can be set to remove
some old style ASN1 functions: this can be used to determine if old
......
......@@ -419,9 +419,7 @@ int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));
X509_ALGOR_free(p7i->key_enc_algor);
p7i->key_enc_algor=(X509_ALGOR *)ASN1_dup(i2d_X509_ALGOR,
(char *(*)())d2i_X509_ALGOR,
(char *)x509->cert_info->key->algor);
p7i->key_enc_algor= X509_ALGOR_dup(x509->cert_info->key->algor);
CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509);
p7i->cert=x509;
......
......@@ -59,6 +59,8 @@
#ifndef HEADER_RSA_H
#define HEADER_RSA_H
#include <openssl/asn1.h>
#ifndef NO_BIO
#include <openssl/bio.h>
#endif
......@@ -222,10 +224,9 @@ const RSA_METHOD *RSA_null_method(void);
void ERR_load_RSA_strings(void );
RSA * d2i_RSAPublicKey(RSA **a, const unsigned char **pp, long length);
int i2d_RSAPublicKey(const RSA *a, unsigned char **pp);
RSA * d2i_RSAPrivateKey(RSA **a, const unsigned char **pp, long length);
int i2d_RSAPrivateKey(const RSA *a, unsigned char **pp);
DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)
DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)
#ifndef NO_FP_API
int RSA_print_fp(FILE *fp, const RSA *r,int offset);
#endif
......
......@@ -115,21 +115,17 @@ int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md)
X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa)
{
return((X509_ATTRIBUTE *)ASN1_dup((int (*)())i2d_X509_ATTRIBUTE,
(char *(*)())d2i_X509_ATTRIBUTE,(char *)xa));
return ASN1_item_dup(&X509_ATTRIBUTE_it,xa);
}
X509 *X509_dup(X509 *x509)
{
return((X509 *)ASN1_dup((int (*)())i2d_X509,
(char *(*)())d2i_X509,(char *)x509));
return ASN1_item_dup(&X509_it,x509);
}
X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex)
{
return((X509_EXTENSION *)ASN1_dup(
(int (*)())i2d_X509_EXTENSION,
(char *(*)())d2i_X509_EXTENSION,(char *)ex));
return ASN1_item_dup(&X509_EXTENSION_it,ex);
}
#ifndef NO_FP_API
......@@ -158,8 +154,7 @@ int i2d_X509_bio(BIO *bp, X509 *x509)
X509_CRL *X509_CRL_dup(X509_CRL *crl)
{
return((X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL,
(char *(*)())d2i_X509_CRL,(char *)crl));
return ASN1_item_dup(&X509_CRL_it, crl);
}
#ifndef NO_FP_API
......@@ -190,8 +185,7 @@ int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl)
PKCS7 *PKCS7_dup(PKCS7 *p7)
{
return((PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7,
(char *(*)())d2i_PKCS7,(char *)p7));
return ASN1_item_dup(&PKCS7_it, p7);
}
#ifndef NO_FP_API
......@@ -222,8 +216,7 @@ int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7)
X509_REQ *X509_REQ_dup(X509_REQ *req)
{
return((X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ,
(char *(*)())d2i_X509_REQ,(char *)req));
return ASN1_item_dup(&X509_REQ_it, req);
}
#ifndef NO_FP_API
......@@ -255,14 +248,12 @@ int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req)
#ifndef NO_RSA
RSA *RSAPublicKey_dup(RSA *rsa)
{
return((RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey,
(char *(*)())d2i_RSAPublicKey,(char *)rsa));
return ASN1_item_dup(&RSAPublicKey_it, rsa);
}
RSA *RSAPrivateKey_dup(RSA *rsa)
{
return((RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey,
(char *(*)())d2i_RSAPrivateKey,(char *)rsa));
return ASN1_item_dup(&RSAPrivateKey_it, rsa);
}
#ifndef NO_FP_API
......@@ -395,20 +386,17 @@ int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn)
{
return((X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,
(char *(*)())d2i_X509_ALGOR,(char *)xn));
return ASN1_item_dup(&X509_ALGOR_it, xn);
}
X509_NAME *X509_NAME_dup(X509_NAME *xn)
{
return((X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME,
(char *(*)())d2i_X509_NAME,(char *)xn));
return ASN1_item_dup(&X509_NAME_it, xn);
}
X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne)
{
return((X509_NAME_ENTRY *)ASN1_dup((int (*)())i2d_X509_NAME_ENTRY,
(char *(*)())d2i_X509_NAME_ENTRY,(char *)ne));
return ASN1_item_dup(&X509_NAME_ENTRY_it, ne);
}
int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册