2019-11-08 10:14:44 +08:00
|
|
|
/*
|
2021-02-18 22:57:13 +08:00
|
|
|
* Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2019-11-08 10:14:44 +08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "prov/ciphercommon.h"
|
2019-12-19 20:33:35 +08:00
|
|
|
#include "crypto/aes_platform.h"
|
|
|
|
#include "crypto/siv.h"
|
2019-11-08 10:14:44 +08:00
|
|
|
|
|
|
|
typedef struct prov_cipher_hw_aes_siv_st {
|
|
|
|
int (*initkey)(void *ctx, const uint8_t *key, size_t keylen);
|
|
|
|
int (*cipher)(void *ctx, unsigned char *out, const unsigned char *in,
|
|
|
|
size_t len);
|
|
|
|
void (*setspeed)(void *ctx, int speed);
|
|
|
|
int (*settag)(void *ctx, const unsigned char *tag, size_t tagl);
|
|
|
|
void (*cleanup)(void *ctx);
|
2020-07-22 08:40:55 +08:00
|
|
|
int (*dupctx)(void *src, void *dst);
|
2019-11-08 10:14:44 +08:00
|
|
|
} PROV_CIPHER_HW_AES_SIV;
|
|
|
|
|
|
|
|
typedef struct prov_siv_ctx_st {
|
|
|
|
unsigned int mode; /* The mode that we are using */
|
|
|
|
unsigned int enc : 1; /* Set to 1 if we are encrypting or 0 otherwise */
|
|
|
|
size_t keylen; /* The input keylength (twice the alg key length) */
|
|
|
|
size_t taglen; /* the taglen is the same as the sivlen */
|
|
|
|
SIV128_CONTEXT siv;
|
|
|
|
EVP_CIPHER *ctr; /* These are fetched - so we need to free them */
|
|
|
|
EVP_CIPHER *cbc;
|
|
|
|
const PROV_CIPHER_HW_AES_SIV *hw;
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx;
|
2019-11-08 10:14:44 +08:00
|
|
|
} PROV_AES_SIV_CTX;
|
|
|
|
|
2020-09-28 10:47:04 +08:00
|
|
|
const PROV_CIPHER_HW_AES_SIV *ossl_prov_cipher_hw_aes_siv(size_t keybits);
|