From 348fa3f6871f56a37dcd16c99ca98118c6d79a38 Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Mon, 4 Mar 2019 12:01:54 +0100 Subject: Backports v4.19.24 Backports generated by toradex backports 515a1fa55cda2b1d952872e1786857481bd54fcc against mainline kernel tag v4.19.24 Signed-off-by: Dominik Sliwa --- backport-include/crypto/aead.h | 33 +++++++++++++++++++++++++++++++++ backport-include/crypto/algapi.h | 16 ++++++++++++++++ backport-include/crypto/hash.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 backport-include/crypto/aead.h create mode 100644 backport-include/crypto/algapi.h create mode 100644 backport-include/crypto/hash.h (limited to 'backport-include/crypto') diff --git a/backport-include/crypto/aead.h b/backport-include/crypto/aead.h new file mode 100644 index 0000000..26b1355 --- /dev/null +++ b/backport-include/crypto/aead.h @@ -0,0 +1,33 @@ +#ifndef __BACKPORT_CRYPTO_AEAD_H +#define __BACKPORT_CRYPTO_AEAD_H +#include_next +#include + +#if LINUX_VERSION_IS_LESS(4,2,0) +#define aead_request_set_ad LINUX_BACKPORT(aead_request_set_ad) +static inline void aead_request_set_ad(struct aead_request *req, + unsigned int assoclen) +{ + req->assoclen = assoclen; +} + +#define crypto_aead_reqsize LINUX_BACKPORT(crypto_aead_reqsize) +unsigned int crypto_aead_reqsize(struct crypto_aead *tfm); + +struct aead_request *crypto_backport_convert(struct aead_request *req); + +static inline int backport_crypto_aead_encrypt(struct aead_request *req) +{ + return crypto_aead_encrypt(crypto_backport_convert(req)); +} +#define crypto_aead_encrypt LINUX_BACKPORT(crypto_aead_encrypt) + +static inline int backport_crypto_aead_decrypt(struct aead_request *req) +{ + return crypto_aead_decrypt(crypto_backport_convert(req)); +} +#define crypto_aead_decrypt LINUX_BACKPORT(crypto_aead_decrypt) + +#endif /* LINUX_VERSION_IS_LESS(4,2,0) */ + +#endif /* __BACKPORT_CRYPTO_AEAD_H */ diff --git a/backport-include/crypto/algapi.h b/backport-include/crypto/algapi.h new file mode 100644 index 0000000..b6fbdd9 --- /dev/null +++ b/backport-include/crypto/algapi.h @@ -0,0 +1,16 @@ +#ifndef __BP_ALGAPI_H +#define __BP_ALGAPI_H +#include +#include_next + +#if LINUX_VERSION_IS_LESS(3,13,0) +#define __crypto_memneq LINUX_BACKPORT(__crypto_memneq) +noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size); +#define crypto_memneq LINUX_BACKPORT(crypto_memneq) +static inline int crypto_memneq(const void *a, const void *b, size_t size) +{ + return __crypto_memneq(a, b, size) != 0UL ? 1 : 0; +} +#endif + +#endif /* __BP_ALGAPI_H */ diff --git a/backport-include/crypto/hash.h b/backport-include/crypto/hash.h new file mode 100644 index 0000000..96ae799 --- /dev/null +++ b/backport-include/crypto/hash.h @@ -0,0 +1,38 @@ +#ifndef _BACKPORT_CRYPTO_HASH_H +#define _BACKPORT_CRYPTO_HASH_H +#include_next +#include + +#if LINUX_VERSION_IS_LESS(4,6,0) +#define shash_desc_zero LINUX_BACKPORT(shash_desc_zero) +static inline void shash_desc_zero(struct shash_desc *desc) +{ + memzero_explicit(desc, + sizeof(*desc) + crypto_shash_descsize(desc->tfm)); +} +#endif + +#if LINUX_VERSION_IS_LESS(4,6,0) +#define ahash_request_zero LINUX_BACKPORT(ahash_request_zero) +static inline void ahash_request_zero(struct ahash_request *req) +{ + memzero_explicit(req, sizeof(*req) + + crypto_ahash_reqsize(crypto_ahash_reqtfm(req))); +} +#endif + +#ifndef AHASH_REQUEST_ON_STACK +#define AHASH_REQUEST_ON_STACK(name, ahash) \ + char __##name##_desc[sizeof(struct ahash_request) + \ + crypto_ahash_reqsize(ahash)] CRYPTO_MINALIGN_ATTR; \ + struct ahash_request *name = (void *)__##name##_desc +#endif + +#ifndef SHASH_DESC_ON_STACK +#define SHASH_DESC_ON_STACK(shash, ctx) \ + char __##shash##_desc[sizeof(struct shash_desc) + \ + crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \ + struct shash_desc *shash = (struct shash_desc *)__##shash##_desc +#endif + +#endif /* _BACKPORT_CRYPTO_HASH_H */ -- cgit v1.2.3