]> Cypherpunks repositories - keks.git/commitdiff
Split out KEMs from encrypted scheme
authorSergey Matveev <stargrave@stargrave.org>
Thu, 10 Apr 2025 09:48:37 +0000 (12:48 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 10 Apr 2025 09:49:44 +0000 (12:49 +0300)
spec/cm/kem-balloon-blake2b-hkdf.texi
spec/cm/kem-gost3410-hkdf.texi
spec/cm/kem-mceliece6960119-x25519-hkdf-shake256.texi
spec/cm/kem-sntrup4591761-x25519-hkdf-blake2b.texi
tcl/schemas/encrypted.tcl
tcl/schemas/kem-balloon-blake2b-hkdf.tcl [new file with mode: 0644]
tcl/schemas/kem-gost3410-hkdf-kexp15.tcl [new file with mode: 0644]
tcl/schemas/kem-with-encap.tcl [new file with mode: 0644]

index faabf297acd7effd57a9785ad92f4aeb9513bb0cf343c48aa4339aef3d7e133e..42461106edd132825ccb95f72d84707dc3bdba94ed1ab5d8fbcb14379d337e46 100644 (file)
@@ -3,19 +3,7 @@
 @nodedescription Balloon-BLAKE2b+HKDF KEM
 @subsubsection Balloon-BLAKE2b+HKDF KEM
 
-@code{/kem/*/a} equals to "balloon-blake2b-hkdf".
-Recipient map must also contain additional fields:
-
-@table @code
-@item /kem/*/cost/s: uint64
-    Balloon's space cost (buffer size, number of hash-output sized blocks).
-@item /kem/*/cost/t: uint64
-    Balloon's time cost (number of rounds).
-@item /kem/*/cost/p: uint64
-    Balloon's parallel cost (number of threads).
-@item /kem/*/salt: bytes
-    Salt.
-@end table
+@verbatiminclude ../tcl/schemas/kem-balloon-blake2b-hkdf.tcl
 
 @url{https://crypto.stanford.edu/balloon/, Balloon} memory-hardened
 password hasher must be used with BLAKE2b hash.
index ef2bbb0fbe186b0a81d60fae4ecf926e41e14a9ff588b0fed90c0bb6117d4341..6db200612412164abd87264800c838745b512e204bf757feaaf9059836f527ff 100644 (file)
@@ -3,15 +3,7 @@
 @nodedescription GOST R 34.10+HKDF KEM
 @subsubsection GOST R 34.10+HKDF KEM
 
-@code{/kem/*/a} equals to "gost3410-hkdf".
-Recipient map must also contain additional fields:
-
-@table @code
-@item /to/*/ukm: bytes
-    Additional 16-bytes keying material.
-@item /to/*/pub: bytes
-    Sender's ephemeral 512-bit public key.
-@end table
+@verbatiminclude ../tcl/schemas/kem-gost3410-hkdf-kexp15.tcl
 
 GOST R 34.10-2012 VKO parameter set A/C ("gost3410-256A", "gost3410-512C")
 must be used for DH operation, with UKM taken from the structure. VKO's
index 949824e49e5dea0fa8ab7e3efe04f4e9cb07b62365bea4e6412b6795aae7235b..5ddee7931e65bf894385c3de185cf2dbbc2a067db8d1affde7e0bb14e88acce2 100644 (file)
@@ -3,15 +3,16 @@
 @nodedescription Classic McEliece 6960-119+X25519+HKDF-SHAKE256 KEM
 @subsubsection Classic McEliece 6960-119+X25519+HKDF-SHAKE256 KEM
 
+@verbatiminclude ../tcl/schemas/kem-with-encap.tcl
+
 @code{/kem/*/a} equals to "mceliece6960119-x25519-hkdf-shake256".
 Recipient public key with
 @ref{cm-pub-mceliece6960119-x25519, @code{mceliece6960119-x25519}}
 algorithm must be used. It should have "kem" key usage set.
 
-Recipient map must also contain additional field:
-@code{/kem/*/encap: bytes} -- concatenation of 194 bytes of
-Classic McEliece 6960-119 ciphertext with 32 bytes of ephemeral
-X25519 public key.
+Recipient's map @code{/kem/*/encap} field is a concatenation of
+194 bytes of Classic McEliece 6960-119 ciphertext with 32 bytes of
+ephemeral X25519 public key.
 
 Recipient performs X25519 and Classic McEliece computations to
 derive/decapsulate two 32-byte shared keys. Then it combines
index 9f54c18a084979803944c9a951e32db069ad4af91a74049557b7d3c1ce4ba672..cd8d89cec77a31e81eafa3f72aa0fbf1504287c0922eb6c4185692d70b5db90a 100644 (file)
@@ -3,14 +3,16 @@
 @nodedescription SNTRUP4591761+X25519+HKDF-BLAKE2b KEM
 @subsubsection SNTRUP4591761+X25519+HKDF-BLAKE2b KEM
 
+@verbatiminclude ../tcl/schemas/kem-with-encap.tcl
+
 @code{/kem/*/a} equals to "sntrup4591761-x25519-hkdf-blake2b".
 Recipient public key with @ref{cm-pub-sntrup4591761-x25519,
 @code{sntrup4591761-x25519}} algorithm must be used. It should have
 "kem" key usage set.
 
-Recipient map must also contain additional field: @code{/kem/*/encap:
-bytes} -- concatenation of 1047 bytes of Streamlined NTRU Prime
-4591^761's ciphertext with 32 bytes of ephemeral X25519 public key.
+Recipient's map @code{/kem/*/encap} field is a concatenation of 1047
+bytes of Streamlined NTRU Prime 4591^761's ciphertext with 32 bytes of
+ephemeral X25519 public key.
 
 Recipient performs X25519 and SNTRUP computations to derive/decapsulate
 two 32-byte shared keys. Then it combines them to get the KEK decryption
index 21e0cbeaed1630f93a6ae83d6d71db6b12316106e70890f31549319c63143efb..7917c39edabea76ab1f8f84b99e3ea6a3372d3500d28bd880f51828546408493 100644 (file)
@@ -17,34 +17,7 @@ kem {
     {field cek {bin} >0}
 }
 
-balloon-cost {
-    {field s {int} >0} {# space cost}
-    {field t {int} >0} {# time cost}
-    {field p {int} >0} {# parallel cost}
-}
-
-kem-balloon-blake2b-hkdf {
-    {field a {str} =balloon-blake2b-hkdf}
-    {field cek {bin} >0}
-    {field salt {bin} >0}
-    {field cost {with balloon-cost}}
-}
-
-kem-gost3410-hkdf-kexp15 {
-    {field a {str} =gost3410-hkdf-kexp15}
-    {field cek {bin} >0}
-    {field ukm {bin} >0}
-    {field pub {bin} >0}
-    {field to {with fpr} optional} {# recipient's public key}
-}
-
-kem-with-encap {
-    {# sntrup4591761-x25519-hkdf-blake2b}
-    {# mceliece6960119-x25519-hkdf-shake256}
-    {field a {str} >0}
-    {field cek {bin} >0}
-    {field encap {bin} >0}
-    {field to {with fpr} optional} {# recipient's public key}
-}
-
 schema-include fpr.tcl
+schema-include kem-with-encap.tcl
+schema-include kem-gost3410-hkdf-kexp15.tcl
+schema-include kem-balloon-blake2b-hkdf.tcl
diff --git a/tcl/schemas/kem-balloon-blake2b-hkdf.tcl b/tcl/schemas/kem-balloon-blake2b-hkdf.tcl
new file mode 100644 (file)
index 0000000..287b137
--- /dev/null
@@ -0,0 +1,12 @@
+balloon-cost {
+    {field s {int} >0} {# space cost}
+    {field t {int} >0} {# time cost}
+    {field p {int} >0} {# parallel cost}
+}
+
+kem-balloon-blake2b-hkdf {
+    {field a {str} =balloon-blake2b-hkdf}
+    {field cek {bin} >0} {# wrapped CEK}
+    {field salt {bin} >0}
+    {field cost {with balloon-cost}}
+}
diff --git a/tcl/schemas/kem-gost3410-hkdf-kexp15.tcl b/tcl/schemas/kem-gost3410-hkdf-kexp15.tcl
new file mode 100644 (file)
index 0000000..08268b2
--- /dev/null
@@ -0,0 +1,7 @@
+kem-gost3410-hkdf-kexp15 {
+    {field a {str} =gost3410-hkdf-kexp15}
+    {field cek {bin} >0} {# wrapped CEK}
+    {field ukm {bin} len=16} {# additional keying material}
+    {field pub {bin} >0} {# sender's ephemeral public key}
+    {field to {with fpr} optional} {# recipient's public key}
+}
diff --git a/tcl/schemas/kem-with-encap.tcl b/tcl/schemas/kem-with-encap.tcl
new file mode 100644 (file)
index 0000000..4f0752d
--- /dev/null
@@ -0,0 +1,8 @@
+kem-with-encap {
+    {# sntrup4591761-x25519-hkdf-blake2b}
+    {# mceliece6960119-x25519-hkdf-shake256}
+    {field a {str} >0}
+    {field cek {bin} >0} {# wrapped CEK}
+    {field encap {bin} >0}
+    {field to {with fpr} optional} {# recipient's public key}
+}