gcry_cipher_algo_name before gcry_cipher_open makes gcry_cipher_open fail

Werner Koch wk at gnupg.org
Sun Sep 12 22:03:40 CEST 2021


Hi!

On Wed,  8 Sep 2021 16:05, Andreas Mattheiss said:

> However swap the two printf statements, i.e. call
> gcry_cipher_algo_name before gcry_cipher_open, and the output is
>
>
> Selected cipher: ?
> Error from opening cipher: 536870924

Which translates to

$ gpg-error 536870924
536870924 = (32, 12) = (GPG_ERR_SOURCE_USER_1, GPG_ERR_CIPHER_ALGO) 

I just tried this myself using my latest libgcrypt 1.9 version and don't
run into any problem.  Please double check that the modified program is
okay:

--8<---------------cut here---------------start------------->8---
#include <gcrypt.h>
#include <stdio.h>

void main() {

gcry_cipher_hd_t handle;
int algo=GCRY_CIPHER_SERPENT128;
int mode=GCRY_CIPHER_MODE_CTR;


printf("Selected cipher: %s \n",gcry_cipher_algo_name (algo));
printf("Error from opening cipher: %i \n",gcry_cipher_open (&handle,
algo, mode, 0));

}
--8<---------------cut here---------------end--------------->8---

I used

  $ gcc x.c -lgcrypt
  $ ./a.out

with gcc (Debian 8.3.0-6) 8.3.0

and also tried runtime linked with different library version.


Shalom-Salam,

   Werner


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gcrypt-devel/attachments/20210912/f29772e8/attachment.sig>


More information about the Gcrypt-devel mailing list