1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery *
4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use
5*b077aed3SPierre Pronchery * this file except in compliance with the License. You can obtain a copy
6*b077aed3SPierre Pronchery * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery */
9*b077aed3SPierre Pronchery
10*b077aed3SPierre Pronchery /*
11*b077aed3SPierre Pronchery * RC2 low level APIs are deprecated for public use, but still ok for internal
12*b077aed3SPierre Pronchery * use.
13*b077aed3SPierre Pronchery */
14*b077aed3SPierre Pronchery #include "internal/deprecated.h"
15*b077aed3SPierre Pronchery
16*b077aed3SPierre Pronchery #include "cipher_rc2.h"
17*b077aed3SPierre Pronchery
cipher_hw_rc2_initkey(PROV_CIPHER_CTX * ctx,const unsigned char * key,size_t keylen)18*b077aed3SPierre Pronchery static int cipher_hw_rc2_initkey(PROV_CIPHER_CTX *ctx,
19*b077aed3SPierre Pronchery const unsigned char *key, size_t keylen)
20*b077aed3SPierre Pronchery {
21*b077aed3SPierre Pronchery PROV_RC2_CTX *rctx = (PROV_RC2_CTX *)ctx;
22*b077aed3SPierre Pronchery RC2_KEY *ks = &(rctx->ks.ks);
23*b077aed3SPierre Pronchery
24*b077aed3SPierre Pronchery RC2_set_key(ks, (int)ctx->keylen, key, (int)rctx->key_bits);
25*b077aed3SPierre Pronchery return 1;
26*b077aed3SPierre Pronchery }
27*b077aed3SPierre Pronchery
28*b077aed3SPierre Pronchery # define PROV_CIPHER_HW_rc2_mode(mode, UCMODE) \
29*b077aed3SPierre Pronchery IMPLEMENT_CIPHER_HW_##UCMODE(mode, rc2, PROV_RC2_CTX, RC2_KEY, \
30*b077aed3SPierre Pronchery RC2_##mode) \
31*b077aed3SPierre Pronchery static const PROV_CIPHER_HW rc2_##mode = { \
32*b077aed3SPierre Pronchery cipher_hw_rc2_initkey, \
33*b077aed3SPierre Pronchery cipher_hw_rc2_##mode##_cipher \
34*b077aed3SPierre Pronchery }; \
35*b077aed3SPierre Pronchery const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc2_##mode(size_t keybits) \
36*b077aed3SPierre Pronchery { \
37*b077aed3SPierre Pronchery return &rc2_##mode; \
38*b077aed3SPierre Pronchery }
39*b077aed3SPierre Pronchery
40*b077aed3SPierre Pronchery PROV_CIPHER_HW_rc2_mode(cbc, CBC)
41*b077aed3SPierre Pronchery PROV_CIPHER_HW_rc2_mode(ecb, ECB)
42*b077aed3SPierre Pronchery PROV_CIPHER_HW_rc2_mode(ofb64, OFB)
43*b077aed3SPierre Pronchery PROV_CIPHER_HW_rc2_mode(cfb64, CFB)
44