On Tue, Feb 21, 2006, Alpt wrote: > > Hi there, > > I want to pack a RSA priv key and this is what I'm doing: > > ... > rsa=RSA_generate_key(1024, RSA_F4, NULL, NULL); > len=i2d_RSAPrivateKey(rsa, priv); > ... > > > Why isn't `len' always the same? > Is it normal?
Yes its normal. Some key components have lengths which may be less than the maximum value. The way you are supposed to use this stuff is to first get the length, then allocate enough memory and finally write out the encoding. It isn't a good idea to make assumptions about the maximum size. It risks buffer overrun vulnerabilities. There have been actual cases of that happening. 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]