X509_cmp.3ossl 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "X509_CMP 3ossl"
  58. .TH X509_CMP 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. X509_cmp, X509_NAME_cmp,
  65. X509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp,
  66. X509_CRL_cmp, X509_CRL_match
  67. \&\- compare X509 certificates and related values
  68. .SH SYNOPSIS
  69. .IX Header "SYNOPSIS"
  70. .Vb 1
  71. \& #include <openssl/x509.h>
  72. \&
  73. \& int X509_cmp(const X509 *a, const X509 *b);
  74. \& int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
  75. \& int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
  76. \& int X509_issuer_name_cmp(const X509 *a, const X509 *b);
  77. \& int X509_subject_name_cmp(const X509 *a, const X509 *b);
  78. \& int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
  79. \& int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
  80. .Ve
  81. .SH DESCRIPTION
  82. .IX Header "DESCRIPTION"
  83. This set of functions are used to compare X509 objects, including X509
  84. certificates, X509 CRL objects and various values in an X509 certificate.
  85. .PP
  86. The \fBX509_cmp()\fR function compares two \fBX509\fR objects indicated by parameters
  87. \&\fIa\fR and \fIb\fR. The comparison is based on the \fBmemcmp\fR result of the hash
  88. values of two \fBX509\fR objects and the canonical (DER) encoding values.
  89. .PP
  90. The \fBX509_NAME_cmp()\fR function compares two \fBX509_NAME\fR objects indicated by
  91. parameters \fIa\fR and \fIb\fR, any of which may be NULL.
  92. The comparison is based on the \fBmemcmp\fR result of the
  93. canonical (DER) encoding values of the two objects using \fBi2d_X509_NAME\fR\|(3).
  94. This procedure adheres to the matching rules for Distinguished Names (DN)
  95. given in RFC 4517 section 4.2.15 and RFC 5280 section 7.1.
  96. In particular, the order of Relative Distinguished Names (RDNs) is relevant.
  97. On the other hand, if an RDN is multi-valued, i.e., it contains a set of
  98. AttributeValueAssertions (AVAs), its members are effectively not ordered.
  99. .PP
  100. The \fBX509_issuer_and_serial_cmp()\fR function compares the serial number and issuer
  101. values in the given \fBX509\fR objects \fIa\fR and \fIb\fR.
  102. .PP
  103. The \fBX509_issuer_name_cmp()\fR, \fBX509_subject_name_cmp()\fR and \fBX509_CRL_cmp()\fR functions
  104. are effectively wrappers of the \fBX509_NAME_cmp()\fR function. These functions compare
  105. issuer names and subject names of the objects, or issuers of \fBX509_CRL\fR
  106. objects, respectively.
  107. .IX Xref "509"
  108. .PP
  109. The \fBX509_CRL_match()\fR function compares two \fBX509_CRL\fR objects. Unlike the
  110. \&\fBX509_CRL_cmp()\fR function, this function compares the whole CRL content instead
  111. of just the issuer name.
  112. .SH "RETURN VALUES"
  113. .IX Header "RETURN VALUES"
  114. The \fBX509\fR comparison functions return \fB\-1\fR, \fB0\fR, or \fB1\fR if object \fIa\fR is
  115. found to be less than, to match, or be greater than object \fIb\fR, respectively.
  116. .PP
  117. \&\fBX509_NAME_cmp()\fR, \fBX509_issuer_and_serial_cmp()\fR, \fBX509_issuer_name_cmp()\fR,
  118. \&\fBX509_subject_name_cmp()\fR, \fBX509_CRL_cmp()\fR, and \fBX509_CRL_match()\fR
  119. may return \fB\-2\fR to indicate an error.
  120. .SH NOTES
  121. .IX Header "NOTES"
  122. These functions in fact utilize the underlying \fBmemcmp\fR of the C library to do
  123. the comparison job. Data to be compared varies from DER encoding data, hash
  124. value or \fBASN1_STRING\fR. The sign of the comparison can be used to order the
  125. objects but it does not have a special meaning in some cases.
  126. .PP
  127. \&\fBX509_NAME_cmp()\fR and wrappers utilize the value \fB\-2\fR to indicate errors in some
  128. circumstances, which could cause confusion for the applications.
  129. .SH "SEE ALSO"
  130. .IX Header "SEE ALSO"
  131. \&\fBi2d_X509_NAME\fR\|(3), \fBi2d_X509\fR\|(3)
  132. .SH COPYRIGHT
  133. .IX Header "COPYRIGHT"
  134. Copyright 2019\-2022 The OpenSSL Project Authors. All Rights Reserved.
  135. .PP
  136. Licensed under the Apache License 2.0 (the "License"). You may not use
  137. this file except in compliance with the License. You can obtain a copy
  138. in the file LICENSE in the source distribution or at
  139. <https://www.openssl.org/source/license.html>.