what about rsa_public_key->n
and rsa_public_key->e You could do BN *n = BN_dup(rsa_public_key->n); BN *e = BN_dup(rsa_public_key->e); And do what you want with them (don't forget to free them) If you are wanting to display them char *n_txt = BN_bn2dec(n); char *e_txt = BN_bn2dec(e); or char *n_hextxt = BN_bn2hex(n); char *e_hextxt = BN_bn2hex(e); if you want the data in a non-openssl format for some other library you can get the bits int n_len = BN_num_bytes(n); int e_len = BN_num_bytes(e); unsigned char *raw_n,*raw_e if (! raw_n = malloc(n_len)) { fail ...} if (! raw_e = malloc(e_len)) { fail ...} if (BN_bn2bin(n,raw_n)!= n_len) { fail...} if (BN_bn2bin(e,raw_e)!= e_len) { fail...} -----Original Message----- From: owner-openssl-us...@openssl.org [mailto:owner-openssl-us...@openssl.org] On Behalf Of Bizhan Gholikhamseh (bgholikh) Sent: Thursday, October 22, 2009 6:20 AM To: openssl-users@openssl.org Subject: Newbie questions: extracting public key's exponent and modules. Hi All, Here is the part of the code that was previously developed. The code successfully extract a public key from some secure server, now I like to know how to extract the exponent and modules of the public key (rsa_public_key). EVP_PKEY *public_key = NULL; RSA *rsa_public_key = NULL; ... ... public_key = ENGINE_load_public_key(e1, file_nm_public, UI_OpenSSL(), NULL); if (public_key == NULL) { ... exit (-1); } rsa_public_key = EVP_PKEY_get1_RSA(public_key); Many thanks in advance, Bizhan ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org