xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/doc/man3/X509_cmp.pod (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos=pod
2*4724848cSchristos
3*4724848cSchristos=head1 NAME
4*4724848cSchristos
5*4724848cSchristosX509_cmp, X509_NAME_cmp,
6*4724848cSchristosX509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp,
7*4724848cSchristosX509_CRL_cmp, X509_CRL_match
8*4724848cSchristos- compare X509 certificates and related values
9*4724848cSchristos
10*4724848cSchristos=head1 SYNOPSIS
11*4724848cSchristos
12*4724848cSchristos #include <openssl/x509.h>
13*4724848cSchristos
14*4724848cSchristos int X509_cmp(const X509 *a, const X509 *b);
15*4724848cSchristos int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
16*4724848cSchristos int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
17*4724848cSchristos int X509_issuer_name_cmp(const X509 *a, const X509 *b);
18*4724848cSchristos int X509_subject_name_cmp(const X509 *a, const X509 *b);
19*4724848cSchristos int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
20*4724848cSchristos int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
21*4724848cSchristos
22*4724848cSchristos=head1 DESCRIPTION
23*4724848cSchristos
24*4724848cSchristosThis set of functions are used to compare X509 objects, including X509
25*4724848cSchristoscertificates, X509 CRL objects and various values in an X509 certificate.
26*4724848cSchristos
27*4724848cSchristosThe X509_cmp() function compares two B<X509> objects indicated by parameters
28*4724848cSchristosB<a> and B<b>. The comparison is based on the B<memcmp> result of the hash
29*4724848cSchristosvalues of two B<X509> objects and the canonical (DER) encoding values.
30*4724848cSchristos
31*4724848cSchristosThe X509_NAME_cmp() function compares two B<X509_NAME> objects indicated by
32*4724848cSchristosparameters B<a> and B<b>. The comparison is based on the B<memcmp> result of
33*4724848cSchristosthe canonical (DER) encoding values of the two objects. L<i2d_X509_NAME(3)>
34*4724848cSchristoshas a more detailed description of the DER encoding of the B<X509_NAME> structure.
35*4724848cSchristos
36*4724848cSchristosThe X509_issuer_and_serial_cmp() function compares the serial number and issuer
37*4724848cSchristosvalues in the given B<X509> objects B<a> and B<b>.
38*4724848cSchristos
39*4724848cSchristosThe X509_issuer_name_cmp(), X509_subject_name_cmp() and X509_CRL_cmp() functions
40*4724848cSchristosare effectively wrappers of the X509_NAME_cmp() function. These functions compare
41*4724848cSchristosissuer names and subject names of the X<509> objects, or issuers of B<X509_CRL>
42*4724848cSchristosobjects, respectively.
43*4724848cSchristos
44*4724848cSchristosThe X509_CRL_match() function compares two B<X509_CRL> objects. Unlike the
45*4724848cSchristosX509_CRL_cmp() function, this function compares the whole CRL content instead
46*4724848cSchristosof just the issuer name.
47*4724848cSchristos
48*4724848cSchristos=head1 RETURN VALUES
49*4724848cSchristos
50*4724848cSchristosLike common memory comparison functions, the B<X509> comparison functions return
51*4724848cSchristosan integer less than, equal to, or greater than zero if object B<a> is found to
52*4724848cSchristosbe less than, to match, or be greater than object B<b>, respectively.
53*4724848cSchristos
54*4724848cSchristosX509_NAME_cmp(), X509_issuer_and_serial_cmp(), X509_issuer_name_cmp(),
55*4724848cSchristosX509_subject_name_cmp() and X509_CRL_cmp() may return B<-2> to indicate an error.
56*4724848cSchristos
57*4724848cSchristos=head1 NOTES
58*4724848cSchristos
59*4724848cSchristosThese functions in fact utilize the underlying B<memcmp> of the C library to do
60*4724848cSchristosthe comparison job. Data to be compared varies from DER encoding data, hash
61*4724848cSchristosvalue or B<ASN1_STRING>. The sign of the comparison can be used to order the
62*4724848cSchristosobjects but it does not have a special meaning in some cases.
63*4724848cSchristos
64*4724848cSchristosX509_NAME_cmp() and wrappers utilize the value B<-2> to indicate errors in some
65*4724848cSchristoscircumstances, which could cause confusion for the applications.
66*4724848cSchristos
67*4724848cSchristos=head1 SEE ALSO
68*4724848cSchristos
69*4724848cSchristosL<i2d_X509_NAME(3)>, L<i2d_X509(3)>
70*4724848cSchristos
71*4724848cSchristos=head1 COPYRIGHT
72*4724848cSchristos
73*4724848cSchristosCopyright 2019 The OpenSSL Project Authors. All Rights Reserved.
74*4724848cSchristos
75*4724848cSchristosLicensed under the Apache License 2.0 (the "License").  You may not use
76*4724848cSchristosthis file except in compliance with the License.  You can obtain a copy
77*4724848cSchristosin the file LICENSE in the source distribution or at
78*4724848cSchristosL<https://www.openssl.org/source/license.html>.
79*4724848cSchristos
80*4724848cSchristos=cut
81