Thanks for the  response Dr. Henson.
I had found this code at 
http://books.google.com/books?id=dbocXYHcUAUC&pg=PA232&lpg=PA232&dq=evp_decryptfinal_ex&source=web&ots=y0dMb3Salh&sig=lLAYthDUIzbaAxMi0bBxJzyOGUg#PPA232,M1
, Page 232. I just changed the variables.
But it seems this book's code does not work.
So, should I do something like this -

int currentReadLength = 0;
            int currentDataLength = 0;
            datalength = 0;
            printf("\n iNumChunks  is %d\n", iNumChunks);
            memset(pBuff,0,pOutLength * sizeof(unsigned char));
            for(int i=0;i<iNumChunks;i++)
            {
                
if(!EVP_EncryptUpdate(&ctx,&pBuff[currentDataLength],&datalength,&pData[currentReadLength],1024))
                {
                    #ifdef SSDK_DEBUG
                        printf("\nEncrypt failed\n");
                        ERR_print_errors_fp(stdout);
                    #endif
                    EVP_CIPHER_CTX_cleanup(&ctx);
                    return CRYPTO_ENCRYPTION_ENGINE_FAILURE;

                }
                printf("\n currentLength is %d\n", currentDataLength);
                printf("\n encrypt datalength 1 is %d\n", datalength);
                fflush(stdout);
                currentReadLength += 1024;
                currentDataLength += datalength;
                printf("\n currentLength is %d\n", currentDataLength);
            }
......

thanks

> Date: Mon, 19 Nov 2007 21:52:35 +0100
> From: [EMAIL PROTECTED]
> To: openssl-users@openssl.org
> Subject: Re: Reposting: EVP_DecryptFinal_ex:bad decrypt
> 
> On Mon, Nov 19, 2007, Pankaj Mathur wrote:
> 
> > 
> > I am still struggling with this issue.
> > I did not get much help from the list, so I am reposting again.
> > 
> if(!EVP_EncryptUpdate(&ctx,&pBuff[currentLength],
>                                               &datalength,
>                                               &pData[currentLength],1024))
> ...
> currentLength += datalength;
> 
> The above shows you are not using EVP_EncryptUpdate properly. It will consume
> all of the input buffer (1024 bytes in this example) and write datalength
> bytes to the output buffer. 
> 
> Your use of EVP_DecryptUpdate() has similar problems.
> 
> Steve.
> -- 
> Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
> OpenSSL project core developer and freelance consultant.
> Funding needed! Details on homepage.
> Homepage: http://www.drh-consultancy.demon.co.uk
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           [EMAIL PROTECTED]

_________________________________________________________________
Post free property ads on Yello Classifieds now! www.yello.in
http://ss1.richmedia.in/recurl.asp?pid=220

Reply via email to