Reading RSA key fips and non fips mode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Reading RSA key fips and non fips mode

prakash babu
Hello All,

I am using the OpenSSL 0.9.7j-fips-dev  on HPUX
I built the above version by enabling the fips option

I have a 512 bit rsa key in a file rsakey.pem
 
# cat rsakey.pem
-----BEGIN RSA PRIVATE KEY-----
MIIBPAIBAAJBAJvyW3C7htCJYQ2sjXM1r4EgOc5uQFN6N62UstEn+8A8+YShdQ2w
FcM7gRKNmTAtizyFP1i8sHO6YGEgkiA8Ye8CAwEAAQJAOQjlmpBrWR+1iEvAnA9Z
de90VOSL0DwV2v1UfRyTfZX9N3j/LdU1F5pgmnBpOnHkHIbecGdEAPeYn9KFYwc4
QQIhAMxYuMew0xMw7kRMpTTxn+79f4zsdTrKv6xHvpmn1uLhAiEAw12tdS9yJGNK
vyQI16X1ytRz63Frape2mTu6wUoGrs8CIQC0UN3MqAW5e4XkktV9IHGGS/6PdeAE
HwB/n1da8zW1QQIhAIY1KzyuXE4M+8M04PIrqx8sNXnPT4hJMoIvmwq/bLnXAiEA
spklHVXuVhyQT/HGaMGpp7ll8OKVQsujpt0E8lxp1B8=
-----END RSA PRIVATE KEY-----

Case 1
 
i, I set the OPENSSL_FIPS flag
   export OPENSSL_FIPS=1
   
ii I read the rsakey as
# openssl rsa -in rsakey.pem

writing RSA key
-----BEGIN PRIVATE KEY-----
MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAm/JbcLuG0IlhDayN
czWvgSA5zm5AU3o3rZSy0Sf7wDz5hKF1DbAVwzuBEo2ZMC2LPIU/WLywc7pgYSCS
IDxh7wIDAQABAkA5COWakGtZH7WIS8CcD1l173RU5IvQPBXa/VR9HJN9lf03eP8t
1TUXmmCacGk6ceQcht5wZ0QA95if0oVjBzhBAiEAzFi4x7DTEzDuREylNPGf7v1/
jOx1Osq/rEe+mafW4uECIQDDXa11L3IkY0q/JAjXpfXK1HPrcWtql7aZO7rBSgau
zwIhALRQ3cyoBbl7heSS1X0gcYZL/o914AQfAH+fV1rzNbVBAiEAhjUrPK5cTgz7
wzTg8iurHyw1ec9PiEkygi+bCr9sudcCIQCymSUdVe5WHJBP8cZowamnuWXw4pVC
y6Om3QTyXGnUHw==
-----END PRIVATE KEY-----
 
This output does not match the one in rsakey.pem
 
Case 2
i. I unset the OPENSSL_FIPS flag
# unset OPENSSL_FIPS
 
ii I read the rsakey as
# /opt/openssl/bin/openssl rsa -in rsakey.pem
writing RSA key
-----BEGIN RSA PRIVATE KEY-----
MIIBPAIBAAJBAJvyW3C7htCJYQ2sjXM1r4EgOc5uQFN6N62UstEn+8A8+YShdQ2w
FcM7gRKNmTAtizyFP1i8sHO6YGEgkiA8Ye8CAwEAAQJAOQjlmpBrWR+1iEvAnA9Z
de90VOSL0DwV2v1UfRyTfZX9N3j/LdU1F5pgmnBpOnHkHIbecGdEAPeYn9KFYwc4
QQIhAMxYuMew0xMw7kRMpTTxn+79f4zsdTrKv6xHvpmn1uLhAiEAw12tdS9yJGNK
vyQI16X1ytRz63Frape2mTu6wUoGrs8CIQC0UN3MqAW5e4XkktV9IHGGS/6PdeAE
HwB/n1da8zW1QQIhAIY1KzyuXE4M+8M04PIrqx8sNXnPT4hJMoIvmwq/bLnXAiEA
spklHVXuVhyQT/HGaMGpp7ll8OKVQsujpt0E8lxp1B8=
-----END RSA PRIVATE KEY-----
 
This output matches the one in rsakey.pem
 
Is reading a rsakey in fips mode different from reading the rsa key in non fips mode.
 
Thanks,
Prakash


Yahoo! Mail - Helps protect you from nasty viruses.
Reply | Threaded
Open this post in threaded view
|

Re: Reading RSA key fips and non fips mode

Dr. Stephen Henson
On Fri, Feb 03, 2006, prakash babu wrote:

>  
> Is reading a rsakey in fips mode different from reading the rsa key in non fips mode.
>  

In FIPS mode apart from certain exceptions the MD5 digest algorithm use is
forbidden. OpenSSL "traditional" encrypted private key format uses MD5 to
derive the symmetric algorithm key and has no option to change that.

This is a problem because functions such as PEM_write_PrivateKey() would use
that algorithm directly and woudl be unable to work in FIPS mode.

The more secure PKCS#8 format using PKCS#5 v2 can use FIPS approved algorithms
such as SHA1 for the key derivation. Functions such as PEM_read_PrivateKey()
can also handle this format transparently.

Instead of making up another non-standard private key format for FIPS mode it
was decided to switch to PKCS#8 mode using SHA1 when function such as
PEM_write_PrivateKey() are used. This means that existing application can use
PEM_write_PrivateKey() in FIPS mode without modification: provided they use a
approved FIPS symmetric algorithm such as 3DES or AES.

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                    [hidden email]
Automated List Manager                           [hidden email]