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