e_afalg.h 2.0 KB

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