File: engine.h

package info (click to toggle)
imx-code-signing-tool 3.4.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,912 kB
  • sloc: ansic: 10,258; sh: 2,558; python: 391; yacc: 245; makefile: 203; lex: 59
file content (96 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* SPDX-License-Identifier: BSD-3-Clause */
/*
 * Copyright 2021-2023 NXP
 */

#ifndef ENGINE_H
#define ENGINE_H

#include <adapt_layer.h>
#include "openssl_helper.h"
#include <openssl/evp.h>
#include <openssl/x509.h>

struct engine_ctx {
	/* Engine configuration */
	ENGINE *engine;
};

/**  engine_ctx_new
 *
 * Allocates a new functional reference.
 *
 * @returns functional reference if successful NULL otherwise.
 */
struct engine_ctx *engine_ctx_new(void);

/** engine_ctx_destroy
 *
 * Destroys context and release the functional reference from ctx_new
 *
 * @param[ctx] Pointer to engine context structure
 *
 * @post if successful memory space allocated for functional reference is freed.
 *
 * @pre  #ctx_new has been called previously.
 *
 * @returns 1 if successful 0 otherwise.
 */
int32_t engine_ctx_destroy(struct engine_ctx *ctx);

/** engine_ctx_init
 *
 * Initialize context
 *
 * @param[ctx] Pointer to engine context structure
 *
 * @post if successful memory space allocated is freed.
 *
 * @pre  #ctx_new has been called previously.
 *
 * @returns 1 if successful 0 otherwise.
 */
int32_t engine_ctx_init(struct engine_ctx *ctx);

/** engine_ctx_finish
 *
 * Finalize engine operations initialized with ctx_init
 *
 * @param[ctx] Functional reference
 *
 * @pre  #ctx_init has been called previously.
 *
 * @returns 1 if successful 0 otherwise.
 */
int32_t engine_ctx_finish(struct engine_ctx *ctx);

/**  ENGINE_load_certificate
 *
 * Read certificate with a given reference from engine.
 *
 * @param[in] e engine instance
 *
 * @param[in] cert_ref certificate reference
 *
 * @pre @a e, @a cert_ref must not be NULL.
 *
 * @returns pointer to X.509 certificate if successful, NULL otherwise.
 */
X509 *ENGINE_load_certificate(ENGINE *e, const char *cert_ref);

/**  ENGINE_load_key
 *
 * Read key with a given reference from engine.
 *
 * @param[in] e engine instance
 *
 * @param[in] key_ref key reference
 *
 * @pre @a e, @a key_ref must not be NULL.
 *
 * @returns pointer to EVP_PKEY key if successful, NULL otherwise.
 */
EVP_PKEY *ENGINE_load_key(ENGINE *e, const char *key_ref);


#endif /* ENGINE_H */