centos 7
crypto weakness #320

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.

   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");
      FAIL();
    }
  if (!MEMEQ(length, data, ciphertext->data))
    {
      fprintf(stderr, "Encrypt failed:\nInput:");
      tstring_print_hex(cleartext);
      fprintf(stderr, "\nOutput: ");
      print_hex(length, data);
      fprintf(stderr, "\nExpected:");
      tstring_print_hex(ciphertext);
      fprintf(stderr, "\n");
      FAIL();
    }
  salsa20_set_key(&ctx, key->length, key->data);
  salsa20_set_iv(&ctx, iv->data);
  crypt(&ctx, length, data, data);

  if (!MEMEQ(length, data, cleartext->data))
    {
      fprintf(stderr, "Decrypt failed:\nInput:");
      tstring_print_hex(ciphertext);
      fprintf(stderr, "\nOutput: ");
      print_hex(length, data);
      fprintf(stderr, "\nExpected:");
      tstring_print_hex(cleartext);
      fprintf(stderr, "\n");
      FAIL();
    }

  free(data);
}

#define test_salsa20(key, iv, cleartext, ciphertext) \
  _test_salsa20 (salsa20_crypt, (key), (iv), (cleartext), (ciphertext))

#define test_salsa20r12(key, iv, cleartext, ciphertext) \
  _test_salsa20 (salsa20r12_crypt, (key), (iv), (cleartext), (ciphertext))

  
void
test_main(void) 

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.