1*b077aed3SPierre Pronchery /* 2*b077aed3SPierre Pronchery * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. 3*b077aed3SPierre Pronchery * 4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use 5*b077aed3SPierre Pronchery * this file except in compliance with the License. You can obtain a copy 6*b077aed3SPierre Pronchery * in the file LICENSE in the source distribution or at 7*b077aed3SPierre Pronchery * https://www.openssl.org/source/license.html 8*b077aed3SPierre Pronchery */ 9*b077aed3SPierre Pronchery 10*b077aed3SPierre Pronchery #include "include/crypto/chacha.h" 11*b077aed3SPierre Pronchery #include "prov/ciphercommon.h" 12*b077aed3SPierre Pronchery 13*b077aed3SPierre Pronchery typedef struct { 14*b077aed3SPierre Pronchery PROV_CIPHER_CTX base; /* must be first */ 15*b077aed3SPierre Pronchery union { 16*b077aed3SPierre Pronchery OSSL_UNION_ALIGN; 17*b077aed3SPierre Pronchery unsigned int d[CHACHA_KEY_SIZE / 4]; 18*b077aed3SPierre Pronchery } key; 19*b077aed3SPierre Pronchery unsigned int counter[CHACHA_CTR_SIZE / 4]; 20*b077aed3SPierre Pronchery unsigned char buf[CHACHA_BLK_SIZE]; 21*b077aed3SPierre Pronchery unsigned int partial_len; 22*b077aed3SPierre Pronchery } PROV_CHACHA20_CTX; 23*b077aed3SPierre Pronchery 24*b077aed3SPierre Pronchery typedef struct prov_cipher_hw_chacha20_st { 25*b077aed3SPierre Pronchery PROV_CIPHER_HW base; /* must be first */ 26*b077aed3SPierre Pronchery int (*initiv)(PROV_CIPHER_CTX *ctx); 27*b077aed3SPierre Pronchery 28*b077aed3SPierre Pronchery } PROV_CIPHER_HW_CHACHA20; 29*b077aed3SPierre Pronchery 30*b077aed3SPierre Pronchery const PROV_CIPHER_HW *ossl_prov_cipher_hw_chacha20(size_t keybits); 31*b077aed3SPierre Pronchery 32*b077aed3SPierre Pronchery OSSL_FUNC_cipher_encrypt_init_fn ossl_chacha20_einit; 33*b077aed3SPierre Pronchery OSSL_FUNC_cipher_decrypt_init_fn ossl_chacha20_dinit; 34*b077aed3SPierre Pronchery void ossl_chacha20_initctx(PROV_CHACHA20_CTX *ctx); 35