@@ -1188,160 +1188,3 @@ int wh_Client_CounterDestroy(whClientContext* c, whNvmId counterId)
11881188 }
11891189 return ret ;
11901190}
1191-
1192- #if 0
1193- #ifndef WOLFHSM_CFG_NO_CRYPTO
1194-
1195- #ifdef HAVE_CURVE25519
1196- int wh_Client_SetKeyIdCurve25519 (curve25519_key * key , whNvmId keyId )
1197- {
1198- if (key == NULL )
1199- return WH_ERROR_BADARGS ;
1200- key -> devCtx = (void * )((intptr_t )keyId );
1201- key -> pubSet = 1 ;
1202- key -> privSet = 1 ;
1203- return WH_ERROR_OK ;
1204- }
1205-
1206- int wh_Client_GetKeyIdCurve25519 (curve25519_key * key , whNvmId * outId )
1207- {
1208- if (key == NULL || outId == NULL )
1209- return WH_ERROR_BADARGS ;
1210- * outId = (intptr_t )key -> devCtx ;
1211- return WH_ERROR_OK ;
1212- }
1213- #endif /* HAVE_CURVE25519 */
1214-
1215- #ifndef NO_RSA
1216- int wh_Client_SetKeyIdRsa (RsaKey * key , whNvmId keyId )
1217- {
1218- if (key == NULL )
1219- return WH_ERROR_BADARGS ;
1220- key -> devCtx = (void * )((intptr_t )keyId );
1221- return WH_ERROR_OK ;
1222- }
1223-
1224- int wh_Client_GetKeyIdRsa (RsaKey * key , whNvmId * outId )
1225- {
1226- if (key == NULL || outId == NULL )
1227- return WH_ERROR_BADARGS ;
1228- * outId = (intptr_t )key -> devCtx ;
1229- return WH_ERROR_OK ;
1230- }
1231- #endif
1232-
1233- #ifndef NO_AES
1234- int wh_Client_SetKeyIdAes (Aes * key , whNvmId keyId )
1235- {
1236- if (key == NULL )
1237- return WH_ERROR_BADARGS ;
1238- key -> devCtx = (void * )((intptr_t )keyId );
1239- return WH_ERROR_OK ;
1240- }
1241-
1242- int wh_Client_GetKeyIdAes (Aes * key , whNvmId * outId )
1243- {
1244- if (key == NULL || outId == NULL )
1245- return WH_ERROR_BADARGS ;
1246- * outId = (intptr_t )key -> devCtx ;
1247- return WH_ERROR_OK ;
1248- }
1249- #endif
1250-
1251- #ifdef WOLFSSL_CMAC
1252- int wh_Client_SetKeyIdCmac (Cmac * key , whNvmId keyId )
1253- {
1254- if (key == NULL )
1255- return WH_ERROR_BADARGS ;
1256- key -> devCtx = (void * )((intptr_t )keyId );
1257- return WH_ERROR_OK ;
1258- }
1259-
1260- int wh_Client_GetKeyIdCmac (Cmac * key , whNvmId * outId )
1261- {
1262- if (key == NULL || outId == NULL )
1263- return WH_ERROR_BADARGS ;
1264- * outId = (intptr_t )key -> devCtx ;
1265- return WH_ERROR_OK ;
1266- }
1267-
1268- int wh_Client_AesCmacGenerate (Cmac * cmac , byte * out , word32 * outSz ,
1269- const byte * in , word32 inSz , whNvmId keyId , void * heap )
1270- {
1271- int ret ;
1272- ret = wc_InitCmac_ex (cmac , NULL , 0 , WC_CMAC_AES , NULL , heap ,
1273- WH_DEV_ID );
1274- /* set keyId */
1275- if (ret == 0 )
1276- ret = wh_Client_SetKeyIdCmac (cmac , keyId );
1277- if (ret == 0 )
1278- ret = wc_CmacUpdate (cmac , in , inSz );
1279- if (ret == 0 )
1280- ret = wc_CmacFinal (cmac , out , outSz );
1281- return ret ;
1282- }
1283-
1284- int wh_Client_AesCmacVerify (Cmac * cmac , const byte * check , word32 checkSz ,
1285- const byte * in , word32 inSz , whNvmId keyId , void * heap )
1286- {
1287- int ret ;
1288- word32 outSz = AES_BLOCK_SIZE ;
1289- byte out [AES_BLOCK_SIZE ];
1290- ret = wc_InitCmac_ex (cmac , NULL , 0 , WC_CMAC_AES , NULL , heap ,
1291- WH_DEV_ID );
1292- /* set keyId */
1293- if (ret == 0 )
1294- ret = wh_Client_SetKeyIdCmac (cmac , keyId );
1295- if (ret == 0 )
1296- ret = wc_CmacUpdate (cmac , in , inSz );
1297- if (ret == 0 )
1298- ret = wc_CmacFinal (cmac , out , & outSz );
1299- if (ret == 0 )
1300- ret = memcmp (out , check , outSz ) == 0 ? 0 : 1 ;
1301- return ret ;
1302- }
1303-
1304- int wh_Client_CmacCancelableResponse (whClientContext * c , Cmac * cmac ,
1305- uint8_t * out , uint16_t * outSz )
1306- {
1307- whPacket * packet ;
1308- uint8_t * packOut ;
1309- int ret ;
1310- uint16_t group ;
1311- uint16_t action ;
1312- uint16_t dataSz ;
1313- if (c == NULL || cmac == NULL )
1314- return WH_ERROR_BADARGS ;
1315- packet = (whPacket * )wh_CommClient_GetDataPtr (c -> comm );
1316- /* out is after the fixed size fields */
1317- packOut = (uint8_t * )(& packet -> cmacRes + 1 );
1318- do {
1319- ret = wh_Client_RecvResponse (c , & group , & action , & dataSz ,
1320- (uint8_t * )packet );
1321- } while (ret == WH_ERROR_NOTREADY );
1322- /* check for out of sequence action */
1323- if (ret == 0 && (group != WH_MESSAGE_GROUP_CRYPTO ||
1324- action != WC_ALGO_TYPE_CMAC )) {
1325- ret = WH_ERROR_ABORTED ;
1326- }
1327- if (ret == 0 ) {
1328- if (packet -> rc != 0 )
1329- ret = packet -> rc ;
1330- /* read keyId and out */
1331- else {
1332- cmac -> devCtx = (void * )((intptr_t )packet -> cmacRes .keyId );
1333- if (out != NULL ) {
1334- if (packet -> cmacRes .outSz > * outSz )
1335- ret = WH_ERROR_BADARGS ;
1336- else {
1337- XMEMCPY (out , packOut , packet -> cmacRes .outSz );
1338- * outSz = packet -> cmacRes .outSz ;
1339- }
1340- }
1341- }
1342- }
1343- return ret ;
1344- }
1345- #endif /* WOLFSSL_CMAC */
1346- #endif /* !WOLFHSM_CFG_NO_CRYPTO */
1347- #endif /*0*/
0 commit comments