Skip to content

Commit e53030e

Browse files
authored
Merge pull request #34 from LabSEC/dev
Add Load & Release methods to DynamicEngine
2 parents 84aa220 + bac1a42 commit e53030e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

include/libcryptosec/DynamicEngine.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ class DynamicEngine : public Engine
5959
* @see Engine::removeFromEnginesList().
6060
*/
6161
void removeFromEnginesList() throw (EngineException);
62+
63+
/**
64+
* Carrega a Engine e seus algoritmos.
65+
* @throw EngineException caso a Engine esteja indisponível ou ocorra erro ao carregá-la.
66+
* @return True se a Engine foi carregada com sucesso, senão False
67+
*/
68+
bool load() throw (EngineException);
69+
70+
/**
71+
* Libera a Engine e seus algoritmos.
72+
* @throw EngineException caso a Engine esteja indisponível.
73+
* @return True se a Engine foi liberada com sucesso, senão False
74+
*/
75+
bool release() throw (EngineException);
6276
};
6377

6478
#endif /*DYNAMICENGINE_H_*/

src/DynamicEngine.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,18 @@ void DynamicEngine::removeFromEnginesList() throw (EngineException)
102102
throw EngineException(EngineException::REMOVE_ENGINE_FROM_LIST, "DynamicEngine::removeFromEnginesList");
103103
}
104104
}
105+
106+
bool DynamicEngine::load() throw (EngineException)
107+
{
108+
int rc = ENGINE_init(this->engine);
109+
rc &= ENGINE_set_default(this->engine, ENGINE_METHOD_ALL);
110+
OpenSSL_add_all_algorithms();
111+
return rc;
112+
}
113+
114+
bool DynamicEngine::release() throw (EngineException)
115+
{
116+
int rc = ENGINE_finish(this->engine);
117+
rc &= ENGINE_free(this->engine);
118+
return rc;
119+
}

0 commit comments

Comments
 (0)