CryptoService::~CryptoService(){
}
-int CryptoService::initialize() {
- int hw_rand_ret = 0;
- int u_rand_ret = 0;
-
- // try to initialize using ERR_load_crypto_strings and OpenSSL_add_all_algorithms
- ERR_load_crypto_strings();
- OpenSSL_add_all_algorithms();
-
- // initialize entropy
- std::ifstream ifile(DEV_HW_RANDOM_FILE);
- if(ifile.is_open()) {
- u_rand_ret= RAND_load_file(DEV_HW_RANDOM_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_rand_ret != 32) {
- LogError("Error in U_RAND_file_load");
- ThrowMsg(CryptoService::Exception::Crypto_internal, "Error in U_RAND_file_load");
- }
- }
-
- return CKM_CRYPTO_INIT_SUCCESS;
-}
-
int CryptoService::createKeyPairRSA(const int size, // size in bits [1024, 2048, 4096]
KeyImpl &createdPrivateKey, // returned value
KeyImpl &createdPublicKey) // returned value
DECLARE_EXCEPTION_TYPE(Base, opensslError);
};
- // During initialization, FIPS_MODE and the antropy source are set.
- // And system certificates are loaded in the memory during initialization.
- // FIPS_MODE - ON, OFF(Default)
- // antropy source - /dev/random,/dev/urandom(Default)
- static int initialize();
-
static int createKeyPairRSA(const int size, // size in bits [1024, 2048, 4096]
KeyImpl &createdPrivateKey, // returned value ==> Key &createdPrivateKey,
KeyImpl &createdPublicKey); // returned value ==> Key &createdPublicKey
namespace SW {
namespace Internals {
+// During initialization, FIPS_MODE and the entropy source are set
+// and system certificates are loaded to memory.
+// FIPS_MODE - ON, OFF(Default)
+// entropy source - /dev/random,/dev/urandom(Default)
int initialize();
void createKeyPairRSA(const int size,
#include <generic-backend/exception.h>
#include <sw-backend/key.h>
#include <sw-backend/store.h>
+#include <sw-backend/internals.h>
namespace CKM {
namespace Crypto {
namespace SW {
+Store::Store(CryptoBackend backendId)
+ : GStore(backendId)
+{
+ // initialize openssl internals
+ Internals::initialize();
+}
+
GKeyShPtr Store::getKey(const Token &token) {
if (token.backendId != m_backendId) {
LogError("Decider choose wrong backend!");
class Store : public GStore {
public:
- explicit Store(CryptoBackend backendId) : GStore(backendId) {}
+ explicit Store(CryptoBackend backendId);
virtual GKeyShPtr getKey(const Token &token);
virtual Token import(DataType dataType, const RawBuffer &buffer);
#include <key-provider.h>
#include <file-system.h>
-/* TODO remove this include */
-#include <sw-backend/crypto-service.h>
-
#define REGISTER_SOCKET_SERVICE(manager, service) \
registerSocketService<service>(manager, #service)
CKM::KeyProvider::initializeLibrary();
- /* ToDO remove it */
- CKM::Crypto::SW::CryptoService::initialize();
-
{
LogInfo("Start!");
CKM::SocketManager manager;