cddl 0.8.8 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cddl +35 -15
  3. data/cddl.gemspec +4 -2
  4. data/data/cddl.abnf +2 -1
  5. data/lib/cbor-pp-play.rb +1 -0
  6. data/lib/cddl.rb +234 -39
  7. data/test/test-cddl.rb +51 -0
  8. data/test-data/7807.cddl +14 -0
  9. data/test-data/abignum.cddl +1 -0
  10. data/test-data/abnf1.cddl +3 -0
  11. data/test-data/abnf2.cddl +37 -0
  12. data/test-data/abnf3.cddl +32 -0
  13. data/test-data/bat.cddl +16 -0
  14. data/test-data/bpv7.cddl +136 -0
  15. data/test-data/bpv7a.cddl +181 -0
  16. data/test-data/bpv7b.cddl +167 -0
  17. data/test-data/cat-re.cddl +2 -0
  18. data/test-data/complex-occ.cddl +11 -0
  19. data/test-data/coral.cddl +10 -0
  20. data/test-data/coral1.cddl +5 -0
  21. data/test-data/coral2.cddl +7 -0
  22. data/test-data/coral3.cddl +7 -0
  23. data/test-data/det1.cddl +12 -0
  24. data/test-data/feat1.cddl +4 -0
  25. data/test-data/feature-controller.cddl +6 -0
  26. data/test-data/feature-detail.cddl +5 -0
  27. data/test-data/foo.cddl +1 -0
  28. data/test-data/homenet-de.cddl +12 -0
  29. data/test-data/homenet-fe.cddl +12 -0
  30. data/test-data/jim-cut-2.cddl +11 -0
  31. data/test-data/jim-cut.cddl +12 -0
  32. data/test-data/jsoniodef.cddl +719 -0
  33. data/test-data/lint1.cddl +9 -0
  34. data/test-data/mdl-ble.cddl +9 -0
  35. data/test-data/mdl-deve.cddl +54 -0
  36. data/test-data/mdl-dp.cddl +11 -0
  37. data/test-data/mdl-mso.cddl +20 -0
  38. data/test-data/mdl-request.cddl +26 -0
  39. data/test-data/mdl-response.cddl +66 -0
  40. data/test-data/mdl.cddl +11 -0
  41. data/test-data/mon-val.cddl +1 -0
  42. data/test-data/multipart-ct.cddl +2 -0
  43. data/test-data/named-group.cddl +7 -0
  44. data/test-data/non-empty.cddl +5 -0
  45. data/test-data/oid.cddl +8 -0
  46. data/test-data/oidbat.cddl +8 -0
  47. data/test-data/plus.cddl +3 -0
  48. data/test-data/sasl.cddl +24 -0
  49. data/test-data/sequence.cddl +1 -0
  50. data/test-data/sipos.cddl +8 -0
  51. data/test-data/star-edited.cddl +98 -0
  52. data/test-data/star.cddl +95 -0
  53. data/test-data/test-gen.cddl +3 -0
  54. data/test-data/time.cddl +11 -0
  55. data/test-data/yangid.cddl +1 -0
  56. data/test-data/yaron1.cddl +95 -0
  57. metadata +70 -8
@@ -0,0 +1,9 @@
1
+ $instance-value-choice = (
2
+ comid.mac-addr => mac-addr-type //
3
+ comid.ip-addr => ip-addr-type //
4
+ comid.serial-number => serial-number-type //
5
+ comid.ueid => ueid //
6
+ comid.uuid => uuid
7
+ )
8
+
9
+ ; this populates a type socket with a group choice
@@ -0,0 +1,9 @@
1
+ BLEIdentification = {
2
+ ? 0 : bool,
3
+ ? 1 : bool,
4
+ ? 10 : bstr,
5
+ ; Indicates support for Peripheral server mode
6
+ ; Indicates support for Central client mode
7
+ ; Optional UUID for peripheral server mode
8
+ ? 11 : bstr ; Optional MAC address for peripheral server mode
9
+ }
@@ -0,0 +1,54 @@
1
+ deviceEngagement = [
2
+ uint,
3
+ security,
4
+ transferMethods,
5
+ options,
6
+ ? proprietary
7
+ ]
8
+ security = [
9
+ bstr,
10
+ uint, uint
11
+ ]
12
+ transferMethods = [
13
+ * transferMethod
14
+ ]
15
+ options = {
16
+ ?"WebAPI" : WebAPI,
17
+ ?"OIDC" : OIDC,
18
+ ?"compact" : bool
19
+ }
20
+ proprietary = {
21
+ * tstr => any
22
+ }
23
+ transferMethod = [
24
+ uint,
25
+ uint, * any
26
+ ]
27
+ OIDC = [
28
+ uint,
29
+ tstr,
30
+ tstr
31
+ ]
32
+ WebAPI = [
33
+ uint,
34
+ tstr, tstr
35
+ ]
36
+ ; Version of device engagement structure, currently 1
37
+ ; Security structure
38
+ ; Transfer methods
39
+ ; Optional elements
40
+ ; Proprietary elements
41
+ ; mDL public ephemeral key, mDL.EPub
42
+ ; curve identifier, see Table 23
43
+ ; cipher suite identifier, see Table 22
44
+ ; details for transfer methods
45
+ ; any number of elements
46
+ ; type
47
+ ; version
48
+ ; specific option(s) to the type
49
+ ; version
50
+ ; url
51
+ ; token
52
+ ; version
53
+ ; url
54
+ ; token
@@ -0,0 +1,11 @@
1
+ driving_privileges = [
2
+ * driving_privilege
3
+ ]
4
+ driving_privilege = {
5
+ vehicle_category_code: tstr
6
+ ?issue_date: #6.0(tstr)
7
+ ?expiry_date: #6.0(tstr)
8
+ ?code: tstr
9
+ ?sign: tstr
10
+ ?value: int
11
+ }
@@ -0,0 +1,20 @@
1
+ MobileSecurityObject = {
2
+ "DigestAlgorithm" : tstr,
3
+ "ValueDigests" : ValueDigests,
4
+ "DeviceKey" : COSE_Key,
5
+ "DocType" : tstr
6
+ }
7
+ ValueDigests = {
8
+ "NameSpaces" : NameSpaces
9
+ }
10
+ NameSpaces = {
11
+ + NameSpace => DigestIDs
12
+ }
13
+ DigestIDs = {
14
+ + DigestID => Digest
15
+ }
16
+ NameSpace = tstr
17
+ DigestID = uint
18
+ Digest = bstr
19
+
20
+ COSE_Key = "COSE_Key"
@@ -0,0 +1,26 @@
1
+ Request = {
2
+ "Version" : tstr,
3
+ "DocRequests" : [+ DocRequest]
4
+ }
5
+ DocRequest = {
6
+ "ItemsRequest" : ItemsRequest,
7
+ ? "ReaderAuth" : COSE_Sign1
8
+ }
9
+ ItemsRequest = {
10
+ ? "DocType" : DocType,
11
+ "NameSpaces" : NameSpaces,
12
+ ? "RequestInfo" : {* tstr => any}
13
+ }
14
+ NameSpaces = {
15
+ + NameSpace => DataItemNames
16
+ }
17
+ DocType = tstr
18
+ NameSpace = tstr
19
+ DataItemNames = [ + tstr ]
20
+ ; Additional info the reader wants to provide
21
+ ; Requested data elements for each NameSpace
22
+ ; See 7.3.2
23
+ ; See 7.3.3
24
+ ; See Table 2
25
+
26
+ COSE_Sign1 = "COSE_Sign1"
@@ -0,0 +1,66 @@
1
+ Response = {
2
+ "Version" : tstr,
3
+ ? "Documents" : Documents,
4
+ ? "Error" : int
5
+ }
6
+ Documents = {
7
+ + DocType => ResponseData
8
+ }
9
+ ; Version of the structure, currently 1.0
10
+ ; Returned documents, may be absent if Error is present
11
+ ; Error codes according to Table 8
12
+ ResponseData = {
13
+ "IssuerSigned" : IssuerSigned, ; Responded data elements signed by the issuer
14
+ "DeviceSigned" : DeviceSigned, ; Responded data elements signed by the mDL
15
+ "Errors" : Errors
16
+ }
17
+ IssuerSigned = {
18
+ "NameSpaces" : IssuerNameSpaces,
19
+ "IssuerAuth" : COSE_Sign1 ; The payload is the MobileSecurityObject, see 9.2.1.4
20
+ }
21
+ IssuerNameSpaces = {
22
+ + NameSpace => [ + IssuerSignedItem ]
23
+ }
24
+ IssuerSignedItem = [
25
+ uint,
26
+ bstr,
27
+ tstr,
28
+ any
29
+ ]
30
+ DeviceSigned = {
31
+ "NameSpaces" : DeviceNameSpaces, ; Currently only online token and URL are defined as DeviceSignedItems
32
+ "DeviceAuth" : DeviceAuth
33
+ }
34
+ DeviceNameSpaces = {
35
+ * NameSpace => DeviceSignedItems
36
+ }
37
+ DeviceSignedItems = {
38
+ + DataItemName => DataItemValue
39
+ }
40
+ DeviceAuth = {
41
+ "Signature" : COSE_Sign1, //
42
+ ; Use a nil value for the payload, the detached content is the DeviceAuthentication structure, see 9.2.2.4
43
+ "MAC" : COSE_Mac0
44
+ }
45
+ Errors = {
46
+ * NameSpace => [ + ErrorItem ]
47
+ }
48
+ ErrorItem = {
49
+ DataItemName => ErrorCode
50
+ }
51
+ DocType = tstr
52
+ NameSpace = tstr
53
+ DataItemName = tstr
54
+ DataItemValue = any
55
+ ErrorCode = int
56
+ ; See table 9
57
+ ; See 7.3.2
58
+ ; See 7.3.3
59
+ ; See Table 2
60
+ ; See Table 2
61
+ ; Error codes according to Table 9
62
+ ; Structures used for DeviceAuth signature or MAC generation, see 9.2.2.4
63
+ ; Structures used for MobileSecurityObject, see 9.2.1.4
64
+
65
+ COSE_Sign1 = "COSE_Sign1"
66
+ COSE_Mac0 = "COSE_Mac0"
@@ -0,0 +1,11 @@
1
+ driving_privileges = [
2
+ * driving_privilege
3
+ ]
4
+ driving_privilege = {
5
+ vehicle_category_code: tstr
6
+ ?issue_date: #6.0(tstr)
7
+ ?expiry_date: #6.0(tstr)
8
+ ?code: tstr
9
+ ?sign: tstr
10
+ ?value: int
11
+ }
@@ -0,0 +1 @@
1
+ decimal-monetary-value = text .regexp "-?[0-9]+(\\.[0-9]+)?"
@@ -0,0 +1,2 @@
1
+ multipart-core = [* multipart-part]
2
+ multipart-part = (type: uint .size 2, part: bytes / null)
@@ -0,0 +1,7 @@
1
+ foo = { + $$elements }
2
+
3
+ $$elements //= element1
4
+ $$elements //= element2
5
+
6
+ element1 = (1: "a")
7
+ element2 = (2: "b")
@@ -0,0 +1,5 @@
1
+ distinguishedName = non-empty<{
2
+ ? country: text
3
+ }>
4
+
5
+ non-empty<M> = (M) .and ({ + any => any })
@@ -0,0 +1,8 @@
1
+ oid = bytes .abnfb ("oid" .cat cbor-tags-oid)
2
+
3
+ cbor-tags-oid = '
4
+ oid = 1*arc
5
+ roid = *arc
6
+ arc = [nlsb] %x00-7f
7
+ nlsb = %x81-ff *%x80-ff
8
+ '
@@ -0,0 +1,8 @@
1
+ oid = bytes .abnfb ("oid" .bat cbor-tags-oid)
2
+
3
+ cbor-tags-oid = '
4
+ oid = 1*arc
5
+ roid = *arc
6
+ arc = [nlsb] %x00-7f
7
+ nlsb = %x81-ff *%x80-ff
8
+ '
@@ -0,0 +1,3 @@
1
+ a = {
2
+ + any => any
3
+ }
@@ -0,0 +1,24 @@
1
+ message = text .abnfb ("message" .cat rfc4505)
2
+
3
+ rfc4505 = '
4
+ message = [ email / token ]
5
+ ;; to be prepared in accordance with Section 3
6
+
7
+ UTF1 = %x00-3F / %x41-7F ;; less "@" (U+0040)
8
+ UTF2 = %xC2-DF UTF0
9
+ UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC 2(UTF0) /
10
+ %xED %x80-9F UTF0 / %xEE-EF 2(UTF0)
11
+ UTF4 = %xF0 %x90-BF 2(UTF0) / %xF1-F3 3(UTF0) /
12
+ %xF4 %x80-8F 2(UTF0)
13
+ UTF0 = %x80-BF
14
+
15
+ TCHAR = UTF1 / UTF2 / UTF3 / UTF4
16
+ ;; any UTF-8 encoded Unicode character
17
+ ;; except "@" (U+0040)
18
+
19
+ email = "too@much.work"; for this example
20
+ ;email = addr-spec
21
+ ;; as defined in [IMAIL]
22
+
23
+ token = 1*255TCHAR
24
+ '
@@ -0,0 +1 @@
1
+ a = [tstr, tstr, tstr]
@@ -0,0 +1,8 @@
1
+ ; start = {*$$socket}
2
+ ; $$socket //= (4: bstr)
3
+ ; $ cddl works.cddl generate
4
+ ; {4: h'6F7267616E69736D'}
5
+ ; $ cat fails.cddl
6
+ start = {*$$socket}
7
+ $$socket //= (some,)
8
+ some = (4: bstr)
@@ -0,0 +1,98 @@
1
+ csr-template-schema = {
2
+ keyTypes: [ 1* $keyType ]
3
+ ? subject: distinguishedName
4
+ extensions: extensions
5
+ }
6
+
7
+ mandatory-wildcard = "**"
8
+ optional-wildcard = "*"
9
+ wildcard = mandatory-wildcard / optional-wildcard
10
+
11
+ ; non-empty = { + any => any }
12
+ non-empty<M> = (M) .and ({ + any => any })
13
+
14
+ ; regtext matches all text strings but "*" and "**"
15
+ regtext = text .regexp "([^\*].*)|([\*][^\*].*)|([\*][\*].+)"
16
+
17
+ regtext-or-wildcard = regtext / wildcard
18
+
19
+ distinguishedName = non-empty<{
20
+ ? country: regtext-or-wildcard
21
+ ? stateOrProvince: regtext-or-wildcard
22
+ ? locality: regtext-or-wildcard
23
+ ? organization: regtext-or-wildcard
24
+ ? organizationalUnit: regtext-or-wildcard
25
+ ? emailAddress: regtext-or-wildcard
26
+ ? commonName: regtext-or-wildcard
27
+ }>
28
+
29
+ $keyType /= rsaKeyType
30
+ $keyType /= ecdsaKeyType
31
+
32
+ rsaKeyType = {
33
+ PublicKeyType: "rsaEncryption" ; OID: 1.2.840.113549.1.1.1
34
+ PublicKeyLength: rsaKeySize
35
+ SignatureType: $rsaSignatureType
36
+ }
37
+
38
+ rsaKeySize = int .ge 2048
39
+
40
+ ; RSASSA-PKCS1-v1_5 with SHA-256
41
+ $rsaSignatureType /= "sha256WithRSAEncryption"
42
+ ; RSASSA-PCKS1-v1_5 with SHA-384
43
+ $rsaSignatureType /= "sha384WithRSAEncryption"
44
+ ; RSASSA-PCKS1-v1_5 with SHA-512
45
+ $rsaSignatureType /= "sha512WithRSAEncryption"
46
+ ; RSASSA-PSS with SHA-256, MGF-1 with SHA-256, and a 32 byte salt
47
+ $rsaSignatureType /= "sha256WithRSAandMGF1"
48
+ ; RSASSA-PSS with SHA-384, MGF-1 with SHA-384, and a 48 byte salt
49
+ $rsaSignatureType /= "sha384WithRSAandMGF1"
50
+ ; RSASSA-PSS with SHA-512, MGF-1 with SHA-512, and a 64 byte salt
51
+ $rsaSignatureType /= "sha512WithRSAandMGF1"
52
+
53
+ ecdsaKeyType = {
54
+ PublicKeyType: "id-ecPublicKey" ; OID: 1.2.840.10045.2.1
55
+ namedCurve: $ecdsaCurve
56
+ SignatureType: $ecdsaSignatureType
57
+ }
58
+
59
+ $ecdsaCurve /= "secp256r1" ; OID: 1.2.840.10045.3.1.7
60
+ $ecdsaCurve /= "secp384r1" ; OID: 1.3.132.0.34
61
+ $ecdsaCurve /= "secp521r1" ; OID: 1.3.132.0.3
62
+
63
+ $ecdsaSignatureType /= "ecdsa-with-SHA256" ; paired with secp256r1
64
+ $ecdsaSignatureType /= "ecdsa-with-SHA384" ; paired with secp384r1
65
+ $ecdsaSignatureType /= "ecdsa-with-SHA512" ; paired with secp521r1
66
+
67
+ subjectaltname = {
68
+ ? DNS: [ 1* regtext-or-wildcard ]
69
+ ? Email: [ 1* regtext ]
70
+ ? URI: [ 1* regtext ]
71
+ * $$subjectaltname-extension
72
+ }
73
+
74
+ extensions = {
75
+ ? keyUsage: [ 1* keyUsageType ]
76
+ ? extendedKeyUsage: [ 1* extendedKeyUsageType ]
77
+ subjectAltName: subjectaltname
78
+ }
79
+
80
+ keyUsageType /= "digitalSignature"
81
+ keyUsageType /= "nonRepudiation"
82
+ keyUsageType /= "keyEncipherment"
83
+ keyUsageType /= "dataEncipherment"
84
+ keyUsageType /= "keyAgreement"
85
+ keyUsageType /= "keyCertSign"
86
+ keyUsageType /= "cRLSign"
87
+ keyUsageType /= "encipherOnly"
88
+ keyUsageType /= "decipherOnly"
89
+
90
+ extendedKeyUsageType /= "serverAuth"
91
+ extendedKeyUsageType /= "clientAuth"
92
+ extendedKeyUsageType /= "codeSigning"
93
+ extendedKeyUsageType /= "emailProtection"
94
+ extendedKeyUsageType /= "timeStamping"
95
+ extendedKeyUsageType /= "OCSPSigning"
96
+ extendedKeyUsageType /= oid
97
+
98
+ oid = text .regexp "[0-9]+(\\.[0-9]+)*"
@@ -0,0 +1,95 @@
1
+ csr-template-schema = {
2
+ keyTypes: [ 1* $keyType ]
3
+ ? subject: distinguishedName
4
+ extensions: extensions
5
+ }
6
+
7
+ mandatory-wildcard = "**"
8
+ optional-wildcard = "*"
9
+ wildcard = mandatory-wildcard / optional-wildcard
10
+
11
+ ; regtext matches all text strings but "*" and "**"
12
+ regtext = text .regexp "([^\*].*)|([\*][^\*].*)|([\*][\*].+)"
13
+
14
+ regtext-or-wildcard = regtext / wildcard
15
+
16
+ distinguishedName = {
17
+ ? country: regtext-or-wildcard
18
+ ? stateOrProvince: regtext-or-wildcard
19
+ ? locality: regtext-or-wildcard
20
+ ? organization: regtext-or-wildcard
21
+ ? organizationalUnit: regtext-or-wildcard
22
+ ? emailAddress: regtext-or-wildcard
23
+ ? commonName: regtext-or-wildcard
24
+ }
25
+
26
+ $keyType /= rsaKeyType
27
+ $keyType /= ecdsaKeyType
28
+
29
+ rsaKeyType = {
30
+ PublicKeyType: "rsaEncryption" ; OID: 1.2.840.113549.1.1.1
31
+ PublicKeyLength: rsaKeySize
32
+ SignatureType: $rsaSignatureType
33
+ }
34
+
35
+ rsaKeySize = int .ge 2048
36
+
37
+ ; RSASSA-PKCS1-v1_5 with SHA-256
38
+ $rsaSignatureType /= "sha256WithRSAEncryption"
39
+ ; RSASSA-PCKS1-v1_5 with SHA-384
40
+ $rsaSignatureType /= "sha384WithRSAEncryption"
41
+ ; RSASSA-PCKS1-v1_5 with SHA-512
42
+ $rsaSignatureType /= "sha512WithRSAEncryption"
43
+ ; RSASSA-PSS with SHA-256, MGF-1 with SHA-256, and a 32 byte salt
44
+ $rsaSignatureType /= "sha256WithRSAandMGF1"
45
+ ; RSASSA-PSS with SHA-384, MGF-1 with SHA-384, and a 48 byte salt
46
+ $rsaSignatureType /= "sha384WithRSAandMGF1"
47
+ ; RSASSA-PSS with SHA-512, MGF-1 with SHA-512, and a 64 byte salt
48
+ $rsaSignatureType /= "sha512WithRSAandMGF1"
49
+
50
+ ecdsaKeyType = {
51
+ PublicKeyType: "id-ecPublicKey" ; OID: 1.2.840.10045.2.1
52
+ namedCurve: $ecdsaCurve
53
+ SignatureType: $ecdsaSignatureType
54
+ }
55
+
56
+ $ecdsaCurve /= "secp256r1" ; OID: 1.2.840.10045.3.1.7
57
+ $ecdsaCurve /= "secp384r1" ; OID: 1.3.132.0.34
58
+ $ecdsaCurve /= "secp521r1" ; OID: 1.3.132.0.3
59
+
60
+ $ecdsaSignatureType /= "ecdsa-with-SHA256" ; paired with secp256r1
61
+ $ecdsaSignatureType /= "ecdsa-with-SHA384" ; paired with secp384r1
62
+ $ecdsaSignatureType /= "ecdsa-with-SHA512" ; paired with secp521r1
63
+
64
+ subjectaltname = {
65
+ ? DNS: [ 1* regtext-or-wildcard ]
66
+ ? Email: [ 1* regtext ]
67
+ ? URI: [ 1* regtext ]
68
+ * $$subjectaltname-extension
69
+ }
70
+
71
+ extensions = {
72
+ ? keyUsage: [ 1* keyUsageType ]
73
+ ? extendedKeyUsage: [ 1* extendedKeyUsageType ]
74
+ subjectAltName: subjectaltname
75
+ }
76
+
77
+ keyUsageType /= "digitalSignature"
78
+ keyUsageType /= "nonRepudiation"
79
+ keyUsageType /= "keyEncipherment"
80
+ keyUsageType /= "dataEncipherment"
81
+ keyUsageType /= "keyAgreement"
82
+ keyUsageType /= "keyCertSign"
83
+ keyUsageType /= "cRLSign"
84
+ keyUsageType /= "encipherOnly"
85
+ keyUsageType /= "decipherOnly"
86
+
87
+ extendedKeyUsageType /= "serverAuth"
88
+ extendedKeyUsageType /= "clientAuth"
89
+ extendedKeyUsageType /= "codeSigning"
90
+ extendedKeyUsageType /= "emailProtection"
91
+ extendedKeyUsageType /= "timeStamping"
92
+ extendedKeyUsageType /= "OCSPSigning"
93
+ extendedKeyUsageType /= oid
94
+
95
+ oid = text .regexp "[0-9]+(\\.[0-9]+)*"
@@ -0,0 +1,3 @@
1
+ foo = arr<mapa<arr<int>, arr<text>>>
2
+ arr<X> = [* X]
3
+ mapa<X, Y> = {a: X, b: Y}
@@ -0,0 +1,11 @@
1
+ etime = #6.1001({
2
+ 1: int,
3
+ ? (
4
+ -3: uint .lt 1000 //
5
+ -6: uint .lt 1000000 //
6
+ -9: uint .lt 1000000000 //
7
+ -12: uint .lt 1000000000000 //
8
+ -15: uint .lt 1000000000000000 //
9
+ -18: uint .lt 1000000000000000000
10
+ )
11
+ })
@@ -0,0 +1 @@
1
+ a = text .regexp "[a-z][a-z0-9]*(-[a-z0-9]+)*"
@@ -0,0 +1,95 @@
1
+ csr-template-schema = {
2
+ keyTypes: [ 1* $keyType ]
3
+ ? subject: distinguishedName
4
+ extensions: extensions
5
+ }
6
+
7
+ mandatory-wildcard = "**"
8
+ optional-wildcard = "*"
9
+ wildcard = mandatory-wildcard / optional-wildcard
10
+
11
+ ; regtext matches all text strings but "*" and "**"
12
+ regtext = text .regexp "([^\*].*)|([\*][^\*].*)|([\*][\*].+)"
13
+
14
+ regtext-or-wildcard = regtext / wildcard
15
+
16
+ distinguishedName = {
17
+ ? country: regtext-or-wildcard
18
+ ? stateOrProvince: regtext-or-wildcard
19
+ ? locality: regtext-or-wildcard
20
+ ? organization: regtext-or-wildcard
21
+ ? organizationalUnit: regtext-or-wildcard
22
+ ? emailAddress: regtext-or-wildcard
23
+ ? commonName: regtext-or-wildcard
24
+ }
25
+
26
+ $keyType /= rsaKeyType
27
+ $keyType /= ecdsaKeyType
28
+
29
+ rsaKeyType = {
30
+ PublicKeyType: "rsaEncryption" ; OID: 1.2.840.113549.1.1.1
31
+ PublicKeyLength: rsaKeySize
32
+ SignatureType: $rsaSignatureType
33
+ }
34
+
35
+ rsaKeySize = int .ge 2048
36
+
37
+ ; RSASSA-PKCS1-v1_5 with SHA-256
38
+ $rsaSignatureType /= "sha256WithRSAEncryption"
39
+ ; RSASSA-PCKS1-v1_5 with SHA-384
40
+ $rsaSignatureType /= "sha384WithRSAEncryption"
41
+ ; RSASSA-PCKS1-v1_5 with SHA-512
42
+ $rsaSignatureType /= "sha512WithRSAEncryption"
43
+ ; RSASSA-PSS with SHA-256, MGF-1 with SHA-256, and a 32 byte salt
44
+ $rsaSignatureType /= "sha256WithRSAandMGF1"
45
+ ; RSASSA-PSS with SHA-384, MGF-1 with SHA-384, and a 48 byte salt
46
+ $rsaSignatureType /= "sha384WithRSAandMGF1"
47
+ ; RSASSA-PSS with SHA-512, MGF-1 with SHA-512, and a 64 byte salt
48
+ $rsaSignatureType /= "sha512WithRSAandMGF1"
49
+
50
+ ecdsaKeyType = {
51
+ PublicKeyType: "id-ecPublicKey" ; OID: 1.2.840.10045.2.1
52
+ namedCurve: $ecdsaCurve
53
+ SignatureType: $ecdsaSignatureType
54
+ }
55
+
56
+ $ecdsaCurve /= "secp256r1" ; OID: 1.2.840.10045.3.1.7
57
+ $ecdsaCurve /= "secp384r1" ; OID: 1.3.132.0.34
58
+ $ecdsaCurve /= "secp521r1" ; OID: 1.3.132.0.3
59
+
60
+ $ecdsaSignatureType /= "ecdsa-with-SHA256" ; paired with secp256r1
61
+ $ecdsaSignatureType /= "ecdsa-with-SHA384" ; paired with secp384r1
62
+ $ecdsaSignatureType /= "ecdsa-with-SHA512" ; paired with secp521r1
63
+
64
+ subjectaltname = {
65
+ ? DNS: [ 1* regtext-or-wildcard ]
66
+ ? Email: [ 1* regtext ]
67
+ ? URI: [ 1* regtext ]
68
+ * $$subjectaltname-extension
69
+ }
70
+
71
+ extensions = {
72
+ ? keyUsage: [ 1* keyUsageType ]
73
+ ? extendedKeyUsage: [ 1* extendedKeyUsageType ]
74
+ subjectAltName: subjectaltname
75
+ }
76
+
77
+ keyUsageType /= "digitalSignature"
78
+ keyUsageType /= "nonRepudiation"
79
+ keyUsageType /= "keyEncipherment"
80
+ keyUsageType /= "dataEncipherment"
81
+ keyUsageType /= "keyAgreement"
82
+ keyUsageType /= "keyCertSign"
83
+ keyUsageType /= "cRLSign"
84
+ keyUsageType /= "encipherOnly"
85
+ keyUsageType /= "decipherOnly"
86
+
87
+ extendedKeyUsageType /= "serverAuth"
88
+ extendedKeyUsageType /= "clientAuth"
89
+ extendedKeyUsageType /= "codeSigning"
90
+ extendedKeyUsageType /= "emailProtection"
91
+ extendedKeyUsageType /= "timeStamping"
92
+ extendedKeyUsageType /= "OCSPSigning"
93
+ extendedKeyUsageType /= oid
94
+
95
+ oid = text .regexp "[0-9]+(\\.[0-9]+)*"