diff options
author | Dr. Stephen Henson <steve@openssl.org> | 1999-11-16 00:56:03 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 1999-11-16 00:56:03 +0000 |
commit | e947f3968926b2ab2b2de895b7a0e2fe3730beb8 (patch) | |
tree | 6a599a9b4e261a40d0020d2b3362bcdad2157211 /crypto/x509 | |
parent | b7cfcfb7f8e17c17f457b3384010eb027f3aad72 (diff) |
New function X509_cmp().
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/x509.h | 2 | ||||
-rw-r--r-- | crypto/x509/x509_cmp.c | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/crypto/x509/x509.h b/crypto/x509/x509.h index a6e61cf6c7..d3d8030086 100644 --- a/crypto/x509/x509.h +++ b/crypto/x509/x509.h @@ -269,6 +269,7 @@ typedef struct x509_st unsigned long ex_kusage; unsigned long ex_xkusage; unsigned long ex_nscert; + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; X509_CERT_AUX *aux; } X509; @@ -869,6 +870,7 @@ unsigned long X509_issuer_name_hash(X509 *a); int X509_subject_name_cmp(X509 *a,X509 *b); unsigned long X509_subject_name_hash(X509 *x); +int X509_cmp (X509 *a, X509 *b); int X509_NAME_cmp (X509_NAME *a, X509_NAME *b); unsigned long X509_NAME_hash(X509_NAME *x); diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 0b0f1605da..62d8013360 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -61,6 +61,7 @@ #include <openssl/asn1.h> #include <openssl/objects.h> #include <openssl/x509.h> +#include <openssl/x509v3.h> int X509_issuer_and_serial_cmp(X509 *a, X509 *b) { @@ -135,6 +136,16 @@ unsigned long X509_subject_name_hash(X509 *x) { return(X509_NAME_hash(x->cert_info->subject)); } +/* Compare two certificates: they must be identical for + * this to work. + */ +int X509_cmp(X509 *a, X509 *b) +{ + /* ensure hash is valid */ + X509_check_purpose(a, -1, 0); + X509_check_purpose(b, -1, 0); + return memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH); +} int X509_NAME_cmp(X509_NAME *a, X509_NAME *b) { |