1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include "prov/ciphercommon.h" 11e1051a39Sopenharmony_ci#include "crypto/aes_platform.h" 12e1051a39Sopenharmony_ci#include "crypto/siv.h" 13e1051a39Sopenharmony_ci 14e1051a39Sopenharmony_citypedef struct prov_cipher_hw_aes_siv_st { 15e1051a39Sopenharmony_ci int (*initkey)(void *ctx, const uint8_t *key, size_t keylen); 16e1051a39Sopenharmony_ci int (*cipher)(void *ctx, unsigned char *out, const unsigned char *in, 17e1051a39Sopenharmony_ci size_t len); 18e1051a39Sopenharmony_ci void (*setspeed)(void *ctx, int speed); 19e1051a39Sopenharmony_ci int (*settag)(void *ctx, const unsigned char *tag, size_t tagl); 20e1051a39Sopenharmony_ci void (*cleanup)(void *ctx); 21e1051a39Sopenharmony_ci int (*dupctx)(void *src, void *dst); 22e1051a39Sopenharmony_ci} PROV_CIPHER_HW_AES_SIV; 23e1051a39Sopenharmony_ci 24e1051a39Sopenharmony_citypedef struct prov_siv_ctx_st { 25e1051a39Sopenharmony_ci unsigned int mode; /* The mode that we are using */ 26e1051a39Sopenharmony_ci unsigned int enc : 1; /* Set to 1 if we are encrypting or 0 otherwise */ 27e1051a39Sopenharmony_ci size_t keylen; /* The input keylength (twice the alg key length) */ 28e1051a39Sopenharmony_ci size_t taglen; /* the taglen is the same as the sivlen */ 29e1051a39Sopenharmony_ci SIV128_CONTEXT siv; 30e1051a39Sopenharmony_ci EVP_CIPHER *ctr; /* These are fetched - so we need to free them */ 31e1051a39Sopenharmony_ci EVP_CIPHER *cbc; 32e1051a39Sopenharmony_ci const PROV_CIPHER_HW_AES_SIV *hw; 33e1051a39Sopenharmony_ci OSSL_LIB_CTX *libctx; 34e1051a39Sopenharmony_ci} PROV_AES_SIV_CTX; 35e1051a39Sopenharmony_ci 36e1051a39Sopenharmony_ciconst PROV_CIPHER_HW_AES_SIV *ossl_prov_cipher_hw_aes_siv(size_t keybits); 37