Skip to content

Commit

Permalink
refactored ENGINE funcs and updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
smittals2 committed Aug 23, 2024
1 parent bb6298c commit f8a3036
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 8 additions & 2 deletions crypto/engine/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ int ENGINE_set_RSA(ENGINE *engine, const RSA_METHOD *method) {
}

const RSA_METHOD *ENGINE_get_RSA(const ENGINE *engine) {
return engine->rsa_method;
if(engine) {
return engine->rsa_method;;
}
return NULL;
}

int ENGINE_set_EC(ENGINE *engine, const EC_KEY_METHOD *method) {
Expand All @@ -64,7 +67,10 @@ int ENGINE_set_EC(ENGINE *engine, const EC_KEY_METHOD *method) {
}

const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *engine) {
return engine->eckey_method;
if(engine) {
return engine->eckey_method;
}
return NULL;
}

OPENSSL_DECLARE_ERROR_REASON(ENGINE, OPERATION_NOT_SUPPORTED)
Expand Down
16 changes: 10 additions & 6 deletions include/openssl/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,24 @@ OPENSSL_EXPORT int ENGINE_free(ENGINE *engine);

// Method accessors.
//
// Method accessors take a method pointer and set it on the |ENGINE| object.
// AWS-LC does not take ownership of the |method| pointer. The consumer
// must free the |method| pointer after all objects referencing it are
// The setter functions do not take ownership of the |method| pointer. The
// consumer must free the |method| pointer after all objects referencing it are
// freed.
//
// Set functions return one on success and zero for failure when
// |engine| is NULL.

// ENGINE_set_RSA takes a |method| pointer and sets it on the |ENGINE| object.
// Returns one on success and zero for failure when |engine| is NULL.
OPENSSL_EXPORT int ENGINE_set_RSA(ENGINE *engine, const RSA_METHOD *method);

// ENGINE_get_RSA returns the meth field of |engine|. If |engine| is NULL,
// function returns NULL.
OPENSSL_EXPORT const RSA_METHOD *ENGINE_get_RSA(const ENGINE *engine);

// ENGINE_set_EC takes a |method| pointer and sets it on the |ENGINE| object.
// Returns one on success and zero for failure when |engine| is NULL.
OPENSSL_EXPORT int ENGINE_set_EC(ENGINE *engine, const EC_KEY_METHOD *method);

// ENGINE_get_EC returns the meth field of |engine|. If |engine| is NULL,
// function returns NULL.
OPENSSL_EXPORT const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *engine);


Expand Down

0 comments on commit f8a3036

Please sign in to comment.