@@ -56,7 +56,26 @@ const POLICY_C_SM3_256: [u8; 32] = [
5656 0x56 , 0x99 , 0xa3 , 0xe3 , 0x9f , 0xc3 , 0x55 , 0x1b , 0xfe , 0xff , 0xcf , 0x13 , 0x2b , 0x49 , 0xe1 , 0x1d ,
5757] ;
5858
59+ /// Creates a Public object for an AK key.
5960fn create_ak_public < IKC : IntoKeyCustomization > (
61+ key_alg : AsymmetricAlgorithm ,
62+ hash_alg : HashingAlgorithm ,
63+ sign_alg : SignatureSchemeAlgorithm ,
64+ key_customization : IKC ,
65+ ) -> Result < Public > {
66+ create_ak_public_2 (
67+ AsymmetricAlgorithmSelection :: try_from ( key_alg) ?,
68+ hash_alg,
69+ sign_alg,
70+ key_customization,
71+ )
72+ }
73+
74+ /// Creates a Public object for an AK key.
75+ ///
76+ /// # Details
77+ /// This is only replace the `create_ak` API in the next major version.
78+ fn create_ak_public_2 < IKC : IntoKeyCustomization > (
6079 key_alg : AsymmetricAlgorithmSelection ,
6180 hash_alg : HashingAlgorithm ,
6281 sign_alg : SignatureSchemeAlgorithm ,
@@ -228,8 +247,36 @@ pub fn load_ak(
228247 Ok ( key_handle)
229248}
230249
231- /// This creates an Attestation Key in the Endorsement hierarchy
250+ /// This creates an Attestation Key in the Endorsement hierarchy.
232251pub fn create_ak < IKC : IntoKeyCustomization > (
252+ context : & mut Context ,
253+ parent : KeyHandle ,
254+ hash_alg : HashingAlgorithm ,
255+ sign_alg : SignatureSchemeAlgorithm ,
256+ ak_auth_value : Option < Auth > ,
257+ key_customization : IKC ,
258+ ) -> Result < CreateKeyResult > {
259+ let key_alg = AsymmetricAlgorithm :: try_from ( sign_alg) . map_err ( |e| {
260+ // sign_alg is either HMAC or Null.
261+ error ! ( "Could not retrieve asymmetric algorithm for provided signature scheme" ) ;
262+ e
263+ } ) ?;
264+ create_ak_2 (
265+ context,
266+ parent,
267+ hash_alg,
268+ AsymmetricAlgorithmSelection :: try_from ( key_alg) ?,
269+ sign_alg,
270+ ak_auth_value,
271+ key_customization,
272+ )
273+ }
274+
275+ /// This creates an Attestation Key in the Endorsement hierarchy.
276+ ///
277+ /// # Details
278+ /// This is only replace the `create_ak` API in the next major version.
279+ pub fn create_ak_2 < IKC : IntoKeyCustomization > (
233280 context : & mut Context ,
234281 parent : KeyHandle ,
235282 hash_alg : HashingAlgorithm ,
0 commit comments