alpine 3.6
crypto weakness #47

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):

The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment.

File Name:

libressl/src/libressl-2.5.5/tests/destest.c

Context:

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

 	printf("input word alignment test");
	for (i=0; i<4; i++)
		{
		printf(" %u",i);
		DES_ncbc_encrypt(&(cbc_out[i]),cbc_in,
				 strlen((char *)cbc_data)+1,&ks,
				 &cbc_iv,DES_ENCRYPT);
		}
	printf("\noutput word alignment test");
	for (i=0; i<4; i++)
		{
		printf(" %u",i);
		DES_ncbc_encrypt(cbc_out,&(cbc_in[i]),
				 strlen((char *)cbc_data)+1,&ks,
				 &cbc_iv,DES_ENCRYPT);
		}
	printf("\n");
	printf("fast crypt test ");
	str=crypt("testing","ef");
	if (strcmp("efGnQx2725bI2",str) != 0)
		{
		printf("fast crypt error, %s should be efGnQx2725bI2\n",str);
		err=1;
		}
	str=crypt("bca76;23","yA");
	if (strcmp("yA1Rp/1hZXIJk",str) != 0)
		{
		printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str);
		err=1;
		}
	printf("\n");
	return(err);
	}

static char *pt(unsigned char *p)
	{
	static char bufs[10][20];
	static int bnum=0;
	char *ret;
	int i;
	static char *f="0123456789ABCDEF";

	ret= &(bufs[bnum++][0]);
	bnum%=10;
	for (i=0; i<8; i++)
		{
		ret[i*2]=f[(p[i]>>4)&0xf];
		ret[i*2+1]=f[p[i]&0xf];
		}
	ret[16]='\0'; 

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.