@@ -1062,24 +1062,22 @@ static CK_RV p11_rsa_ctx_init( mbedtls_pk_context * pk,
10621062 xResult = CKR_FUNCTION_FAILED ;
10631063 }
10641064
1065- /*
1066- * TODO: corePKCS11 does not allow exporting RSA public attributes.
1067- * This function should be updated to properly initialize the
1068- * mbedtls_rsa_context when this is addressed.
1069- */
1070-
1071- /* CK_ATTRIBUTE pxAttrs[ 2 ] = */
1072- /* { */
1073- /* { .type = CKA_MODULUS, .ulValueLen = 0, .pValue = NULL }, */
1074- /* { .type = CKA_PUBLIC_EXPONENT, .ulValueLen = 0, .pValue = NULL }, */
1075- /* { .type = CKA_PRIME_1, .ulValueLen = 0, .pValue = NULL }, */
1076- /* { .type = CKA_PRIME_2, .ulValueLen = 0, .pValue = NULL }, */
1077- /* { .type = CKA_EXPONENT_1, .ulValueLen = 0, .pValue = NULL }, */
1078- /* { .type = CKA_EXPONENT_2, .ulValueLen = 0, .pValue = NULL }, */
1079- /* { .type = CKA_COEFFICIENT, .ulValueLen = 0, .pValue = NULL }, */
1080- /* }; */
1081-
1082- ( void ) pxMbedRsaCtx ;
1065+ CK_ATTRIBUTE pxAttrs [ 8 ] =
1066+ {
1067+ { .type = CKA_MODULUS , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> N ) },
1068+ { .type = CKA_PUBLIC_EXPONENT , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> E ) },
1069+ { .type = CKA_PRIME_1 , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> P ) },
1070+ { .type = CKA_PRIME_2 , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> Q ) },
1071+ { .type = CKA_PRIVATE_EXPONENT , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> D ) },
1072+ { .type = CKA_EXPONENT_1 , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> DP ) },
1073+ { .type = CKA_EXPONENT_2 , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> DQ ) },
1074+ { .type = CKA_COEFFICIENT , .ulValueLen = sizeof ( mbedtls_mpi ), .pValue = & ( pxMbedRsaCtx -> QP ) },
1075+ };
1076+
1077+ xResult = pxFunctionList -> C_GetAttributeValue ( xSessionHandle ,
1078+ xPkHandle ,
1079+ pxAttrs ,
1080+ sizeof ( pxAttrs ) / sizeof ( CK_ATTRIBUTE ) );
10831081
10841082 if ( xResult == CKR_OK )
10851083 {
0 commit comments