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