patches: refresh patches on v4.14-rc1
[openwrt/staging/blogic.git] / patches / crypto-ccm.patch
1 --- a/compat/crypto-ccm.c
2 +++ b/compat/crypto-ccm.c
3 @@ -14,13 +14,44 @@
4 #include <crypto/internal/hash.h>
5 #include <crypto/internal/skcipher.h>
6 #include <crypto/scatterwalk.h>
7 +#include <crypto/algapi.h>
8 #include <linux/err.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>
14
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)
19 +{
20 + unsigned long neq = 0;
21 +
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); */
26 + barrier();
27 + a += sizeof(unsigned long);
28 + b += sizeof(unsigned long);
29 + size -= sizeof(unsigned long);
30 + }
31 +#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
32 + while (size > 0) {
33 + neq |= *(unsigned char *)a ^ *(unsigned char *)b;
34 + /* OPTIMIZER_HIDE_VAR(neq); */
35 + barrier();
36 + a += 1;
37 + b += 1;
38 + size -= 1;
39 + }
40 + return neq != 0UL ? 1 : 0;
41 +}
42 +#endif
43 +
44 +/* from internal.h */
45 +struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
46
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,
51 };
52
53 -static int __init crypto_ccm_module_init(void)
54 +int __init crypto_ccm_module_init(void)
55 {
56 int err;
57
58 @@ -1033,19 +1064,10 @@ out_undo_cbcmac:
59 goto out;
60 }
61
62 -static void __exit crypto_ccm_module_exit(void)
63 +void __exit crypto_ccm_module_exit(void)
64 {
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);
69 }
70 -
71 -module_init(crypto_ccm_module_init);
72 -module_exit(crypto_ccm_module_exit);
73 -
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");