des_generic.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) | des_generic.c (231baecdef7a906579925ccf1bd45aa734f32320) |
---|---|
1/* 2 * Cryptographic API. 3 * 4 * DES & Triple DES EDE Cipher Algorithms. 5 * 6 * Copyright (c) 2005 Dag Arne Osvik <da@osvik.no> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 775 unchanged lines hidden (view full) --- 784 struct des_ctx *dctx = crypto_tfm_ctx(tfm); 785 u32 *flags = &tfm->crt_flags; 786 u32 tmp[DES_EXPKEY_WORDS]; 787 int ret; 788 789 /* Expand to tmp */ 790 ret = des_ekey(tmp, key); 791 | 1/* 2 * Cryptographic API. 3 * 4 * DES & Triple DES EDE Cipher Algorithms. 5 * 6 * Copyright (c) 2005 Dag Arne Osvik <da@osvik.no> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 775 unchanged lines hidden (view full) --- 784 struct des_ctx *dctx = crypto_tfm_ctx(tfm); 785 u32 *flags = &tfm->crt_flags; 786 u32 tmp[DES_EXPKEY_WORDS]; 787 int ret; 788 789 /* Expand to tmp */ 790 ret = des_ekey(tmp, key); 791 |
792 if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) { | 792 if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { |
793 *flags |= CRYPTO_TFM_RES_WEAK_KEY; 794 return -EINVAL; 795 } 796 797 /* Copy to output */ 798 memcpy(dctx->expkey, tmp, sizeof(dctx->expkey)); 799 800 return 0; --- 60 unchanged lines hidden (view full) --- 861 */ 862int __des3_ede_setkey(u32 *expkey, u32 *flags, const u8 *key, 863 unsigned int keylen) 864{ 865 const u32 *K = (const u32 *)key; 866 867 if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) || 868 !((K[2] ^ K[4]) | (K[3] ^ K[5]))) && | 793 *flags |= CRYPTO_TFM_RES_WEAK_KEY; 794 return -EINVAL; 795 } 796 797 /* Copy to output */ 798 memcpy(dctx->expkey, tmp, sizeof(dctx->expkey)); 799 800 return 0; --- 60 unchanged lines hidden (view full) --- 861 */ 862int __des3_ede_setkey(u32 *expkey, u32 *flags, const u8 *key, 863 unsigned int keylen) 864{ 865 const u32 *K = (const u32 *)key; 866 867 if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) || 868 !((K[2] ^ K[4]) | (K[3] ^ K[5]))) && |
869 (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) { | 869 (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { |
870 *flags |= CRYPTO_TFM_RES_WEAK_KEY; 871 return -EINVAL; 872 } 873 874 des_ekey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE; 875 dkey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE; 876 des_ekey(expkey, key); 877 --- 128 unchanged lines hidden --- | 870 *flags |= CRYPTO_TFM_RES_WEAK_KEY; 871 return -EINVAL; 872 } 873 874 des_ekey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE; 875 dkey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE; 876 des_ekey(expkey, key); 877 --- 128 unchanged lines hidden --- |