2019-09-15 18:06:28 +08:00
|
|
|
/*
|
2021-02-18 22:57:13 +08:00
|
|
|
* Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2019-09-15 18:06:28 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Dispatch functions for Blowfish cipher modes ecb, cbc, ofb, cfb */
|
|
|
|
|
2020-01-02 22:25:27 +08:00
|
|
|
/*
|
|
|
|
* BF low level APIs are deprecated for public use, but still ok for internal
|
|
|
|
* use.
|
|
|
|
*/
|
|
|
|
#include "internal/deprecated.h"
|
|
|
|
|
2019-09-15 18:06:28 +08:00
|
|
|
#include "cipher_blowfish.h"
|
2019-10-04 21:20:48 +08:00
|
|
|
#include "prov/implementations.h"
|
2020-09-08 10:56:34 +08:00
|
|
|
#include "prov/providercommon.h"
|
2019-09-15 18:06:28 +08:00
|
|
|
|
2020-12-17 14:39:57 +08:00
|
|
|
#define BF_FLAGS PROV_CIPHER_FLAG_VARIABLE_LENGTH
|
2019-09-25 15:07:20 +08:00
|
|
|
|
2020-06-21 07:19:16 +08:00
|
|
|
static OSSL_FUNC_cipher_freectx_fn blowfish_freectx;
|
|
|
|
static OSSL_FUNC_cipher_dupctx_fn blowfish_dupctx;
|
2019-09-15 18:06:28 +08:00
|
|
|
|
|
|
|
static void blowfish_freectx(void *vctx)
|
|
|
|
{
|
|
|
|
PROV_BLOWFISH_CTX *ctx = (PROV_BLOWFISH_CTX *)vctx;
|
|
|
|
|
2020-09-29 15:40:26 +08:00
|
|
|
ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
|
2019-09-15 18:06:28 +08:00
|
|
|
OPENSSL_clear_free(ctx, sizeof(*ctx));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *blowfish_dupctx(void *ctx)
|
|
|
|
{
|
|
|
|
PROV_BLOWFISH_CTX *in = (PROV_BLOWFISH_CTX *)ctx;
|
2020-09-08 10:56:34 +08:00
|
|
|
PROV_BLOWFISH_CTX *ret;
|
2019-09-15 18:06:28 +08:00
|
|
|
|
2020-09-08 10:56:34 +08:00
|
|
|
if (!ossl_prov_is_running())
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = OPENSSL_malloc(sizeof(*ret));
|
2019-09-15 18:06:28 +08:00
|
|
|
if (ret == NULL) {
|
|
|
|
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*ret = *in;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bf_ecb_functions */
|
2019-11-15 00:05:19 +08:00
|
|
|
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, ecb, ECB, BF_FLAGS, 128, 64, 0, block)
|
2019-09-15 18:06:28 +08:00
|
|
|
/* bf_cbc_functions */
|
2019-11-15 00:05:19 +08:00
|
|
|
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, cbc, CBC, BF_FLAGS, 128, 64, 64, block)
|
2019-09-15 18:06:28 +08:00
|
|
|
/* bf_ofb_functions */
|
2019-11-15 00:05:19 +08:00
|
|
|
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, ofb64, OFB, BF_FLAGS, 64, 8, 64, stream)
|
2019-09-15 18:06:28 +08:00
|
|
|
/* bf_cfb_functions */
|
2019-11-15 00:05:19 +08:00
|
|
|
IMPLEMENT_var_keylen_cipher(blowfish, BLOWFISH, cfb64, CFB, BF_FLAGS, 64, 8, 64, stream)
|