Many spelling fixes/typo's corrected.
[openssl.git] / engines / e_afalg.h
1 /*
2  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (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 HEADER_AFALG_H
11 # define HEADER_AFALG_H
12
13 # if defined(__GNUC__) && __GNUC__ >= 4 && \
14      (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
15 #  pragma GCC diagnostic ignored "-Wvariadic-macros"
16 # endif
17
18 # ifdef ALG_DEBUG
19 #  define ALG_DGB(x, ...) fprintf(stderr, "ALG_DBG: " x, __VA_ARGS__)
20 #  define ALG_INFO(x, ...) fprintf(stderr, "ALG_INFO: " x, __VA_ARGS__)
21 #  define ALG_WARN(x, ...) fprintf(stderr, "ALG_WARN: " x, __VA_ARGS__)
22 # else
23 #  define ALG_DGB(x, ...)
24 #  define ALG_INFO(x, ...)
25 #  define ALG_WARN(x, ...)
26 # endif
27
28 # define ALG_ERR(x, ...) fprintf(stderr, "ALG_ERR: " x, __VA_ARGS__)
29 # define ALG_PERR(x, ...) \
30                 do { \
31                     fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
32                     perror(NULL); \
33                 } while(0)
34 # define ALG_PWARN(x, ...) \
35                 do { \
36                     fprintf(stderr, "ALG_PERR: " x, __VA_ARGS__); \
37                     perror(NULL); \
38                 } while(0)
39
40 # ifndef AES_BLOCK_SIZE
41 #  define AES_BLOCK_SIZE   16
42 # endif
43 # define AES_KEY_SIZE_128 16
44 # define AES_IV_LEN       16
45
46 # define MAX_INFLIGHTS 1
47
48 typedef enum {
49     MODE_UNINIT = 0,
50     MODE_SYNC,
51     MODE_ASYNC
52 } op_mode;
53
54 struct afalg_aio_st {
55     int efd;
56     op_mode mode;
57     aio_context_t aio_ctx;
58     struct io_event events[MAX_INFLIGHTS];
59     struct iocb cbt[MAX_INFLIGHTS];
60 };
61 typedef struct afalg_aio_st afalg_aio;
62
63 /*
64  * MAGIC Number to identify correct initialisation
65  * of afalg_ctx.
66  */
67 # define MAGIC_INIT_NUM 0x1890671
68
69 struct afalg_ctx_st {
70     int init_done;
71     int sfd;
72     int bfd;
73 # ifdef ALG_ZERO_COPY
74     int zc_pipe[2];
75 # endif
76     afalg_aio aio;
77 };
78
79 typedef struct afalg_ctx_st afalg_ctx;
80 #endif