On Thu, May 06, 2010, heiko vonsachsen wrote:
> Dear all,
> attached a small code example which does not work...
>
> EVP_PKEY* pkey=PEM_read_bio_PUBKEY(mem,NULL,NULL,NULL) does not return any
> value...can anybody please explaine me why? i've spend hours without any
> results!
> thanks in advance,
> Heiko
> _______________________________________
>
>
> #include "stdafx.h"
> #include "string.h"
> #include "openssl\evp.h"
> #include "openssl\ecdsa.h"
> #include "openssl\pem.h"
> #include "openssl\sha.h"
> #include "openssl\err.h"
>
> int CalculateHash()
> {
> CRYPTO_malloc_init();
> OpenSSL_add_all_algorithms();
> unsigned char sha1sum[SHA_DIGEST_LENGTH];
> const char sig[] =
> "BDUwMwIXGkSR09jzv2juC1I/kV1BrV37un16SzoCGEUtRZ7kdguqV8HtZ9LcecMZmCZOOTsD8A==";
> char* data =
> ";\"4399901587311\";\"20063650118-01679\";\"4313822000018\";\"20091201143327230\";";
> char* key =
> "MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEwiljC8QSd5Q89jqg+Qk5KmFXdbbR+006PMkmr9eGEmDTsB9GVY9OTx8+b3nNqdMS";
>
> // make hash of data
> SHA1((const unsigned char*)data, strlen(data), sha1sum);
>
> // load key
> BIO* b64 = BIO_new(BIO_f_base64());
> BIO* mem = BIO_new(BIO_s_mem());
> BIO_puts(mem,key);
> mem = BIO_push(b64,mem);
> EVP_PKEY* pkey=PEM_read_bio_PUBKEY(mem,NULL,NULL,NULL);
> if( pkey == 0){
> ERR_print_errors_fp(stdout);
> }
> EC_KEY* eckey = EVP_PKEY_get1_EC_KEY(pkey);
>
This possibly:
http://www.openssl.org/support/faq.html#PROG15
Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]