| 1 |
// Copyright (c) 2014, Google Inc. |
| 2 |
// SPDX-License-Identifier: ISC |
| 3 |
|
| 4 |
#include <openssl/engine.h> |
| 5 |
|
| 6 |
#include <string.h> |
| 7 |
#include <assert.h> |
| 8 |
|
| 9 |
#include <openssl/ec_key.h> |
| 10 |
#include <openssl/err.h> |
| 11 |
#include <openssl/mem.h> |
| 12 |
#include <openssl/rsa.h> |
| 13 |
#include <openssl/thread.h> |
| 14 |
|
| 15 |
#include "../internal.h" |
| 16 |
#include "../crypto/fipsmodule/ec/internal.h" |
| 17 |
|
| 18 |
|
| 19 |
struct engine_st { |
| 20 |
RSA_METHOD *rsa_method; |
| 21 |
EC_KEY_METHOD *eckey_method; |
| 22 |
}; |
| 23 |
|
| 24 |
ENGINE *ENGINE_new(void) { return OPENSSL_zalloc(sizeof(ENGINE)); } |
| 25 |
|
| 26 |
int ENGINE_free(ENGINE *engine) { |
| 27 |
OPENSSL_free(engine); |
| 28 |
return 1; |
| 29 |
} |
| 30 |
|
| 31 |
int ENGINE_set_RSA(ENGINE *engine, const RSA_METHOD *method) { |
| 32 |
if(!engine) { |
| 33 |
OPENSSL_PUT_ERROR(ENGINE, ERR_R_PASSED_NULL_PARAMETER); |
| 34 |
return 0; |
| 35 |
} |
| 36 |
|
| 37 |
engine->rsa_method = (RSA_METHOD *)method; |
| 38 |
return 1; |
| 39 |
} |
| 40 |
|
| 41 |
const RSA_METHOD *ENGINE_get_RSA(const ENGINE *engine) { |
| 42 |
if(engine) { |
| 43 |
return engine->rsa_method;; |
| 44 |
} |
| 45 |
return NULL; |
| 46 |
} |
| 47 |
|
| 48 |
int ENGINE_set_EC(ENGINE *engine, const EC_KEY_METHOD *method) { |
| 49 |
if(!engine) { |
| 50 |
OPENSSL_PUT_ERROR(ENGINE, ERR_R_PASSED_NULL_PARAMETER); |
| 51 |
return 0; |
| 52 |
} |
| 53 |
|
| 54 |
engine->eckey_method = (EC_KEY_METHOD *)method; |
| 55 |
return 1; |
| 56 |
} |
| 57 |
|
| 58 |
const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *engine) { |
| 59 |
if(engine) { |
| 60 |
return engine->eckey_method; |
| 61 |
} |
| 62 |
return NULL; |
| 63 |
} |
| 64 |
|
| 65 |
OPENSSL_DECLARE_ERROR_REASON(ENGINE, OPERATION_NOT_SUPPORTED) |
| 66 |
|
| 67 |
void ENGINE_cleanup(void) {} |