]> git.ipfire.org Git - thirdparty/openssl.git/blob - providers/default/ciphers/cipher_rc4_hw.c
Reorganize private crypto header files
[thirdparty/openssl.git] / providers / default / ciphers / cipher_rc4_hw.c
1 /*
2 * Copyright 2019 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 #include "cipher_rc4.h"
11
12 static int cipher_hw_rc4_initkey(PROV_CIPHER_CTX *ctx,
13 const unsigned char *key, size_t keylen)
14 {
15 PROV_RC4_CTX *rctx = (PROV_RC4_CTX *)ctx;
16
17 RC4_set_key(&rctx->ks.ks, keylen, key);
18 return 1;
19 }
20
21 static int cipher_hw_rc4_cipher(PROV_CIPHER_CTX *ctx, unsigned char *out,
22 const unsigned char *in, size_t len)
23 {
24 PROV_RC4_CTX *rctx = (PROV_RC4_CTX *)ctx;
25
26 RC4(&rctx->ks.ks, len, in, out);
27 return 1;
28 }
29
30 static const PROV_CIPHER_HW rc4_hw = {
31 cipher_hw_rc4_initkey,
32 cipher_hw_rc4_cipher
33 };
34 const PROV_CIPHER_HW *PROV_CIPHER_HW_rc4(size_t keybits)
35 {
36 return &rc4_hw;
37 }
38