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 * RC5 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_rc5.h"
17e1051a39Sopenharmony_ci
18e1051a39Sopenharmony_cistatic int cipher_hw_rc5_initkey(PROV_CIPHER_CTX *ctx,
19e1051a39Sopenharmony_ci                                 const unsigned char *key, size_t keylen)
20e1051a39Sopenharmony_ci{
21e1051a39Sopenharmony_ci    PROV_RC5_CTX *rctx = (PROV_RC5_CTX *)ctx;
22e1051a39Sopenharmony_ci
23e1051a39Sopenharmony_ci    return RC5_32_set_key(&rctx->ks.ks, keylen, key, rctx->rounds);
24e1051a39Sopenharmony_ci}
25e1051a39Sopenharmony_ci
26e1051a39Sopenharmony_ci# define PROV_CIPHER_HW_rc5_mode(mode, UCMODE)                                 \
27e1051a39Sopenharmony_ciIMPLEMENT_CIPHER_HW_##UCMODE(mode, rc5, PROV_RC5_CTX, RC5_32_KEY,              \
28e1051a39Sopenharmony_ci                             RC5_32_##mode)                                    \
29e1051a39Sopenharmony_cistatic const PROV_CIPHER_HW rc5_##mode = {                                     \
30e1051a39Sopenharmony_ci    cipher_hw_rc5_initkey,                                                     \
31e1051a39Sopenharmony_ci    cipher_hw_rc5_##mode##_cipher                                              \
32e1051a39Sopenharmony_ci};                                                                             \
33e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_rc5_##mode(size_t keybits)           \
34e1051a39Sopenharmony_ci{                                                                              \
35e1051a39Sopenharmony_ci    return &rc5_##mode;                                                        \
36e1051a39Sopenharmony_ci}
37e1051a39Sopenharmony_ci
38e1051a39Sopenharmony_ciPROV_CIPHER_HW_rc5_mode(cbc, CBC)
39e1051a39Sopenharmony_ciPROV_CIPHER_HW_rc5_mode(ecb, ECB)
40e1051a39Sopenharmony_ciPROV_CIPHER_HW_rc5_mode(ofb64, OFB)
41e1051a39Sopenharmony_ciPROV_CIPHER_HW_rc5_mode(cfb64, CFB)
42