1e1051a39Sopenharmony_ci/*
2e1051a39Sopenharmony_ci * Copyright 2019-2020 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/*
11e1051a39Sopenharmony_ci * BF low level APIs are deprecated for public use, but still ok for internal
12e1051a39Sopenharmony_ci * use.
13e1051a39Sopenharmony_ci */
14e1051a39Sopenharmony_ci#include "internal/deprecated.h"
15e1051a39Sopenharmony_ci
16e1051a39Sopenharmony_ci#include "cipher_blowfish.h"
17e1051a39Sopenharmony_ci
18e1051a39Sopenharmony_cistatic int cipher_hw_blowfish_initkey(PROV_CIPHER_CTX *ctx,
19e1051a39Sopenharmony_ci                                      const unsigned char *key, size_t keylen)
20e1051a39Sopenharmony_ci{
21e1051a39Sopenharmony_ci    PROV_BLOWFISH_CTX *bctx =  (PROV_BLOWFISH_CTX *)ctx;
22e1051a39Sopenharmony_ci
23e1051a39Sopenharmony_ci    BF_set_key(&bctx->ks.ks, keylen, key);
24e1051a39Sopenharmony_ci    return 1;
25e1051a39Sopenharmony_ci}
26e1051a39Sopenharmony_ci
27e1051a39Sopenharmony_ci# define PROV_CIPHER_HW_blowfish_mode(mode, UCMODE)                            \
28e1051a39Sopenharmony_ciIMPLEMENT_CIPHER_HW_##UCMODE(mode, blowfish, PROV_BLOWFISH_CTX, BF_KEY,        \
29e1051a39Sopenharmony_ci                             BF_##mode)                                        \
30e1051a39Sopenharmony_cistatic const PROV_CIPHER_HW bf_##mode = {                                      \
31e1051a39Sopenharmony_ci    cipher_hw_blowfish_initkey,                                                \
32e1051a39Sopenharmony_ci    cipher_hw_blowfish_##mode##_cipher                                         \
33e1051a39Sopenharmony_ci};                                                                             \
34e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_blowfish_##mode(size_t keybits)      \
35e1051a39Sopenharmony_ci{                                                                              \
36e1051a39Sopenharmony_ci    return &bf_##mode;                                                         \
37e1051a39Sopenharmony_ci}
38e1051a39Sopenharmony_ci
39e1051a39Sopenharmony_ciPROV_CIPHER_HW_blowfish_mode(cbc, CBC)
40e1051a39Sopenharmony_ciPROV_CIPHER_HW_blowfish_mode(ecb, ECB)
41e1051a39Sopenharmony_ciPROV_CIPHER_HW_blowfish_mode(ofb64, OFB)
42e1051a39Sopenharmony_ciPROV_CIPHER_HW_blowfish_mode(cfb64, CFB)
43