1/*
2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License").  You may not use
5 * this file except in compliance with the License.  You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10/*
11 * RC4 low level APIs are deprecated for public use, but still ok for internal
12 * use.
13 */
14#include "internal/deprecated.h"
15
16#include "cipher_rc4.h"
17
18static int cipher_hw_rc4_initkey(PROV_CIPHER_CTX *ctx,
19                                 const unsigned char *key, size_t keylen)
20{
21    PROV_RC4_CTX *rctx =  (PROV_RC4_CTX *)ctx;
22
23    RC4_set_key(&rctx->ks.ks, keylen, key);
24    return 1;
25}
26
27static int cipher_hw_rc4_cipher(PROV_CIPHER_CTX *ctx, unsigned char *out,
28                                const unsigned char *in, size_t len)
29{
30    PROV_RC4_CTX *rctx =  (PROV_RC4_CTX *)ctx;
31
32    RC4(&rctx->ks.ks, len, in, out);
33    return 1;
34}
35
36static const PROV_CIPHER_HW rc4_hw = {
37    cipher_hw_rc4_initkey,
38    cipher_hw_rc4_cipher
39};
40const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc4(size_t keybits)
41{
42    return &rc4_hw;
43}
44
45