cddl 0.8.20 → 0.8.29

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 400024278cc4fce962a5e51e60ba6025ec371cd5768685c0ce10534a06393fa2
4
- data.tar.gz: cbac2ff6008501c65984cb816cc95b79a8adc361609c4858ba518c073e317937
3
+ metadata.gz: d71bf9745f9a7e1c96d6ae4007cf598a36617347c1ed772950ace7dedef3c121
4
+ data.tar.gz: ca84d02afd7243260046c0e75ae0b14eb5442238b97ef56f050ff0d9cbecd6c4
5
5
  SHA512:
6
- metadata.gz: 71babdced5f362b46a1877fdb8676faf2efec9594069b9b95c80daecdfb9aad5bf13ca73577437089fb1dd4819506b00311c003699831110fbba464c06d86fad
7
- data.tar.gz: 2a29deef318b1c31a830e8937618d776fc439bc6a5b792b7daa79545ed29aedb028f6e78ce3f3b04f36767f21cf38ff349f6251ff3d83103f02c94a124132f34
6
+ metadata.gz: '0595a939e1677462971fba537b6cab3268b84662e4764e2ab69658009928687ca85da7ceb721ee23c6b803c1bf70cebcb90471703cd6fb17325f37838bc45fc7'
7
+ data.tar.gz: a69d45135335bfcdacc58c03339ec5a7316cb4d99596e65b67b7ca947e65a47adc3fcbd7469b442d9c6bd5fec2d1ee9da8a7a07204f26a489c3c3505205abd6c
data/bin/cddl CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env RUBY_THREAD_VM_STACK_SIZE=5000000 ruby
2
2
  # -*- coding: utf-8 -*-
3
3
  # require_relative '../lib/cddl'
4
4
  require 'cddl'
@@ -19,17 +19,19 @@ def usage
19
19
  exit EX_USAGE
20
20
  end
21
21
 
22
- def read_arg(arg)
22
+ def read_arg(arg, remember_fn = true)
23
23
  if arg == "-"
24
+ $fn = "(stdin)" if remember_fn
24
25
  STDIN.read
25
26
  else
26
27
  usage unless arg
28
+ $fn = arg if remember_fn
27
29
  File.read(arg, mode: "rb")
28
30
  end
29
31
  end
30
32
 
31
33
  def parser
32
- @parser ||= CDDL::Parser.new(read_arg(ARGV[0]))
34
+ @parser ||= CDDL::Parser.new(read_arg(ARGV[0], false))
33
35
  end
34
36
 
35
37
  def my_pp(v)
data/cddl.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'cddl'
3
- s.version = '0.8.20'
3
+ s.version = '0.8.29'
4
4
  s.summary = "CDDL generator and validator."
5
5
  s.description = %{A parser, generator, and validator for CDDL}
6
6
  s.add_dependency('cbor-diag')
data/lib/cbor-pp-play.rb CHANGED
@@ -2,6 +2,7 @@ require_relative "cbor-pp"
2
2
 
3
3
  a = [1, {foo: "bar", busel: "basel", baz: "bass", ant: "cat", bat: "dog", eel: "fox"},
4
4
  2, 3, 4, [3]*55, "foo".b, 0.00006103515625, 0.0000099, 1e-7, nil]
5
+ a[0].cbor_annotation_add "flurp"
5
6
  a[1].cbor_annotation_add "fasel"
6
7
  CBOR::PP.pp a
7
8
 
data/lib/cddl.rb CHANGED
@@ -56,6 +56,8 @@ module CDDL
56
56
  @ast = @abnf.ast?
57
57
  # our little argument stack for rule processing
58
58
  @insides = []
59
+ # collect error information
60
+ @last_message = ""
59
61
  end
60
62
 
61
63
  def apr # for debugging
@@ -458,10 +460,13 @@ module CDDL
458
460
  generate1(target, inmap)
459
461
  when :feature
460
462
  generate1(target, inmap)
461
- when :cat, :bat
463
+ when :cat, :det
462
464
  lhs = generate1(target, inmap)
463
465
  rhs = generate1(control)
464
- rhs = remove_indentation(rhs) if conop == :bat
466
+ if conop == :det
467
+ lhs = remove_indentation(lhs)
468
+ rhs = remove_indentation(rhs)
469
+ end
465
470
  begin
466
471
  lhs + rhs
467
472
  rescue Exception => e
@@ -529,6 +534,7 @@ module CDDL
529
534
  unless !bytes.nil? && String === grammar
530
535
  fail "Don't know yet how to generate #{where}"
531
536
  end
537
+ grammar << "\n" unless grammar =~ /\n\z/
532
538
  out = ABNF_PARSER_FOR_STRING[grammar].generate
533
539
  if conop == :abnfb
534
540
  out = out.codepoints.pack("C*")
@@ -599,7 +605,7 @@ module CDDL
599
605
  elsif t[0] == :anno
600
606
  _, conop, target, control = t
601
607
  # warn ["EXV0", conop, target, control].inspect
602
- if conop == :cat || conop == :plus || conop == :bat
608
+ if conop == :cat || conop == :plus || conop == :det
603
609
  ok1, v1, vt1 = extract_value(target)
604
610
  ok2, v2, vt2 = extract_value(control)
605
611
  # warn ["EXV", ok1, v1, vt1, ok2, v2, vt2].inspect
@@ -609,7 +615,10 @@ module CDDL
609
615
  elsif vt1 == Float
610
616
  [true, v1 + v2, vt1] if vt2 == Integer || vt2 == Float
611
617
  else
612
- v2 = remove_indentation(v2) if conop == :bat
618
+ if conop == :det
619
+ v1 = remove_indentation(v1)
620
+ v2 = remove_indentation(v2)
621
+ end
613
622
  [true, v1 + v2, vt1] if vt1 == vt2
614
623
  end
615
624
  end rescue nil
@@ -641,7 +650,7 @@ module CDDL
641
650
  ok = ENV["CDDL_FEATURE_OK"] and ok = ok.split(/,\s*/) or ok = []
642
651
  # warn([:OK, ok, $features].inspect)
643
652
  features = $features.reject {|k, v| ok.include? k.to_s }
644
- warn "** Features potentially used: #{features.map {|k, v| "#{k}: #{v.keys}"}.join(", ")}" if features != {}
653
+ warn "** Features potentially used (#$fn): #{features.map {|k, v| "#{k}: #{v.keys}"}.join(", ")}" if features != {}
645
654
  end
646
655
  else
647
656
  warn "CDDL validation failure (#{result.inspect} for #{d.inspect}):"
@@ -778,13 +787,17 @@ module CDDL
778
787
  puts "COMPLEX: #{k.inspect} #{simple.inspect} #{simpleval.inspect}" if ENV["CDDL_TRACE"]
779
788
  keys = d_check.keys
780
789
  ta, keys = keys.partition{ |key| validate1(key, k)}
781
- # XXX check ta.size against s/e
782
- ta.all? { |val|
783
- if (ann2 = validate1a(d[val], v)) &&
784
- d_check.delete(val) {:not_found} != :not_found
785
- anno.concat(ann2)
786
- end
787
- }
790
+ count = 0
791
+ catch :enough do
792
+ ta.all? { |val|
793
+ if (ann2 = validate1a(d[val], v)) && # XXX check cut or not!
794
+ d_check.delete(val) {:not_found} != :not_found
795
+ anno.concat(ann2)
796
+ throw :enough, true if (count += 1) == e
797
+ true
798
+ end
799
+ }
800
+ end and validate_result(count >= s) { "not enough #{ta.inspect} for #{r.inspect}" }
788
801
  end
789
802
  end
790
803
  else
@@ -848,13 +861,16 @@ module CDDL
848
861
  [] if where[2] === d && where[1].include?(d)
849
862
  when :anno
850
863
  _, conop, target, control = where
851
- if conop == :cat || conop == :plus
864
+ if conop == :cat || conop == :plus || conop == :det
852
865
  ok1, v1, vt1 = extract_value(target)
853
866
  ok2, v2, vt2 = extract_value(control)
854
867
  # warn ["ANNO0", ok1, v1, vt1, ok2, v2, vt2, d].inspect
855
868
  if ok1 && ok2
856
869
  v2 = Integer(v2) if vt1 == Integer
857
- v2 = remove_indentation(v2) if conop == :bat
870
+ if conop == :det
871
+ v1 = remove_indentation(v1)
872
+ v2 = remove_indentation(v2)
873
+ end
858
874
  # warn ["ANNO", ok1, v1, vt1, ok2, v2, vt2, d].inspect
859
875
  [] if d == v1 + v2 # XXX Focus ArgumentError
860
876
  end
@@ -903,11 +919,13 @@ module CDDL
903
919
  if ok
904
920
  nm = v
905
921
  det = d
922
+ warn "*** feature controller should be a string: #{control.inspect}" unless String == vt
906
923
  else
907
924
  ok, *v = extract_array(control)
908
925
  if ok && v.size == 2
909
926
  nm = v[0][0]
910
927
  det = v[1][0]
928
+ warn "*** first element of feature controller should be a string: #{control.inspect}" unless String === nm
911
929
  else
912
930
  warn "*** feature controller not implemented: #{control.inspect}"
913
931
  end
@@ -1224,9 +1242,13 @@ module CDDL
1224
1242
  def g_process(name, g, genericargs)
1225
1243
  r, ids = g
1226
1244
  args = genericargs.children(:type1).map {|x| type1(x, true)}
1245
+ # warn "** args #{args.inspect}"
1227
1246
  fail "number of args #{name} #{ids.size} #{args.size}" if ids.size != args.size
1228
1247
  bindings = Hash[ids.zip(args)]
1229
- r_process("#{name}<#{genericargs._strip}>", r, bindings)
1248
+ # warn "** bindings: #{bindings.inspect}"
1249
+ genname = "#{name}<#{args.inspect}>" # XXX this works up to a RECURSE...
1250
+ # warn "** genname #{genname}"
1251
+ r_process(genname, r, bindings)
1230
1252
  end
1231
1253
 
1232
1254
  def type_recall(name, canbegroup, genericargs)
@@ -1304,7 +1326,7 @@ module CDDL
1304
1326
  RANGE_EXCLUDE_END = {".." => false, "..." => true}
1305
1327
  SUPPORTED_ANNOTATIONS = [:bits, :size, :regexp, :cbor, :cborseq, :within, :and,
1306
1328
  :default, :lt, :le, :gt, :ge, :eq, :ne,
1307
- :feature, :abnf, :abnfb, :bat, :cat, :plus]
1329
+ :feature, :abnf, :abnfb, :det, :cat, :plus]
1308
1330
 
1309
1331
  def type1(n, canbegroup = false)
1310
1332
  # puts "NVALUE #{n.value.inspect}"
@@ -0,0 +1,16 @@
1
+ start = [v1, v2, v3, v4]
2
+
3
+ v1 = "a" .bat "b"
4
+
5
+ v2 = "a" .bat " b"
6
+
7
+ v3 = "a" .bat '
8
+ oid = 1*arc
9
+ roid = *arc
10
+ arc = [nlsb] %x00-7f
11
+ nlsb = %x81-ff *%x80-ff
12
+ '
13
+
14
+ bbat<v1, v2> = ("" .bat v1) .bat v2
15
+
16
+ v4 = bbat<" a", " b">
@@ -0,0 +1,11 @@
1
+ foo = {
2
+ 2*4 any => any
3
+ }
4
+
5
+ ;;sed -n 's/^; //p' complex-occ.cddl | sh
6
+ ; echo '{}' | cddl complex-occ.cddl v -
7
+ ; echo '{"1": 2}' | cddl complex-occ.cddl v -
8
+ ; echo '{"1": 2, "2": 3}' | cddl complex-occ.cddl v -
9
+ ; echo '{"1": 2, "2": 3, "3": 4}' | cddl complex-occ.cddl v -
10
+ ; echo '{"1": 2, "2": 3, "3": 4, "4": 5}' | cddl complex-occ.cddl v -
11
+ ; echo '{"1": 2, "2": 3, "3": 4, "4": 5, "5": 6}' | cddl complex-occ.cddl v -
@@ -0,0 +1,12 @@
1
+ bar = ["" .cat foo, "" .cat cbor-tags-oid]
2
+
3
+ foo = '' .det cbor-tags-oid
4
+
5
+ cbor-tags-oid = '
6
+ oid = 1*arc
7
+ roid = *arc
8
+ arc = [nlsb] %x00-7f
9
+ nlsb = %x81-ff *%x80-ff
10
+ ' .det ''
11
+
12
+ cbor-tags-oid-decrypted = cbor-tags-oid .det (([]) .det ([]))
@@ -0,0 +1,6 @@
1
+ a = b .feature 3
2
+ b = c .feature 3.3
3
+ c = d .feature (["drei", "ok"])
4
+ d = e .feature ([[], "ok"])
5
+ e = f .feature ([1, "ok"])
6
+ f = int .feature (1)
@@ -0,0 +1,12 @@
1
+ hna-configuration = {
2
+ "registred_domain" : tstr,
3
+ "dm" : tstr,
4
+ ? "dm_transport" : "53" // "DoT" // "DoH" // "DoQ"
5
+ ? "dm_port" : uint,
6
+ ? "dm_acl" : hna-acl // [ +hna-acl ]
7
+ ? "hna_auth_method": hna-auth-method
8
+ ? "hna_certificate": tstr
9
+ }
10
+
11
+ hna-acl = tstr
12
+ hna-auth-method /= "certificate"
@@ -0,0 +1,12 @@
1
+ hna-configuration = {
2
+ "registered_domain" : tstr,
3
+ "dm" : tstr,
4
+ ? "dm_transport" : "53" / "DoT" / "DoH" / "DoQ"
5
+ ? "dm_port" : uint,
6
+ ? "dm_acl" : hna-acl / [ +hna-acl ]
7
+ ? "hna_auth_method": hna-auth-method
8
+ ? "hna_certificate": tstr
9
+ }
10
+
11
+ hna-acl = tstr
12
+ hna-auth-method /= "certificate"
@@ -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,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" .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,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,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]+)*"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.20
4
+ version: 0.8.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-27 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cbor-diag
@@ -121,11 +121,13 @@ files:
121
121
  - test-data/b.cddl
122
122
  - test-data/badaddr.cddl
123
123
  - test-data/basic_syntax_example.cddl
124
+ - test-data/bat.cddl
124
125
  - test-data/bpv7.cddl
125
126
  - test-data/bpv7a.cddl
126
127
  - test-data/bpv7b.cddl
127
128
  - test-data/cat-re.cddl
128
129
  - test-data/cdni-ct.cddl
130
+ - test-data/complex-occ.cddl
129
131
  - test-data/coral.cddl
130
132
  - test-data/coral1.cddl
131
133
  - test-data/coral2.cddl
@@ -133,9 +135,11 @@ files:
133
135
  - test-data/cose.cddl
134
136
  - test-data/dcaf.cddl
135
137
  - test-data/dcaf1.cddl
138
+ - test-data/det1.cddl
136
139
  - test-data/dotsize.cddl
137
140
  - test-data/extractor-demo.cddl
138
141
  - test-data/feat1.cddl
142
+ - test-data/feature-controller.cddl
139
143
  - test-data/feature-detail.cddl
140
144
  - test-data/foo.cddl
141
145
  - test-data/grasp-01-extract.cddl
@@ -144,6 +148,8 @@ files:
144
148
  - test-data/grasp-09.cddl
145
149
  - test-data/grasp-v1.cddl
146
150
  - test-data/grasp-v2X.cddl
151
+ - test-data/homenet-de.cddl
152
+ - test-data/homenet-fe.cddl
147
153
  - test-data/ifmap-base-2.0v17.cddl
148
154
  - test-data/ifmap-base-2.2v9_fh-cabo.cddl
149
155
  - test-data/ifmap-metadata-2.2v9_fh-cabo.cddl
@@ -153,6 +159,7 @@ files:
153
159
  - test-data/jim-cut.cddl
154
160
  - test-data/jsoniodef.cddl
155
161
  - test-data/kevin5.cddl
162
+ - test-data/lint1.cddl
156
163
  - test-data/map-group.cddl
157
164
  - test-data/mapkey.cddl
158
165
  - test-data/mdl-ble.cddl
@@ -166,13 +173,20 @@ files:
166
173
  - test-data/mon-val.cddl
167
174
  - test-data/multipart-ct.cddl
168
175
  - test-data/named-group.cddl
176
+ - test-data/non-empty.cddl
169
177
  - test-data/oid.cddl
178
+ - test-data/oidbat.cddl
170
179
  - test-data/patch1.cddl
180
+ - test-data/plus.cddl
171
181
  - test-data/reused_named_group.cddl
172
182
  - test-data/sasl.cddl
173
183
  - test-data/sequence.cddl
184
+ - test-data/sipos.cddl
185
+ - test-data/star-edited.cddl
186
+ - test-data/star.cddl
174
187
  - test-data/structure.cddl
175
188
  - test-data/test-gen.cddl
189
+ - test-data/time.cddl
176
190
  - test-data/toerless0.cddl
177
191
  - test-data/toerless1.cddl
178
192
  - test-data/two_anonymous_groups.cddl
@@ -181,6 +195,8 @@ files:
181
195
  - test-data/wrong2.cddl
182
196
  - test-data/wrong2a.cddl
183
197
  - test-data/xmlmig.cddl
198
+ - test-data/yangid.cddl
199
+ - test-data/yaron1.cddl
184
200
  - test/test-cddl.rb
185
201
  homepage: http://github.com/cabo/cddl
186
202
  licenses:
@@ -201,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
217
  - !ruby/object:Gem::Version
202
218
  version: '0'
203
219
  requirements: []
204
- rubygems_version: 3.2.3
220
+ rubygems_version: 3.3.11
205
221
  signing_key:
206
222
  specification_version: 4
207
223
  summary: CDDL generator and validator.