@@ -2267,19 +2267,19 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
22672267 XMEMCPY (& dest -> tpmKey , & src -> tpmKey , sizeof (WOLFTPM2_KEYBLOB ));
22682268
22692269 /* Initialize TPM handle to NULL for the destination */
2270- dest -> tpmKey . handle .hndl = TPM_RH_NULL ;
2270+ dest -> tpmKey -> handle .hndl = TPM_RH_NULL ;
22712271
22722272 /* Initialize the wolf key structures based on key type */
22732273 switch (src -> type ) {
22742274#ifndef NO_RSA
22752275 case CKK_RSA :
2276- ret = wc_InitRsaKey_ex (& dest -> data . rsaKey , NULL ,
2276+ ret = wc_InitRsaKey_ex (& dest -> data -> rsaKey , NULL ,
22772277 dest -> slot -> devId );
22782278 break ;
22792279#endif
22802280#ifdef HAVE_ECC
22812281 case CKK_EC :
2282- ret = wc_ecc_init_ex (& dest -> data . ecKey , NULL ,
2282+ ret = wc_ecc_init_ex (& dest -> data -> ecKey , NULL ,
22832283 dest -> slot -> devId );
22842284 break ;
22852285#endif
@@ -2294,14 +2294,14 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
22942294 case CKK_RSA :
22952295 /* Load public portion into wolf RsaKey structure */
22962296 ret = wolfTPM2_RsaKey_TpmToWolf (& dest -> slot -> tpmDev ,
2297- (WOLFTPM2_KEY * )& dest -> tpmKey , & dest -> data . rsaKey );
2297+ (WOLFTPM2_KEY * )& dest -> tpmKey , dest -> data -> rsaKey );
22982298 break ;
22992299#endif
23002300#ifdef HAVE_ECC
23012301 case CKK_EC :
23022302 /* Load public portion into wolf EccKey structure */
23032303 ret = wolfTPM2_EccKey_TpmToWolf (& dest -> slot -> tpmDev ,
2304- (WOLFTPM2_KEY * )& dest -> tpmKey , & dest -> data . ecKey );
2304+ (WOLFTPM2_KEY * )& dest -> tpmKey , dest -> data -> ecKey );
23052305 break ;
23062306#endif
23072307 default :
@@ -2320,18 +2320,18 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
23202320 int derSz = 0 ;
23212321
23222322 /* Initialize destination RSA key */
2323- ret = wc_InitRsaKey_ex (& dest -> data .rsaKey , NULL ,
2323+ ret = wc_InitRsaKey_ex (dest -> data .rsaKey , NULL ,
23242324 dest -> slot -> devId );
23252325 if (ret != 0 )
23262326 break ;
23272327
23282328 /* Determine if this is a private or public key and get DER
23292329 * size */
23302330 if (src -> objClass == CKO_PRIVATE_KEY ) {
2331- ret = wc_RsaKeyToDer (& src -> data .rsaKey , NULL , 0 );
2331+ ret = wc_RsaKeyToDer (src -> data .rsaKey , NULL , 0 );
23322332 }
23332333 else {
2334- ret = wc_RsaKeyToPublicDer (& src -> data .rsaKey , NULL , 0 );
2334+ ret = wc_RsaKeyToPublicDer (src -> data .rsaKey , NULL , 0 );
23352335 }
23362336
23372337 if (ret == 0 ) /* Should not happen */
@@ -2349,10 +2349,11 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
23492349 if (ret == 0 ) {
23502350 /* Encode the source key to DER */
23512351 if (src -> objClass == CKO_PRIVATE_KEY ) {
2352- ret = wc_RsaKeyToDer (& src -> data .rsaKey , derBuf , derSz );
2352+ ret = wc_RsaKeyToDer (src -> data .rsaKey , derBuf ,
2353+ derSz );
23532354 }
23542355 else {
2355- ret = wc_RsaKeyToPublicDer (& src -> data .rsaKey , derBuf ,
2356+ ret = wc_RsaKeyToPublicDer (src -> data .rsaKey , derBuf ,
23562357 derSz );
23572358 }
23582359 if (ret == 0 ) /* Should not happen */
@@ -2365,12 +2366,12 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
23652366 word32 idx = 0 ;
23662367 if (src -> objClass == CKO_PRIVATE_KEY ) {
23672368 ret = wc_RsaPrivateKeyDecode (derBuf , & idx ,
2368- & dest -> data .rsaKey ,
2369+ dest -> data .rsaKey ,
23692370 (word32 )derSz );
23702371 }
23712372 else {
23722373 ret = wc_RsaPublicKeyDecode (derBuf , & idx ,
2373- & dest -> data .rsaKey ,
2374+ dest -> data .rsaKey ,
23742375 (word32 )derSz );
23752376 }
23762377 }
@@ -2385,17 +2386,17 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
23852386 int derSz = 0 ;
23862387
23872388 /* Initialize destination ECC key */
2388- ret = wc_ecc_init_ex (& dest -> data .ecKey , NULL ,
2389+ ret = wc_ecc_init_ex (dest -> data .ecKey , NULL ,
23892390 dest -> slot -> devId );
23902391 if (ret != 0 )
23912392 break ;
23922393
23932394 /* Determine if this is a private or public key and get DER
23942395 * size */
23952396 if (src -> objClass == CKO_PRIVATE_KEY )
2396- derSz = wc_EccKeyDerSize (& src -> data .ecKey , 0 );
2397+ derSz = wc_EccKeyDerSize (src -> data .ecKey , 0 );
23972398 else
2398- derSz = wc_EccPublicKeyDerSize (& src -> data .ecKey , 1 );
2399+ derSz = wc_EccPublicKeyDerSize (src -> data .ecKey , 1 );
23992400
24002401 if (derSz < 0 )
24012402 ret = derSz ;
@@ -2411,11 +2412,11 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
24112412 if (ret == 0 ) {
24122413 /* Encode the source key to DER with retry logic */
24132414 if (src -> objClass == CKO_PRIVATE_KEY ) {
2414- ret = wc_EccPrivateKeyToDer (& src -> data .ecKey ,
2415+ ret = wc_EccPrivateKeyToDer (src -> data .ecKey ,
24152416 derBuf , derSz );
24162417 }
24172418 else {
2418- ret = wc_EccPublicKeyToDer (& src -> data .ecKey , derBuf ,
2419+ ret = wc_EccPublicKeyToDer (src -> data .ecKey , derBuf ,
24192420 derSz , 1 );
24202421 }
24212422
@@ -2431,12 +2432,12 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
24312432 word32 idx = 0 ;
24322433 if (src -> objClass == CKO_PRIVATE_KEY ) {
24332434 ret = wc_EccPrivateKeyDecode (derBuf , & idx ,
2434- & dest -> data .ecKey ,
2435+ dest -> data .ecKey ,
24352436 (word32 )derSz );
24362437 }
24372438 else {
24382439 ret = wc_EccPublicKeyDecode (derBuf , & idx ,
2439- & dest -> data .ecKey ,
2440+ dest -> data .ecKey ,
24402441 (word32 )derSz );
24412442 }
24422443 }
@@ -2449,7 +2450,7 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
24492450
24502451 /* Free destination key on failure */
24512452 if (ret != 0 ) {
2452- wc_ecc_free (& dest -> data .ecKey );
2453+ wc_ecc_free (dest -> data .ecKey );
24532454 }
24542455
24552456 break ;
@@ -2466,8 +2467,9 @@ int WP11_Object_Copy(WP11_Object *src, WP11_Object *dest)
24662467 case CKK_HKDF :
24672468#endif
24682469 case CKK_GENERIC_SECRET :
2469- XMEMCPY (& dest -> data .symmKey , & src -> data .symmKey ,
2470- sizeof (dest -> data .symmKey ));
2470+ XMEMCPY (dest -> data .symmKey -> data , src -> data .symmKey -> data ,
2471+ src -> data .symmKey -> len );
2472+ dest -> data .symmKey -> len = src -> data .symmKey -> len ;
24712473 break ;
24722474 }
24732475 }
@@ -6767,7 +6769,7 @@ int WP11_Session_SetAesWrapParams(WP11_Session* session, byte* iv, word32 ivLen,
67676769 if (ret == 0 ) {
67686770 if (object -> onToken )
67696771 WP11_Lock_LockRO (object -> lock );
6770- key = & object -> data .symmKey ;
6772+ key = object -> data .symmKey ;
67716773 ret = wc_AesSetKey (& wrap -> aes , key -> data , key -> len , NULL ,
67726774 enc ? AES_ENCRYPTION : AES_DECRYPTION );
67736775 if (object -> onToken )
@@ -9952,7 +9954,7 @@ int WP11_Rsa_Verify_Recover(CK_MECHANISM_TYPE mechanism, unsigned char* sig,
99529954 switch (mechanism ) {
99539955 case CKM_RSA_PKCS :
99549956 ret = wc_RsaSSL_Verify (sig , sigLen , out , (word32 )* outLen ,
9955- & pub -> data .rsaKey );
9957+ pub -> data .rsaKey );
99569958 if (ret == RSA_BUFFER_E )
99579959 return CKR_BUFFER_TOO_SMALL ;
99589960 if (ret < 0 )
@@ -9965,7 +9967,7 @@ int WP11_Rsa_Verify_Recover(CK_MECHANISM_TYPE mechanism, unsigned char* sig,
99659967 byte * data_out = NULL ;
99669968 byte * pos ;
99679969 ret = wc_RsaDirect (sig , sigLen , out , (word32 * )outLen ,
9968- & pub -> data .rsaKey , RSA_PUBLIC_DECRYPT , NULL );
9970+ pub -> data .rsaKey , RSA_PUBLIC_DECRYPT , NULL );
99699971 if (ret < 0 )
99709972 return CKR_FUNCTION_FAILED ;
99719973 /* Result is front padded with 0x00 */
@@ -10641,7 +10643,7 @@ int WP11_EC_Derive(unsigned char* point, word32 pointLen, unsigned char* key,
1064110643 #endif
1064210644 {
1064310645 PRIVATE_KEY_UNLOCK ();
10644- ret = wc_ecc_shared_secret (& priv -> data .ecKey , & pubKey , key , keyLen );
10646+ ret = wc_ecc_shared_secret (priv -> data .ecKey , & pubKey , key , keyLen );
1064510647 PRIVATE_KEY_LOCK ();
1064610648
1064710649 #ifdef WOLFPKCS11_TPM
@@ -10747,8 +10749,8 @@ int WP11_KDF_Derive(WP11_Session* session, CK_HKDF_PARAMS_PTR params,
1074710749 privLen = priv -> data .genericData .dataLen ;
1074810750 }
1074910751 else {
10750- privData = priv -> data .symmKey . data ;
10751- privLen = priv -> data .symmKey . len ;
10752+ privData = priv -> data .symmKey -> data ;
10753+ privLen = priv -> data .symmKey -> len ;
1075210754 }
1075310755 if (params -> bExtract && !params -> bExpand ) {
1075410756 ret = wc_HKDF_Extract (hashType , salt , (word32 )saltLen ,
0 commit comments