[Pkg-openssl-devel] Bug#412979: Small sample program illustrating the problem

maf at appgate.com maf at appgate.com
Sun Mar 4 23:38:29 CET 2007


I have extracted the calls which encfs make to openssl into a small test
program. I compiled it with 0.9.8c and 0.9.8e and the results were (I
had expected the final hex-string to be identical):

Version: OpenSSL 0.9.8c 05 Sep 2006
CTX_key_length: 20   CIPHER_key_length 16
1e38f6b7331143d01630febf3b194bd8494b6439101496969735192d

Version: OpenSSL 0.9.8e 23 Feb 2007
CTX_key_length: 16   CIPHER_key_length 16
866e5c71e19f1f568e665479e997175e6ec609a50179527f8041f177


The source code is:
============================================================================
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/blowfish.h>

static void
init(unsigned char *buf, int length)
{
    int i;

    for (i=0; i<length; i++) {
        buf[i] = i;
    }
}

int
main(int argc, char ** argv)
{
    EVP_CIPHER_CTX ctx;
    unsigned char iv[8], in[28], out[128], key[20];
    int outlen = 0, outlen2 = 0, i;

    init(key, sizeof(key));
    init(iv, sizeof(iv));
    init(in, sizeof(in));

    printf("Version: %s\n", OPENSSL_VERSION_TEXT);

    EVP_CIPHER_CTX_init(&ctx);
    EVP_DecryptInit_ex(&ctx, EVP_bf_cfb(), NULL, NULL, NULL);
    EVP_CIPHER_CTX_set_key_length(&ctx, 20);
    printf("CTX_key_length: %d   CIPHER_key_length %d\n",
           EVP_CIPHER_CTX_key_length(&ctx),
           EVP_CIPHER_key_length(EVP_bf_cfb()));
    EVP_CIPHER_CTX_set_padding(&ctx, 0);
    EVP_DecryptInit_ex(&ctx, NULL, NULL, key, NULL);

    EVP_DecryptInit_ex(&ctx, NULL, NULL, NULL, iv);
    EVP_DecryptUpdate(&ctx, out, &outlen, in, sizeof(in));
    EVP_DecryptFinal_ex(&ctx, out+outlen, &outlen2);

    for(i=0; i<outlen+outlen2; i++) {
        printf("%02x", out[i]);
    }
    printf("\n");

    return 0;
}
============================================================================

	/MaF




More information about the Pkg-openssl-devel mailing list