@@ -958,6 +958,36 @@ int test_ecdsa_p192_pkey(void *data)
958958 pkey = d2i_PrivateKey (EVP_PKEY_EC , NULL , & p , sizeof (ecc_key_der_192 ));
959959 err = pkey == NULL ;
960960 }
961+ #if defined(HAVE_FIPS ) || defined(HAVE_FIPS_VERSION )
962+ /* In FIPS mode, P-192 operations are not allowed, so we expect all operations to fail */
963+ if (err == 0 ) {
964+ PRINT_MSG ("Sign with OpenSSL" );
965+ ecdsaSigLen = sizeof (ecdsaSig );
966+ err = test_pkey_sign_ecc (pkey , osslLibCtx , buf , sizeof (buf ), ecdsaSig ,
967+ & ecdsaSigLen );
968+ /* OpenSSL should also reject P-192 in FIPS mode */
969+ err = err != 1 ;
970+ if (err == 0 ) {
971+ PRINT_MSG ("OpenSSL sign failed, expected (P-192 not allowed w/ FIPS)" );
972+ }
973+ else {
974+ PRINT_MSG ("OpenSSL sign succeeded, unexpected (P-192 not allowed w/ FIPS)" );
975+ }
976+ }
977+ if (err == 0 ) {
978+ PRINT_MSG ("Sign with wolfprovider" );
979+ ecdsaSigLen = sizeof (ecdsaSig );
980+ err = test_pkey_sign_ecc (pkey , wpLibCtx , buf , sizeof (buf ), ecdsaSig ,
981+ & ecdsaSigLen );
982+ err = err != 1 ;
983+ if (err == 0 ) {
984+ PRINT_MSG ("ECDSA failed, expected (P-192 not allowed w/ FIPS)" );
985+ }
986+ else {
987+ PRINT_MSG ("ECDSA succeeded, unexpected (P-192 not allowed w/ FIPS)" );
988+ }
989+ }
990+ #else
961991 if (err == 0 ) {
962992 PRINT_MSG ("Sign with OpenSSL" );
963993 ecdsaSigLen = sizeof (ecdsaSig );
@@ -982,17 +1012,6 @@ int test_ecdsa_p192_pkey(void *data)
9821012 ecdsaSigLen = sizeof (ecdsaSig );
9831013 err = test_pkey_sign_ecc (pkey , wpLibCtx , buf , sizeof (buf ), ecdsaSig ,
9841014 & ecdsaSigLen );
985- #if defined(HAVE_FIPS ) || defined(HAVE_FIPS_VERSION )
986- err = err != 1 ;
987- if (err == 0 ) {
988- PRINT_MSG ("ECDSA failed, expected (P-192 not allowed w/ FIPS)" );
989- }
990- else {
991- PRINT_MSG ("ECDSA succeeded, unexpected (P-192 not allowed w/ "
992- "FIPS)" );
993- }
994- }
995- #else
9961015 }
9971016 if (err == 0 ) {
9981017 PRINT_MSG ("Verify with OpenSSL" );
@@ -1250,6 +1269,37 @@ int test_ecdsa_p192(void *data)
12501269 pkey = d2i_PrivateKey (EVP_PKEY_EC , NULL , & p , sizeof (ecc_key_der_192 ));
12511270 err = pkey == NULL ;
12521271 }
1272+ #if defined(HAVE_FIPS ) || defined(HAVE_FIPS_VERSION )
1273+ /* In FIPS mode, P-192 operations are not allowed, so we expect all operations to fail */
1274+ if (err == 0 ) {
1275+ PRINT_MSG ("Sign with OpenSSL" );
1276+ ecdsaSigLen = sizeof (ecdsaSig );
1277+ err = test_digest_sign (pkey , osslLibCtx , buf , sizeof (buf ), md ,
1278+ ecdsaSig , & ecdsaSigLen , 0 );
1279+ /* OpenSSL should also reject P-192 in FIPS mode */
1280+ err = err != 1 ;
1281+ if (err == 0 ) {
1282+ PRINT_MSG ("OpenSSL sign failed, expected (P-192 not allowed w/ FIPS)" );
1283+ }
1284+ else {
1285+ PRINT_MSG ("OpenSSL sign succeeded, unexpected (P-192 not allowed w/ FIPS)" );
1286+ }
1287+ }
1288+ if (err == 0 ) {
1289+ PRINT_MSG ("Sign with wolfprovider" );
1290+ ecdsaSigLen = sizeof (ecdsaSig );
1291+ err = test_digest_sign (pkey , wpLibCtx , buf , sizeof (buf ), md ,
1292+ ecdsaSig , & ecdsaSigLen , 0 );
1293+ err = err != 1 ;
1294+ if (err == 0 ) {
1295+ PRINT_MSG ("ECDSA failed, expected (P-192 not allowed w/ FIPS)" );
1296+ }
1297+ else {
1298+ PRINT_MSG ("ECDSA succeeded, unexpected (P-192 not allowed w/ "
1299+ "FIPS)" );
1300+ }
1301+ }
1302+ #else
12531303 if (err == 0 ) {
12541304 PRINT_MSG ("Sign with OpenSSL" );
12551305 ecdsaSigLen = sizeof (ecdsaSig );
@@ -1275,17 +1325,6 @@ int test_ecdsa_p192(void *data)
12751325 ecdsaSigLen = sizeof (ecdsaSig );
12761326 err = test_digest_sign (pkey , wpLibCtx , buf , sizeof (buf ), md ,
12771327 ecdsaSig , & ecdsaSigLen , 0 );
1278- #if defined(HAVE_FIPS ) || defined(HAVE_FIPS_VERSION )
1279- err = err != 1 ;
1280- if (err == 0 ) {
1281- PRINT_MSG ("ECDSA failed, expected (P-192 not allowed w/ FIPS)" );
1282- }
1283- else {
1284- PRINT_MSG ("ECDSA succeeded, unexpected (P-192 not allowed w/ "
1285- "FIPS)" );
1286- }
1287- }
1288- #else
12891328 }
12901329 if (err == 0 ) {
12911330 PRINT_MSG ("Verify with OpenSSL" );
0 commit comments