alistair23-linux/include/crypto
Gustavo A. R. Silva 5a8a076506 crypto: Replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-06 12:28:21 +11:00
..
internal crypto: poly1305 - add new 32 and 64-bit generic versions 2020-01-16 15:18:12 +08:00
acompress.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aead.h crypto: aead - move crypto_aead_maxauthsize() to <crypto/aead.h> 2019-12-11 16:37:00 +08:00
aes.h crypto: aes - helper function to validate key length for AES algorithms 2019-08-09 15:11:43 +10:00
akcipher.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
algapi.h crypto: algapi - remove crypto_template::{alloc,free}() 2020-01-09 11:30:58 +08:00
arc4.h crypto: arc4 - refactor arc4 core code into separate library 2019-06-20 14:18:33 +08:00
asym_tpm_subtype.h KEYS: asym_tpm: extract key size & public key [ver #2] 2018-10-26 09:30:46 +01:00
authenc.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
b128ops.h
blake2s.h crypto: blake2s - generic C library implementation and selftest 2019-11-17 09:02:42 +08:00
blowfish.h
cast5.h
cast6.h crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN 2020-01-09 11:30:53 +08:00
cast_common.h
cbc.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
chacha.h crypto: x86/chacha - expose SIMD ChaCha routine as library function 2019-11-17 09:02:39 +08:00
chacha20poly1305.h crypto: lib/chacha20poly1305 - reimplement crypt_from_sg() routine 2019-11-17 09:02:44 +08:00
cryptd.h crypto: cryptd - remove ability to instantiate ablkciphers 2019-04-18 22:15:04 +08:00
ctr.h crypto: ctr - add helper for performing a CTR encryption walk 2019-07-26 14:56:07 +10:00
curve25519.h crypto: curve25519 - generic C library implementations 2019-11-17 09:02:43 +08:00
des.h crypto: des - remove now unused __des3_ede_setkey() 2019-08-22 14:57:33 +10:00
dh.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
drbg.h crypto: drbg - add FIPS 140-2 CTRNG for noise source 2019-05-23 14:01:06 +08:00
ecdh.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
engine.h crypto: ablkcipher - remove deprecated and unused ablkcipher support 2019-11-17 09:02:49 +08:00
gcm.h crypto: gcm - helper functions for assoclen/authsize check 2019-08-09 15:11:41 +10:00
gf128mul.h
ghash.h crypto: ghash - add comment and improve help text 2019-07-27 21:08:38 +10:00
hash.h crypto: shash - Add init_tfm/exit_tfm and verify descsize 2019-12-11 16:48:39 +08:00
hash_info.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
hmac.h
if_alg.h crypto: Replace zero-length array with flexible-array member 2020-03-06 12:28:21 +11:00
kpp.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
md5.h
nhpoly1305.h crypto: poly1305 - add new 32 and 64-bit generic versions 2020-01-16 15:18:12 +08:00
null.h crypto: null - Remove VLA usage of skcipher 2018-09-28 12:46:08 +08:00
padlock.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
pcrypt.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 335 2019-06-05 17:37:06 +02:00
pkcs7.h PKCS#7: Introduce pkcs7_get_digest() 2019-08-05 18:40:19 -04:00
poly1305.h crypto: poly1305 - add new 32 and 64-bit generic versions 2020-01-16 15:18:12 +08:00
public_key.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
rng.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
scatterwalk.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
serpent.h crypto: x86 - Regularize glue function prototypes 2019-12-11 16:36:54 +08:00
sha.h crypto: sha256 - Remove sha256/224_init code duplication 2019-09-05 14:54:54 +10:00
sha1_base.h crypto: add header include guards 2019-08-02 14:44:02 +10:00
sha3.h
sha256_base.h crypto: sha256 - Remove sha256/224_init code duplication 2019-09-05 14:54:54 +10:00
sha512_base.h crypto: add header include guards 2019-08-02 14:44:02 +10:00
skcipher.h crypto: skcipher - add crypto_skcipher_min_keysize() 2019-12-11 16:37:00 +08:00
sm3.h
sm3_base.h crypto: add header include guards 2019-08-02 14:44:02 +10:00
sm4.h
streebog.h crypto: streebog - fix unaligned memory accesses 2019-04-08 14:42:55 +08:00
twofish.h crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN 2020-01-09 11:30:53 +08:00
xts.h crypto: remove CRYPTO_TFM_RES_WEAK_KEY 2020-01-09 11:30:53 +08:00