http://lxr.kelp.or.kr/ident?v=2.6.28;i=des_setkey
* Cryptographic API.
*
* s390 implementation of the DES Cipher Algorithm.
*
* Copyright IBM Corp. 2003,2007
* Author(s): Thomas Spatzier
* Jan Glauber ([email protected])
TypeA a = xy;
nomfonction (typeA * a, typeA b)
-> nomfonction (& A, A);
crypto_des_check_key(const u8 *key, unsigned int keylen, u32 *flags)
{
u32 n, w;
n = parity[key[0]]; n <<= 4;
n |= parity[key[1]]; n <<= 4;
n |= parity[key[2]]; n <<= 4;
n |= parity[key[3]]; n <<= 4;
n |= parity[key[4]]; n <<= 4;
n |= parity[key[5]]; n <<= 4;
n |= parity[key[6]]; n <<= 4;
n |= parity[key[7]];
w = 0x88888888L;
if ((*flags & CRYPTO_TFM_REQ_WEAK_KEY)
&& !((n - (w >> 3)) & w)) { /* 1 in
-> CRYPTO_TFM_REQ_WEAK_KEY est un drapeau -> Source/include/linux/crypto.h
/*
* Transform masks and values (for crt_flags).
*/
#define CRYPTO_TFM_REQ_MASK 0x000fff00
#define CRYPTO_TFM_RES_MASK 0xfff00000
#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
#define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200
#define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
Source/arch/s390/Crypto/des_s390.c
#define DES_EXPKEY_WORDS 32
typedef unsigned char u8;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef signed char s8;
typedef short s16;
typedef int s32;
typedef long long s64;
static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
{
return setkey(((struct des_ctx *)ctx)->expkey, key, keylen, flags);
}
struct des_ctx {
u32 expkey[DES_EXPKEY_WORDS];
};
Il est un peu difficile à dire sans plus de contexte. Cela fait-il partie d'une bibliothèque accessible au public? Avez-vous de la documentation sur cette fonction? Généralement, DES prend une clé 56 + 8 = 64 bits. Le paramètre flags définit probablement le mode de fonctionnement (ce qui peut nécessiter ou non de définir un vecteur d'initialisation). – dirkgently
Je peux voir pourquoi vous avez eu du mal à trouver des réponses pour cela, le noyau Linux a changé. Il n'y a pas du tout d'utilisation réelle dans le noyau. – IanNorton