/*
- * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
*
* 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
*/
#include "internal/deprecated.h"
+#include <openssl/proverr.h>
#include "cipher_aes_xts.h"
#include "prov/implementations.h"
#include "prov/providercommon.h"
-#include "prov/providercommonerr.h"
#define AES_XTS_FLAGS PROV_CIPHER_FLAG_CUSTOM_IV
#define AES_XTS_IV_BITS 128
* Provider dispatch functions
*/
static int aes_xts_init(void *vctx, const unsigned char *key, size_t keylen,
- const unsigned char *iv, size_t ivlen, int enc)
+ const unsigned char *iv, size_t ivlen,
+ const OSSL_PARAM params[], int enc)
{
PROV_AES_XTS_CTX *xctx = (PROV_AES_XTS_CTX *)vctx;
PROV_CIPHER_CTX *ctx = &xctx->base;
}
if (!aes_xts_check_keys_differ(key, keylen / 2, enc))
return 0;
- return ctx->hw->init(ctx, key, keylen);
+ if (!ctx->hw->init(ctx, key, keylen))
+ return 0;
}
- return 1;
+ return aes_xts_set_ctx_params(ctx, params);
}
static int aes_xts_einit(void *vctx, const unsigned char *key, size_t keylen,
- const unsigned char *iv, size_t ivlen)
+ const unsigned char *iv, size_t ivlen,
+ const OSSL_PARAM params[])
{
- return aes_xts_init(vctx, key, keylen, iv, ivlen, 1);
+ return aes_xts_init(vctx, key, keylen, iv, ivlen, params, 1);
}
static int aes_xts_dinit(void *vctx, const unsigned char *key, size_t keylen,
- const unsigned char *iv, size_t ivlen)
+ const unsigned char *iv, size_t ivlen,
+ const OSSL_PARAM params[])
{
- return aes_xts_init(vctx, key, keylen, iv, ivlen, 0);
+ return aes_xts_init(vctx, key, keylen, iv, ivlen, params, 0);
}
static void *aes_xts_newctx(void *provctx, unsigned int mode, uint64_t flags,
OSSL_PARAM_END
};
-static const OSSL_PARAM *aes_xts_settable_ctx_params(ossl_unused void *provctx)
+static const OSSL_PARAM *aes_xts_settable_ctx_params(ossl_unused void *cctx,
+ ossl_unused void *provctx)
{
return aes_xts_known_settable_ctx_params;
}
PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx;
const OSSL_PARAM *p;
+ if (params == NULL)
+ return 1;
+
p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN);
if (p != NULL) {
size_t keylen;