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