On Wed, Nov 21, 2007, Lidia Fernndez wrote: > I have to encrypt a file in c with openssl and then i have to decrypt in > Java. > > In Java i use to decrypt the algorithm > > Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); > > With OpenSSL i use > > openssl enc -a -des-ecb -in file -out file.enc -pass pass:abcdefgh > > but i have an error message in Java that say > > javax.crypto.BadPaddingException: Given final block not properly padded > > > What padding does OpenSSL use??? How can i specify the padding?? >
OpenSSL uses standard block padding aka PKCS#5 padding. Unless your Java code implements the necessary key derivation and file parsing functions I suspect you problem may be that the salt value prepended to the output stream. Ypu can avoid this using the -nosalt option and specfying the key explicitly. Though for any kind of security the use of unsalted keys along with DES in ECB mode isn't much use. 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]