From 54cb253e0bd7a21266ab36cb0b1bbd96e86634a6 Mon Sep 17 00:00:00 2001 From: "yuseok.jeon" Date: Tue, 1 Jul 2014 16:08:19 +0900 Subject: [PATCH] fix CryptoService ititialize method Change-Id: I4c42f6a5023fc48d85132c60f556cdadb00c6438 Signed-off-by: yuseok.jeon --- src/manager/service/CryptoService.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/manager/service/CryptoService.cpp diff --git a/src/manager/service/CryptoService.cpp b/src/manager/service/CryptoService.cpp old mode 100644 new mode 100755 index 906a7c3..852d4a5 --- a/src/manager/service/CryptoService.cpp +++ b/src/manager/service/CryptoService.cpp @@ -34,10 +34,12 @@ CryptoService::CryptoService(){ CryptoService::~CryptoService(){ } + + int CryptoService::initialize() { int mode = 0; int rc = 0; - int hw_ret = 0, u_ret = 0; + int hw_rand_ret = 0, u_rand_ret = 0; // try to initialize using ERR_load_crypto_strings and OpenSSL_add_all_algorithms ERR_load_crypto_strings(); @@ -51,24 +53,19 @@ int CryptoService::initialize() { if(rc == 0) { LogError("Error in FIPS_mode_set function"); - ThrowMsg(Exception::Base, "Error in FIPS_mode_set function"); } } // initialize entropy std::ifstream ifile(DEV_HW_RANDOM_FILE); if(ifile.is_open()) { - u_ret= RAND_load_file(DEV_HW_RANDOM_FILE, 32); - - if(u_ret != 32) { - LogError("Error in HW_RAND file load"); - ThrowMsg(CryptoService::Exception::Crypto_internal, "Error in HW_RAND file load"); - } + u_rand_ret= RAND_load_file(DEV_HW_RANDOM_FILE, 32); } - else { - hw_ret = RAND_load_file(DEV_URANDOM_FILE, 32); + if(u_rand_ret != 32 ){ + LogError("Error in HW_RAND file load"); + hw_rand_ret = RAND_load_file(DEV_URANDOM_FILE, 32); - if(hw_ret != 32) { + if(hw_rand_ret != 32) { LogError("Error in U_RAND_file_load"); ThrowMsg(CryptoService::Exception::Crypto_internal, "Error in U_RAND_file_load"); } @@ -77,6 +74,8 @@ int CryptoService::initialize() { return CKM_CRYPTO_INIT_SUCCESS; } + + int CryptoService::createKeyPairRSA(const int size, // size in bits [1024, 2048, 4096] GenericKey &createdPrivateKey, // returned value GenericKey &createdPublicKey) // returned value -- 2.7.4