Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/openssl/engines/e_afalg.h
105221 views
1
/*
2
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3
*
4
* Licensed under the Apache License 2.0 (the "License"). You may not use
5
* this file except in compliance with the License. You can obtain a copy
6
* in the file LICENSE in the source distribution or at
7
* https://www.openssl.org/source/license.html
8
*/
9
10
#ifndef OSSL_ENGINES_E_AFALG_H
11
#define OSSL_ENGINES_E_AFALG_H
12
13
#if defined(__GNUC__) && __GNUC__ >= 4 && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
14
#pragma GCC diagnostic ignored "-Wvariadic-macros"
15
#endif
16
17
#ifdef ALG_DEBUG
18
#define ALG_DGB(x, ...) fprintf(stderr, "ALG_DBG: " x, __VA_ARGS__)
19
#define ALG_INFO(x, ...) fprintf(stderr, "ALG_INFO: " x, __VA_ARGS__)
20
#define ALG_WARN(x, ...) fprintf(stderr, "ALG_WARN: " x, __VA_ARGS__)
21
#else
22
#define ALG_DGB(x, ...)
23
#define ALG_INFO(x, ...)
24
#define ALG_WARN(x, ...)
25
#endif
26
27
#define ALG_ERR(x, ...) fprintf(stderr, "ALG_ERR: " x, __VA_ARGS__)
28
#define ALG_PERR(x, ...) \
29
do { \
30
fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
31
perror(NULL); \
32
} while (0)
33
#define ALG_PWARN(x, ...) \
34
do { \
35
fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
36
perror(NULL); \
37
} while (0)
38
39
#ifndef AES_BLOCK_SIZE
40
#define AES_BLOCK_SIZE 16
41
#endif
42
#define AES_KEY_SIZE_128 16
43
#define AES_KEY_SIZE_192 24
44
#define AES_KEY_SIZE_256 32
45
#define AES_IV_LEN 16
46
47
#define MAX_INFLIGHTS 1
48
49
typedef enum {
50
MODE_UNINIT = 0,
51
MODE_SYNC,
52
MODE_ASYNC
53
} op_mode;
54
55
enum {
56
AES_CBC_128 = 0,
57
AES_CBC_192,
58
AES_CBC_256
59
};
60
61
struct cbc_cipher_handles {
62
int key_size;
63
EVP_CIPHER *_hidden;
64
};
65
66
typedef struct cbc_cipher_handles cbc_handles;
67
68
struct afalg_aio_st {
69
int efd;
70
op_mode mode;
71
aio_context_t aio_ctx;
72
struct io_event events[MAX_INFLIGHTS];
73
struct iocb cbt[MAX_INFLIGHTS];
74
};
75
typedef struct afalg_aio_st afalg_aio;
76
77
/*
78
* MAGIC Number to identify correct initialisation
79
* of afalg_ctx.
80
*/
81
#define MAGIC_INIT_NUM 0x1890671
82
83
struct afalg_ctx_st {
84
int init_done;
85
int sfd;
86
int bfd;
87
#ifdef ALG_ZERO_COPY
88
int zc_pipe[2];
89
#endif
90
afalg_aio aio;
91
};
92
93
typedef struct afalg_ctx_st afalg_ctx;
94
#endif
95
96