Hi everybody. I'm developing an aplication in C++ which uses some OpenSSL crypto operations. Concretely, I need to offer support to cipher operations, that is, there is a method whis initializes an encrypt operation, an operation which encrypts an input data and which will be called multiple times to encrypt successive blocks of data and one operation to finalize a encrypt operation. My problem is that I'm not obtaining the results I could hope when I make succesive calls to the encypt / decrypt operations (EVP_EncryptUpdate / EVP_DecryptUpdate(), gives back not expected values suchs as 0 values ).


The operation which initialize a cipher is like this:


    EVP_CIPHER_CTX * ctx = (EVP_CIPHER_CTX *)LocalAlloc(LMEM_ZEROINIT, sizeof(EVP_CIPHER_CTX));


    EVP_CIPHER_CTX_init(ctx);

    EVP_CipherInit_ex(ctx, enc, NULL, NULL, NULL, 1);

    EVP_CIPHER_CTX_set_key_length(ctx, key_len);

    /* We finished modifying parameters so now we can set key and IV */

    int result = EVP_CipherInit_ex(ctx, NULL, NULL, key,iv, 1);


The function whick make a cipher by parts is:


    int result = EVP_CipherUpdate(ctx, pEncryptedPart, pulEncryptedPartLen, pPart, ulPartLen);


where pEncryptedPart is a buffer whith the neccesary long (ulPartLen + cipher_block_size - 1).


The function which finalizes the encrypt operation is:


    int result = EVP_CipherFinal_ex(ctx, pLastEncryptedPart,(int *)pulLastEncryptedPartLen);


    EVP_CIPHER_CTX_cleanup(ctx);


What can be happening?. Thanks in advance


----------------------------------------------------------------------
Antonio Andrés Espallardo (
[EMAIL PROTECTED])
Dept. Ingeniería de la Información y las Comunicaciones
Facultad de Informática
Universidad de Murcia
----------------------------------------------------------------------

Reply via email to