On Wed, Apr 15, 2009 at 08:19:34PM +0300, Atti wrote:

> Okay, well as I said, I compiled and ran the example from the OpenSSL
> docs (http://openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES),
> which has an IV, and the application still behaves the same.

What key and IV sizes does the following code variant report? On
a Unix system both 0.9.8i and 1.0.0-beta1 produce consistent
identical ciphertexts that decrypt via "openssl bf -in cipher.bin -K
000102030405060708090A0B0C0D0E0F -iv 0102030405060708 -d" as advertised.

#include <openssl/evp.h>
#include <stdio.h>
int do_crypt(char *outfile)
{
    unsigned char outbuf[1024];
    int outlen, tmplen;
    unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
    unsigned char iv[] = {1,2,3,4,5,6,7,8};
    char intext[] = "Some Crypto Text";
    EVP_CIPHER_CTX ctx;
    FILE *out;

    EVP_CIPHER_CTX_init(&ctx);
    EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv);
    fprintf(stderr, "key length=%d, IV length=%d\n",
            EVP_CIPHER_CTX_key_length(&ctx),
            EVP_CIPHER_CTX_iv_length(&ctx));
    if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
        return 0;
    if(!EVP_EncryptFinal_ex(&ctx, outbuf + outlen, &tmplen))
        return 0;
    outlen += tmplen;
    EVP_CIPHER_CTX_cleanup(&ctx);

    out = fopen(outfile, "wb");
    fwrite(outbuf, 1, outlen, out);
    fclose(out);
    return 1;
}
int main(int argc, char *argv[]) { return !do_crypt(argv[1]); }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to