mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-28 06:23:08 -08:00
add kyber512 from libcrux
This commit is contained in:
198
Cargo.lock
generated
198
Cargo.lock
generated
@@ -999,6 +999,44 @@ version = "0.15.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hax-lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd2dddf00d9120e8ff07ec0411cd48f6f419782b53c109d3984b6bf94345c822"
|
||||||
|
dependencies = [
|
||||||
|
"hax-lib-macros",
|
||||||
|
"num-bigint",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hax-lib-macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "013ec0c6e58481b11658007e794ee09be35b97ef02c92102b9a5c01afd43a82f"
|
||||||
|
dependencies = [
|
||||||
|
"hax-lib-macros-types",
|
||||||
|
"paste",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.98",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hax-lib-macros-types"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "01e897f0a73b06263b106327db34e77b8df37a9a94a3fba759ee7c9b69493396"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heapless"
|
name = "heapless"
|
||||||
version = "0.7.17"
|
version = "0.7.17"
|
||||||
@@ -1089,7 +1127,7 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"rand",
|
"rand 0.8.5",
|
||||||
"serde",
|
"serde",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"uuid",
|
"uuid",
|
||||||
@@ -1184,7 +1222,7 @@ dependencies = [
|
|||||||
"libcrux-hacl",
|
"libcrux-hacl",
|
||||||
"libcrux-platform",
|
"libcrux-platform",
|
||||||
"libjade-sys",
|
"libjade-sys",
|
||||||
"rand",
|
"rand 0.8.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1217,6 +1255,15 @@ dependencies = [
|
|||||||
"libcrux-macros",
|
"libcrux-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libcrux-intrinsics"
|
||||||
|
version = "0.0.2-beta.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5256e25c0b16c98b715f7cc6b3ed268723a1158f78a236b1625ffe4a941cab41"
|
||||||
|
dependencies = [
|
||||||
|
"hax-lib",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcrux-macros"
|
name = "libcrux-macros"
|
||||||
version = "0.0.2-beta.3"
|
version = "0.0.2-beta.3"
|
||||||
@@ -1227,6 +1274,19 @@ dependencies = [
|
|||||||
"syn 2.0.98",
|
"syn 2.0.98",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libcrux-ml-kem"
|
||||||
|
version = "0.0.2-beta.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89cbf9aad4ad38d53cfdd7ffe9041cc4cf516c8c5a6f9c1a7bb8136a82b7b6d6"
|
||||||
|
dependencies = [
|
||||||
|
"hax-lib",
|
||||||
|
"libcrux-intrinsics",
|
||||||
|
"libcrux-platform",
|
||||||
|
"libcrux-sha3",
|
||||||
|
"rand 0.9.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcrux-platform"
|
name = "libcrux-platform"
|
||||||
version = "0.0.2-pre.2"
|
version = "0.0.2-pre.2"
|
||||||
@@ -1246,6 +1306,17 @@ dependencies = [
|
|||||||
"libcrux-macros",
|
"libcrux-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libcrux-sha3"
|
||||||
|
version = "0.0.2-beta.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6afd802f5c7862be77f1f320df6c0fea0f09a78ca94e79df26625c60d2d96de7"
|
||||||
|
dependencies = [
|
||||||
|
"hax-lib",
|
||||||
|
"libcrux-intrinsics",
|
||||||
|
"libcrux-platform",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libfuzzer-sys"
|
name = "libfuzzer-sys"
|
||||||
version = "0.4.9"
|
version = "0.4.9"
|
||||||
@@ -1508,6 +1579,25 @@ dependencies = [
|
|||||||
"minimal-lexical",
|
"minimal-lexical",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-bigint"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
|
||||||
|
dependencies = [
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.46"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.19"
|
||||||
@@ -1668,7 +1758,7 @@ version = "0.2.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy",
|
"zerocopy 0.7.35",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1681,6 +1771,30 @@ dependencies = [
|
|||||||
"syn 2.0.98",
|
"syn 2.0.98",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error-attr",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error-attr"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.93"
|
version = "1.0.93"
|
||||||
@@ -1730,8 +1844,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"rand_chacha",
|
"rand_chacha 0.3.1",
|
||||||
"rand_core",
|
"rand_core 0.6.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
|
||||||
|
dependencies = [
|
||||||
|
"rand_chacha 0.9.0",
|
||||||
|
"rand_core 0.9.2",
|
||||||
|
"zerocopy 0.8.20",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1741,7 +1866,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ppv-lite86",
|
"ppv-lite86",
|
||||||
"rand_core",
|
"rand_core 0.6.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1753,6 +1888,16 @@ dependencies = [
|
|||||||
"getrandom 0.2.15",
|
"getrandom 0.2.15",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.3.1",
|
||||||
|
"zerocopy 0.8.20",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
@@ -1838,7 +1983,7 @@ dependencies = [
|
|||||||
"mio",
|
"mio",
|
||||||
"paste",
|
"paste",
|
||||||
"procspawn",
|
"procspawn",
|
||||||
"rand",
|
"rand 0.8.5",
|
||||||
"rosenpass-cipher-traits",
|
"rosenpass-cipher-traits",
|
||||||
"rosenpass-ciphers",
|
"rosenpass-ciphers",
|
||||||
"rosenpass-constant-time",
|
"rosenpass-constant-time",
|
||||||
@@ -1857,7 +2002,7 @@ dependencies = [
|
|||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"toml",
|
"toml",
|
||||||
"uds",
|
"uds",
|
||||||
"zerocopy",
|
"zerocopy 0.7.35",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1881,7 +2026,8 @@ dependencies = [
|
|||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
"libcrux",
|
"libcrux",
|
||||||
"libcrux-chacha20poly1305",
|
"libcrux-chacha20poly1305",
|
||||||
"rand",
|
"libcrux-ml-kem",
|
||||||
|
"rand 0.8.5",
|
||||||
"rosenpass-cipher-traits",
|
"rosenpass-cipher-traits",
|
||||||
"rosenpass-constant-time",
|
"rosenpass-constant-time",
|
||||||
"rosenpass-oqs",
|
"rosenpass-oqs",
|
||||||
@@ -1898,7 +2044,7 @@ name = "rosenpass-constant-time"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memsec",
|
"memsec",
|
||||||
"rand",
|
"rand 0.8.5",
|
||||||
"rosenpass-to",
|
"rosenpass-to",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1939,7 +2085,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"memsec",
|
"memsec",
|
||||||
"procspawn",
|
"procspawn",
|
||||||
"rand",
|
"rand 0.8.5",
|
||||||
"rosenpass-to",
|
"rosenpass-to",
|
||||||
"rosenpass-util",
|
"rosenpass-util",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
@@ -1966,7 +2112,7 @@ dependencies = [
|
|||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"typenum",
|
"typenum",
|
||||||
"uds",
|
"uds",
|
||||||
"zerocopy",
|
"zerocopy 0.7.35",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1983,7 +2129,7 @@ dependencies = [
|
|||||||
"mio",
|
"mio",
|
||||||
"postcard",
|
"postcard",
|
||||||
"procspawn",
|
"procspawn",
|
||||||
"rand",
|
"rand 0.8.5",
|
||||||
"rosenpass-secret-memory",
|
"rosenpass-secret-memory",
|
||||||
"rosenpass-to",
|
"rosenpass-to",
|
||||||
"rosenpass-util",
|
"rosenpass-util",
|
||||||
@@ -1991,7 +2137,7 @@ dependencies = [
|
|||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"tokio",
|
"tokio",
|
||||||
"wireguard-uapi",
|
"wireguard-uapi",
|
||||||
"zerocopy",
|
"zerocopy 0.7.35",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2982,7 +3128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277"
|
checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"curve25519-dalek",
|
"curve25519-dalek",
|
||||||
"rand_core",
|
"rand_core 0.6.4",
|
||||||
"serde",
|
"serde",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
@@ -2994,7 +3140,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"zerocopy-derive",
|
"zerocopy-derive 0.7.35",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.8.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive 0.8.20",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3008,6 +3163,17 @@ dependencies = [
|
|||||||
"syn 2.0.98",
|
"syn 2.0.98",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.8.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.98",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zeroize"
|
name = "zeroize"
|
||||||
version = "1.8.1"
|
version = "1.8.1"
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ tokio = { version = "1.42", features = ["macros", "rt-multi-thread"] }
|
|||||||
postcard = { version = "1.1.1", features = ["alloc"] }
|
postcard = { version = "1.1.1", features = ["alloc"] }
|
||||||
libcrux = { version = "0.0.2-pre.2" }
|
libcrux = { version = "0.0.2-pre.2" }
|
||||||
libcrux-chacha20poly1305 = { version = "0.0.2-beta.3" }
|
libcrux-chacha20poly1305 = { version = "0.0.2-beta.3" }
|
||||||
|
libcrux-ml-kem = { version = "0.0.2-beta.3" }
|
||||||
hex-literal = { version = "0.4.1" }
|
hex-literal = { version = "0.4.1" }
|
||||||
hex = { version = "0.4.3" }
|
hex = { version = "0.4.3" }
|
||||||
heck = { version = "0.5.0" }
|
heck = { version = "0.5.0" }
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ readme = "readme.md"
|
|||||||
experiment_libcrux = [
|
experiment_libcrux = [
|
||||||
"dep:libcrux",
|
"dep:libcrux",
|
||||||
"dep:libcrux-chacha20poly1305",
|
"dep:libcrux-chacha20poly1305",
|
||||||
|
"dep:libcrux-ml-kem",
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -28,7 +29,10 @@ zeroize = { workspace = true }
|
|||||||
chacha20poly1305 = { workspace = true }
|
chacha20poly1305 = { workspace = true }
|
||||||
blake2 = { workspace = true }
|
blake2 = { workspace = true }
|
||||||
libcrux = { workspace = true, optional = true }
|
libcrux = { workspace = true, optional = true }
|
||||||
sha3 = {workspace = true}
|
|
||||||
libcrux-chacha20poly1305 = { workspace = true, optional = true }
|
libcrux-chacha20poly1305 = { workspace = true, optional = true }
|
||||||
|
libcrux-ml-kem = { workspace = true, optional = true, features = ["kyber"] }
|
||||||
|
sha3 = { workspace = true }
|
||||||
|
rand = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
|
|||||||
62
ciphers/src/subtle/libcrux/kyber512.rs
Normal file
62
ciphers/src/subtle/libcrux/kyber512.rs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
use libcrux_ml_kem::kyber512;
|
||||||
|
|
||||||
|
use rand::RngCore;
|
||||||
|
|
||||||
|
use rosenpass_cipher_traits::algorithms::kem_kyber512::*;
|
||||||
|
use rosenpass_cipher_traits::primitives::{Kem, KemError};
|
||||||
|
|
||||||
|
pub struct Kyber512;
|
||||||
|
|
||||||
|
impl Kem<SK_LEN, PK_LEN, CT_LEN, SHK_LEN> for Kyber512 {
|
||||||
|
fn keygen(&self, sk: &mut [u8; SK_LEN], pk: &mut [u8; PK_LEN]) -> Result<(), KemError> {
|
||||||
|
let mut randomness = [0u8; libcrux_ml_kem::KEY_GENERATION_SEED_SIZE];
|
||||||
|
rand::thread_rng().fill_bytes(&mut randomness);
|
||||||
|
|
||||||
|
let key_pair = kyber512::generate_key_pair(randomness);
|
||||||
|
|
||||||
|
let new_sk: &[u8; SK_LEN] = key_pair.sk();
|
||||||
|
let new_pk: &[u8; PK_LEN] = key_pair.pk();
|
||||||
|
|
||||||
|
sk.clone_from_slice(new_sk);
|
||||||
|
pk.clone_from_slice(new_pk);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn encaps(
|
||||||
|
&self,
|
||||||
|
shk: &mut [u8; SHK_LEN],
|
||||||
|
ct: &mut [u8; CT_LEN],
|
||||||
|
pk: &[u8; PK_LEN],
|
||||||
|
) -> Result<(), KemError> {
|
||||||
|
let mut randomness = [0u8; libcrux_ml_kem::SHARED_SECRET_SIZE];
|
||||||
|
rand::thread_rng().fill_bytes(&mut randomness);
|
||||||
|
|
||||||
|
let (new_ct, new_shk) = kyber512::encapsulate(&pk.into(), randomness);
|
||||||
|
let new_ct: &[u8; CT_LEN] = new_ct.as_slice();
|
||||||
|
|
||||||
|
shk.clone_from_slice(&new_shk);
|
||||||
|
ct.clone_from_slice(new_ct);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decaps(
|
||||||
|
&self,
|
||||||
|
shk: &mut [u8; SHK_LEN],
|
||||||
|
sk: &[u8; SK_LEN],
|
||||||
|
ct: &[u8; CT_LEN],
|
||||||
|
) -> Result<(), KemError> {
|
||||||
|
let new_shk: [u8; SHK_LEN] = kyber512::decapsulate(&sk.into(), &ct.into());
|
||||||
|
shk.clone_from(&new_shk);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Kyber512 {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl KemKyber512 for Kyber512 {}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
//! Implementations backed by libcrux, a verified crypto library
|
//! Implementations backed by libcrux, a verified crypto library
|
||||||
|
|
||||||
pub mod chacha20poly1305_ietf;
|
pub mod chacha20poly1305_ietf;
|
||||||
|
pub mod kyber512;
|
||||||
|
|||||||
Reference in New Issue
Block a user