X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fx509%2Fx509_cmp.c;h=62d801336087ba643f83976cb33f0ad5a61a4d95;hp=0b0f1605da0d3abf54670c7bb1d930904ab815ab;hb=e947f3968926b2ab2b2de895b7a0e2fe3730beb8;hpb=b7cfcfb7f8e17c17f457b3384010eb027f3aad72 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 #include #include +#include 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) {