| 1 |
// Copyright (c) 2014, Google Inc. |
| 2 |
// SPDX-License-Identifier: ISC |
| 3 |
|
| 4 |
#ifndef OPENSSL_HEADER_ENGINE_H |
| 5 |
#define OPENSSL_HEADER_ENGINE_H |
| 6 |
|
| 7 |
#include <openssl/base.h> |
| 8 |
|
| 9 |
#if defined(__cplusplus) |
| 10 |
extern "C" { |
| 11 |
#endif |
| 12 |
|
| 13 |
|
| 14 |
// Engines are collections of methods. Methods are tables of function pointers, |
| 15 |
// defined for certain algorithms, that allow operations on those algorithms to |
| 16 |
// be overridden via a callback. This can be used, for example, to implement an |
| 17 |
// RSA* that forwards operations to a hardware module. |
| 18 |
// |
| 19 |
// Default Methods are zero initialized. You should set the function pointers |
| 20 |
// that you wish before setting it on an |ENGINE|. Any functions pointers that |
| 21 |
// are NULL indicate that the default behaviour should be used. |
| 22 |
|
| 23 |
|
| 24 |
// Allocation and destruction. |
| 25 |
|
| 26 |
// ENGINE_new returns an empty ENGINE that uses the default method for all |
| 27 |
// algorithms. |
| 28 |
OPENSSL_EXPORT ENGINE *ENGINE_new(void); |
| 29 |
|
| 30 |
// ENGINE_free decrements the reference counts for all methods linked from |
| 31 |
// |engine| and frees |engine| itself. It returns one. |
| 32 |
OPENSSL_EXPORT int ENGINE_free(ENGINE *engine); |
| 33 |
|
| 34 |
|
| 35 |
// Method accessors. |
| 36 |
// |
| 37 |
// The setter functions do not take ownership of the |method| pointer. The |
| 38 |
// consumer must free the |method| pointer after all objects referencing it are |
| 39 |
// freed. |
| 40 |
|
| 41 |
// ENGINE_set_RSA takes a |method| pointer and sets it on the |ENGINE| object. |
| 42 |
// Returns one on success and zero for failure when |engine| is NULL. |
| 43 |
OPENSSL_EXPORT int ENGINE_set_RSA(ENGINE *engine, const RSA_METHOD *method); |
| 44 |
|
| 45 |
// ENGINE_get_RSA returns the meth field of |engine|. If |engine| is NULL, |
| 46 |
// function returns NULL. |
| 47 |
OPENSSL_EXPORT const RSA_METHOD *ENGINE_get_RSA(const ENGINE *engine); |
| 48 |
|
| 49 |
// ENGINE_set_EC takes a |method| pointer and sets it on the |ENGINE| object. |
| 50 |
// Returns one on success and zero for failure when |engine| is NULL. |
| 51 |
OPENSSL_EXPORT int ENGINE_set_EC(ENGINE *engine, const EC_KEY_METHOD *method); |
| 52 |
|
| 53 |
// ENGINE_get_EC returns the meth field of |engine|. If |engine| is NULL, |
| 54 |
// function returns NULL. |
| 55 |
OPENSSL_EXPORT const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *engine); |
| 56 |
|
| 57 |
|
| 58 |
// Deprecated functions. |
| 59 |
|
| 60 |
// ENGINE_cleanup does nothing. This has been deprecated since OpenSSL 1.1.0 and |
| 61 |
// applications should not rely on it. |
| 62 |
OPENSSL_EXPORT void ENGINE_cleanup(void); |
| 63 |
|
| 64 |
|
| 65 |
#if defined(__cplusplus) |
| 66 |
} // extern C |
| 67 |
|
| 68 |
extern "C++" { |
| 69 |
|
| 70 |
BSSL_NAMESPACE_BEGIN |
| 71 |
|
| 72 |
BORINGSSL_MAKE_DELETER(ENGINE, ENGINE_free) |
| 73 |
|
| 74 |
BSSL_NAMESPACE_END |
| 75 |
|
| 76 |
} // extern C++ |
| 77 |
|
| 78 |
#endif |
| 79 |
|
| 80 |
#define ENGINE_R_OPERATION_NOT_SUPPORTED 100 |
| 81 |
|
| 82 |
#endif // OPENSSL_HEADER_ENGINE_H |