sg1
sg1

Reputation: 485

Difference between EVP_PKEY_RSA and EVP_PKEY_RSA2 in OpenSSL?

What is the difference between the 2 key types in OpenSSL:

1) EVP_PKEY_RSA

2) EVP_PKEY_RSA2

In the library the 2 are defined as:

#define EVP_PKEY_RSA    NID_rsaEncryption
#define EVP_PKEY_RSA2   NID_rsa

Further, the NIDs are defined as:

#define NID_rsaEncryption       6
#define NID_rsa             19

Upvotes: 2

Views: 2524

Answers (1)

philippe lhardy
philippe lhardy

Reputation: 3286

Both are EVP_PKEY_RSA type then covers same rsa key pairs, but with different object identifiers used in different contexts, PKCS1 or X509 certificates.

code lines extracted from *crypto/objects/obj_dat.h*

for EVP_PKEY_RSA NID_rsaEncryption :

0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,/* [ 38] OBJ_rsaEncryption */    
{"rsaEncryption","rsaEncryption",NID_rsaEncryption,9,&(lvalues[38]),0},

which is PKCS1 RSA encryption 1.2.840.113549.1.1.1

for EVP_PKEY_RSA2 NID_rsa

0x55,0x08,0x01,0x01,                         /* [104] OBJ_rsa */
{"RSA","rsa",NID_rsa,4,&(lvalues[104]),0},

which is rsa encryption for X.500 defined algorithms id-ea-rsa 2.5.8.1.1

Upvotes: 3

Related Questions