des_glue.c (23d19ba06b9c5614d6457f5fed349ec8f6d4dac9) des_glue.c (231baecdef7a906579925ccf1bd45aa734f32320)
1/* Glue code for DES encryption optimized for sparc64 crypto opcodes.
2 *
3 * Copyright (C) 2012 David S. Miller <davem@davemloft.net>
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/crypto.h>

--- 39 unchanged lines hidden (view full) ---

48 u32 tmp[DES_EXPKEY_WORDS];
49 int ret;
50
51 /* Even though we have special instructions for key expansion,
52 * we call des_ekey() so that we don't have to write our own
53 * weak key detection code.
54 */
55 ret = des_ekey(tmp, key);
1/* Glue code for DES encryption optimized for sparc64 crypto opcodes.
2 *
3 * Copyright (C) 2012 David S. Miller <davem@davemloft.net>
4 */
5
6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7
8#include <linux/crypto.h>

--- 39 unchanged lines hidden (view full) ---

48 u32 tmp[DES_EXPKEY_WORDS];
49 int ret;
50
51 /* Even though we have special instructions for key expansion,
52 * we call des_ekey() so that we don't have to write our own
53 * weak key detection code.
54 */
55 ret = des_ekey(tmp, key);
56 if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
56 if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
57 *flags |= CRYPTO_TFM_RES_WEAK_KEY;
58 return -EINVAL;
59 }
60
61 des_sparc64_key_expand((const u32 *) key, &dctx->encrypt_expkey[0]);
62 encrypt_to_decrypt(&dctx->decrypt_expkey[0], &dctx->encrypt_expkey[0]);
63
64 return 0;

--- 139 unchanged lines hidden (view full) ---

204 const u32 *K = (const u32 *)key;
205 u32 *flags = &tfm->crt_flags;
206 u64 k1[DES_EXPKEY_WORDS / 2];
207 u64 k2[DES_EXPKEY_WORDS / 2];
208 u64 k3[DES_EXPKEY_WORDS / 2];
209
210 if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) ||
211 !((K[2] ^ K[4]) | (K[3] ^ K[5]))) &&
57 *flags |= CRYPTO_TFM_RES_WEAK_KEY;
58 return -EINVAL;
59 }
60
61 des_sparc64_key_expand((const u32 *) key, &dctx->encrypt_expkey[0]);
62 encrypt_to_decrypt(&dctx->decrypt_expkey[0], &dctx->encrypt_expkey[0]);
63
64 return 0;

--- 139 unchanged lines hidden (view full) ---

204 const u32 *K = (const u32 *)key;
205 u32 *flags = &tfm->crt_flags;
206 u64 k1[DES_EXPKEY_WORDS / 2];
207 u64 k2[DES_EXPKEY_WORDS / 2];
208 u64 k3[DES_EXPKEY_WORDS / 2];
209
210 if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) ||
211 !((K[2] ^ K[4]) | (K[3] ^ K[5]))) &&
212 (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
212 (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
213 *flags |= CRYPTO_TFM_RES_WEAK_KEY;
214 return -EINVAL;
215 }
216
217 des_sparc64_key_expand((const u32 *)key, k1);
218 key += DES_KEY_SIZE;
219 des_sparc64_key_expand((const u32 *)key, k2);
220 key += DES_KEY_SIZE;

--- 315 unchanged lines hidden ---
213 *flags |= CRYPTO_TFM_RES_WEAK_KEY;
214 return -EINVAL;
215 }
216
217 des_sparc64_key_expand((const u32 *)key, k1);
218 key += DES_KEY_SIZE;
219 des_sparc64_key_expand((const u32 *)key, k2);
220 key += DES_KEY_SIZE;

--- 315 unchanged lines hidden ---