mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-14 20:37:55 +00:00
Cryptography_add_osrandom_engine should be safe to call multiple times
This commit is contained in:
parent
d2f24580aa
commit
7f25030b53
2 changed files with 8 additions and 1 deletions
|
|
@ -98,7 +98,7 @@ class Binding(object):
|
|||
_OSX_PRE_INCLUDE, _OSX_POST_INCLUDE,
|
||||
libraries)
|
||||
res = cls.lib.Cryptography_add_osrandom_engine()
|
||||
assert res == 1
|
||||
assert res != 0
|
||||
|
||||
@classmethod
|
||||
def is_available(cls):
|
||||
|
|
|
|||
|
|
@ -175,6 +175,13 @@ static RAND_METHOD osrandom_rand = {
|
|||
};
|
||||
|
||||
int Cryptography_add_osrandom_engine(void) {
|
||||
ENGINE *engine = ENGINE_by_id(Cryptography_osrandom_engine_id);
|
||||
if (engine != NULL) {
|
||||
// The engine has already been added,
|
||||
ENGINE_free(engine);
|
||||
return 2;
|
||||
}
|
||||
|
||||
ENGINE *e = ENGINE_new();
|
||||
if (e == NULL) {
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue