Skip to content

Commit 2f54486

Browse files
CABF SMIME 7.1.4.2.h If present, the subject:emailAddress SHALL contain a single Mailbox Address (#752)
* CABF SMIMS 4.1.4.2.h If present, the subject:emailAddress SHALL contain a single Mailbox Address * go imports the files
1 parent 2f0f4b8 commit 2f54486

File tree

5 files changed

+218
-0
lines changed

5 files changed

+218
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* ZLint Copyright 2023 Regents of the University of Michigan
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy
6+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11+
* implied. See the License for the specific language governing
12+
* permissions and limitations under the License.
13+
*/
14+
15+
package cabf_smime_br
16+
17+
import (
18+
"fmt"
19+
20+
"github.com/zmap/zcrypto/x509"
21+
"github.com/zmap/zlint/v3/lint"
22+
"github.com/zmap/zlint/v3/util"
23+
)
24+
25+
func init() {
26+
lint.RegisterLint(&lint.Lint{
27+
Name: "e_single_email_if_present",
28+
Description: "If present, the subject:emailAddress SHALL contain a single Mailbox Address",
29+
Citation: "7.1.4.2.h",
30+
Source: lint.CABFSMIMEBaselineRequirements,
31+
EffectiveDate: util.CABF_SMIME_BRs_1_0_0_Date,
32+
Lint: func() lint.LintInterface { return &singleEmailIfPresent{} },
33+
})
34+
}
35+
36+
type singleEmailIfPresent struct{}
37+
38+
func NewSingleEmailIfPresent() lint.LintInterface {
39+
return &singleEmailIfPresent{}
40+
}
41+
42+
func (l *singleEmailIfPresent) CheckApplies(c *x509.Certificate) bool {
43+
return util.IsSubscriberCert(c) && c.EmailAddresses != nil && len(c.EmailAddresses) != 0
44+
}
45+
46+
func (l *singleEmailIfPresent) Execute(c *x509.Certificate) *lint.LintResult {
47+
if len(c.EmailAddresses) == 1 {
48+
return &lint.LintResult{
49+
Status: lint.Pass,
50+
}
51+
} else {
52+
return &lint.LintResult{
53+
Status: lint.Error,
54+
Details: fmt.Sprintf("subject:emailAddress was present and containted %d names (%s)", len(c.EmailAddresses), c.EmailAddresses),
55+
LintMetadata: lint.LintMetadata{},
56+
}
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package cabf_smime_br
2+
3+
import (
4+
"testing"
5+
6+
"github.com/zmap/zlint/v3/lint"
7+
"github.com/zmap/zlint/v3/test"
8+
)
9+
10+
func TestSingleEmailIfPresent(t *testing.T) {
11+
testCases := []struct {
12+
Name string
13+
InputFilename string
14+
ExpectedResult lint.LintStatus
15+
}{
16+
{
17+
Name: "pass - cert with one email address",
18+
InputFilename: "smime/single_email_present.pem",
19+
ExpectedResult: lint.Pass,
20+
},
21+
{
22+
Name: "NA - cert with no email addresses",
23+
InputFilename: "smime/no_email_present.pem",
24+
ExpectedResult: lint.NA,
25+
},
26+
{
27+
Name: "Error - cert with multiple email addresses",
28+
InputFilename: "smime/multiple_email_present.pem",
29+
ExpectedResult: lint.Error,
30+
},
31+
}
32+
for _, tc := range testCases {
33+
t.Run(tc.Name, func(t *testing.T) {
34+
result := test.TestLint("e_single_email_if_present", tc.InputFilename)
35+
if result.Status != tc.ExpectedResult {
36+
t.Errorf("expected result %v was %v - details: %v", tc.ExpectedResult, result.Status, result.Details)
37+
}
38+
})
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Certificate:
2+
Data:
3+
Version: 3 (0x2)
4+
Serial Number: 3 (0x3)
5+
Signature Algorithm: ecdsa-with-SHA256
6+
Issuer:
7+
Validity
8+
Not Before: Oct 15 17:52:28 2023 GMT
9+
Not After : Nov 30 00:00:00 9998 GMT
10+
Subject:
11+
Subject Public Key Info:
12+
Public Key Algorithm: id-ecPublicKey
13+
Public-Key: (256 bit)
14+
pub:
15+
04:cb:41:d2:58:66:06:29:c0:c8:bf:c9:20:76:7f:
16+
49:a7:6d:2a:f1:f4:7f:36:4c:94:b4:91:ac:6d:76:
17+
29:65:11:d0:34:0b:d5:d2:53:e0:dd:86:42:5b:ee:
18+
37:ca:bb:a0:bc:be:73:7f:61:cb:45:af:8e:46:74:
19+
ce:4b:9a:ff:a2
20+
ASN1 OID: prime256v1
21+
NIST CURVE: P-256
22+
X509v3 extensions:
23+
X509v3 Extended Key Usage:
24+
E-mail Protection
25+
X509v3 Subject Alternative Name:
26+
27+
Signature Algorithm: ecdsa-with-SHA256
28+
Signature Value:
29+
30:46:02:21:00:90:32:cc:3f:a1:bf:31:e7:be:57:8f:a7:30:
30+
33:bc:ed:2f:92:9a:7a:69:50:bc:7f:e1:72:aa:b1:25:1a:2e:
31+
fe:02:21:00:c1:88:2d:90:b9:72:d4:03:12:c3:45:3a:b5:f3:
32+
45:72:23:9c:65:73:b4:5e:50:cd:f6:bc:4c:a7:ba:8e:6d:b8
33+
-----BEGIN CERTIFICATE-----
34+
MIIBQTCB56ADAgECAgEDMAoGCCqGSM49BAMCMAAwIBcNMjMxMDE1MTc1MjI4WhgP
35+
OTk5ODExMzAwMDAwMDBaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATLQdJY
36+
ZgYpwMi/ySB2f0mnbSrx9H82TJS0kaxtdillEdA0C9XSU+DdhkJb7jfKu6C8vnN/
37+
YctFr45GdM5Lmv+io1AwTjATBgNVHSUEDDAKBggrBgEFBQcDBDA3BgNVHREEMDAu
38+
gRVjb29sZ3V5QGNvb2xwbGFjZS5jb22BFWRydW1zb2xvQHJvY2tzdGFyLm9yZzAK
39+
BggqhkjOPQQDAgNJADBGAiEAkDLMP6G/Mee+V4+nMDO87S+SmnppULx/4XKqsSUa
40+
Lv4CIQDBiC2QuXLUAxLDRTq180VyI5xlc7ReUM32vEynuo5tuA==
41+
-----END CERTIFICATE-----
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Certificate:
2+
Data:
3+
Version: 3 (0x2)
4+
Serial Number: 3 (0x3)
5+
Signature Algorithm: ecdsa-with-SHA256
6+
Issuer:
7+
Validity
8+
Not Before: Oct 15 17:53:09 2023 GMT
9+
Not After : Nov 30 00:00:00 9998 GMT
10+
Subject:
11+
Subject Public Key Info:
12+
Public Key Algorithm: id-ecPublicKey
13+
Public-Key: (256 bit)
14+
pub:
15+
04:4f:e8:85:20:80:1b:21:66:01:b1:ff:0b:db:f6:
16+
f9:51:6d:d7:66:f4:64:2b:67:b3:31:99:65:35:97:
17+
9d:d1:69:29:b7:d3:15:65:84:8a:55:24:21:78:a5:
18+
89:43:be:14:b6:9f:8e:8f:63:50:85:62:44:52:4c:
19+
59:a1:0a:65:70
20+
ASN1 OID: prime256v1
21+
NIST CURVE: P-256
22+
X509v3 extensions:
23+
X509v3 Extended Key Usage:
24+
E-mail Protection
25+
Signature Algorithm: ecdsa-with-SHA256
26+
Signature Value:
27+
30:45:02:20:77:4e:a8:1e:bc:68:c9:ff:83:7b:ac:dc:16:2b:
28+
cb:8f:38:1c:95:81:a5:db:55:93:fe:2a:ac:53:a7:f2:e2:4c:
29+
02:21:00:b0:9b:8b:b0:1f:a4:b6:3f:7e:8d:01:6e:0b:98:43:
30+
a1:95:aa:8f:79:31:1d:35:5a:ed:3c:a1:30:2c:c6:1a:b2
31+
-----BEGIN CERTIFICATE-----
32+
MIIBBzCBrqADAgECAgEDMAoGCCqGSM49BAMCMAAwIBcNMjMxMDE1MTc1MzA5WhgP
33+
OTk5ODExMzAwMDAwMDBaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARP6IUg
34+
gBshZgGx/wvb9vlRbddm9GQrZ7MxmWU1l53RaSm30xVlhIpVJCF4pYlDvhS2n46P
35+
Y1CFYkRSTFmhCmVwoxcwFTATBgNVHSUEDDAKBggrBgEFBQcDBDAKBggqhkjOPQQD
36+
AgNIADBFAiB3TqgevGjJ/4N7rNwWK8uPOByVgaXbVZP+KqxTp/LiTAIhALCbi7Af
37+
pLY/fo0BbguYQ6GVqo95MR01Wu08oTAsxhqy
38+
-----END CERTIFICATE-----
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Certificate:
2+
Data:
3+
Version: 3 (0x2)
4+
Serial Number: 3 (0x3)
5+
Signature Algorithm: ecdsa-with-SHA256
6+
Issuer:
7+
Validity
8+
Not Before: Oct 15 17:49:19 2023 GMT
9+
Not After : Nov 30 00:00:00 9998 GMT
10+
Subject:
11+
Subject Public Key Info:
12+
Public Key Algorithm: id-ecPublicKey
13+
Public-Key: (256 bit)
14+
pub:
15+
04:ef:76:01:b8:fe:88:a0:d2:69:ea:ed:d0:16:0f:
16+
b2:57:f3:b9:a5:8c:50:e2:f6:82:ff:fc:6b:b6:0a:
17+
41:23:cb:dc:52:6f:26:1e:9b:c1:db:aa:26:9e:c0:
18+
58:6d:bc:ea:d1:1b:b3:55:ec:dd:dc:93:ed:07:36:
19+
06:44:f5:02:9c
20+
ASN1 OID: prime256v1
21+
NIST CURVE: P-256
22+
X509v3 extensions:
23+
X509v3 Extended Key Usage:
24+
E-mail Protection
25+
X509v3 Subject Alternative Name:
26+
27+
Signature Algorithm: ecdsa-with-SHA256
28+
Signature Value:
29+
30:45:02:20:58:18:e5:5b:31:e1:83:a6:5e:5c:76:40:fe:eb:
30+
a2:82:3a:2b:d9:e0:0f:09:f6:d2:b7:ae:5e:e4:a7:36:13:e5:
31+
02:21:00:f6:f8:43:f6:76:2d:18:af:33:91:20:71:78:f5:2a:
32+
9e:9b:08:66:98:c6:ef:bf:cb:06:b9:62:7e:c2:44:92:51
33+
-----BEGIN CERTIFICATE-----
34+
MIIBKTCB0KADAgECAgEDMAoGCCqGSM49BAMCMAAwIBcNMjMxMDE1MTc0OTE5WhgP
35+
OTk5ODExMzAwMDAwMDBaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATvdgG4
36+
/oig0mnq7dAWD7JX87mljFDi9oL//Gu2CkEjy9xSbyYem8HbqiaewFhtvOrRG7NV
37+
7N3ck+0HNgZE9QKcozkwNzATBgNVHSUEDDAKBggrBgEFBQcDBDAgBgNVHREEGTAX
38+
gRVjb29sZ3V5QGNvb2xwbGFjZS5jb20wCgYIKoZIzj0EAwIDSAAwRQIgWBjlWzHh
39+
g6ZeXHZA/uuigjor2eAPCfbSt65e5Kc2E+UCIQD2+EP2di0YrzORIHF49Sqemwhm
40+
mMbvv8sGuWJ+wkSSUQ==
41+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)