<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/crypto/skcipher.c, branch v4.11</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>crypto: Replaced gcc specific attributes with macros from compiler.h</title>
<updated>2017-01-12T16:24:39+00:00</updated>
<author>
<name>Gideon Israel Dsouza</name>
<email>gidisrael@gmail.com</email>
</author>
<published>2016-12-31T15:56:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=d8c34b949d8c9f61e099e00f22770e400adf2b76'/>
<id>d8c34b949d8c9f61e099e00f22770e400adf2b76</id>
<content type='text'>
Continuing from this commit: 52f5684c8e1e
("kernel: use macros from compiler.h instead of __attribute__((...))")

I submitted 4 total patches. They are part of task I've taken up to
increase compiler portability in the kernel. I've cleaned up the
subsystems under /kernel /mm /block and /security, this patch targets
/crypto.

There is &lt;linux/compiler.h&gt; which provides macros for various gcc specific
constructs. Eg: __weak for __attribute__((weak)). I've cleaned all
instances of gcc specific attributes with the right macros for the crypto
subsystem.

I had to make one additional change into compiler-gcc.h for the case when
one wants to use this: __attribute__((aligned) and not specify an alignment
factor. From the gcc docs, this will result in the largest alignment for
that data type on the target machine so I've named the macro
__aligned_largest. Please advise if another name is more appropriate.

Signed-off-by: Gideon Israel Dsouza &lt;gidisrael@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Continuing from this commit: 52f5684c8e1e
("kernel: use macros from compiler.h instead of __attribute__((...))")

I submitted 4 total patches. They are part of task I've taken up to
increase compiler portability in the kernel. I've cleaned up the
subsystems under /kernel /mm /block and /security, this patch targets
/crypto.

There is &lt;linux/compiler.h&gt; which provides macros for various gcc specific
constructs. Eg: __weak for __attribute__((weak)). I've cleaned all
instances of gcc specific attributes with the right macros for the crypto
subsystem.

I had to make one additional change into compiler-gcc.h for the case when
one wants to use this: __attribute__((aligned) and not specify an alignment
factor. From the gcc docs, this will result in the largest alignment for
that data type on the target machine so I've named the macro
__aligned_largest. Please advise if another name is more appropriate.

Signed-off-by: Gideon Israel Dsouza &lt;gidisrael@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - introduce walksize attribute for SIMD algos</title>
<updated>2016-12-30T11:52:47+00:00</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2016-12-29T14:09:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c821f6ab2e47946f35ee2f30781c5185e5d07f65'/>
<id>c821f6ab2e47946f35ee2f30781c5185e5d07f65</id>
<content type='text'>
In some cases, SIMD algorithms can only perform optimally when
allowed to operate on multiple input blocks in parallel. This is
especially true for bit slicing algorithms, which typically take
the same amount of time processing a single block or 8 blocks in
parallel. However, other SIMD algorithms may benefit as well from
bigger strides.

So add a walksize attribute to the skcipher algorithm definition, and
wire it up to the skcipher walk API. To avoid confusion between the
skcipher and AEAD attributes, rename the skcipher_walk chunksize
attribute to 'stride', and set it from the walksize (in the skcipher
case) or from the chunksize (in the AEAD case).

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In some cases, SIMD algorithms can only perform optimally when
allowed to operate on multiple input blocks in parallel. This is
especially true for bit slicing algorithms, which typically take
the same amount of time processing a single block or 8 blocks in
parallel. However, other SIMD algorithms may benefit as well from
bigger strides.

So add a walksize attribute to the skcipher algorithm definition, and
wire it up to the skcipher walk API. To avoid confusion between the
skcipher and AEAD attributes, rename the skcipher_walk chunksize
attribute to 'stride', and set it from the walksize (in the skcipher
case) or from the chunksize (in the AEAD case).

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - fix crash in virtual walk</title>
<updated>2016-12-14T10:33:14+00:00</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2016-12-13T13:34:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=18e615ad87bce9125ef3990377a4a946ec0f21f3'/>
<id>18e615ad87bce9125ef3990377a4a946ec0f21f3</id>
<content type='text'>
The new skcipher walk API may crash in the following way. (Interestingly,
the tcrypt boot time tests seem unaffected, while an explicit test using
the module triggers it)

  Unable to handle kernel NULL pointer dereference at virtual address 00000000
  ...
  [&lt;ffff000008431d84&gt;] __memcpy+0x84/0x180
  [&lt;ffff0000083ec0d0&gt;] skcipher_walk_done+0x328/0x340
  [&lt;ffff0000080c5c04&gt;] ctr_encrypt+0x84/0x100
  [&lt;ffff000008406d60&gt;] simd_skcipher_encrypt+0x88/0x98
  [&lt;ffff0000083fa05c&gt;] crypto_rfc3686_crypt+0x8c/0x98
  [&lt;ffff0000009b0900&gt;] test_skcipher_speed+0x518/0x820 [tcrypt]
  [&lt;ffff0000009b31c0&gt;] do_test+0x1408/0x3b70 [tcrypt]
  [&lt;ffff0000009bd050&gt;] tcrypt_mod_init+0x50/0x1000 [tcrypt]
  [&lt;ffff0000080838f4&gt;] do_one_initcall+0x44/0x138
  [&lt;ffff0000081aee60&gt;] do_init_module+0x68/0x1e0
  [&lt;ffff0000081524d0&gt;] load_module+0x1fd0/0x2458
  [&lt;ffff000008152c38&gt;] SyS_finit_module+0xe0/0xf0
  [&lt;ffff0000080836f0&gt;] el0_svc_naked+0x24/0x28

This is due to the fact that skcipher_done_slow() may be entered with
walk-&gt;buffer unset. Since skcipher_walk_done() already deals with the
case where walk-&gt;buffer == walk-&gt;page, it appears to be the intention
that walk-&gt;buffer point to walk-&gt;page after skcipher_next_slow(), so
ensure that is the case.

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The new skcipher walk API may crash in the following way. (Interestingly,
the tcrypt boot time tests seem unaffected, while an explicit test using
the module triggers it)

  Unable to handle kernel NULL pointer dereference at virtual address 00000000
  ...
  [&lt;ffff000008431d84&gt;] __memcpy+0x84/0x180
  [&lt;ffff0000083ec0d0&gt;] skcipher_walk_done+0x328/0x340
  [&lt;ffff0000080c5c04&gt;] ctr_encrypt+0x84/0x100
  [&lt;ffff000008406d60&gt;] simd_skcipher_encrypt+0x88/0x98
  [&lt;ffff0000083fa05c&gt;] crypto_rfc3686_crypt+0x8c/0x98
  [&lt;ffff0000009b0900&gt;] test_skcipher_speed+0x518/0x820 [tcrypt]
  [&lt;ffff0000009b31c0&gt;] do_test+0x1408/0x3b70 [tcrypt]
  [&lt;ffff0000009bd050&gt;] tcrypt_mod_init+0x50/0x1000 [tcrypt]
  [&lt;ffff0000080838f4&gt;] do_one_initcall+0x44/0x138
  [&lt;ffff0000081aee60&gt;] do_init_module+0x68/0x1e0
  [&lt;ffff0000081524d0&gt;] load_module+0x1fd0/0x2458
  [&lt;ffff000008152c38&gt;] SyS_finit_module+0xe0/0xf0
  [&lt;ffff0000080836f0&gt;] el0_svc_naked+0x24/0x28

This is due to the fact that skcipher_done_slow() may be entered with
walk-&gt;buffer unset. Since skcipher_walk_done() already deals with the
case where walk-&gt;buffer == walk-&gt;page, it appears to be the intention
that walk-&gt;buffer point to walk-&gt;page after skcipher_next_slow(), so
ensure that is the case.

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - Add separate walker for AEAD decryption</title>
<updated>2016-12-01T13:06:17+00:00</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-11-30T13:14:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=34bc085c839cef85e3e795b1cee29514f69c3081'/>
<id>34bc085c839cef85e3e795b1cee29514f69c3081</id>
<content type='text'>
The AEAD decrypt interface includes the authentication tag in
req-&gt;cryptlen.  Therefore we need to exlucde that when doing
a walk over it.

This patch adds separate walker functions for AEAD encryption
and decryption.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Reviewed-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The AEAD decrypt interface includes the authentication tag in
req-&gt;cryptlen.  Therefore we need to exlucde that when doing
a walk over it.

This patch adds separate walker functions for AEAD encryption
and decryption.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Reviewed-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - fix crash in skcipher_walk_aead()</title>
<updated>2016-11-30T12:01:43+00:00</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2016-11-29T13:05:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=3cbf61fb9fe24c0c3a1591b65175f8c5b3ddaac2'/>
<id>3cbf61fb9fe24c0c3a1591b65175f8c5b3ddaac2</id>
<content type='text'>
The new skcipher_walk_aead() may crash in the following way due to
the walk flag SKCIPHER_WALK_PHYS not being cleared at the start of the
walk:

Unable to handle kernel NULL pointer dereference at virtual address 00000001
[..]
Internal error: Oops: 96000044 [#1] PREEMPT SMP
[..]
PC is at skcipher_walk_next+0x208/0x450
LR is at skcipher_walk_next+0x1e4/0x450
pc : [&lt;ffff2b93b7104e20&gt;] lr : [&lt;ffff2b93b7104dfc&gt;] pstate: 40000045
sp : ffffb925fa517940
[...]
[&lt;ffff2b93b7104e20&gt;] skcipher_walk_next+0x208/0x450
[&lt;ffff2b93b710535c&gt;] skcipher_walk_first+0x54/0x148
[&lt;ffff2b93b7105664&gt;] skcipher_walk_aead+0xd4/0x108
[&lt;ffff2b93b6e77928&gt;] ccm_encrypt+0x68/0x158

So clear the flag at the appropriate time.

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The new skcipher_walk_aead() may crash in the following way due to
the walk flag SKCIPHER_WALK_PHYS not being cleared at the start of the
walk:

Unable to handle kernel NULL pointer dereference at virtual address 00000001
[..]
Internal error: Oops: 96000044 [#1] PREEMPT SMP
[..]
PC is at skcipher_walk_next+0x208/0x450
LR is at skcipher_walk_next+0x1e4/0x450
pc : [&lt;ffff2b93b7104e20&gt;] lr : [&lt;ffff2b93b7104dfc&gt;] pstate: 40000045
sp : ffffb925fa517940
[...]
[&lt;ffff2b93b7104e20&gt;] skcipher_walk_next+0x208/0x450
[&lt;ffff2b93b710535c&gt;] skcipher_walk_first+0x54/0x148
[&lt;ffff2b93b7105664&gt;] skcipher_walk_aead+0xd4/0x108
[&lt;ffff2b93b6e77928&gt;] ccm_encrypt+0x68/0x158

So clear the flag at the appropriate time.

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - Add skcipher walk interface</title>
<updated>2016-11-28T13:23:17+00:00</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-11-22T12:08:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=b286d8b1a690667e99a89d22245832b6898c6279'/>
<id>b286d8b1a690667e99a89d22245832b6898c6279</id>
<content type='text'>
This patch adds the skcipher walk interface which replaces both
blkcipher walk and ablkcipher walk.  Just like blkcipher walk it
can also be used for AEAD algorithms.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds the skcipher walk interface which replaces both
blkcipher walk and ablkcipher walk.  Just like blkcipher walk it
can also be used for AEAD algorithms.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - Remove top-level givcipher interface</title>
<updated>2016-07-18T09:35:46+00:00</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-07-12T05:17:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=3a01d0ee2b991c8c267620e63a4ab47cd8c30cc4'/>
<id>3a01d0ee2b991c8c267620e63a4ab47cd8c30cc4</id>
<content type='text'>
This patch removes the old crypto_grab_skcipher helper and replaces
it with crypto_grab_skcipher2.

As this is the final entry point into givcipher this patch also
removes all traces of the top-level givcipher interface, including
all implicit IV generators such as chainiv.

The bottom-level givcipher interface remains until the drivers
using it are converted.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch removes the old crypto_grab_skcipher helper and replaces
it with crypto_grab_skcipher2.

As this is the final entry point into givcipher this patch also
removes all traces of the top-level givcipher interface, including
all implicit IV generators such as chainiv.

The bottom-level givcipher interface remains until the drivers
using it are converted.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - Add low-level skcipher interface</title>
<updated>2016-07-18T09:35:36+00:00</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-07-12T05:17:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=4e6c3df4d729f85997cbf276bfa8ffd8579b8e77'/>
<id>4e6c3df4d729f85997cbf276bfa8ffd8579b8e77</id>
<content type='text'>
This patch allows skcipher algorithms and instances to be created
and registered with the crypto API.  They are accessible through
the top-level skcipher interface, along with ablkcipher/blkcipher
algorithms and instances.

This patch also introduces a new parameter called chunk size
which is meant for ciphers such as CTR and CTS which ostensibly
can handle arbitrary lengths, but still behave like block ciphers
in that you can only process a partial block at the very end.

For these ciphers the block size will continue to be set to 1
as it is now while the chunk size will be set to the underlying
block size.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch allows skcipher algorithms and instances to be created
and registered with the crypto API.  They are accessible through
the top-level skcipher interface, along with ablkcipher/blkcipher
algorithms and instances.

This patch also introduces a new parameter called chunk size
which is meant for ciphers such as CTR and CTS which ostensibly
can handle arbitrary lengths, but still behave like block ciphers
in that you can only process a partial block at the very end.

For these ciphers the block size will continue to be set to 1
as it is now while the chunk size will be set to the underlying
block size.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - Add default key size helper</title>
<updated>2016-01-25T14:42:11+00:00</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-01-21T09:10:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=973fb3fb50e3959d90179d09ed3ce454dd7bc6e4'/>
<id>973fb3fb50e3959d90179d09ed3ce454dd7bc6e4</id>
<content type='text'>
While converting ecryptfs over to skcipher I found that it needs
to pick a default key size if one isn't given.  Rather than having
it poke into the guts of the algorithm to get max_keysize, let's
provide a helper that is meant to give a sane default (just in
case we ever get an algorithm that has no maximum key size).

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While converting ecryptfs over to skcipher I found that it needs
to pick a default key size if one isn't given.  Rather than having
it poke into the guts of the algorithm to get max_keysize, let's
provide a helper that is meant to give a sane default (just in
case we ever get an algorithm that has no maximum key size).

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>crypto: skcipher - Add crypto_skcipher_has_setkey</title>
<updated>2016-01-18T10:16:12+00:00</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-01-11T13:26:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a1383cd86a062fc798899ab20f0ec2116cce39cb'/>
<id>a1383cd86a062fc798899ab20f0ec2116cce39cb</id>
<content type='text'>
This patch adds a way for skcipher users to determine whether a key
is required by a transform.

Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds a way for skcipher users to determine whether a key
is required by a transform.

Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</pre>
</div>
</content>
</entry>
</feed>
