cipher_chacha20.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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 "include/crypto/chacha.h"
  10. #include "prov/ciphercommon.h"
  11. typedef struct {
  12. PROV_CIPHER_CTX base; /* must be first */
  13. union {
  14. OSSL_UNION_ALIGN;
  15. unsigned int d[CHACHA_KEY_SIZE / 4];
  16. } key;
  17. unsigned int counter[CHACHA_CTR_SIZE / 4];
  18. unsigned char buf[CHACHA_BLK_SIZE];
  19. unsigned int partial_len;
  20. } PROV_CHACHA20_CTX;
  21. typedef struct prov_cipher_hw_chacha20_st {
  22. PROV_CIPHER_HW base; /* must be first */
  23. int (*initiv)(PROV_CIPHER_CTX *ctx);
  24. } PROV_CIPHER_HW_CHACHA20;
  25. const PROV_CIPHER_HW *ossl_prov_cipher_hw_chacha20(size_t keybits);
  26. OSSL_FUNC_cipher_encrypt_init_fn ossl_chacha20_einit;
  27. OSSL_FUNC_cipher_decrypt_init_fn ossl_chacha20_dinit;
  28. void ossl_chacha20_initctx(PROV_CHACHA20_CTX *ctx);