summaryrefslogtreecommitdiffstats
path: root/providers/implementations/ciphers/cipher_blowfish.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-10-04 14:44:42 +0200
committerRichard Levitte <levitte@openssl.org>2019-10-10 14:12:15 +0200
commit604e884bb8aba9b549c7e5effe01e406ccab3bcd (patch)
tree9ef1f699e8376854b11ea237191c264d408b3c2b /providers/implementations/ciphers/cipher_blowfish.c
parentProviders: move all digests (diff)
downloadopenssl-604e884bb8aba9b549c7e5effe01e406ccab3bcd.tar.xz
openssl-604e884bb8aba9b549c7e5effe01e406ccab3bcd.zip
Providers: move all ciphers
From providers/{common,default}/ to providers/implementations/ Except for common code, which remains in providers/common/ciphers/. However, we do move providers/common/include/internal/ciphers/*.h to providers/common/include/prov/, and adjust all source including any of those header files. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10088)
Diffstat (limited to 'providers/implementations/ciphers/cipher_blowfish.c')
-rw-r--r--providers/implementations/ciphers/cipher_blowfish.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/providers/implementations/ciphers/cipher_blowfish.c b/providers/implementations/ciphers/cipher_blowfish.c
new file mode 100644
index 0000000000..4730f1fd40
--- /dev/null
+++ b/providers/implementations/ciphers/cipher_blowfish.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019 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
+ * 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 */
+
+#include "cipher_blowfish.h"
+#include "internal/provider_algs.h"
+
+#define BF_FLAGS (EVP_CIPH_VARIABLE_LENGTH)
+
+static OSSL_OP_cipher_freectx_fn blowfish_freectx;
+static OSSL_OP_cipher_dupctx_fn blowfish_dupctx;
+
+static void blowfish_freectx(void *vctx)
+{
+ PROV_BLOWFISH_CTX *ctx = (PROV_BLOWFISH_CTX *)vctx;
+
+ OPENSSL_clear_free(ctx, sizeof(*ctx));
+}
+
+static void *blowfish_dupctx(void *ctx)
+{
+ PROV_BLOWFISH_CTX *in = (PROV_BLOWFISH_CTX *)ctx;
+ PROV_BLOWFISH_CTX *ret = OPENSSL_malloc(sizeof(*ret));
+
+ if (ret == NULL) {
+ ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
+ *ret = *in;
+
+ return ret;
+}
+
+/* bf_ecb_functions */
+IMPLEMENT_generic_cipher(blowfish, BLOWFISH, ecb, ECB, BF_FLAGS, 128, 64, 0, block)
+/* bf_cbc_functions */
+IMPLEMENT_generic_cipher(blowfish, BLOWFISH, cbc, CBC, BF_FLAGS, 128, 64, 64, block)
+/* bf_ofb_functions */
+IMPLEMENT_generic_cipher(blowfish, BLOWFISH, ofb64, OFB, BF_FLAGS, 64, 8, 64, stream)
+/* bf_cfb_functions */
+IMPLEMENT_generic_cipher(blowfish, BLOWFISH, cfb64, CFB, BF_FLAGS, 64, 8, 64, stream)