segmentation fault while checking algorithm from which provider being used

Ishani 18r01a05n6 at gmail.com
Tue Jul 18 18:37:49 UTC 2023


Hi All,

    I'm trying to get provider name to know which provider algo
implementation is being used but I'm facing segmentation fault issue. Here
is my code

EVP_CIPHER_CTX *ect = EVP_CIPHER_CTX_new();
if(ect == NULL){
return err;
}
const EVP_CIPHER *c = EVP_CIPHER_fetch(NULL,(char *)cipher_name,NULL);
if(c == NULL){
return err;
}
int ret = EVP_CipherInit_ex(ect, c, NULL, Key, IV, 1);  // no IV  provided
if(!ret){
return err;
}

const EVP_CIPHER *ctx = EVP_CIPHER_CTX_get0_cipher(ect);

if(ctx != NULL){

 const OSSL_PROVIDER *ossl_prov = EVP_CIPHER_get0_provider(ctx);

 if(ossl_prov != NULL){

const char *provname = OSSL_PROVIDER_get0_name(ossl_prov);

printf("The provider used is : %s",provname);
  }

}

*Little more details:*
It's failing while printing provname, while debugging it step by step and
trying to print OSSL_PROVIDER_get0_name(ossl_prov) is printing default (ran
command : p OSSL_PROVIDER_get0_name(ossl_prov)) but failing while printing
provname. I don't see any issues with provname variable definition and it's
usage.

Initially I was testing with loading fips provider programmatically , I
assumed it didn't work as some deprecated API's were also being used and
invoked before the above code is executed in the application (as mentioned
in openssl document that if deprecated API's like engines are used then
fips cannot be used so was expecting that fips will not load but it's
loading successfully and also encryption/decryption working fine somehow ).

At what point fips will not work if deprecated API's like engines are used?

Also, similar error i.e; segmentation fault is being thrown with
default,legacy providers as well.

Tried printing directly the output like
printf(OSSL_PROVIDER_get0_name(ossl_prov)) or  printf("%s",
OSSL_PROVIDER_get0_name(ossl_prov)) or
printf(OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(EVP_CIPHER_CTX_get0_cipher(ect))))
but still same issue 😔.

tried many other things but still same issue...

Any idea what wrong am I doing? any help/suggestions please?

Regards
Ishani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mta.openssl.org/pipermail/openssl-users/attachments/20230719/0fc11415/attachment.htm>


More information about the openssl-users mailing list