@@ -9873,7 +9873,7 @@ SymCryptLmsSign(
98739873// modules. Special care must be taken to ensure that the same private key state is not used more than once to
98749874// sign messages. This can be done, for instance, by releasing a signature only after verifying that the private
98759875// key has been updated and serialized to a physical storage.
9876- //
9876+ //
98779877// Parameters:
98789878// pKey: A pointer to a SYMCRYPT_LMS_KEY structure that represents the LMS key object to be used for signing the message.
98799879// The structure must be valid and non-null, and must contain the private key values for the LMS scheme. The private key
@@ -10003,6 +10003,17 @@ SymCryptMlKemkeyFree(
1000310003 _Inout_ PSYMCRYPT_MLKEMKEY pkMlKemkey );
1000410004
1000510005
10006+ // d and z are each 32 bytes
10007+ #define SYMCRYPT_MLKEM_PRIVATE_SEED_SIZE (2*32)
10008+
10009+ #define SYMCRYPT_MLKEM_ENCAPSULATION_KEY_SIZE_MLKEM512 (800)
10010+ #define SYMCRYPT_MLKEM_ENCAPSULATION_KEY_SIZE_MLKEM768 (1184)
10011+ #define SYMCRYPT_MLKEM_ENCAPSULATION_KEY_SIZE_MLKEM1024 (1568)
10012+
10013+ #define SYMCRYPT_MLKEM_DECAPSULATION_KEY_SIZE_MLKEM512 (1632)
10014+ #define SYMCRYPT_MLKEM_DECAPSULATION_KEY_SIZE_MLKEM768 (2400)
10015+ #define SYMCRYPT_MLKEM_DECAPSULATION_KEY_SIZE_MLKEM1024 (3168)
10016+
1000610017SYMCRYPT_ERROR
1000710018SYMCRYPT_CALL
1000810019SymCryptMlKemSizeofKeyFormatFromParams (
@@ -10011,7 +10022,7 @@ SymCryptMlKemSizeofKeyFormatFromParams(
1001110022 _Out_ SIZE_T * pcbKeyFormat );
1001210023//
1001310024// Gives the size in bytes of the blob of the given format for the given ML-KEM
10014- // parameters and the specified format via cbKeyFormat output.
10025+ // parameters via pcbKeyFormat output.
1001510026// Returns SYMCRYPT_INCOMPATIBLE_FORMAT if mlKemkeyFormat is an unsupported value,
1001610027// or SYMCRYPT_INVALID_ARGUMENT if other parameters are invalid.
1001710028//
@@ -10135,7 +10146,7 @@ SymCryptMlKemDecapsulate(
1013510146//
1013610147// Performs the Decapsulate operation of ML-KEM.
1013710148// This uses the private information of an ML-KEM keypair to generate an agreed
10138- // secret and a ciphertext which can be decapsulated with the secret decapsulation key .
10149+ // secret from a ciphertext.
1013910150//
1014010151// The arguments are the following:
1014110152// - pkMlKemkey: a key which contains private information required for decapsulation.
@@ -10150,9 +10161,8 @@ SymCryptMlKemDecapsulate(
1015010161// will "implicitly reject" the ciphertext, by returning success in equal time to a valid
1015110162// decapsulation operation, with pseudo-random agreed secret output. This forces higher
1015210163// level protocols to fail later when symmetric keys of peers do not match.
10153- // So decapsulate will only ever fail if there are programming errors (i.e. incorrect
10154- // size, use of uninitialized pkMlKemkey), or something fundamentally goes wrong with the
10155- // environment (i.e. internal memory allocation fails, or self-test detect hardware error).
10164+ // So decapsulate will only ever return an error if there are programming errors (e.g. incorrect size),
10165+ // or something fundamentally goes wrong with the environment (e.g. internal memory allocation fails).
1015610166//
1015710167
1015810168VOID
@@ -10164,6 +10174,219 @@ SymCryptMlKemSelftest(void);
1016410174// keys with FIPS validation, so most callers should never use this function.
1016510175//
1016610176
10177+ //
10178+ // COMPOSITE MLKEMKEY objects' API
10179+ //
10180+ // The below formats apply **only to external formats**: When somebody is importing or exporting
10181+ // a key. The internal format of the keys is not visible to the caller.
10182+ typedef enum _SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT {
10183+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT_NULL = 0 ,
10184+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT_IRTF_PRIVATE_SEED = 1 ,
10185+ // 32-byte seed for deriving Composite ML-KEM key, per irtf-cfrg-hybrid-kems CG framework
10186+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT_LAMPS_PRIVATE_KEY = 2 ,
10187+ // Standard byte encoding of a Composite ML-KEM private key, per LAMPS composite ML-KEM draft 12.
10188+ // Concatenation of ML-KEM private seed and private key of the traditional component:
10189+ // mlkemSeed || tradSK
10190+ // Size in bytes are MLKEM768_P256: 115, MLKEM768_X25519: 96, MLKEM1024_P384: 128
10191+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT_PUBLIC_KEY = 3 ,
10192+ // Standard byte encoding of a Composite ML-KEM public key, per irtf-cfrg-hybrid-kems CG framework
10193+ // and LAMPS composite ML-KEM draft 12.
10194+ // Concatenation of ML-KEM encapsulation key and public key of the traditional component:
10195+ // mlkemPK || tradPK
10196+ // Size in bytes are MLKEM768_P256: 1249, MLKEM768_X25519: 1216, MLKEM1024_P384: 1665
10197+ } SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT ;
10198+
10199+
10200+ typedef enum _SYMCRYPT_COMPOSITE_MLKEM_PARAMS {
10201+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS_NULL = 0 ,
10202+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS_MLKEM768_P256 = 1 ,
10203+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS_MLKEM768_X25519 = 2 ,
10204+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS_MLKEM1024_P384 = 3 ,
10205+ } SYMCRYPT_COMPOSITE_MLKEM_PARAMS ;
10206+ //
10207+ // Currently supported Composite ML-KEM parameter sets are represented externally only by the enum
10208+ //
10209+
10210+ PSYMCRYPT_COMPOSITE_MLKEMKEY
10211+ SYMCRYPT_CALL
10212+ SymCryptCompositeMlKemkeyAllocate (
10213+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS params );
10214+ //
10215+ // Allocate and create a new COMPOSITE_MLKEMKEY object sized according to the specified parameters.
10216+ //
10217+ // This call does not initialize the key. It should be
10218+ // followed by a call to SymCryptCompositeMlKemkeyGenerate or
10219+ // SymCryptCompositeMlKemkeySetValue.
10220+ //
10221+
10222+ VOID
10223+ SYMCRYPT_CALL
10224+ SymCryptCompositeMlKemkeyFree (
10225+ _Inout_ PSYMCRYPT_COMPOSITE_MLKEMKEY pkCompositeMlKemkey );
10226+
10227+
10228+ #define SYMCRYPT_COMPOSITE_MLKEM_IRTF_PRIVATE_SEED_SIZE (32)
10229+
10230+ #define SYMCRYPT_COMPOSITE_MLKEM_LAMPS_PRIVATE_KEY_SIZE_MLKEM768_P256 (115)
10231+ #define SYMCRYPT_COMPOSITE_MLKEM_LAMPS_PRIVATE_KEY_SIZE_MLKEM768_X25519 (96)
10232+ #define SYMCRYPT_COMPOSITE_MLKEM_LAMPS_PRIVATE_KEY_SIZE_MLKEM1024_P384 (128)
10233+
10234+ #define SYMCRYPT_COMPOSITE_MLKEM_PUBLIC_KEY_SIZE_MLKEM768_P256 (1249)
10235+ #define SYMCRYPT_COMPOSITE_MLKEM_PUBLIC_KEY_SIZE_MLKEM768_X25519 (1216)
10236+ #define SYMCRYPT_COMPOSITE_MLKEM_PUBLIC_KEY_SIZE_MLKEM1024_P384 (1665)
10237+
10238+
10239+ SYMCRYPT_ERROR
10240+ SYMCRYPT_CALL
10241+ SymCryptCompositeMlKemSizeofKeyFormatFromParams (
10242+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS params ,
10243+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT compositeMlKemkeyformat ,
10244+ _Out_ SIZE_T * pcbKeyFormat );
10245+ //
10246+ // Gives the size in bytes of the blob of the given format for the given Composite ML-KEM
10247+ // parameters via pcbKeyFormat output.
10248+ // Returns SYMCRYPT_INCOMPATIBLE_FORMAT if compositeMlKemkeyformat is an unsupported value,
10249+ // or SYMCRYPT_INVALID_ARGUMENT if other parameters are invalid.
10250+ //
10251+
10252+ #define SYMCRYPT_COMPOSITE_MLKEM_CIPHERTEXT_SIZE_MLKEM768_P256 (1153)
10253+ #define SYMCRYPT_COMPOSITE_MLKEM_CIPHERTEXT_SIZE_MLKEM768_X25519 (1120)
10254+ #define SYMCRYPT_COMPOSITE_MLKEM_CIPHERTEXT_SIZE_MLKEM1024_P384 (1665)
10255+
10256+ SYMCRYPT_ERROR
10257+ SYMCRYPT_CALL
10258+ SymCryptCompositeMlKemSizeofCiphertextFromParams (
10259+ SYMCRYPT_COMPOSITE_MLKEM_PARAMS params ,
10260+ _Out_ SIZE_T * pcbCiphertext );
10261+ //
10262+ // Gives the size in bytes of the ciphertext for the given Composite ML-KEM parameters.
10263+ // Returns SYMCRYPT_INVALID_ARGUMENT if parameters are invalid.
10264+ //
10265+
10266+ SYMCRYPT_ERROR
10267+ SYMCRYPT_CALL
10268+ SymCryptCompositeMlKemkeyGenerate (
10269+ _Inout_ PSYMCRYPT_COMPOSITE_MLKEMKEY pkCompositeMlKemkey ,
10270+ UINT32 flags );
10271+ //
10272+ // Generate a new random Composite ML-KEM key using the information from the
10273+ // parameters passed to SymCryptCompositeMlKemkeyAllocate.
10274+ //
10275+ // Allowed flags:
10276+ //
10277+ // - SYMCRYPT_FLAG_KEY_NO_FIPS
10278+ // Opt-out of performing validation required for FIPS
10279+ //
10280+ // Described in more detail in the "Flags for asymmetric key generation and import" section above
10281+ //
10282+
10283+ SYMCRYPT_ERROR
10284+ SYMCRYPT_CALL
10285+ SymCryptCompositeMlKemkeySetValue (
10286+ _In_reads_bytes_ ( cbSrc ) PCBYTE pbSrc ,
10287+ SIZE_T cbSrc ,
10288+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT compositeMlKemkeyFormat ,
10289+ UINT32 flags ,
10290+ _Inout_ PSYMCRYPT_COMPOSITE_MLKEMKEY pkCompositeMlKemkey );
10291+ //
10292+ // Import key material to a Composite ML-KEM key object. The arguments are the following:
10293+ // - (pbSrc, cbSrc): a buffer containing a representation of a Composite ML-KEM key,
10294+ // in format specified by compositeMlKemkeyFormat.
10295+ // - compositeMlKemkeyFormat format of the input
10296+ //
10297+ // Allowed flags:
10298+ //
10299+ // - SYMCRYPT_FLAG_KEY_NO_FIPS
10300+ // Opt-out of performing validation required for FIPS
10301+ //
10302+ // - SYMCRYPT_FLAG_KEY_MINIMAL_VALIDATION
10303+ // Opt-out of performing almost all validation - must be specified with SYMCRYPT_FLAG_KEY_NO_FIPS
10304+ //
10305+ // Remarks:
10306+ // - cbSrc must be equal to the cbKeyFormat returned from
10307+ // SymCryptCompositeMlKemSizeofKeyFormatFromParams(params, compositeMlKemkeyFormat, &cbKeyFormat), though
10308+ // typically this value can be known statically (see definition of SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT)
10309+ //
10310+
10311+ SYMCRYPT_ERROR
10312+ SYMCRYPT_CALL
10313+ SymCryptCompositeMlKemkeyGetValue (
10314+ _In_ PCSYMCRYPT_COMPOSITE_MLKEMKEY pkCompositeMlKemkey ,
10315+ _Out_writes_bytes_ ( cbDst ) PBYTE pbDst ,
10316+ SIZE_T cbDst ,
10317+ SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT compositeMlKemkeyFormat ,
10318+ UINT32 flags );
10319+ //
10320+ // Export key material from a Composite ML-KEM key object. The arguments are the following:
10321+ // - (pbDst, cbDst): a buffer into which a representation of a Composite ML-KEM key is
10322+ // written, in the format specified by compositeMlKemkeyFormat.
10323+ // - compositeMlKemkeyFormat format of the output
10324+ //
10325+ // Allowed flags:
10326+ // - None.
10327+ //
10328+ // Remarks:
10329+ // - If the key object does not have the information required to export to the format
10330+ // specified by compositeMlKemkeyFormat this function will return SYMCRYPT_INCOMPATIBLE_FORMAT.
10331+ // - cbDst must be equal to the cbKeyFormat returned from
10332+ // SymCryptCompositeMlKemSizeofKeyFormatFromParams(params, compositeMlKemkeyFormat, &cbKeyFormat), though typically this
10333+ // value can be known statically (see definition of SYMCRYPT_COMPOSITE_MLKEMKEY_FORMAT)
10334+ //
10335+
10336+ SYMCRYPT_ERROR
10337+ SYMCRYPT_CALL
10338+ SymCryptCompositeMlKemEncapsulate (
10339+ _In_ PCSYMCRYPT_COMPOSITE_MLKEMKEY pkCompositeMlKemkey ,
10340+ _Out_writes_bytes_ ( cbAgreedSecret ) PBYTE pbAgreedSecret ,
10341+ SIZE_T cbAgreedSecret ,
10342+ _Out_writes_bytes_ ( cbCiphertext ) PBYTE pbCiphertext ,
10343+ SIZE_T cbCiphertext );
10344+ //
10345+ // Performs the Encapsulate operation of Composite ML-KEM.
10346+ // This uses the public information of a Composite ML-KEM keypair to generate an agreed secret
10347+ // and a ciphertext. Only a peer with the private information of a Composite ML-KEM keypair can
10348+ // decapsulate the ciphertext to compute the agreed secret.
10349+ //
10350+ // The arguments are the following:
10351+ // - pkCompositeMlKemkey: a key which contains public information required for encapsulation.
10352+ // - (pbAgreedSecret, cbAgreedSecret): a buffer into which the generated secret is written.
10353+ // Currently cbAgreedSecret must be 32 for all parameterizations of Composite ML-KEM.
10354+ // - (pbCiphertext, cbCiphertext): a buffer into which the encapsulated secret is written.
10355+ // cbCiphertext must equal cbCiphertext given by SymCryptCompositeMlKemSizeofCiphertextFromParams,
10356+ // though typically this value can be known statically (see definition of
10357+ // SYMCRYPT_COMPOSITE_MLKEM_CIPHERTEXT_SIZE_*).
10358+ //
10359+
10360+ SYMCRYPT_ERROR
10361+ SYMCRYPT_CALL
10362+ SymCryptCompositeMlKemDecapsulate (
10363+ _In_ PCSYMCRYPT_COMPOSITE_MLKEMKEY pkCompositeMlKemkey ,
10364+ _In_reads_bytes_ ( cbCiphertext ) PCBYTE pbCiphertext ,
10365+ SIZE_T cbCiphertext ,
10366+ _Out_writes_bytes_ ( cbAgreedSecret ) PBYTE pbAgreedSecret ,
10367+ SIZE_T cbAgreedSecret );
10368+ //
10369+ // Performs the Decapsulate operation of Composite ML-KEM.
10370+ // This uses the private information of a Composite ML-KEM keypair to generate an agreed
10371+ // secret from a ciphertext.
10372+ //
10373+ // The arguments are the following:
10374+ // - pkCompositeMlKemkey: a key which contains private information required for decapsulation.
10375+ // - (pbCiphertext, cbCiphertext): a buffer containing an encapsulated secret.
10376+ // cbCiphertext must equal cbCiphertext given by SymCryptCompositeMlKemSizeofCiphertextFromParams,
10377+ // though typically this value can be known statically (see definition of
10378+ // SYMCRYPT_COMPOSITE_MLKEM_CIPHERTEXT_SIZE_*).
10379+ // - (pbAgreedSecret, cbAgreedSecret): a buffer into which the generated secret is written.
10380+ // Currently cbAgreedSecret must be 32 for all parameterizations of Composite ML-KEM.
10381+ //
10382+ // Note: Given an invalid, but correctly-sized, ciphertext, the Composite ML-KEM Decapsulation operation
10383+ // will "implicitly reject" the ciphertext, by returning success in equal time to a valid
10384+ // decapsulation operation, with pseudo-random agreed secret output. This forces higher
10385+ // level protocols to fail later when symmetric keys of peers do not match.
10386+ // So decapsulate will only ever return an error if there are programming errors (e.g. incorrect size),
10387+ // or something fundamentally goes wrong with the environment (e.g. internal memory allocation fails).
10388+ //
10389+
1016710390////////////////////////////////////////////////////////////
1016810391// Module-Lattice-Based Digital Signature Algorithm (ML-DSA)
1016910392////////////////////////////////////////////////////////////
@@ -10445,7 +10668,7 @@ SymCryptHashMlDsaSign(
1044510668// ML-DSA-65 (lambda = 192): SHA-384, SHA-512, SHA3-384, SHA3-512, SHAKE256
1044610669// ML-DSA-87 (lambda = 256): SHA-512, SHA3-512, SHAKE256
1044710670//
10448- // Additionally, cbHash must match the output length of the hash algorithm.
10671+ // Additionally, cbHash must match the output length of the hash algorithm.
1044910672// For XOFs, the any output length >= the minimum collision strength is acceptable. If this
1045010673// requirement is not met, the function returns SYMCRYPT_INVALID_ARGUMENT.
1045110674//
0 commit comments