Skip to contentSkip to conversation

Question about error codes

DISCUSSION Erik Lotspeich 3 participants 4 messages Jun 16, 2009 – Jun 17, 2009 Crypto API

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a question about the meaning of the error codes returned by the Linux kernel crypto API. In particular, I am interested in the codes returned by crypto_ablkcipher_encrypt() & crypto_ablkcipher_decrypt(). I am receiving a return value of 22 from crypto_ablkcipher_encrypt. I would like to find what this means. I don't get this error code consistently, so I'm trying to find out if I am using the API incorrectly; I'm using the test code, tcrypt.c, as a guide.

I looked through the source, but it was not obvious in the code where these error codes were coming from; I did not see them enumerated in a header file either.

Any help would be greatly appreciated.

Regards,

Erik
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAko3zJMACgkQY21D/n6bGwc6QACgoXNEKl1xWtADpXzBexeJfokT N4cAoJdEElT7Ko1sjEoPfxkh5DCg14YD
=2kfv
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 1 line · * Erik Lotspeich | 2009-06-16 11:47:15 [-0500]:

Hi,

Hi,

Quoted 5 lines

I have a question about the meaning of the error codes returned by the Linux kernel crypto API. In particular, I am interested in the codes returned by crypto_ablkcipher_encrypt() & crypto_ablkcipher_decrypt(). I am receiving a return value of 22 from crypto_ablkcipher_encrypt. I

I thing you mean -22 and that one means
| #define EINVAL 22 /* Invalid argument */

You can look them up in include/asm-generic/errno-base.h _or_ strerror() in userland.

Quoted 3 lines

would like to find what this means. I don't get this error code consistently, so I'm trying to find out if I am using the API incorrectly; I'm using the test code, tcrypt.c, as a guide.

So you are using an older kernel. Starting with v2.6.28 that part of tcrypt moved to test_skcipher() in crypto/testmgr.c. Hoewever, the logic as it did not change.

Quoted 3 lines

I looked through the source, but it was not obvious in the code where these error codes were coming from; I did not see them enumerated in a header file either.

It besically depends on the algorithm you are using. So in case of cbc(aes) you go through
crypto_ablkcipher_encrypt -> crypto_cbc_encrypt -> aes_encrypt
plus a little API in between tof those calls.

Quoted 1 line

Any help would be greatly appreciated.

I guess the number of bytes to decrypt/encrypt ist not always a modulos of the blockmode.

Quoted 3 lines

Regards,

Erik

Sebastian

maintainer
#2 lore raw
Quoted 4 lines · Sebastian Andrzej Siewior
Quoted 2 lines

Any help would be greatly appreciated.

I guess the number of bytes to decrypt/encrypt ist not always a modulos of the blockmode.

Yes that's probably what it is.

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Herbert, Sebastian:

Thanks so much for your response; your answers were very helpful!

Regards,

Erik.

Quoted 8 lines · Herbert Xu
Quoted 3 lines · Sebastian Andrzej Siewior
Quoted 1 line

Any help would be greatly appreciated.

I guess the number of bytes to decrypt/encrypt ist not always a modulos of the blockmode.

Yes that's probably what it is.

Thanks,

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAko4hYcACgkQY21D/n6bGwc6SACgu9Su2ba1BXJ/xh/+DpwzTpRi 5jYAoKvs9INfBmAaY8ZQDn85j8eu7W3F
=vNQ9
-----END PGP SIGNATURE-----