1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

ssl client/server: add parsing function for key_opaque_algs command line option

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel
2022-04-25 12:42:55 +02:00
parent e6e7bf58d1
commit 85d692d1c4
2 changed files with 48 additions and 0 deletions

View File

@@ -193,6 +193,34 @@ int rng_get( void *p_rng, unsigned char *output, size_t output_len )
#endif /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
}
int key_opaque_alg_parse( const char *arg, const char **alg1, const char **alg2 )
{
char* separator;
if( ( separator = strchr( arg, ',' ) ) == NULL )
return 1;
*separator = '\0';
*alg1 = arg;
*alg2 = separator + 1;
if ( strcmp( *alg1, "rsa-sign-pkcs1" ) != 0 &&
strcmp( *alg1, "rsa-sign-pss" ) != 0 &&
strcmp( *alg1, "rsa-decrypt" ) != 0 &&
strcmp( *alg1, "ecdsa-sign" ) != 0 &&
strcmp( *alg1, "ecdh" ) != 0 )
return 1;
if ( strcmp( *alg2, "rsa-sign-pkcs1" ) != 0 &&
strcmp( *alg2, "rsa-sign-pss" ) != 0 &&
strcmp( *alg2, "rsa-decrypt" ) != 0 &&
strcmp( *alg2, "ecdsa-sign" ) != 0 &&
strcmp( *alg2, "ecdh" ) != 0 &&
strcmp( *alg2, "none" ) != 0 )
return 1;
return 0;
}
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
int ca_callback( void *data, mbedtls_x509_crt const *child,
mbedtls_x509_crt **candidates )