Hi,
I'm trying to encrypt and decrypt data using RSA.
In order to test, I generated a key pair using openssl rsa -outform DER
and I transformed it into a C array getting this :
unsigned char clepriv_der[] = {
0x30, 0x81, 0xab, 0x02, 0x01, 0x00, 0x02, 0x21, 0x00, 0xdb,
0x46, 0x81,
0xdc, 0x1c, 0xc4, 0x6a, 0x7d, 0xa3, 0xcc, 0xc1, 0x60, 0x91,
0x5e, 0x5a,
0xf1, 0x79, 0x75, 0x76, 0x33, 0x73, 0x4c, 0x4d, 0xa0, 0x8e,
0x25, 0x17,
0xa7, 0xfb, 0x46, 0x15, 0x57, 0x02, 0x03, 0x01, 0x00, 0x01,
0x02, 0x20,
0x1e, 0xa9, 0x41, 0x47, 0x52, 0x0e, 0x75, 0x05, 0x94, 0x7d,
0xf1, 0x1c,
0x5b, 0xb7, 0x61, 0xe7, 0xd7, 0xd9, 0x1f, 0x1e, 0xd7, 0x36,
0xf8, 0xfe,
0xb5, 0xd3, 0xa9, 0x41, 0xc0, 0x9e, 0x48, 0xa1, 0x02, 0x11,
0x00, 0xf2,
0x5e, 0x7e, 0x7c, 0x81, 0xe3, 0x78, 0x93, 0x22, 0xa9, 0xd4,
0xb7, 0x36,
0xe6, 0x57, 0x83, 0x02, 0x11, 0x00, 0xe7, 0x9b, 0x85, 0xa0,
0xa4, 0x25,
0x39, 0x03, 0x9e, 0x97, 0xc7, 0xfc, 0x39, 0x5d, 0xce, 0x9d,
0x02, 0x11,
0x00, 0xe1, 0xe5, 0xb6, 0xe8, 0x9f, 0x3b, 0x7f, 0x97, 0x4b,
0xb8, 0x94,
0xdd, 0x8b, 0x1a, 0xd7, 0xb7, 0x02, 0x10, 0x6c, 0x45, 0x62,
0xf1, 0x96,
0xea, 0xa3, 0xbd, 0x92, 0x6d, 0x28, 0x1b, 0x3c, 0x02, 0x23,
0x6d, 0x02,
0x11, 0x00, 0xa4, 0x69, 0xd3, 0x20, 0x2c, 0xd4, 0x07, 0xd8,
0x3d, 0x7a,
0x50, 0x0f, 0xc4, 0xb3, 0x94, 0x91
};
unsigned char clepub_der[] = {
0x30, 0x3c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d,
0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x2b, 0x00, 0x30, 0x28,
0x02, 0x21,
0x00, 0xdb, 0x46, 0x81, 0xdc, 0x1c, 0xc4, 0x6a, 0x7d, 0xa3,
0xcc, 0xc1,
0x60, 0x91, 0x5e, 0x5a, 0xf1, 0x79, 0x75, 0x76, 0x33, 0x73,
0x4c, 0x4d,
0xa0, 0x8e, 0x25, 0x17, 0xa7, 0xfb, 0x46, 0x15, 0x57, 0x02,
0x03, 0x01,
0x00, 0x01
};
When I try to use them, I use this code :
RSA *clefpub;
RSA *clefpriv;
unsigned char *pub;
unsigned char *priv;
pub=clepub_der;
priv=clepriv_der;
clefpub=d2i_RSA_PUBKEY(NULL,(const unsigned char**)&pub,62);
clefpriv=d2i_RSAPrivateKey(NULL,(const unsigned char**)&priv,230);
puts("Chargement des clés terminé");
if(RSA_check_key(clefpub)!=1) {
puts("Erreur vérification de clé publique");
exit(-1);
} else puts("Clé publique valide");
if(RSA_check_key(clefpriv)!=1) {
puts("Erreur vérification de clé privée");
exit(-1);
} else puts("Clé privée valide");
During execution, there is a segmentation fault in RSA_check_key.
I tried by initialising the RSA pointers with RSA_new and got the
same problem and also using d2i_RSAPublicKey instead of d2i_RSA_PUBKEY.
Thank you for your replies.
--
Florian Manach
NUMLOG
[EMAIL PROTECTED]
(+33)0130791616
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]