1=pod 2 3=head1 NAME 4 5X509_cmp, X509_NAME_cmp, 6X509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp, 7X509_CRL_cmp, X509_CRL_match 8- compare X509 certificates and related values 9 10=head1 SYNOPSIS 11 12 #include <openssl/x509.h> 13 14 int X509_cmp(const X509 *a, const X509 *b); 15 int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); 16 int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); 17 int X509_issuer_name_cmp(const X509 *a, const X509 *b); 18 int X509_subject_name_cmp(const X509 *a, const X509 *b); 19 int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); 20 int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); 21 22=head1 DESCRIPTION 23 24This set of functions are used to compare X509 objects, including X509 25certificates, X509 CRL objects and various values in an X509 certificate. 26 27The X509_cmp() function compares two B<X509> objects indicated by parameters 28I<a> and I<b>. The comparison is based on the B<memcmp> result of the hash 29values of two B<X509> objects and the canonical (DER) encoding values. 30 31The X509_NAME_cmp() function compares two B<X509_NAME> objects indicated by 32parameters I<a> and I<b>, any of which may be NULL. 33The comparison is based on the B<memcmp> result of the 34canonical (DER) encoding values of the two objects using L<i2d_X509_NAME(3)>. 35This procedure adheres to the matching rules for Distinguished Names (DN) 36given in RFC 4517 section 4.2.15 and RFC 5280 section 7.1. 37In particular, the order of Relative Distinguished Names (RDNs) is relevant. 38On the other hand, if an RDN is multi-valued, i.e., it contains a set of 39AttributeValueAssertions (AVAs), its members are effectively not ordered. 40 41The X509_issuer_and_serial_cmp() function compares the serial number and issuer 42values in the given B<X509> objects I<a> and I<b>. 43 44The X509_issuer_name_cmp(), X509_subject_name_cmp() and X509_CRL_cmp() functions 45are effectively wrappers of the X509_NAME_cmp() function. These functions compare 46issuer names and subject names of the X<509> objects, or issuers of B<X509_CRL> 47objects, respectively. 48 49The X509_CRL_match() function compares two B<X509_CRL> objects. Unlike the 50X509_CRL_cmp() function, this function compares the whole CRL content instead 51of just the issuer name. 52 53=head1 RETURN VALUES 54 55The B<X509> comparison functions return B<-1>, B<0>, or B<1> if object I<a> is 56found to be less than, to match, or be greater than object I<b>, respectively. 57 58X509_NAME_cmp(), X509_issuer_and_serial_cmp(), X509_issuer_name_cmp(), 59X509_subject_name_cmp(), X509_CRL_cmp(), and X509_CRL_match() 60may return B<-2> to indicate an error. 61 62=head1 NOTES 63 64These functions in fact utilize the underlying B<memcmp> of the C library to do 65the comparison job. Data to be compared varies from DER encoding data, hash 66value or B<ASN1_STRING>. The sign of the comparison can be used to order the 67objects but it does not have a special meaning in some cases. 68 69X509_NAME_cmp() and wrappers utilize the value B<-2> to indicate errors in some 70circumstances, which could cause confusion for the applications. 71 72=head1 SEE ALSO 73 74L<i2d_X509_NAME(3)>, L<i2d_X509(3)> 75 76=head1 COPYRIGHT 77 78Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved. 79 80Licensed under the Apache License 2.0 (the "License"). You may not use 81this file except in compliance with the License. You can obtain a copy 82in the file LICENSE in the source distribution or at 83L<https://www.openssl.org/source/license.html>. 84 85=cut 86