From f77e1e4d2adf4422943c10a1906854c3027391d8 Mon Sep 17 00:00:00 2001 From: open-license-manager <rillf@maildrop.cc> Date: 周一, 14 4月 2014 01:11:41 +0800 Subject: [PATCH] first roundtrip test --- src/library/os/linux/os-linux.cpp | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/library/os/linux/os-linux.cpp b/src/library/os/linux/os-linux.cpp index b8ad61c..2028d47 100644 --- a/src/library/os/linux/os-linux.cpp +++ b/src/library/os/linux/os-linux.cpp @@ -69,12 +69,16 @@ char *pubKey = PUBLIC_KEY ; - BIO* bio = BIO_new_mem_buf((void*) (pubKey), sizeof(pubKey)); - EVP_PKEY *pktmp = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL); + BIO* bio = BIO_new_mem_buf((void*) (pubKey), strlen(pubKey)); + RSA *rsa = PEM_read_bio_RSAPublicKey(bio, NULL,NULL,NULL); BIO_free(bio); - if (pktmp == NULL) { + if (rsa == NULL) { throw new logic_error("Error reading public key"); } + EVP_PKEY *pkey = EVP_PKEY_new(); + + EVP_PKEY_assign_RSA(pkey, rsa); + /*BIO* bo = BIO_new(BIO_s_mem()); BIO_write(bo, pubKey, strlen(pubKey)); RSA *key = 0; @@ -87,7 +91,7 @@ if (!(mdctx = EVP_MD_CTX_create())) { throw new logic_error("Error creating context"); } - if (1 != EVP_DigestVerifyInit(mdctx, NULL, EVP_sha256(), NULL, pktmp)) { + if (1 != EVP_DigestVerifyInit(mdctx, NULL, EVP_sha256(), NULL, pkey)) { throw new logic_error("Error initializing digest"); } -- Gitblit v1.9.1