| OLD | NEW |
| 1 /* crypto/x509/x_all.c */ | 1 /* crypto/x509/x_all.c */ |
| 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 * SUCH DAMAGE. | 51 * SUCH DAMAGE. |
| 52 * | 52 * |
| 53 * The licence and distribution terms for any publically available version or | 53 * The licence and distribution terms for any publically available version or |
| 54 * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 * copied and put under another distribution licence | 55 * copied and put under another distribution licence |
| 56 * [including the GNU Public Licence.] | 56 * [including the GNU Public Licence.] |
| 57 */ | 57 */ |
| 58 | 58 |
| 59 #include <stdio.h> | 59 #include <stdio.h> |
| 60 #undef SSLEAY_MACROS | |
| 61 #include <openssl/stack.h> | 60 #include <openssl/stack.h> |
| 62 #include "cryptlib.h" | 61 #include "cryptlib.h" |
| 63 #include <openssl/buffer.h> | 62 #include <openssl/buffer.h> |
| 64 #include <openssl/asn1.h> | 63 #include <openssl/asn1.h> |
| 65 #include <openssl/evp.h> | 64 #include <openssl/evp.h> |
| 66 #include <openssl/x509.h> | 65 #include <openssl/x509.h> |
| 67 #ifndef OPENSSL_NO_RSA | 66 #ifndef OPENSSL_NO_RSA |
| 68 #include <openssl/rsa.h> | 67 #include <openssl/rsa.h> |
| 69 #endif | 68 #endif |
| 70 #ifndef OPENSSL_NO_DSA | 69 #ifndef OPENSSL_NO_DSA |
| 71 #include <openssl/dsa.h> | 70 #include <openssl/dsa.h> |
| 72 #endif | 71 #endif |
| 73 | 72 |
| 74 int X509_verify(X509 *a, EVP_PKEY *r) | 73 int X509_verify(X509 *a, EVP_PKEY *r) |
| 75 { | 74 { |
| 76 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg, | 75 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg, |
| 77 a->signature,a->cert_info,r)); | 76 a->signature,a->cert_info,r)); |
| 78 } | 77 } |
| 79 | 78 |
| 80 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) | 79 int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) |
| 81 { | 80 { |
| 82 return( ASN1_item_verify(ASN1_ITEM_rptr(X509_REQ_INFO), | 81 return( ASN1_item_verify(ASN1_ITEM_rptr(X509_REQ_INFO), |
| 83 a->sig_alg,a->signature,a->req_info,r)); | 82 a->sig_alg,a->signature,a->req_info,r)); |
| 84 } | 83 } |
| 85 | 84 |
| 86 int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r) | |
| 87 { | |
| 88 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO), | |
| 89 a->sig_alg, a->signature,a->crl,r)); | |
| 90 } | |
| 91 | |
| 92 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) | 85 int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) |
| 93 { | 86 { |
| 94 return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC), | 87 return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC), |
| 95 a->sig_algor,a->signature,a->spkac,r)); | 88 a->sig_algor,a->signature,a->spkac,r)); |
| 96 } | 89 } |
| 97 | 90 |
| 98 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) | 91 int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) |
| 99 { | 92 { |
| 93 x->cert_info->enc.modified = 1; |
| 100 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature
, | 94 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature
, |
| 101 x->sig_alg, x->signature, x->cert_info,pkey,md)); | 95 x->sig_alg, x->signature, x->cert_info,pkey,md)); |
| 102 } | 96 } |
| 103 | 97 |
| 104 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md) | 98 int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md) |
| 105 { | 99 { |
| 106 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_REQ_INFO),x->sig_alg, NULL, | 100 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_REQ_INFO),x->sig_alg, NULL, |
| 107 x->signature, x->req_info,pkey,md)); | 101 x->signature, x->req_info,pkey,md)); |
| 108 } | 102 } |
| 109 | 103 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 507 |
| 514 int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey) | 508 int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey) |
| 515 { | 509 { |
| 516 return ASN1_i2d_bio_of(EVP_PKEY,i2d_PUBKEY,bp,pkey); | 510 return ASN1_i2d_bio_of(EVP_PKEY,i2d_PUBKEY,bp,pkey); |
| 517 } | 511 } |
| 518 | 512 |
| 519 EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a) | 513 EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a) |
| 520 { | 514 { |
| 521 return ASN1_d2i_bio_of(EVP_PKEY,EVP_PKEY_new,d2i_PUBKEY,bp,a); | 515 return ASN1_d2i_bio_of(EVP_PKEY,EVP_PKEY_new,d2i_PUBKEY,bp,a); |
| 522 } | 516 } |
| OLD | NEW |