Dr. Stephen Henson wrote: >On Thu, Sep 09, 2004, Steve Hay wrote: > > > >>I've no idea what the ASN1_TYPE *param is, or where to get one from. I >>had a look at EVP_CIPHER_param_to_asn1(), but it says that the cipher IV >>in the ctx passed to it must be set when the call is made, which seems >>to be a chicken-and-egg problem to me -- I haven't got the cipher IV yet ;) >> >>Any clues how to use PKCS5_v2_PBE_keyivgen() would be greatly appreciated. >> >> >> > >The function itself is intended to be used to generate or supply various >paramaters in an appropriate DER structure. > >The password based encryption functions are intended to be called via the >EVP_PBE_CipherInit() interface which is very similar to EVP_CipherInit(). >The ASN1_TYPE parameter comes from various places depending on the PBE >algorithm in use. For PKCS#5 v2.0 PKCS5_pbe2_set() is used. This is primarily >to allow the PBE stuff to be used in appropriate ASN1 structures. > >The IV is generated randomly and included in the structure. Currently there's >no way to supply your own IV but that will be fixed at some point... > I'm afraid I don't know what "password based encryption" is, so I don't know if this is the right thing to even be trying to do. It doesn't sound like what I wanted...
Does the fact that the IV is generated randomly mean that this will be no good for encrypting and then later (i.e. with a different IV) decrypting some data? If so, then this no good anyway. > >Alternatively you can get at the "guts" of the function by using >PKCS5_PBKDF2_HMAC_SHA1(). Then you have to generate your own salt and pass it >to the function along with the password and interation count. > Sounds a little more hopeful. Where do I get the "salt" from? Would randomly generating it lead to the same encryption/decryption problem as with the IV above? Would hard-coding something in the source code suffice or is that not advisable? However, PKCS5_PBKDF2_HMAC_SHA1() only seems to generate a key, not an IV, but I already have a key -- it's the IV that I want! It may be worth taking a step back and reconsidering what I'm trying to achieve. I'm just trying to create a program to encrypt (and later decrypt) a plain text file. The user chooses (or more likely randomly generates) a key and specifies this as the key to use when *building* the program. I then discovered that the encryption/decryption functions require an IV too, but still don't really know what an IV is... At the moment I'm trying to generate the IV, and also getting a new key, from the "key" that the user has supplied, and I'm getting lost in all sorts of things that I don't understand and wasn't expecting to encounter -- passwords, IV's, salt, PKCS#5, etc :( Is it necessary/advisable to generate a key+IV in this way, or would it in fact suffice to have the user supply the IV too and just use the given key+IV? - Steve ------------------------------------------------ Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]