alpine 3.6
crypto weakness #34

4

Weakness Breakdown


Definition:

This weakness involves creating non-standard or non-tested algorithms, using weak algorithms or applying cryptographic algorithms incorrectly. Algorithms that were once considered safe are commonly later found to be unsafe, as the algorithms were broken.

Warning code(s):

DES only supports a 56-bit keysize, which is too small given today's computers.

File Name:

libressl/src/libressl-2.5.5/crypto/evp/e_xcbc_d.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 crypto weakness.

 
typedef struct {
	DES_key_schedule ks;/* key schedule */
	DES_cblock inw;
	DES_cblock outw;
} DESX_CBC_KEY;

#define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data)

static const EVP_CIPHER d_xcbc_cipher = {
	NID_desx_cbc,
	8, 24, 8,
	EVP_CIPH_CBC_MODE,
	desx_cbc_init_key,
	desx_cbc_cipher,
	NULL,
	sizeof(DESX_CBC_KEY),
	EVP_CIPHER_set_asn1_iv,
	EVP_CIPHER_get_asn1_iv,
	NULL,
	NULL
};

const EVP_CIPHER *
EVP_desx_cbc(void)
{
	return (&d_xcbc_cipher);
}

static int
desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
    const unsigned char *iv, int enc)
{
	DES_cblock *deskey = (DES_cblock *)key;

	DES_set_key_unchecked(deskey, &data(ctx)->ks);
	memcpy(&data(ctx)->inw[0], &key[8], 8);
	memcpy(&data(ctx)->outw[0], &key[16], 8);

	return 1;
}

static int
desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
    const unsigned char *in, size_t inl)
{
	while (inl >= EVP_MAXCHUNK) {
		DES_xcbc_encrypt(in, out, (long)EVP_MAXCHUNK, &data(ctx)->ks,
		    (DES_cblock *)&(ctx->iv[0]), &data(ctx)->inw,
		    &data(ctx)->outw, ctx->encrypt); 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.