centos 7
crypto weakness #318

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:

nettle-2.7.1/testsuite/salsa20-test.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 7 crypto weakness.

 	{
	  fprintf(stderr, "Encrypt failed for length %u:\n", j);
	  fprintf(stderr, "\nOutput: ");
	  print_hex(j, data);
	  fprintf(stderr, "\nExpected:");
	  print_hex(j, stream);
	  fprintf(stderr, "\n");
	  FAIL();
	}
      if (!memzero_p (data + j, STREAM_LENGTH + 1 - j))
	{
	  fprintf(stderr, "Encrypt failed for length %u, wrote too much:\n", j);
	  fprintf(stderr, "\nOutput: ");
	  print_hex(STREAM_LENGTH + 1 - j, data + j);
	  fprintf(stderr, "\n");
	  FAIL();
	}
    }
}

typedef void salsa20_func(struct salsa20_ctx *ctx,
			  unsigned length, uint8_t *dst,
			  const uint8_t *src);
static void
_test_salsa20(salsa20_func *crypt,
	      const struct tstring *key,
	      const struct tstring *iv,
	      const struct tstring *cleartext,
	      const struct tstring *ciphertext)
{
  struct salsa20_ctx ctx;
  uint8_t *data;
  unsigned length;

  ASSERT (cleartext->length == ciphertext->length);
  length = cleartext->length;

  ASSERT (iv->length == SALSA20_IV_SIZE);

  data = xalloc(length + 1);

  salsa20_set_key(&ctx, key->length, key->data);
  salsa20_set_iv(&ctx, iv->data);
  data[length] = 17;
  crypt(&ctx, length, data, cleartext->data);
  if (data[length] != 17)
    {
      fprintf(stderr, "Encrypt of %u bytes wrote too much!\nInput:", length);
      tstring_print_hex(cleartext);
      fprintf(stderr, "\n"); 

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.