alpine 3.6
crypto weakness #14

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:

ffmpeg/src/ffmpeg-3.2.9/libavutil/tests/des.c

Context:

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

         if (decrypt)
            return res == 0xc5cecf63ecec514cULL;
        else
            return res == 0xcb191f85d1ed8439ULL;
    } else {
        if (decrypt)
            return res == 0x8325397644091a0aULL;
        else
            return res == 0xdd17e8b8b437d232ULL;
    }
}

int main(void)
{
    AVDES d;
    int i;
    uint64_t key[3];
    uint64_t data;
    uint64_t ct;
    uint64_t roundkeys[16];
    srand(av_gettime());
    key[0] = AV_RB64(test_key);
    data   = AV_RB64(plain);
    gen_roundkeys(roundkeys, key[0]);
    if (des_encdec(data, roundkeys, 0) != AV_RB64(crypt)) {
        printf("Test 1 failed\n");
        return 1;
    }
    av_des_init(&d, test_key, 64, 0);
    av_des_crypt(&d, tmp, plain, 1, NULL, 0);
    if (memcmp(tmp, crypt, sizeof(crypt))) {
        printf("Public API decryption failed\n");
        return 1;
    }
    if (!run_test(0, 0) || !run_test(0, 1) || !run_test(1, 0) || !run_test(1, 1)) {
        printf("Partial Monte-Carlo test failed\n");
        return 1;
    }
    for (i = 0; i < 1000; i++) {
        key[0] = rand64();
        key[1] = rand64();
        key[2] = rand64();
        data   = rand64();
        av_des_init(&d, (uint8_t *) key, 192, 0);
        av_des_crypt(&d, (uint8_t *) &ct, (uint8_t *) &data, 1, NULL, 0);
        av_des_init(&d, (uint8_t *) key, 192, 1);
        av_des_crypt(&d, (uint8_t *) &ct, (uint8_t *) &ct, 1, NULL, 1);
        if (ct != data) {
            printf("Test 2 failed\n");
            return 1; 

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.