diff --git a/Cargo.toml b/Cargo.toml index 16dd7b7b2f1..7917d341a84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hpke-dispatch" -version = "0.6.0" +version = "0.7.0" edition = "2021" description = "runtime algorithmic selection for hybrid public key encryption" license = "MPL-2.0" @@ -24,8 +24,10 @@ kdf-all = ["kdf-sha256", "kdf-sha384", "kdf-sha512"] kdf-sha256 = [] kdf-sha384 = [] kdf-sha512 = [] -kem-all = ["kem-dh-p256-hkdf-sha256", "kem-x25519-hkdf-sha256"] +kem-all = ["kem-dh-p256-hkdf-sha256", "kem-dh-p384-hkdf-sha384", "kem-dh-p521-hkdf-sha512", "kem-x25519-hkdf-sha256"] kem-dh-p256-hkdf-sha256 = ["hpke/p256"] +kem-dh-p384-hkdf-sha384 = ["hpke/p384"] +kem-dh-p521-hkdf-sha512 = ["hpke/p521"] kem-x25519-hkdf-sha256 = ["hpke/x25519"] [dependencies] diff --git a/README.md b/README.md index 981d0454575..251dc7c0e5f 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,8 @@ from rust, even when opting out of `algo-all`. * *kdf-all*: Enables `kdf-sha256`, `kdf-sha384`, `kdf-sha512` algorithm features. Enabled by default. -* *kem-all*: Enables both `kem-dh-p256-hkdf-sha256` and +* *kem-all*: Enables `kem-dh-p256-hkdf-sha256`, + `kem-dh-p384-hkdf-sha384`, `kem-dh-p521-hkdf-sha512`, and `kem-x25519-hkdf-sha256` algorithm features. Enabled by default. * *serde*: enables derived serde serialization and deserialization for diff --git a/package-lock.json b/package-lock.json index bfa07f5aeda..cd6e7888a4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hpke", - "version": "0.5.1", + "version": "0.7.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hpke", - "version": "0.5.1", + "version": "0.7.0", "license": "MPL-2.0", "devDependencies": { "@tsconfig/node18": "^1.0.1", @@ -21,7 +21,7 @@ "prettier": "^2.7.1", "ts-mocha": "^10.0.0", "typescript": "^4.7.4", - "wasm-pack": "^0.10.3" + "wasm-pack": "^0.13.0" } }, "node_modules/@eslint/eslintrc": { @@ -556,12 +556,12 @@ } }, "node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "dev": true, "dependencies": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.14.8" } }, "node_modules/balanced-match": { @@ -580,14 +580,14 @@ } }, "node_modules/binary-install": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-0.1.1.tgz", - "integrity": "sha512-DqED0D/6LrS+BHDkKn34vhRqOGjy5gTMgvYZsGK2TpNbdPuz4h+MRlNgGv5QBRd7pWq/jylM4eKNCizgAq3kNQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-1.1.0.tgz", + "integrity": "sha512-rkwNGW+3aQVSZoD0/o3mfPN6Yxh3Id0R/xzTVBVVpGNlVz8EGwusksxRlbk/A5iKTZt9zkMn3qIqmAt3vpfbzg==", "dev": true, "dependencies": { - "axios": "^0.21.1", + "axios": "^0.26.1", "rimraf": "^3.0.2", - "tar": "^6.1.0" + "tar": "^6.1.11" }, "engines": { "node": ">=10" @@ -1822,6 +1822,18 @@ "node": ">= 8" } }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2620,13 +2632,10 @@ "dev": true }, "node_modules/minipass": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz", - "integrity": "sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, "engines": { "node": ">=8" } @@ -2644,6 +2653,18 @@ "node": ">= 8" } }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -3535,20 +3556,20 @@ } }, "node_modules/tar": { - "version": "6.1.11", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", - "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" }, "engines": { - "node": ">= 10" + "node": ">=10" } }, "node_modules/text-table": { @@ -3752,13 +3773,13 @@ } }, "node_modules/wasm-pack": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/wasm-pack/-/wasm-pack-0.10.3.tgz", - "integrity": "sha512-dg1PPyp+QwWrhfHsgG12K/y5xzwfaAoK1yuVC/DUAuQsDy5JywWDuA7Y/ionGwQz+JBZVw8jknaKBnaxaJfwTA==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/wasm-pack/-/wasm-pack-0.13.0.tgz", + "integrity": "sha512-AmboGZEnZoIcVCzSlkLEmNFEqJN+IwgshJ5S7pi30uNUTce4LvWkifQzsQRxnWj47G8gkqZxlyGlyQplsnIS7w==", "dev": true, "hasInstallScript": true, "dependencies": { - "binary-install": "^0.1.0" + "binary-install": "^1.0.1" }, "bin": { "wasm-pack": "run.js" @@ -4279,12 +4300,12 @@ "dev": true }, "axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "dev": true, "requires": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.14.8" } }, "balanced-match": { @@ -4300,14 +4321,14 @@ "dev": true }, "binary-install": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-0.1.1.tgz", - "integrity": "sha512-DqED0D/6LrS+BHDkKn34vhRqOGjy5gTMgvYZsGK2TpNbdPuz4h+MRlNgGv5QBRd7pWq/jylM4eKNCizgAq3kNQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-1.1.0.tgz", + "integrity": "sha512-rkwNGW+3aQVSZoD0/o3mfPN6Yxh3Id0R/xzTVBVVpGNlVz8EGwusksxRlbk/A5iKTZt9zkMn3qIqmAt3vpfbzg==", "dev": true, "requires": { - "axios": "^0.21.1", + "axios": "^0.26.1", "rimraf": "^3.0.2", - "tar": "^6.1.0" + "tar": "^6.1.11" } }, "brace-expansion": { @@ -5139,6 +5160,17 @@ "dev": true, "requires": { "minipass": "^3.0.0" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + } } }, "fs.realpath": { @@ -5721,13 +5753,10 @@ "dev": true }, "minipass": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz", - "integrity": "sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true }, "minizlib": { "version": "2.1.2", @@ -5737,6 +5766,17 @@ "requires": { "minipass": "^3.0.0", "yallist": "^4.0.0" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + } } }, "mkdirp": { @@ -6363,14 +6403,14 @@ "dev": true }, "tar": { - "version": "6.1.11", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", - "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -6525,12 +6565,12 @@ } }, "wasm-pack": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/wasm-pack/-/wasm-pack-0.10.3.tgz", - "integrity": "sha512-dg1PPyp+QwWrhfHsgG12K/y5xzwfaAoK1yuVC/DUAuQsDy5JywWDuA7Y/ionGwQz+JBZVw8jknaKBnaxaJfwTA==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/wasm-pack/-/wasm-pack-0.13.0.tgz", + "integrity": "sha512-AmboGZEnZoIcVCzSlkLEmNFEqJN+IwgshJ5S7pi30uNUTce4LvWkifQzsQRxnWj47G8gkqZxlyGlyQplsnIS7w==", "dev": true, "requires": { - "binary-install": "^0.1.0" + "binary-install": "^1.0.1" } }, "which": { diff --git a/package.json b/package.json index bb4a89a1920..75d7da5a3f4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hpke", "description": "hybrid public key encryption", - "version": "0.5.1", + "version": "0.7.0", "license": "MPL-2.0", "repository": { "type": "git", @@ -35,6 +35,6 @@ "prettier": "^2.7.1", "ts-mocha": "^10.0.0", "typescript": "^4.7.4", - "wasm-pack": "^0.10.3" + "wasm-pack": "^0.13.0" } } diff --git a/src/kem.rs b/src/kem.rs index a63ff564136..5cd2201ec43 100644 --- a/src/kem.rs +++ b/src/kem.rs @@ -7,7 +7,7 @@ use wasm_bindgen::prelude::*; /** Kem represents an asymmetric key encapsulation mechanism, as per -[RFC9180§7.1][section-7.1]. Currently only two of options listed in +[RFC9180§7.1][section-7.1]. Currently only four of the options listed in the hpke draft are available. [section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1 @@ -27,6 +27,14 @@ pub enum Kem { #[cfg(feature = "kem-dh-p256-hkdf-sha256")] DhP256HkdfSha256 = 16, + /// DHKEM(P-384, HKDF-SHA384) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4) + #[cfg(feature = "kem-dh-p384-hkdf-sha384")] + DhP384HkdfSha384 = 17, + + /// DHKEM(P-521, HKDF-SHA512) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4) + #[cfg(feature = "kem-dh-p521-hkdf-sha512")] + DhP521HkdfSha512 = 18, + /// DHKEM(X25519, HKDF-SHA256) [RFC7748](https://www.rfc-editor.org/info/rfc7748) #[cfg(feature = "kem-x25519-hkdf-sha256")] X25519HkdfSha256 = 32, @@ -41,6 +49,14 @@ impl FromStr for Kem { "p256sha256" | "dhkemp256hkdfsha256" | "p256hkdfsha256" | "dhkem(p256, hkdfsha256)" => { Ok(Self::DhP256HkdfSha256) } + #[cfg(feature = "kem-dh-p384-hkdf-sha384")] + "p384sha384" | "dhkemp384hkdfsha384" | "p384hkdfsha384" | "dhkem(p384, hkdfsha384)" => { + Ok(Self::DhP384HkdfSha384) + } + #[cfg(feature = "kem-dh-p521-hkdf-sha512")] + "p521sha512" | "dhkemp521hkdfsha512" | "p521hkdfsha512" | "dhkem(p521, hkdfsha512)" => { + Ok(Self::DhP521HkdfSha512) + } #[cfg(feature = "kem-x25519-hkdf-sha256")] "x25519sha256" | "dhkemx25519hkdfsha256" @@ -63,6 +79,10 @@ impl Kem { pub const KEM_ALL: &[Kem] = &[ #[cfg(feature = "kem-dh-p256-hkdf-sha256")] Kem::DhP256HkdfSha256, + #[cfg(feature = "kem-dh-p384-hkdf-sha384")] + Kem::DhP384HkdfSha384, + #[cfg(feature = "kem-dh-p521-hkdf-sha512")] + Kem::DhP521HkdfSha512, #[cfg(feature = "kem-x25519-hkdf-sha256")] Kem::X25519HkdfSha256, ]; diff --git a/src/keypair.rs b/src/keypair.rs index d42c8460585..ac73c357086 100644 --- a/src/keypair.rs +++ b/src/keypair.rs @@ -40,6 +40,12 @@ pub fn gen_keypair(kem: Kem) -> Keypair { #[cfg(feature = "kem-dh-p256-hkdf-sha256")] Kem::DhP256HkdfSha256 => gen_kp::(), + #[cfg(feature = "kem-dh-p384-hkdf-sha384")] + Kem::DhP384HkdfSha384 => gen_kp::(), + + #[cfg(feature = "kem-dh-p521-hkdf-sha512")] + Kem::DhP521HkdfSha512 => gen_kp::(), + #[cfg(feature = "kem-x25519-hkdf-sha256")] Kem::X25519HkdfSha256 => gen_kp::(), } diff --git a/src/macros.rs b/src/macros.rs index 75dd1fc442a..cd89a551e6e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -33,6 +33,10 @@ macro_rules! match_algo { match $kem { #[cfg(feature = "kem-dh-p256-hkdf-sha256")] $crate::Kem::DhP256HkdfSha256 => $fn::<$aead, $kdf, hpke::kem::DhP256HkdfSha256>, + #[cfg(feature = "kem-dh-p384-hkdf-sha384")] + $crate::Kem::DhP384HkdfSha384 => $fn::<$aead, $kdf, hpke::kem::DhP384HkdfSha384>, + #[cfg(feature = "kem-dh-p521-hkdf-sha512")] + $crate::Kem::DhP521HkdfSha512 => $fn::<$aead, $kdf, hpke::kem::DhP521HkdfSha512>, #[cfg(feature = "kem-x25519-hkdf-sha256")] $crate::Kem::X25519HkdfSha256 => $fn::<$aead, $kdf, hpke::kem::X25519HkdfSha256>, }