From: Sergey Matveev Date: Sat, 28 Jun 2025 09:16:37 +0000 (+0300) Subject: Explicitly check type of the root element X-Git-Tag: v0.0.0~9 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=82f782e41af574072af8b4088cdef138e770b48571db75b9f34b9699722a070f;p=keks.git Explicitly check type of the root element --- diff --git a/spec/schema/cmds b/spec/schema/cmds index f5f6574..0285094 100644 --- a/spec/schema/cmds +++ b/spec/schema/cmds @@ -86,6 +86,7 @@ For example let's check "our" structure, described in CDDL as: Corresponding schema can be: {"our": [ + ["T", "M"], [".", "a"], ["E"], ["T", "S"], diff --git a/spec/schema/tcl b/spec/schema/tcl index 1eb0c2e..885d1ec 100644 --- a/spec/schema/tcl +++ b/spec/schema/tcl @@ -8,6 +8,7 @@ Example with "our" structure (from [schema/cmds]) can be written as: ai {{field . {str} >0}} fpr {{field . {bin} len=32}} our { + {field . {map}} {field a {with ai}} {field v {bin str}} {field fpr {with fpr}} @@ -37,7 +38,7 @@ an encoded map with "cmds*" commands for "s*" schemas. "field" command helps creation of commands related to the field. - {field N {T} [optional] [!exists] [{of type T}] [{of S}] + {field N {T ...} [optional] [!exists] [{of type T}] [{of S}] [>n] [0} {field id {hexlet} optional} @@ -14,6 +15,7 @@ dem { } kem { + {field . {map}} {field a {str} >0} {field cek {bin} >0} } diff --git a/tcl/schemas/kem-balloon-blake2b-hkdf.tcl b/tcl/schemas/kem-balloon-blake2b-hkdf.tcl index 287b137..4e9ce08 100644 --- a/tcl/schemas/kem-balloon-blake2b-hkdf.tcl +++ b/tcl/schemas/kem-balloon-blake2b-hkdf.tcl @@ -1,10 +1,12 @@ balloon-cost { + {field . {map}} {field s {int} >0} {# space cost} {field t {int} >0} {# time cost} {field p {int} >0} {# parallel cost} } kem-balloon-blake2b-hkdf { + {field . {map}} {field a {str} =balloon-blake2b-hkdf} {field cek {bin} >0} {# wrapped CEK} {field salt {bin} >0} diff --git a/tcl/schemas/kem-gost3410-hkdf.tcl b/tcl/schemas/kem-gost3410-hkdf.tcl index 8cce4ec..e68a721 100644 --- a/tcl/schemas/kem-gost3410-hkdf.tcl +++ b/tcl/schemas/kem-gost3410-hkdf.tcl @@ -1,4 +1,5 @@ kem-gost3410-hkdf { + {field . {map}} {field a {str} =gost3410-hkdf} {field cek {bin} >0} {# wrapped CEK} {field ukm {bin} len=16} {# additional keying material} diff --git a/tcl/schemas/kem-pbkdf2.tcl b/tcl/schemas/kem-pbkdf2.tcl index bf8392f..fee50e7 100644 --- a/tcl/schemas/kem-pbkdf2.tcl +++ b/tcl/schemas/kem-pbkdf2.tcl @@ -1,4 +1,5 @@ kem-pbkdf2 { + {field . {map}} {field a {str} =pbkdf2} {field cek {bin} >0} {# wrapped CEK} {field hash {str} >0} {# hash algorithm identifier} diff --git a/tcl/schemas/kem-with-encap.tcl b/tcl/schemas/kem-with-encap.tcl index 0d43e0c..0db2b68 100644 --- a/tcl/schemas/kem-with-encap.tcl +++ b/tcl/schemas/kem-with-encap.tcl @@ -1,4 +1,5 @@ kem-with-encap { + {field . {map}} {field a {str} >0} {# sntrup761-x25519-hkdf-blake2b} {# mceliece6960119-x25519-hkdf-shake256} {field cek {bin} >0} {# wrapped CEK} diff --git a/tcl/schemas/prehash.tcl b/tcl/schemas/prehash.tcl index 312b92c..279cb56 100644 --- a/tcl/schemas/prehash.tcl +++ b/tcl/schemas/prehash.tcl @@ -1,4 +1,5 @@ prehash { + {field . {map}} {field t {str} =prehash} {field algos {set} >0} {# set of hash algorithm identifiers} } diff --git a/tcl/schemas/pub.tcl b/tcl/schemas/pub.tcl index 827e640..6e1c0ef 100644 --- a/tcl/schemas/pub.tcl +++ b/tcl/schemas/pub.tcl @@ -1,4 +1,5 @@ pub { + {field . {map}} {field load {with load}} {field sigs {list} {of sig} >0 optional} {field pubs {list} {of pub} >0 optional} @@ -17,6 +18,7 @@ av { } sig { + {field . {map}} {field tbs {with pub-sig-tbs}} {field sign {with av}} } diff --git a/tcl/schemas/signed.tcl b/tcl/schemas/signed.tcl index ce17fab..3ff6548 100644 --- a/tcl/schemas/signed.tcl +++ b/tcl/schemas/signed.tcl @@ -2,6 +2,7 @@ schema-include av.tcl schema-include fpr.tcl signed { + {field . {map}} {field load {with load}} {field sigs {list} {of sig} >0 optional} {field pubs {list} {of type map} >0 optional} @@ -14,6 +15,7 @@ load { } sig { + {field . {map}} {field tbs {with tbs}} {field sign {with av}} }