crypto/x509: Make GENERAL_NAME_cmp a total order.

GENERAL_NAME_cmp returned -1 in both directions when the name types
differed, as did ASN1_TYPE_cmp (used for otherName values), and
edipartyname_cmp when the nameAssigner fields differed. This made them
unsuitable for sorting. Instead, order by type first, then by the
type-specific contents, with an absent nameAssigner sorting first.
Which non-NULL inputs compare equal is unchanged.

ASN1_TYPE_cmp now sorts NULL before non-NULL values, so two NULLs
compare equal. This lets X509_ALGOR_cmp drop its special case and also
become a total order, with an absent parameter sorting first. Which
inputs compare equal is unchanged.

The one remaining exception is X509_NAME_cmp's -2 return when a name
cannot be serialized, which cannot happen for unmodified parsed names.

While I'm here, remove NULL checks in GENERAL_NAME_cmp and othername_cmp
that cannot be hit.

Update-Note: ASN1_TYPE_cmp and X509_ALGOR_cmp now return a consistent
ordering. Callers that only compare the result against zero are
unaffected, except that ASN1_TYPE_cmp(NULL, NULL) now returns zero
instead of -1. Callers that checked for a specific non-zero value, such
as -1, should compare against zero instead.

Bug: 565047760
Change-Id: I7d8f98c25fe967afbe6ec518b4012a52b1c5e3ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/104768
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Moreno Ambrosin <ambrosin@google.com>
8 files changed
tree: 59fa5860051b06475e95eba1a06bf143dd79dba6
  1. .agents/
  2. .bcr/
  3. .github/
  4. _agents/
  5. bench/
  6. cmake/
  7. crypto/
  8. decrepit/
  9. docs/
  10. fuzz/
  11. gen/
  12. include/
  13. infra/
  14. pki/
  15. rust/
  16. ssl/
  17. third_party/
  18. tool/
  19. util/
  20. .bazelignore
  21. .bazelrc
  22. .bazelversion
  23. .clang-format
  24. .clang-format-ignore
  25. .clangd
  26. .gitattributes
  27. .gitignore
  28. API-CONVENTIONS.md
  29. AUTHORS
  30. BREAKING-CHANGES.md
  31. BUILD.bazel
  32. build.json
  33. BUILDING.md
  34. CMakeLists.txt
  35. codereview.settings
  36. CONTRIBUTING.md
  37. FUZZING.md
  38. go.mod
  39. go.sum
  40. INCORPORATING.md
  41. LICENSE
  42. MODULE.bazel
  43. MODULE.bazel.lock
  44. PORTING.md
  45. PRESUBMIT.py
  46. PrivacyInfo.xcprivacy
  47. README.md
  48. SANDBOXING.md
  49. SECURITY.md
  50. STYLE.md
README.md

BoringSSL

BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.

Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.

Programs ship their own copies of BoringSSL when they use it and we update everything as needed when deciding to make API changes. This allows us to mostly avoid compromises in the name of compatibility. It works for us, but it may not work for you.

BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built up a large number of patches that were maintained while tracking upstream OpenSSL. As Google's product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved in maintaining all these patches in multiple places was growing steadily.

Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's not part of the NDK) and a number of other apps/programs.

Project links:

To file a security issue, use the Chromium process and mention in the report this is for BoringSSL. You can ignore the parts of the process that are specific to Chromium/Chrome.

There are other files in this directory which might be helpful: