ssl_server2: use key opaque algs given from command line
@@ -2596,6 +2596,20 @@ int main( int argc, char *argv[] )
psa_algorithm_t psa_alg, psa_alg2;
psa_key_usage_t psa_usage;
+ if ( strcmp( opt.key1_opaque_alg1, DFL_KEY_OPAQUE_ALG ) != 0 )
+ {
+ ret = key_opaque_set_alg_usage( opt.key1_opaque_alg1,
+ opt.key1_opaque_alg2,
+ &psa_alg, &psa_alg2, &psa_usage );
+ if( ret != 0 )
+ {
+ mbedtls_printf( " failed\n ! key_opaque_set_alg_usage returned -0x%x\n\n",
+ (unsigned int) -ret );
+ goto exit;
+ }
+ }
+ else
+ {
if ( mbedtls_pk_get_type( &pkey ) == MBEDTLS_PK_ECKEY ||
mbedtls_pk_get_type( &pkey ) == MBEDTLS_PK_RSA )
{
@@ -2611,6 +2625,8 @@ int main( int argc, char *argv[] )
psa_alg2 = PSA_ALG_NONE;
psa_usage = PSA_KEY_USAGE_SIGN_HASH;
}
+ }
+ }
if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey, &key_slot,
psa_alg,
@@ -2621,8 +2637,22 @@ int main( int argc, char *argv[] )
"mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
- }
+
+ if ( strcmp( opt.key2_opaque_alg1, DFL_KEY_OPAQUE_ALG ) != 0 )
+ {
+ ret = key_opaque_set_alg_usage( opt.key2_opaque_alg1,
+ opt.key2_opaque_alg2,
+ &psa_alg, &psa_alg2, &psa_usage );
+ if( ret != 0 )
+ {
+ mbedtls_printf( " failed\n ! key_opaque_set_alg_usage returned -0x%x\n\n",
+ (unsigned int) -ret );
+ goto exit;
+ }
+ }
+ else
+ {
if ( mbedtls_pk_get_type( &pkey2 ) == MBEDTLS_PK_ECKEY ||
mbedtls_pk_get_type( &pkey2 ) == MBEDTLS_PK_RSA )
{
@@ -2638,6 +2668,8 @@ int main( int argc, char *argv[] )
psa_alg2 = PSA_ALG_NONE;
psa_usage = PSA_KEY_USAGE_SIGN_HASH;
}
+ }
+ }
if( ( ret = mbedtls_pk_wrap_as_opaque( &pkey2, &key_slot2,
psa_alg,
@@ -2649,7 +2681,6 @@ int main( int argc, char *argv[] )
goto exit;
}
}
- }
#endif /* MBEDTLS_USE_PSA_CRYPTO */
mbedtls_printf( " ok (key types: %s, %s)\n",
