1 --- a/compat/crypto-ccm.c
2 +++ b/compat/crypto-ccm.c
4 #include <crypto/internal/hash.h>
5 #include <crypto/internal/skcipher.h>
6 #include <crypto/scatterwalk.h>
7 +#include <crypto/algapi.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/slab.h>
13 +#include <linux/version.h>
15 -#include "internal.h"
16 +#if LINUX_VERSION_IS_LESS(3,13,0)
17 +/* consider properly backporting this? */
18 +static int crypto_memneq(const void *a, const void *b, size_t size)
20 + unsigned long neq = 0;
22 +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
23 + while (size >= sizeof(unsigned long)) {
24 + neq |= *(unsigned long *)a ^ *(unsigned long *)b;
25 + /* OPTIMIZER_HIDE_VAR(neq); */
27 + a += sizeof(unsigned long);
28 + b += sizeof(unsigned long);
29 + size -= sizeof(unsigned long);
31 +#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
33 + neq |= *(unsigned char *)a ^ *(unsigned char *)b;
34 + /* OPTIMIZER_HIDE_VAR(neq); */
40 + return neq != 0UL ? 1 : 0;
44 +/* from internal.h */
45 +struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
47 struct ccm_instance_ctx {
48 struct crypto_skcipher_spawn ctr;
49 @@ -1001,7 +1032,7 @@ static struct crypto_template crypto_cbc
50 .module = THIS_MODULE,
53 -static int __init crypto_ccm_module_init(void)
54 +int __init crypto_ccm_module_init(void)
58 @@ -1033,19 +1064,10 @@ out_undo_cbcmac:
62 -static void __exit crypto_ccm_module_exit(void)
63 +void __exit crypto_ccm_module_exit(void)
65 crypto_unregister_template(&crypto_rfc4309_tmpl);
66 crypto_unregister_template(&crypto_ccm_tmpl);
67 crypto_unregister_template(&crypto_ccm_base_tmpl);
68 crypto_unregister_template(&crypto_cbcmac_tmpl);
71 -module_init(crypto_ccm_module_init);
72 -module_exit(crypto_ccm_module_exit);
74 -MODULE_LICENSE("GPL");
75 -MODULE_DESCRIPTION("Counter with CBC MAC");
76 -MODULE_ALIAS_CRYPTO("ccm_base");
77 -MODULE_ALIAS_CRYPTO("rfc4309");
78 -MODULE_ALIAS_CRYPTO("ccm");