centos 6
crypto weakness #300

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:

krb5-1.10.3/src/lib/crypto/openssl/enc_provider/des.c

Context:

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

 
    *empty = (input_length == 0);
    return 0;
}

static krb5_error_code
k5_des_encrypt(krb5_key key, const krb5_data *ivec, krb5_crypto_iov *data,
               size_t num_data)
{
    int ret, olen = DES_BLOCK_SIZE;
    unsigned char iblock[DES_BLOCK_SIZE], oblock[DES_BLOCK_SIZE];
    struct iov_block_state input_pos, output_pos;
    EVP_CIPHER_CTX ciph_ctx;
    krb5_boolean empty;

    IOV_BLOCK_STATE_INIT(&input_pos);
    IOV_BLOCK_STATE_INIT(&output_pos);

    ret = validate(key, ivec, data, num_data, &empty);
    if (ret != 0 || empty)
        return ret;

    EVP_CIPHER_CTX_init(&ciph_ctx);

    ret = EVP_EncryptInit_ex(&ciph_ctx, EVP_des_cbc(), NULL,
                             key->keyblock.contents, (ivec && ivec->data) ? (unsigned char*)ivec->data : NULL);
    if (!ret)
        return KRB5_CRYPTO_INTERNAL;

    EVP_CIPHER_CTX_set_padding(&ciph_ctx,0);

    for (;;) {

        if (!krb5int_c_iov_get_block(iblock, DES_BLOCK_SIZE, data,
                                     num_data, &input_pos))
            break;

        ret = EVP_EncryptUpdate(&ciph_ctx, oblock, &olen,
                                (unsigned char *)iblock, DES_BLOCK_SIZE);
        if (!ret)
            break;

        krb5int_c_iov_put_block(data, num_data, oblock, DES_BLOCK_SIZE,
                                &output_pos);
    }

    if (ivec != NULL)
        memcpy(ivec->data, oblock, DES_BLOCK_SIZE);

    EVP_CIPHER_CTX_cleanup(&ciph_ctx); 

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.