This problem has been resolved.

int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
         ENGINE *impl, unsigned char *key, unsigned char *iv);

EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv);

In the example at 
http://www.openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES the 
function is called with incorrect parameters. Parameter two needs to be 
a const EVP_CIPHER *type and parameter three should be type ENGINE 
*impl. The EVP_EncryptInit_ex() function in the example should be as 
follows: EVP_EncryptInit_ex(&ctx, NULL, EVP_bf_cbc(), key, iv);




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, NULL, EVP_bf_cbc(), key, iv);

        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;
        }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to