2009-06-16 17:46:01

by Erik Lotspeich

[permalink] [raw]
Subject: Question about error codes

-----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-----


Subject: Re: Question about error codes

* Erik Lotspeich | 2009-06-16 11:47:15 [-0500]:

>Hi,
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
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.

>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.

>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.


>Any help would be greatly appreciated.
I guess the number of bytes to decrypt/encrypt ist not always a modulos
of the blockmode.

>Regards,
>
>Erik

Sebastian

2009-06-17 01:52:53

by Herbert Xu

[permalink] [raw]
Subject: Re: Question about error codes

On Tue, Jun 16, 2009 at 10:34:06PM +0200, Sebastian Andrzej Siewior wrote:
>
> >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,
--
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

2009-06-17 05:58:15

by Erik Lotspeich

[permalink] [raw]
Subject: Re: Question about error codes

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

Hi Herbert, Sebastian:

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

Regards,

Erik.

Herbert Xu wrote:
> On Tue, Jun 16, 2009 at 10:34:06PM +0200, Sebastian Andrzej Siewior wrote:
>>> 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-----