diff options
Diffstat (limited to 'crypto/tea.c')
-rw-r--r-- | crypto/tea.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/crypto/tea.c b/crypto/tea.c index a6a02b30e470..5367adc82fc9 100644 --- a/crypto/tea.c +++ b/crypto/tea.c | |||
@@ -45,10 +45,10 @@ struct xtea_ctx { | |||
45 | u32 KEY[4]; | 45 | u32 KEY[4]; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static int tea_setkey(void *ctx_arg, const u8 *in_key, | 48 | static int tea_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
49 | unsigned int key_len, u32 *flags) | 49 | unsigned int key_len, u32 *flags) |
50 | { | 50 | { |
51 | struct tea_ctx *ctx = ctx_arg; | 51 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
52 | const __le32 *key = (const __le32 *)in_key; | 52 | const __le32 *key = (const __le32 *)in_key; |
53 | 53 | ||
54 | if (key_len != 16) | 54 | if (key_len != 16) |
@@ -66,12 +66,11 @@ static int tea_setkey(void *ctx_arg, const u8 *in_key, | |||
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | static void tea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 69 | static void tea_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
70 | { | 70 | { |
71 | u32 y, z, n, sum = 0; | 71 | u32 y, z, n, sum = 0; |
72 | u32 k0, k1, k2, k3; | 72 | u32 k0, k1, k2, k3; |
73 | 73 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); | |
74 | struct tea_ctx *ctx = ctx_arg; | ||
75 | const __le32 *in = (const __le32 *)src; | 74 | const __le32 *in = (const __le32 *)src; |
76 | __le32 *out = (__le32 *)dst; | 75 | __le32 *out = (__le32 *)dst; |
77 | 76 | ||
@@ -95,11 +94,11 @@ static void tea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
95 | out[1] = cpu_to_le32(z); | 94 | out[1] = cpu_to_le32(z); |
96 | } | 95 | } |
97 | 96 | ||
98 | static void tea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 97 | static void tea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
99 | { | 98 | { |
100 | u32 y, z, n, sum; | 99 | u32 y, z, n, sum; |
101 | u32 k0, k1, k2, k3; | 100 | u32 k0, k1, k2, k3; |
102 | struct tea_ctx *ctx = ctx_arg; | 101 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
103 | const __le32 *in = (const __le32 *)src; | 102 | const __le32 *in = (const __le32 *)src; |
104 | __le32 *out = (__le32 *)dst; | 103 | __le32 *out = (__le32 *)dst; |
105 | 104 | ||
@@ -125,10 +124,10 @@ static void tea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
125 | out[1] = cpu_to_le32(z); | 124 | out[1] = cpu_to_le32(z); |
126 | } | 125 | } |
127 | 126 | ||
128 | static int xtea_setkey(void *ctx_arg, const u8 *in_key, | 127 | static int xtea_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
129 | unsigned int key_len, u32 *flags) | 128 | unsigned int key_len, u32 *flags) |
130 | { | 129 | { |
131 | struct xtea_ctx *ctx = ctx_arg; | 130 | struct xtea_ctx *ctx = crypto_tfm_ctx(tfm); |
132 | const __le32 *key = (const __le32 *)in_key; | 131 | const __le32 *key = (const __le32 *)in_key; |
133 | 132 | ||
134 | if (key_len != 16) | 133 | if (key_len != 16) |
@@ -146,12 +145,11 @@ static int xtea_setkey(void *ctx_arg, const u8 *in_key, | |||
146 | 145 | ||
147 | } | 146 | } |
148 | 147 | ||
149 | static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 148 | static void xtea_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
150 | { | 149 | { |
151 | u32 y, z, sum = 0; | 150 | u32 y, z, sum = 0; |
152 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; | 151 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; |
153 | 152 | struct xtea_ctx *ctx = crypto_tfm_ctx(tfm); | |
154 | struct xtea_ctx *ctx = ctx_arg; | ||
155 | const __le32 *in = (const __le32 *)src; | 153 | const __le32 *in = (const __le32 *)src; |
156 | __le32 *out = (__le32 *)dst; | 154 | __le32 *out = (__le32 *)dst; |
157 | 155 | ||
@@ -168,10 +166,10 @@ static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
168 | out[1] = cpu_to_le32(z); | 166 | out[1] = cpu_to_le32(z); |
169 | } | 167 | } |
170 | 168 | ||
171 | static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 169 | static void xtea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
172 | { | 170 | { |
173 | u32 y, z, sum; | 171 | u32 y, z, sum; |
174 | struct tea_ctx *ctx = ctx_arg; | 172 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
175 | const __le32 *in = (const __le32 *)src; | 173 | const __le32 *in = (const __le32 *)src; |
176 | __le32 *out = (__le32 *)dst; | 174 | __le32 *out = (__le32 *)dst; |
177 | 175 | ||
@@ -191,12 +189,11 @@ static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
191 | } | 189 | } |
192 | 190 | ||
193 | 191 | ||
194 | static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 192 | static void xeta_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
195 | { | 193 | { |
196 | u32 y, z, sum = 0; | 194 | u32 y, z, sum = 0; |
197 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; | 195 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; |
198 | 196 | struct xtea_ctx *ctx = crypto_tfm_ctx(tfm); | |
199 | struct xtea_ctx *ctx = ctx_arg; | ||
200 | const __le32 *in = (const __le32 *)src; | 197 | const __le32 *in = (const __le32 *)src; |
201 | __le32 *out = (__le32 *)dst; | 198 | __le32 *out = (__le32 *)dst; |
202 | 199 | ||
@@ -213,10 +210,10 @@ static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
213 | out[1] = cpu_to_le32(z); | 210 | out[1] = cpu_to_le32(z); |
214 | } | 211 | } |
215 | 212 | ||
216 | static void xeta_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 213 | static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
217 | { | 214 | { |
218 | u32 y, z, sum; | 215 | u32 y, z, sum; |
219 | struct tea_ctx *ctx = ctx_arg; | 216 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
220 | const __le32 *in = (const __le32 *)src; | 217 | const __le32 *in = (const __le32 *)src; |
221 | __le32 *out = (__le32 *)dst; | 218 | __le32 *out = (__le32 *)dst; |
222 | 219 | ||