cipher_aes_siv.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright 2019-2021 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. #include "prov/ciphercommon.h"
  10. #include "crypto/aes_platform.h"
  11. #include "crypto/siv.h"
  12. typedef struct prov_cipher_hw_aes_siv_st {
  13. int (*initkey)(void *ctx, const uint8_t *key, size_t keylen);
  14. int (*cipher)(void *ctx, unsigned char *out, const unsigned char *in,
  15. size_t len);
  16. void (*setspeed)(void *ctx, int speed);
  17. int (*settag)(void *ctx, const unsigned char *tag, size_t tagl);
  18. void (*cleanup)(void *ctx);
  19. int (*dupctx)(void *src, void *dst);
  20. } PROV_CIPHER_HW_AES_SIV;
  21. typedef struct prov_siv_ctx_st {
  22. unsigned int mode; /* The mode that we are using */
  23. unsigned int enc : 1; /* Set to 1 if we are encrypting or 0 otherwise */
  24. size_t keylen; /* The input keylength (twice the alg key length) */
  25. size_t taglen; /* the taglen is the same as the sivlen */
  26. SIV128_CONTEXT siv;
  27. EVP_CIPHER *ctr; /* These are fetched - so we need to free them */
  28. EVP_CIPHER *cbc;
  29. const PROV_CIPHER_HW_AES_SIV *hw;
  30. OSSL_LIB_CTX *libctx;
  31. } PROV_AES_SIV_CTX;
  32. const PROV_CIPHER_HW_AES_SIV *ossl_prov_cipher_hw_aes_siv(size_t keybits);