Hi, thanks for the help, I havn't got it to work yet though. One question. The RFC states "An RSA encrypted value is encoded with PKCS #1 block type 2 as described in [PKCS1]." should I use d2i_X509 for that?
thanks!
From: Tan Eng Ten <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: RSA public key Date: Tue, 07 Sep 2004 13:46:56 +0800
Vadym Fedyukovych wrote:
Tan Eng Ten wrote:
If you have the cert buffer in ASN1 DER encoding, why don't you just use the d2i function like this:
----- unsigned char *ptr; X509 *x509; EVP_PKEY *pubkey;
ptr = cert;
I think there should be x509 = NULL; before
x509 = d2i_X509(&x509, &ptr, cert_len);
pubkey = X509_get_pubkey(x509); -----
There is an RSA object encapsulated in EVP_PKEY, but I am unsure if we should access it directly or must we get a handle through the function EVP_PKEY_get1_RSA().
Anyone can help out?
Niklas Olsson wrote:
Hi, thanks for the reply. I have two questions. The first: Is PEM and ASN1 two different formats on how to represent a certificate? because I think TLS v1.0 uses ASN1. I'm not certain I should use the PEM_* functions?
the next question is about your code, I get a certificate from the server containing the public key, but you wrote PEM_read_bio_PrivateKey(mem_ptr, 0, 0, 0);
should I use a PrivateKey function when I'm only after the public key (and when the certificate doesn't contain a private key)
thanks! /Niklas
From: Sid Hegde <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: RSA public key Date: Mon, 6 Sep 2004 04:27:11 -0700 (PDT)
This is how I read a RSA key from a string buffer where private_key is char * terminated by a \0
RSA *pub_key=NULL; BIO *mem_ptr=NULL; EVP_PKEY *pkey = NULL;
mem_ptr = BIO_new(BIO_s_mem()); BIO_puts(mem_ptr, private_key); pkey = PEM_read_bio_PrivateKey(mem_ptr, 0, 0, 0); pub_key = EVP_PKEY_get1_RSA(pkey);
Hope this helps
- Sid
--- Niklas Olsson <[EMAIL PROTECTED]> wrote:
> > Hi, > I have been look through this mailing list to try to > understand how to read > the public key and encrypt my message. > > so far I think I should use > > PEM_read_bio_RSAPublicKey > and > RSA_public_encrypt > > I get the certificate in a buffer from the server > (TLS - ServerHello > message) > > I would think I should use > BIO *in=NULL; > in = BIO_new_mem_buf(cert, 1558); //cert if the > buffer with the certifiate > RSA *pKey=NULL; > pKey = PEM_read_bio_RSAPublicKey(in,NULL, NULL, > NULL); > > but pKey is always NULL, I thought maybe the in > buffer should only be the > public key so I copied that only, but again I only > get a pKey that is NULL. > > How am I supposed to read my certificate and get a > correct RSA *pKey? > > thanks! > > _________________________________________________________________ > Chat: Ha en fest p� Habbo Hotel > http://habbohotel.msn.se/habbo/sv/channelizer Checka > in h�r! > > ______________________________________________________________________ > OpenSSL Project > http://www.openssl.org > User Support Mailing List > [EMAIL PROTECTED] > Automated List Manager > [EMAIL PROTECTED] >
__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
_________________________________________________________________
Chatt: Tr�ffa nya n�tkompisar p� Habbo Hotel http://habbohotel.msn.se/habbo/sv/channelizer
______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED] g
______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
_________________________________________________________________ L�ttare att hitta dr�mresan med MSN Resor http://www.msn.se/resor/
______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
