cddl 0.8.9 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cddl.gemspec +1 -1
- data/data/cddl.abnf +1 -0
- data/lib/cddl.rb +125 -14
- data/test-data/7807.cddl +14 -0
- data/test-data/abignum.cddl +1 -0
- data/test-data/coral.cddl +10 -0
- data/test-data/coral1.cddl +5 -0
- data/test-data/coral2.cddl +7 -0
- data/test-data/coral3.cddl +7 -0
- data/test-data/feat1.cddl +4 -0
- data/test-data/feature-detail.cddl +5 -0
- data/test-data/jim-cut-2.cddl +11 -0
- data/test-data/jim-cut.cddl +12 -0
- data/test-data/mdl-ble.cddl +9 -0
- data/test-data/mdl-deve.cddl +54 -0
- data/test-data/mdl-dp.cddl +11 -0
- data/test-data/mdl-mso.cddl +20 -0
- data/test-data/mdl-request.cddl +26 -0
- data/test-data/mdl-response.cddl +66 -0
- data/test-data/mdl.cddl +11 -0
- data/test-data/mon-val.cddl +1 -0
- data/test-data/multipart-ct.cddl +2 -0
- data/test-data/test-gen.cddl +3 -0
- data/test/test-cddl.rb +51 -0
- metadata +26 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 182b4b76590226a9f1f72dd534266693e566b2dea3188e5f0c073c69474c1f07
|
4
|
+
data.tar.gz: 49170c49b5f8153a0fd589d31ffd7d4b10f7b394828a816c8a240e8880487754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b1cced35bb95e5eaded068c3f66f25498ff8f03c0de30a992132aa7d254fb6ce4fc8571dc7d4d7cc32799acc97da8cbe6b43b9c90b8254ad0bf54a645763667
|
7
|
+
data.tar.gz: f8a7c15619656ae72b792f9fcac5c408a9180a81f51c825e148b086c21a7ba1fa85ef69f4c329bb0cad019198458c33ebe2e0cfa3a030bd11b46eea324e6645d
|
data/cddl.gemspec
CHANGED
data/data/cddl.abnf
CHANGED
@@ -16,6 +16,7 @@ type1 = type2 [S (rangeop / annotator) S type2]
|
|
16
16
|
/ "#" "6" ["." uint] "(" S type S ")" ; note no space!
|
17
17
|
/ "#" DIGIT ["." uint] ; major/ai
|
18
18
|
/ "#" ; any
|
19
|
+
/ "~" S typename [genericarg]
|
19
20
|
/ "{" S group S "}"
|
20
21
|
/ "[" S group S "]"
|
21
22
|
/ "&" S "(" S group S ")"
|
data/lib/cddl.rb
CHANGED
@@ -439,6 +439,31 @@ module CDDL
|
|
439
439
|
$default_warned = true
|
440
440
|
end
|
441
441
|
generate1(target, inmap)
|
442
|
+
when :feature
|
443
|
+
generate1(target, inmap)
|
444
|
+
when :cat
|
445
|
+
lhs = generate1(target, inmap)
|
446
|
+
rhs = generate1(control)
|
447
|
+
begin
|
448
|
+
lhs + rhs
|
449
|
+
rescue Exception => e
|
450
|
+
fail "Can't #{lhs.inspect} .cat #{rhs.inspect}: #{e.message}"
|
451
|
+
end
|
452
|
+
when :plus
|
453
|
+
lhs = generate1(target, inmap)
|
454
|
+
rhs = generate1(control)
|
455
|
+
begin
|
456
|
+
case lhs
|
457
|
+
when Integer
|
458
|
+
lhs + Integer(rhs)
|
459
|
+
when Numeric
|
460
|
+
lhs + rhs
|
461
|
+
else
|
462
|
+
fail "#{lhs.inspect}: Not a number"
|
463
|
+
end
|
464
|
+
rescue Exception => e
|
465
|
+
fail "Can't #{lhs.inspect} .plus #{rhs.inspect}: #{e.message}"
|
466
|
+
end
|
442
467
|
when :eq
|
443
468
|
content = generate1(control)
|
444
469
|
if validate1(content, where)
|
@@ -527,7 +552,7 @@ module CDDL
|
|
527
552
|
end
|
528
553
|
end
|
529
554
|
|
530
|
-
VALUE_TYPE = {text: String, int: Integer, float: Float}
|
555
|
+
VALUE_TYPE = {text: String, bytes: String, int: Integer, float: Float}
|
531
556
|
SIMPLE_VALUE = {
|
532
557
|
[:prim, 7, 20] => [true, false, :bool],
|
533
558
|
[:prim, 7, 21] => [true, true, :bool],
|
@@ -540,9 +565,34 @@ module CDDL
|
|
540
565
|
[true, t[1], vt]
|
541
566
|
elsif v = SIMPLE_VALUE[t]
|
542
567
|
v
|
543
|
-
|
544
|
-
|
545
|
-
|
568
|
+
elsif t[0] == :anno
|
569
|
+
_, conop, target, control = t
|
570
|
+
# warn ["EXV0", conop, target, control].inspect
|
571
|
+
if conop == :cat || conop == :plus
|
572
|
+
ok1, v1, vt1 = extract_value(target)
|
573
|
+
ok2, v2, vt2 = extract_value(control)
|
574
|
+
# warn ["EXV", ok1, v1, vt1, ok2, v2, vt2].inspect
|
575
|
+
if ok1 && ok2
|
576
|
+
if vt1 == Integer
|
577
|
+
[true, v1 + Integer(v2), Integer] if vt2 == Integer || vt2 == Float
|
578
|
+
elsif vt1 == Float
|
579
|
+
[true, v1 + v2, vt1] if vt2 == Integer || vt2 == Float
|
580
|
+
else
|
581
|
+
[true, v1 + v2, vt1] if vt1 == vt2
|
582
|
+
end
|
583
|
+
end rescue nil
|
584
|
+
end
|
585
|
+
end || [false]
|
586
|
+
end
|
587
|
+
|
588
|
+
def extract_array(t)
|
589
|
+
return [false] unless t[0] == :array
|
590
|
+
[true, *t[1..-1].map { |el|
|
591
|
+
return [false] unless el[0..3] == [:member, 1, 1, nil]
|
592
|
+
ok, v, vt = extract_value(el[4])
|
593
|
+
return [false] unless ok
|
594
|
+
[v, vt]
|
595
|
+
}]
|
546
596
|
end
|
547
597
|
|
548
598
|
def validate_diag
|
@@ -551,11 +601,17 @@ module CDDL
|
|
551
601
|
|
552
602
|
def validate(d, warn=true)
|
553
603
|
@recursion = 0
|
604
|
+
$features = Hash.new {|h, k| h[k] = {}}
|
554
605
|
result = validate1a(d, rules)
|
555
|
-
|
556
|
-
if
|
606
|
+
if warn
|
607
|
+
if result
|
608
|
+
if $features != {}
|
609
|
+
warn "** Features potentially used: #{$features.map {|k, v| "#{k}: #{v.keys}"}.join(", ")}"
|
610
|
+
end
|
611
|
+
else
|
557
612
|
warn "CDDL validation failure (#{result.inspect} for #{d.inspect}):"
|
558
613
|
PP::pp(validate_diag, STDERR)
|
614
|
+
puts(validate_diag.cbor_diagnostic)
|
559
615
|
end
|
560
616
|
end
|
561
617
|
result
|
@@ -745,16 +801,27 @@ module CDDL
|
|
745
801
|
idx, ann = validate_forward(d, 0, where)
|
746
802
|
ann if validate_result(idx == d.size) { "#{validate_diag.inspect} -- cannot complete (#{idx}, #{d.size}) array #{d} for #{where}" }
|
747
803
|
end
|
748
|
-
when :
|
804
|
+
when :int, :float
|
749
805
|
_, v = extract_value(where)
|
750
806
|
[] if d == v
|
807
|
+
when :text, :bytes
|
808
|
+
_, v = extract_value(where)
|
809
|
+
[] if d == v && ((d.encoding == Encoding::BINARY) == (v.encoding == Encoding::BINARY))
|
751
810
|
when :range
|
752
811
|
[] if where[2] === d && where[1].include?(d)
|
753
812
|
when :anno
|
754
|
-
target = where
|
755
|
-
if
|
756
|
-
|
757
|
-
|
813
|
+
_, conop, target, control = where
|
814
|
+
if conop == :cat || conop == :plus
|
815
|
+
ok1, v1, vt1 = extract_value(target)
|
816
|
+
ok2, v2, vt2 = extract_value(control)
|
817
|
+
# warn ["ANNO0", ok1, v1, vt1, ok2, v2, vt2, d].inspect
|
818
|
+
if ok1 && ok2
|
819
|
+
v2 = Integer(v2) if vt1 == Integer
|
820
|
+
# warn ["ANNO", ok1, v1, vt1, ok2, v2, vt2, d].inspect
|
821
|
+
[] if d == v1 + v2 # XXX Focus ArgumentError
|
822
|
+
end
|
823
|
+
elsif ann = validate1a(d, target)
|
824
|
+
case conop
|
758
825
|
when :size
|
759
826
|
case d
|
760
827
|
when Integer
|
@@ -793,8 +860,24 @@ module CDDL
|
|
793
860
|
$default_warned = true
|
794
861
|
end
|
795
862
|
ann
|
863
|
+
when :feature
|
864
|
+
ok, v, vt = extract_value(control)
|
865
|
+
if ok
|
866
|
+
nm = v
|
867
|
+
det = d
|
868
|
+
else
|
869
|
+
ok, *v = extract_array(control)
|
870
|
+
if ok && v.size == 2
|
871
|
+
nm = v[0][0]
|
872
|
+
det = v[1][0]
|
873
|
+
else
|
874
|
+
warn "*** feature controller not implemented: #{control.inspect}"
|
875
|
+
end
|
876
|
+
end
|
877
|
+
$features[nm][det] = true
|
878
|
+
ann
|
796
879
|
when :lt, :le, :gt, :ge, :eq, :ne
|
797
|
-
op = OPERATORS[
|
880
|
+
op = OPERATORS[conop]
|
798
881
|
ok, v, _vt = extract_value(control)
|
799
882
|
if ok
|
800
883
|
ann if d.send(op, v) rescue nil # XXX Focus ArgumentError
|
@@ -841,6 +924,14 @@ module CDDL
|
|
841
924
|
when 3
|
842
925
|
String === d && d.encoding != Encoding::BINARY # cheat
|
843
926
|
when 6
|
927
|
+
if Integer === d
|
928
|
+
t = 2 # assuming only 2/3 match an Integer
|
929
|
+
if d < 0
|
930
|
+
d = ~d
|
931
|
+
t = 3
|
932
|
+
end
|
933
|
+
d = CBOR::Tagged.new(t, d == 0 ? "".b : d.digits(256).reverse!.pack("C*"))
|
934
|
+
end
|
844
935
|
CBOR::Tagged === d && d.tag == where[2] && validate1a(d.data, where[3])
|
845
936
|
when 7
|
846
937
|
t, v = extract_value(where)
|
@@ -963,7 +1054,7 @@ module CDDL
|
|
963
1054
|
when ""
|
964
1055
|
parts[1].b
|
965
1056
|
when "h"
|
966
|
-
parts[1].gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join
|
1057
|
+
parts[1].gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join.b
|
967
1058
|
when "b64"
|
968
1059
|
Base64.urlsafe_decode64(parts[1])
|
969
1060
|
else
|
@@ -1156,7 +1247,7 @@ module CDDL
|
|
1156
1247
|
BRACE = {"{" => :map, "[" => :array}
|
1157
1248
|
RANGE_EXCLUDE_END = {".." => false, "..." => true}
|
1158
1249
|
SUPPORTED_ANNOTATIONS = [:bits, :size, :regexp, :cbor, :cborseq, :within, :and,
|
1159
|
-
:default, :lt, :le, :gt, :ge, :eq, :ne]
|
1250
|
+
:default, :lt, :le, :gt, :ge, :eq, :ne, :feature, :cat, :plus]
|
1160
1251
|
|
1161
1252
|
def type1(n, canbegroup = false)
|
1162
1253
|
# puts "NVALUE #{n.value.inspect}"
|
@@ -1218,6 +1309,26 @@ module CDDL
|
|
1218
1309
|
v
|
1219
1310
|
}
|
1220
1311
|
]
|
1312
|
+
when /\A~/
|
1313
|
+
if tn = n.typename
|
1314
|
+
s = type_recall(tn.to_s, false, n.genericarg).flatten(1)
|
1315
|
+
else
|
1316
|
+
fail "No typename in unwrap #{n}"
|
1317
|
+
end
|
1318
|
+
if s[0] != :type1
|
1319
|
+
fail [:UNWRAPs0, s].inspect
|
1320
|
+
end
|
1321
|
+
case s[1]
|
1322
|
+
when :map, :array
|
1323
|
+
[:grpent, s[2..-1]]
|
1324
|
+
when :prim
|
1325
|
+
if s[2] != 6
|
1326
|
+
fail [:UNWRAPs2, s].inspect
|
1327
|
+
end
|
1328
|
+
s[4] # check :type1?
|
1329
|
+
else
|
1330
|
+
fail [:UNWRAPs1, s].inspect
|
1331
|
+
end
|
1221
1332
|
else
|
1222
1333
|
"unimplemented #{n}"
|
1223
1334
|
end
|
data/test-data/7807.cddl
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
coap-problem-details = {
|
2
|
+
type => uint,
|
3
|
+
? title => text,
|
4
|
+
? response-code => bstr .size 1,
|
5
|
+
? detail => text,
|
6
|
+
? instance => uri,
|
7
|
+
* $$coap-problem-details-extension,
|
8
|
+
}
|
9
|
+
|
10
|
+
type = 0
|
11
|
+
title = 1
|
12
|
+
response-code = 2
|
13
|
+
detail = 3
|
14
|
+
instance = 4
|
@@ -0,0 +1 @@
|
|
1
|
+
abignum = unsigned
|
@@ -0,0 +1,10 @@
|
|
1
|
+
coral = [+ s-exp]
|
2
|
+
s-exp = ((text, value, ?coral) // directive)
|
3
|
+
value = ctext / cbytes / cint / cfloat / cboolean / cdatetime / null / {"_link": tstr} / {"_form": tstr}
|
4
|
+
ctext = text / {"_text": text}
|
5
|
+
cint = {"_int": int}
|
6
|
+
cfloat = float / {"_float": float}
|
7
|
+
cboolean = bool / {"_bool": bool}
|
8
|
+
cdatetime = {"_datetime": text}
|
9
|
+
cbytes = {"_bytes": text} ; base64url no padding
|
10
|
+
directive = (("_using", {* text => text}) // ("_base", text))
|
@@ -0,0 +1,7 @@
|
|
1
|
+
document = {*element}
|
2
|
+
element = (text => value / [2*value])
|
3
|
+
value = text / float / bool / tagged
|
4
|
+
tagged = {"_int":int,*element} / {"_float":float,*element} / {"_text":text,*element} / {"_bytes":bytes,*element} / {"_datetime":text,*element} / {"_bool":bool,*element} / {"_link":ciri,*element} / {"_form":ciri,*element}
|
5
|
+
ciri = text ; full IRI given
|
6
|
+
/ [text] ; suffix for default prefix
|
7
|
+
/ [text, text] ; prefix, suffix for that prefix
|
@@ -0,0 +1,7 @@
|
|
1
|
+
document = {? ("_using" => {* text => text}), *element}
|
2
|
+
element = (text => value / [2*value])
|
3
|
+
value = text / float / bool / tagged / {*element}
|
4
|
+
tagged = {"_int": int, *element} / {"_float": float, *element} / {"_text": text, *element} / {"_bytes": bytes, *element} / {"_datetime": text, *element} / {"_bool": bool, *element} / {"_link": ciri, *element} / {"_form": ciri, *element}
|
5
|
+
ciri = text ; full IRI given
|
6
|
+
/ [text] ; suffix for default prefix
|
7
|
+
/ [text, text] ; prefix, suffix for that prefix
|
@@ -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,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"
|
data/test-data/mdl.cddl
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
decimal-monetary-value = text .regexp "-?[0-9]+(\\.[0-9]+)?"
|
data/test/test-cddl.rb
CHANGED
@@ -171,6 +171,57 @@ HERE
|
|
171
171
|
assert parser.validate_for_test(true)
|
172
172
|
end
|
173
173
|
|
174
|
+
def test_validate_bignum
|
175
|
+
parser = CDDL::Parser.new <<HERE
|
176
|
+
test = bigint
|
177
|
+
HERE
|
178
|
+
assert parser.validate_for_test(2**4711)
|
179
|
+
assert parser.validate_for_test(-2**815)
|
180
|
+
assert parser.validate_for_test(1)
|
181
|
+
assert parser.validate_for_test(0)
|
182
|
+
assert parser.validate_for_test(-11)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_aaaaaaaa_invalidate_bignum
|
186
|
+
parser = CDDL::Parser.new <<HERE
|
187
|
+
test = bignint
|
188
|
+
HERE
|
189
|
+
refute parser.validate_for_test(2**4711, false)
|
190
|
+
assert parser.validate_for_test(-2**815)
|
191
|
+
refute parser.validate_for_test(1, false)
|
192
|
+
refute parser.validate_for_test(0, false)
|
193
|
+
assert parser.validate_for_test(-11)
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
def test_aaaaaaaa_validate_bignum0b
|
198
|
+
parser = CDDL::Parser.new <<HERE
|
199
|
+
test = #6.2("")
|
200
|
+
HERE
|
201
|
+
refute parser.validate_for_test(1, false)
|
202
|
+
refute parser.validate_for_test(0, false)
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
def test_aaaaaaaa_validate_bignum0
|
207
|
+
parser = CDDL::Parser.new <<HERE
|
208
|
+
test = #6.2(h'')
|
209
|
+
HERE
|
210
|
+
assert parser.validate_for_test(0)
|
211
|
+
refute parser.validate_for_test(1, false)
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
def test_aaaaaaaa_validate_bignum1
|
216
|
+
parser = CDDL::Parser.new <<HERE
|
217
|
+
test = #6.2(h'01')
|
218
|
+
HERE
|
219
|
+
assert parser.validate_for_test(1)
|
220
|
+
refute parser.validate_for_test(0, false)
|
221
|
+
refute parser.validate_for_test(2, false)
|
222
|
+
end
|
223
|
+
|
224
|
+
|
174
225
|
def test_validate_a
|
175
226
|
parser = CDDL::Parser.new <<HERE
|
176
227
|
test = [* one: 1]
|
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.
|
4
|
+
version: 0.8.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cbor-diag
|
@@ -97,7 +97,9 @@ files:
|
|
97
97
|
- test-data/7071-concise-cut.cddl
|
98
98
|
- test-data/7071-concise.cddl
|
99
99
|
- test-data/7071-verbose.cddl
|
100
|
+
- test-data/7807.cddl
|
100
101
|
- test-data/a.cddl
|
102
|
+
- test-data/abignum.cddl
|
101
103
|
- test-data/ambig.cddl
|
102
104
|
- test-data/b.cddl
|
103
105
|
- test-data/badaddr.cddl
|
@@ -106,11 +108,17 @@ files:
|
|
106
108
|
- test-data/bpv7a.cddl
|
107
109
|
- test-data/bpv7b.cddl
|
108
110
|
- test-data/cdni-ct.cddl
|
111
|
+
- test-data/coral.cddl
|
112
|
+
- test-data/coral1.cddl
|
113
|
+
- test-data/coral2.cddl
|
114
|
+
- test-data/coral3.cddl
|
109
115
|
- test-data/cose.cddl
|
110
116
|
- test-data/dcaf.cddl
|
111
117
|
- test-data/dcaf1.cddl
|
112
118
|
- test-data/dotsize.cddl
|
113
119
|
- test-data/extractor-demo.cddl
|
120
|
+
- test-data/feat1.cddl
|
121
|
+
- test-data/feature-detail.cddl
|
114
122
|
- test-data/foo.cddl
|
115
123
|
- test-data/grasp-01-extract.cddl
|
116
124
|
- test-data/grasp-01-test.cddl
|
@@ -123,15 +131,27 @@ files:
|
|
123
131
|
- test-data/ifmap-metadata-2.2v9_fh-cabo.cddl
|
124
132
|
- test-data/ifmap2.cddl
|
125
133
|
- test-data/jcr-ex.cddl
|
134
|
+
- test-data/jim-cut-2.cddl
|
135
|
+
- test-data/jim-cut.cddl
|
126
136
|
- test-data/jsoniodef.cddl
|
127
137
|
- test-data/kevin5.cddl
|
128
138
|
- test-data/map-group.cddl
|
129
139
|
- test-data/mapkey.cddl
|
140
|
+
- test-data/mdl-ble.cddl
|
141
|
+
- test-data/mdl-deve.cddl
|
142
|
+
- test-data/mdl-dp.cddl
|
143
|
+
- test-data/mdl-mso.cddl
|
144
|
+
- test-data/mdl-request.cddl
|
145
|
+
- test-data/mdl-response.cddl
|
146
|
+
- test-data/mdl.cddl
|
130
147
|
- test-data/minimal.cddl
|
148
|
+
- test-data/mon-val.cddl
|
149
|
+
- test-data/multipart-ct.cddl
|
131
150
|
- test-data/named-group.cddl
|
132
151
|
- test-data/patch1.cddl
|
133
152
|
- test-data/reused_named_group.cddl
|
134
153
|
- test-data/structure.cddl
|
154
|
+
- test-data/test-gen.cddl
|
135
155
|
- test-data/toerless0.cddl
|
136
156
|
- test-data/toerless1.cddl
|
137
157
|
- test-data/two_anonymous_groups.cddl
|
@@ -145,7 +165,7 @@ homepage: http://github.com/cabo/cddl
|
|
145
165
|
licenses:
|
146
166
|
- MIT
|
147
167
|
metadata: {}
|
148
|
-
post_install_message:
|
168
|
+
post_install_message:
|
149
169
|
rdoc_options: []
|
150
170
|
require_paths:
|
151
171
|
- lib
|
@@ -160,8 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
180
|
- !ruby/object:Gem::Version
|
161
181
|
version: '0'
|
162
182
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
-
signing_key:
|
183
|
+
rubygems_version: 3.1.2
|
184
|
+
signing_key:
|
165
185
|
specification_version: 4
|
166
186
|
summary: CDDL generator and validator.
|
167
187
|
test_files: []
|