crypto/x509: remove OpenSSL exception for name constraints "@example.com".

OpenSSL accepts "@example.com" name constraints, while RFC5280 does not:

| A name constraint for Internet mail addresses MAY specify a
| particular mailbox, all addresses at a particular host, or all
| mailboxes in a domain.  To indicate a particular mailbox, the
| constraint is the complete mail address.  For example,
| "root@example.com" indicates the root mailbox on the host
| "example.com".  To indicate all Internet mail addresses on a
| particular host, the constraint is specified as the host name.  For
| example, the constraint "example.com" is satisfied by any mail
| address at the host "example.com".  To specify any address within a
| domain, the constraint is specified with a leading period (as with
| URIs).  For example, ".example.com" indicates all the Internet mail
| addresses in the domain "example.com", but not Internet mail
| addresses on the host "example.com".

Update-Note: name constraints for an RFC822 email address to match an entire domain must always be encoded as "example.com", as in RFC5280. They will no longer work if encoded as "@example.com", which is invalid.

Change-Id: I0141ad872050fda46fe6a800d77598c26a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/92067
Commit-Queue: Xiangfei Ding <xfding@google.com>
Reviewed-by: Xiangfei Ding <xfding@google.com>
diff --git a/crypto/x509/v3_ncons.cc b/crypto/x509/v3_ncons.cc
index 28618d5..eff5398 100644
--- a/crypto/x509/v3_ncons.cc
+++ b/crypto/x509/v3_ncons.cc
@@ -525,15 +525,6 @@
 
   CBS base_local, base_domain;
   bool base_has_at = CBS_get_until_first(&base_cbs, &base_local, '@');
-  if (base_has_at && CBS_len(&base_local) == 0) {
-    // OpenSSL ignores a stray leading @.
-    // This is a difference to libpki, which does not have this exception!
-    //
-    // TODO: crbug.com/500243591 - This is not in RFC5280. Document, or remove
-    // this block?
-    base_has_at = false;
-    CBS_skip(&base_cbs, 1);
-  }
   if (base_has_at) {
     CBS_skip(&base_cbs, 1);
     base_domain = base_cbs;
diff --git a/crypto/x509/x509_test.cc b/crypto/x509/x509_test.cc
index eff7b54..e8a4072 100644
--- a/crypto/x509/x509_test.cc
+++ b/crypto/x509/x509_test.cc
@@ -2293,11 +2293,13 @@
        SpecialCase::kExcludedViolationIfDNAttribute},
       {GEN_EMAIL, "foo@example.com", "bar@example.com",
        X509_V_ERR_PERMITTED_VIOLATION},
-      // OpenSSL ignores a stray leading @.
-      {GEN_EMAIL, "foo@example.com", "@example.com", X509_V_OK},
-      {GEN_EMAIL, "foo@example.com", "@EXAMPLE.COM", X509_V_OK},
+      // OpenSSL ignores a stray leading @. BoringSSL does not.
+      {GEN_EMAIL, "foo@example.com", "@example.com",
+       X509_V_ERR_UNSUPPORTED_NAME_SYNTAX},
+      {GEN_EMAIL, "foo@example.com", "@EXAMPLE.COM",
+       X509_V_ERR_UNSUPPORTED_NAME_SYNTAX},
       {GEN_EMAIL, "foo@bar.example.com", "@example.com",
-       X509_V_ERR_PERMITTED_VIOLATION},
+       X509_V_ERR_UNSUPPORTED_NAME_SYNTAX},
 
       // Basic syntax check.
       {GEN_URI, "not-a-url", "not-a-url", X509_V_ERR_UNSUPPORTED_NAME_SYNTAX},