mirror of https://github.com/torvalds/linux.git
'at_least' array sizes for 6.19
C supports lower bounds on the sizes of array parameters, using the static keyword as follows: 'void f(int a[static 32]);'. This allows the compiler to warn about a too-small array being passed. As discussed, this reuse of the 'static' keyword, while standard, is a bit obscure. Therefore, add an alias 'at_least' to compiler_types.h. Then, add this 'at_least' annotation to the array parameters of various crypto library functions. -----BEGIN PGP SIGNATURE----- iIoEABYIADIWIQSacvsUNc7UX4ntmEPzXCl4vpKOKwUCaSuslxQcZWJpZ2dlcnNA a2VybmVsLm9yZwAKCRDzXCl4vpKOK/dXAP9WyuTsEYOOSwSaDI5sKzdNXT3GZNeO jGhx9qPN3KIq8QD/RElN9oF7iU9wsKvU6kKpnqGcajGTzkW/GOAA20BFcAM= =qFEB -----END PGP SIGNATURE----- Merge tag 'libcrypto-at-least-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux Pull 'at_least' array size update from Eric Biggers: "C supports lower bounds on the sizes of array parameters, using the static keyword as follows: 'void f(int a[static 32]);'. This allows the compiler to warn about a too-small array being passed. As discussed, this reuse of the 'static' keyword, while standard, is a bit obscure. Therefore, add an alias 'at_least' to compiler_types.h. Then, add this 'at_least' annotation to the array parameters of various crypto library functions" * tag 'libcrypto-at-least-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux: lib/crypto: sha2: Add at_least decoration to fixed-size array params lib/crypto: sha1: Add at_least decoration to fixed-size array params lib/crypto: poly1305: Add at_least decoration to fixed-size array params lib/crypto: md5: Add at_least decoration to fixed-size array params lib/crypto: curve25519: Add at_least decoration to fixed-size array params lib/crypto: chacha: Add at_least decoration to fixed-size array params lib/crypto: chacha20poly1305: Statically check fixed array lengths compiler_types: introduce at_least parameter decoration pseudo keyword wifi: iwlwifi: trans: rename at_least variable to min_mode
This commit is contained in:
commit
906003e151
|
|
@ -129,7 +129,7 @@ static enum iwl_reset_mode
|
|||
iwl_trans_determine_restart_mode(struct iwl_trans *trans)
|
||||
{
|
||||
struct iwl_trans_dev_restart_data *data;
|
||||
enum iwl_reset_mode at_least = 0;
|
||||
enum iwl_reset_mode min_mode = 0;
|
||||
unsigned int index;
|
||||
static const enum iwl_reset_mode escalation_list_old[] = {
|
||||
IWL_RESET_MODE_SW_RESET,
|
||||
|
|
@ -173,11 +173,11 @@ iwl_trans_determine_restart_mode(struct iwl_trans *trans)
|
|||
}
|
||||
|
||||
if (trans->restart.during_reset)
|
||||
at_least = IWL_RESET_MODE_REPROBE;
|
||||
min_mode = IWL_RESET_MODE_REPROBE;
|
||||
|
||||
data = iwl_trans_get_restart_data(trans->dev);
|
||||
if (!data)
|
||||
return at_least;
|
||||
return min_mode;
|
||||
|
||||
if (!data->backoff &&
|
||||
ktime_get_boottime_seconds() - data->last_error >=
|
||||
|
|
@ -194,7 +194,7 @@ iwl_trans_determine_restart_mode(struct iwl_trans *trans)
|
|||
data->backoff = false;
|
||||
}
|
||||
|
||||
return max(at_least, escalation_list[index]);
|
||||
return max(min_mode, escalation_list[index]);
|
||||
}
|
||||
|
||||
#define IWL_TRANS_TOP_FOLLOWER_WAIT 180 /* ms */
|
||||
|
|
|
|||
|
|
@ -38,18 +38,18 @@ struct chacha_state {
|
|||
};
|
||||
|
||||
void chacha_block_generic(struct chacha_state *state,
|
||||
u8 out[CHACHA_BLOCK_SIZE], int nrounds);
|
||||
u8 out[at_least CHACHA_BLOCK_SIZE], int nrounds);
|
||||
static inline void chacha20_block(struct chacha_state *state,
|
||||
u8 out[CHACHA_BLOCK_SIZE])
|
||||
u8 out[at_least CHACHA_BLOCK_SIZE])
|
||||
{
|
||||
chacha_block_generic(state, out, 20);
|
||||
}
|
||||
|
||||
void hchacha_block_generic(const struct chacha_state *state,
|
||||
u32 out[HCHACHA_OUT_WORDS], int nrounds);
|
||||
u32 out[at_least HCHACHA_OUT_WORDS], int nrounds);
|
||||
|
||||
void hchacha_block(const struct chacha_state *state,
|
||||
u32 out[HCHACHA_OUT_WORDS], int nrounds);
|
||||
u32 out[at_least HCHACHA_OUT_WORDS], int nrounds);
|
||||
|
||||
enum chacha_constants { /* expand 32-byte k */
|
||||
CHACHA_CONSTANT_EXPA = 0x61707865U,
|
||||
|
|
@ -67,8 +67,8 @@ static inline void chacha_init_consts(struct chacha_state *state)
|
|||
}
|
||||
|
||||
static inline void chacha_init(struct chacha_state *state,
|
||||
const u32 key[CHACHA_KEY_WORDS],
|
||||
const u8 iv[CHACHA_IV_SIZE])
|
||||
const u32 key[at_least CHACHA_KEY_WORDS],
|
||||
const u8 iv[at_least CHACHA_IV_SIZE])
|
||||
{
|
||||
chacha_init_consts(state);
|
||||
state->x[4] = key[0];
|
||||
|
|
|
|||
|
|
@ -18,32 +18,33 @@ enum chacha20poly1305_lengths {
|
|||
void chacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
bool __must_check
|
||||
chacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len, const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
void xchacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
const u8 nonce[at_least XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
bool __must_check xchacha20poly1305_decrypt(
|
||||
u8 *dst, const u8 *src, const size_t src_len, const u8 *ad,
|
||||
const size_t ad_len, const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u8 nonce[at_least XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
bool chacha20poly1305_encrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
bool chacha20poly1305_decrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
bool chacha20poly1305_selftest(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,24 +13,28 @@ enum curve25519_lengths {
|
|||
CURVE25519_KEY_SIZE = 32
|
||||
};
|
||||
|
||||
void curve25519_generic(u8 out[CURVE25519_KEY_SIZE],
|
||||
const u8 scalar[CURVE25519_KEY_SIZE],
|
||||
const u8 point[CURVE25519_KEY_SIZE]);
|
||||
void curve25519_generic(u8 out[at_least CURVE25519_KEY_SIZE],
|
||||
const u8 scalar[at_least CURVE25519_KEY_SIZE],
|
||||
const u8 point[at_least CURVE25519_KEY_SIZE]);
|
||||
|
||||
bool __must_check curve25519(u8 mypublic[CURVE25519_KEY_SIZE],
|
||||
const u8 secret[CURVE25519_KEY_SIZE],
|
||||
const u8 basepoint[CURVE25519_KEY_SIZE]);
|
||||
bool __must_check
|
||||
curve25519(u8 mypublic[at_least CURVE25519_KEY_SIZE],
|
||||
const u8 secret[at_least CURVE25519_KEY_SIZE],
|
||||
const u8 basepoint[at_least CURVE25519_KEY_SIZE]);
|
||||
|
||||
bool __must_check curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
|
||||
const u8 secret[CURVE25519_KEY_SIZE]);
|
||||
bool __must_check
|
||||
curve25519_generate_public(u8 pub[at_least CURVE25519_KEY_SIZE],
|
||||
const u8 secret[at_least CURVE25519_KEY_SIZE]);
|
||||
|
||||
static inline void curve25519_clamp_secret(u8 secret[CURVE25519_KEY_SIZE])
|
||||
static inline void
|
||||
curve25519_clamp_secret(u8 secret[at_least CURVE25519_KEY_SIZE])
|
||||
{
|
||||
secret[0] &= 248;
|
||||
secret[31] = (secret[31] & 127) | 64;
|
||||
}
|
||||
|
||||
static inline void curve25519_generate_secret(u8 secret[CURVE25519_KEY_SIZE])
|
||||
static inline void
|
||||
curve25519_generate_secret(u8 secret[at_least CURVE25519_KEY_SIZE])
|
||||
{
|
||||
get_random_bytes_wait(secret, CURVE25519_KEY_SIZE);
|
||||
curve25519_clamp_secret(secret);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void md5_update(struct md5_ctx *ctx, const u8 *data, size_t len);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void md5_final(struct md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
|
||||
void md5_final(struct md5_ctx *ctx, u8 out[at_least MD5_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* md5() - Compute MD5 message digest in one shot
|
||||
|
|
@ -86,7 +86,7 @@ void md5_final(struct md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void md5(const u8 *data, size_t len, u8 out[MD5_DIGEST_SIZE]);
|
||||
void md5(const u8 *data, size_t len, u8 out[at_least MD5_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct hmac_md5_key - Prepared key for HMAC-MD5
|
||||
|
|
@ -173,7 +173,7 @@ static inline void hmac_md5_update(struct hmac_md5_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void hmac_md5_final(struct hmac_md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
|
||||
void hmac_md5_final(struct hmac_md5_ctx *ctx, u8 out[at_least MD5_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_md5() - Compute HMAC-MD5 in one shot, using a prepared key
|
||||
|
|
@ -187,7 +187,8 @@ void hmac_md5_final(struct hmac_md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void hmac_md5(const struct hmac_md5_key *key,
|
||||
const u8 *data, size_t data_len, u8 out[MD5_DIGEST_SIZE]);
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[at_least MD5_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_md5_usingrawkey() - Compute HMAC-MD5 in one shot, using a raw key
|
||||
|
|
@ -204,6 +205,6 @@ void hmac_md5(const struct hmac_md5_key *key,
|
|||
*/
|
||||
void hmac_md5_usingrawkey(const u8 *raw_key, size_t raw_key_len,
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[MD5_DIGEST_SIZE]);
|
||||
u8 out[at_least MD5_DIGEST_SIZE]);
|
||||
|
||||
#endif /* _CRYPTO_MD5_H */
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ struct poly1305_desc_ctx {
|
|||
};
|
||||
|
||||
void poly1305_init(struct poly1305_desc_ctx *desc,
|
||||
const u8 key[POLY1305_KEY_SIZE]);
|
||||
const u8 key[at_least POLY1305_KEY_SIZE]);
|
||||
void poly1305_update(struct poly1305_desc_ctx *desc,
|
||||
const u8 *src, unsigned int nbytes);
|
||||
void poly1305_final(struct poly1305_desc_ctx *desc, u8 *digest);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void sha1_update(struct sha1_ctx *ctx, const u8 *data, size_t len);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha1_final(struct sha1_ctx *ctx, u8 out[SHA1_DIGEST_SIZE]);
|
||||
void sha1_final(struct sha1_ctx *ctx, u8 out[at_least SHA1_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha1() - Compute SHA-1 message digest in one shot
|
||||
|
|
@ -94,7 +94,7 @@ void sha1_final(struct sha1_ctx *ctx, u8 out[SHA1_DIGEST_SIZE]);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha1(const u8 *data, size_t len, u8 out[SHA1_DIGEST_SIZE]);
|
||||
void sha1(const u8 *data, size_t len, u8 out[at_least SHA1_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct hmac_sha1_key - Prepared key for HMAC-SHA1
|
||||
|
|
@ -181,7 +181,8 @@ static inline void hmac_sha1_update(struct hmac_sha1_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha1_final(struct hmac_sha1_ctx *ctx, u8 out[SHA1_DIGEST_SIZE]);
|
||||
void hmac_sha1_final(struct hmac_sha1_ctx *ctx,
|
||||
u8 out[at_least SHA1_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha1() - Compute HMAC-SHA1 in one shot, using a prepared key
|
||||
|
|
@ -195,7 +196,8 @@ void hmac_sha1_final(struct hmac_sha1_ctx *ctx, u8 out[SHA1_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha1(const struct hmac_sha1_key *key,
|
||||
const u8 *data, size_t data_len, u8 out[SHA1_DIGEST_SIZE]);
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[at_least SHA1_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha1_usingrawkey() - Compute HMAC-SHA1 in one shot, using a raw key
|
||||
|
|
@ -212,6 +214,6 @@ void hmac_sha1(const struct hmac_sha1_key *key,
|
|||
*/
|
||||
void hmac_sha1_usingrawkey(const u8 *raw_key, size_t raw_key_len,
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[SHA1_DIGEST_SIZE]);
|
||||
u8 out[at_least SHA1_DIGEST_SIZE]);
|
||||
|
||||
#endif /* _CRYPTO_SHA1_H */
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ static inline void sha224_update(struct sha224_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha224_final(struct sha224_ctx *ctx, u8 out[SHA224_DIGEST_SIZE]);
|
||||
void sha224_final(struct sha224_ctx *ctx, u8 out[at_least SHA224_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha224() - Compute SHA-224 message digest in one shot
|
||||
|
|
@ -200,7 +200,7 @@ void sha224_final(struct sha224_ctx *ctx, u8 out[SHA224_DIGEST_SIZE]);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha224(const u8 *data, size_t len, u8 out[SHA224_DIGEST_SIZE]);
|
||||
void sha224(const u8 *data, size_t len, u8 out[at_least SHA224_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct hmac_sha224_key - Prepared key for HMAC-SHA224
|
||||
|
|
@ -287,7 +287,8 @@ static inline void hmac_sha224_update(struct hmac_sha224_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha224_final(struct hmac_sha224_ctx *ctx, u8 out[SHA224_DIGEST_SIZE]);
|
||||
void hmac_sha224_final(struct hmac_sha224_ctx *ctx,
|
||||
u8 out[at_least SHA224_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha224() - Compute HMAC-SHA224 in one shot, using a prepared key
|
||||
|
|
@ -301,7 +302,8 @@ void hmac_sha224_final(struct hmac_sha224_ctx *ctx, u8 out[SHA224_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha224(const struct hmac_sha224_key *key,
|
||||
const u8 *data, size_t data_len, u8 out[SHA224_DIGEST_SIZE]);
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[at_least SHA224_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha224_usingrawkey() - Compute HMAC-SHA224 in one shot, using a raw key
|
||||
|
|
@ -318,7 +320,7 @@ void hmac_sha224(const struct hmac_sha224_key *key,
|
|||
*/
|
||||
void hmac_sha224_usingrawkey(const u8 *raw_key, size_t raw_key_len,
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[SHA224_DIGEST_SIZE]);
|
||||
u8 out[at_least SHA224_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct sha256_ctx - Context for hashing a message with SHA-256
|
||||
|
|
@ -363,7 +365,7 @@ static inline void sha256_update(struct sha256_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha256_final(struct sha256_ctx *ctx, u8 out[SHA256_DIGEST_SIZE]);
|
||||
void sha256_final(struct sha256_ctx *ctx, u8 out[at_least SHA256_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha256() - Compute SHA-256 message digest in one shot
|
||||
|
|
@ -373,7 +375,7 @@ void sha256_final(struct sha256_ctx *ctx, u8 out[SHA256_DIGEST_SIZE]);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha256(const u8 *data, size_t len, u8 out[SHA256_DIGEST_SIZE]);
|
||||
void sha256(const u8 *data, size_t len, u8 out[at_least SHA256_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha256_finup_2x() - Compute two SHA-256 digests from a common initial
|
||||
|
|
@ -390,8 +392,9 @@ void sha256(const u8 *data, size_t len, u8 out[SHA256_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void sha256_finup_2x(const struct sha256_ctx *ctx, const u8 *data1,
|
||||
const u8 *data2, size_t len, u8 out1[SHA256_DIGEST_SIZE],
|
||||
u8 out2[SHA256_DIGEST_SIZE]);
|
||||
const u8 *data2, size_t len,
|
||||
u8 out1[at_least SHA256_DIGEST_SIZE],
|
||||
u8 out2[at_least SHA256_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha256_finup_2x_is_optimized() - Check if sha256_finup_2x() is using a real
|
||||
|
|
@ -488,7 +491,8 @@ static inline void hmac_sha256_update(struct hmac_sha256_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha256_final(struct hmac_sha256_ctx *ctx, u8 out[SHA256_DIGEST_SIZE]);
|
||||
void hmac_sha256_final(struct hmac_sha256_ctx *ctx,
|
||||
u8 out[at_least SHA256_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha256() - Compute HMAC-SHA256 in one shot, using a prepared key
|
||||
|
|
@ -502,7 +506,8 @@ void hmac_sha256_final(struct hmac_sha256_ctx *ctx, u8 out[SHA256_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha256(const struct hmac_sha256_key *key,
|
||||
const u8 *data, size_t data_len, u8 out[SHA256_DIGEST_SIZE]);
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[at_least SHA256_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha256_usingrawkey() - Compute HMAC-SHA256 in one shot, using a raw key
|
||||
|
|
@ -519,7 +524,7 @@ void hmac_sha256(const struct hmac_sha256_key *key,
|
|||
*/
|
||||
void hmac_sha256_usingrawkey(const u8 *raw_key, size_t raw_key_len,
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[SHA256_DIGEST_SIZE]);
|
||||
u8 out[at_least SHA256_DIGEST_SIZE]);
|
||||
|
||||
/* State for the SHA-512 (and SHA-384) compression function */
|
||||
struct sha512_block_state {
|
||||
|
|
@ -598,7 +603,7 @@ static inline void sha384_update(struct sha384_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha384_final(struct sha384_ctx *ctx, u8 out[SHA384_DIGEST_SIZE]);
|
||||
void sha384_final(struct sha384_ctx *ctx, u8 out[at_least SHA384_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha384() - Compute SHA-384 message digest in one shot
|
||||
|
|
@ -608,7 +613,7 @@ void sha384_final(struct sha384_ctx *ctx, u8 out[SHA384_DIGEST_SIZE]);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha384(const u8 *data, size_t len, u8 out[SHA384_DIGEST_SIZE]);
|
||||
void sha384(const u8 *data, size_t len, u8 out[at_least SHA384_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct hmac_sha384_key - Prepared key for HMAC-SHA384
|
||||
|
|
@ -695,7 +700,8 @@ static inline void hmac_sha384_update(struct hmac_sha384_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha384_final(struct hmac_sha384_ctx *ctx, u8 out[SHA384_DIGEST_SIZE]);
|
||||
void hmac_sha384_final(struct hmac_sha384_ctx *ctx,
|
||||
u8 out[at_least SHA384_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha384() - Compute HMAC-SHA384 in one shot, using a prepared key
|
||||
|
|
@ -709,7 +715,8 @@ void hmac_sha384_final(struct hmac_sha384_ctx *ctx, u8 out[SHA384_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha384(const struct hmac_sha384_key *key,
|
||||
const u8 *data, size_t data_len, u8 out[SHA384_DIGEST_SIZE]);
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[at_least SHA384_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha384_usingrawkey() - Compute HMAC-SHA384 in one shot, using a raw key
|
||||
|
|
@ -726,7 +733,7 @@ void hmac_sha384(const struct hmac_sha384_key *key,
|
|||
*/
|
||||
void hmac_sha384_usingrawkey(const u8 *raw_key, size_t raw_key_len,
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[SHA384_DIGEST_SIZE]);
|
||||
u8 out[at_least SHA384_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct sha512_ctx - Context for hashing a message with SHA-512
|
||||
|
|
@ -771,7 +778,7 @@ static inline void sha512_update(struct sha512_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha512_final(struct sha512_ctx *ctx, u8 out[SHA512_DIGEST_SIZE]);
|
||||
void sha512_final(struct sha512_ctx *ctx, u8 out[at_least SHA512_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* sha512() - Compute SHA-512 message digest in one shot
|
||||
|
|
@ -781,7 +788,7 @@ void sha512_final(struct sha512_ctx *ctx, u8 out[SHA512_DIGEST_SIZE]);
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void sha512(const u8 *data, size_t len, u8 out[SHA512_DIGEST_SIZE]);
|
||||
void sha512(const u8 *data, size_t len, u8 out[at_least SHA512_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* struct hmac_sha512_key - Prepared key for HMAC-SHA512
|
||||
|
|
@ -868,7 +875,8 @@ static inline void hmac_sha512_update(struct hmac_sha512_ctx *ctx,
|
|||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha512_final(struct hmac_sha512_ctx *ctx, u8 out[SHA512_DIGEST_SIZE]);
|
||||
void hmac_sha512_final(struct hmac_sha512_ctx *ctx,
|
||||
u8 out[at_least SHA512_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha512() - Compute HMAC-SHA512 in one shot, using a prepared key
|
||||
|
|
@ -882,7 +890,8 @@ void hmac_sha512_final(struct hmac_sha512_ctx *ctx, u8 out[SHA512_DIGEST_SIZE]);
|
|||
* Context: Any context.
|
||||
*/
|
||||
void hmac_sha512(const struct hmac_sha512_key *key,
|
||||
const u8 *data, size_t data_len, u8 out[SHA512_DIGEST_SIZE]);
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[at_least SHA512_DIGEST_SIZE]);
|
||||
|
||||
/**
|
||||
* hmac_sha512_usingrawkey() - Compute HMAC-SHA512 in one shot, using a raw key
|
||||
|
|
@ -899,6 +908,6 @@ void hmac_sha512(const struct hmac_sha512_key *key,
|
|||
*/
|
||||
void hmac_sha512_usingrawkey(const u8 *raw_key, size_t raw_key_len,
|
||||
const u8 *data, size_t data_len,
|
||||
u8 out[SHA512_DIGEST_SIZE]);
|
||||
u8 out[at_least SHA512_DIGEST_SIZE]);
|
||||
|
||||
#endif /* _CRYPTO_SHA2_H */
|
||||
|
|
|
|||
|
|
@ -393,6 +393,21 @@ struct ftrace_likely_data {
|
|||
#define __counted_by_be(member) __counted_by(member)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This designates the minimum number of elements a passed array parameter must
|
||||
* have. For example:
|
||||
*
|
||||
* void some_function(u8 param[at_least 7]);
|
||||
*
|
||||
* If a caller passes an array with fewer than 7 elements, the compiler will
|
||||
* emit a warning.
|
||||
*/
|
||||
#ifndef __CHECKER__
|
||||
#define at_least static
|
||||
#else
|
||||
#define at_least
|
||||
#endif
|
||||
|
||||
/* Do not trap wrapping arithmetic within an annotated function. */
|
||||
#ifdef CONFIG_UBSAN_INTEGER_WRAP
|
||||
# define __signed_wrap __attribute__((no_sanitize("signed-integer-overflow")))
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ __chacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len,
|
|||
void chacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE])
|
||||
{
|
||||
struct chacha_state chacha_state;
|
||||
u32 k[CHACHA_KEY_WORDS];
|
||||
|
|
@ -111,8 +111,8 @@ EXPORT_SYMBOL(chacha20poly1305_encrypt);
|
|||
|
||||
void xchacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
const u8 nonce[at_least XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE])
|
||||
{
|
||||
struct chacha_state chacha_state;
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ __chacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len,
|
|||
bool chacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE])
|
||||
{
|
||||
struct chacha_state chacha_state;
|
||||
u32 k[CHACHA_KEY_WORDS];
|
||||
|
|
@ -195,8 +195,8 @@ EXPORT_SYMBOL(chacha20poly1305_decrypt);
|
|||
|
||||
bool xchacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
const u8 nonce[at_least XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE])
|
||||
{
|
||||
struct chacha_state chacha_state;
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ bool chacha20poly1305_crypt_sg_inplace(struct scatterlist *src,
|
|||
const size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE],
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE],
|
||||
int encrypt)
|
||||
{
|
||||
const u8 *pad0 = page_address(ZERO_PAGE(0));
|
||||
|
|
@ -335,7 +335,7 @@ bool chacha20poly1305_crypt_sg_inplace(struct scatterlist *src,
|
|||
bool chacha20poly1305_encrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE])
|
||||
{
|
||||
return chacha20poly1305_crypt_sg_inplace(src, src_len, ad, ad_len,
|
||||
nonce, key, 1);
|
||||
|
|
@ -345,7 +345,7 @@ EXPORT_SYMBOL(chacha20poly1305_encrypt_sg_inplace);
|
|||
bool chacha20poly1305_decrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
const u8 *ad, const size_t ad_len,
|
||||
const u64 nonce,
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
const u8 key[at_least CHACHA20POLY1305_KEY_SIZE])
|
||||
{
|
||||
if (unlikely(src_len < POLY1305_DIGEST_SIZE))
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue