| ... | @@ -1,13 +1,8 @@ | ... | @@ -1,13 +1,8 @@ |
| 1 | //! Implementation of the IND-CCA2 post-quantum secure key encapsulation mechanism (KEM) | 1 | //! Implementation of the IND-CCA2 post-quantum secure key encapsulation mechanism (KEM) |
| 2 | //! ML-KEM (NIST FIPS-203 publication) and CRYSTALS-Kyber (v3.02/"draft00" CFRG draft). | 2 | //! ML-KEM (NIST FIPS-203 publication) and CRYSTALS-Kyber (v3.02/"draft00" CFRG draft). |
| 3 | //! | 3 | //! |
| 4 | //! The Kyber namespace suffix (currently `_d00`) refers to the version currently | 4 | //! The namespace `d00` refers to the version currently implemented, in accordance with the CFRG draft. |
| 5 | //! implemented, in accordance with the CFRG draft. | 5 | //! The `nist` namespace refers to the FIPS-203 publication. |
| 6 | //! | | |
| 7 | //! The ML-KEM namespace refers to the FIPS-203 publication. | | |
| 8 | //! | | |
| 9 | //! Suffixes may not be updated if new versions of the documents only include editorial changes. | | |
| 10 | //! The suffixes will be removed once the schemes are finalized. | | |
| 11 | //! | 6 | //! |
| 12 | //! Quoting from the CFRG I-D: | 7 | //! Quoting from the CFRG I-D: |
| 13 | //! | 8 | //! |
| ... | @@ -146,7 +141,7 @@ const Params = struct { | ... | @@ -146,7 +141,7 @@ const Params = struct { |
| 146 | dv: u8, | 141 | dv: u8, |
| 147 | }; | 142 | }; |
| 148 | | 143 | |
| 149 | pub const kyber_d00 = struct { | 144 | pub const d00 = struct { |
| 150 | pub const Kyber512 = Kyber(.{ | 145 | pub const Kyber512 = Kyber(.{ |
| 151 | .name = "Kyber512", | 146 | .name = "Kyber512", |
| 152 | .k = 2, | 147 | .k = 2, |
| ... | @@ -172,9 +167,7 @@ pub const kyber_d00 = struct { | ... | @@ -172,9 +167,7 @@ pub const kyber_d00 = struct { |
| 172 | }); | 167 | }); |
| 173 | }; | 168 | }; |
| 174 | | 169 | |
| 175 | pub const ml_kem_01 = @compileError("deprecated: final version of the specification has been published, use ml_kem instead"); | 170 | pub const nist = struct { |
| 176 | | | |
| 177 | pub const ml_kem = struct { | | |
| 178 | pub const MLKem512 = Kyber(.{ | 171 | pub const MLKem512 = Kyber(.{ |
| 179 | .name = "ML-KEM-512", | 172 | .name = "ML-KEM-512", |
| 180 | .ml_kem = true, | 173 | .ml_kem = true, |
| ... | @@ -204,12 +197,12 @@ pub const ml_kem = struct { | ... | @@ -204,12 +197,12 @@ pub const ml_kem = struct { |
| 204 | }; | 197 | }; |
| 205 | | 198 | |
| 206 | const modes = [_]type{ | 199 | const modes = [_]type{ |
| 207 | kyber_d00.Kyber512, | 200 | d00.Kyber512, |
| 208 | kyber_d00.Kyber768, | 201 | d00.Kyber768, |
| 209 | kyber_d00.Kyber1024, | 202 | d00.Kyber1024, |
| 210 | ml_kem.MLKem512, | 203 | nist.MLKem512, |
| 211 | ml_kem.MLKem768, | 204 | nist.MLKem768, |
| 212 | ml_kem.MLKem1024, | 205 | nist.MLKem1024, |
| 213 | }; | 206 | }; |
| 214 | const h_length: usize = 32; | 207 | const h_length: usize = 32; |
| 215 | const inner_seed_length: usize = 32; | 208 | const inner_seed_length: usize = 32; |
| ... | @@ -1725,9 +1718,9 @@ const sha2 = crypto.hash.sha2; | ... | @@ -1725,9 +1718,9 @@ const sha2 = crypto.hash.sha2; |
| 1725 | | 1718 | |
| 1726 | test "NIST KAT test" { | 1719 | test "NIST KAT test" { |
| 1727 | inline for (.{ | 1720 | inline for (.{ |
| 1728 | .{ kyber_d00.Kyber512, "e9c2bd37133fcb40772f81559f14b1f58dccd1c816701be9ba6214d43baf4547" }, | 1721 | .{ d00.Kyber512, "e9c2bd37133fcb40772f81559f14b1f58dccd1c816701be9ba6214d43baf4547" }, |
| 1729 | .{ kyber_d00.Kyber1024, "89248f2f33f7f4f7051729111f3049c409a933ec904aedadf035f30fa5646cd5" }, | 1722 | .{ d00.Kyber1024, "89248f2f33f7f4f7051729111f3049c409a933ec904aedadf035f30fa5646cd5" }, |
| 1730 | .{ kyber_d00.Kyber768, "a1e122cad3c24bc51622e4c242d8b8acbcd3f618fee4220400605ca8f9ea02c2" }, | 1723 | .{ d00.Kyber768, "a1e122cad3c24bc51622e4c242d8b8acbcd3f618fee4220400605ca8f9ea02c2" }, |
| 1731 | }) |modeHash| { | 1724 | }) |modeHash| { |
| 1732 | const mode = modeHash[0]; | 1725 | const mode = modeHash[0]; |
| 1733 | var seed: [48]u8 = undefined; | 1726 | var seed: [48]u8 = undefined; |