[lkml]   [2014]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: crypto: algif_skcipher: check for IV size superfluous?
On Sat, Nov 08, 2014 at 01:32:30AM +0100, Stephan Mueller wrote:
> Hi Herbert,
> I am in the process to extend algif_skcipher to support AEAD ciphers as well.
> The code already works but I want to run final tests before releasing it.
> In the course of the development I stumbled over the following code:
> static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
> struct msghdr *msg, size_t size)
> {
> ...
> if (con.iv && con.iv->ivlen != ivsize)
> return -EINVAL;
> This code effectively requires that any user space code trying to use a cipher
> must provide an IV that is equal to the blocksize of the cipher.
> I am wondering why this check is there or whether we can remove that.
> When using the kernel crypto API inside the kernel, there is no such
> enforcement. One can take shorter IVs which are implicitly padded with
> trailing zeros.

The kernel requires you to provide an IV that's exactly the size
required by the algorithm. As otherwise the API would need to
specify an explicit IV size per request.

> However, if we conclude that the check should remain, then I am wondering
> whether we have to move it to the various _setiv functions of the kernel
> crypto API instead of leaving it in the skcipher interface.

The kernel interface does not have an explicit IV size in the
request. Therefore there is no way for us to check.

Email: Herbert Xu <>
Home Page:
PGP Key:

 \ /
  Last update: 2014-11-10 15:41    [W:0.023 / U:3.728 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site