I am recieving this error when decryption routine is executed to decrypt the encrypted input. someone pls tell me the reason for this error and if possible what we need to do in order to solve this.
Code Snippet for Decryption: int decrypt (int infd, int outfd) { unsigned char outbuf[IP_SIZE]; int olen, tlen, n,i; unsigned char inbuff[OP_SIZE]; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init (&ctx); printf("128 bit key:\n"); for (i = 0; i < 16; i++) printf ("%c \t", key[i]); printf ("\n ------ \n"); printf("Initialization vector\n"); for (i = 0; i < 8; i++) printf ("%c \t", iv[i]); printf ("\n ------ \n"); EVP_DecryptInit_ex (&ctx, EVP_bf_cbc (), NULL , key, iv); //for (;;) //{ bzero (&inbuff, OP_SIZE); if ((n = read (infd, inbuff, OP_SIZE)) == -1) { perror ("read error"); exit; } else if (n == 0) exit; bzero (&outbuf, IP_SIZE); if (EVP_DecryptUpdate (&ctx, outbuf, &olen, inbuff, n) != 1) { printf ("error in decrypt update\n"); return 0; } if (EVP_DecryptFinal_ex (&ctx, outbuf + olen, &tlen) != 1) { printf ("error in decrypt final\n"); return 0; } olen += tlen; if ((n = write (outfd, outbuf, olen)) == -1) perror ("write error"); //} EVP_CIPHER_CTX_cleanup (&ctx); return 1; } Have used this unsigned char key[16]="FEDCBA9876543210"; unsigned char iv[8]="12345678"; to have constant KEY and IV regards, Rounak