2
0

X509_cmp.pod 3.3 KB

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