Coverage Report

Created: 2025-06-24 07:00

/src/boringssl/crypto/cipher/e_rc4.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <assert.h>
16
#include <string.h>
17
18
#include <openssl/cipher.h>
19
#include <openssl/nid.h>
20
#include <openssl/rc4.h>
21
22
#include "../fipsmodule/cipher/internal.h"
23
24
25
static int rc4_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
26
0
                        const uint8_t *iv, int enc) {
27
0
  RC4_KEY *rc4key = (RC4_KEY *)ctx->cipher_data;
28
29
0
  RC4_set_key(rc4key, EVP_CIPHER_CTX_key_length(ctx), key);
30
0
  return 1;
31
0
}
32
33
static int rc4_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
34
0
                      size_t in_len) {
35
0
  RC4_KEY *rc4key = (RC4_KEY *)ctx->cipher_data;
36
37
0
  RC4(rc4key, in_len, in, out);
38
0
  return 1;
39
0
}
40
41
static const EVP_CIPHER rc4 = {
42
    /*nid=*/NID_rc4,
43
    /*block_size=*/1,
44
    /*key_len=*/16,
45
    /*iv_len=*/0,
46
    /*ctx_size=*/sizeof(RC4_KEY),
47
    /*flags=*/EVP_CIPH_VARIABLE_LENGTH,
48
    /*init=*/rc4_init_key,
49
    /*cipher=*/rc4_cipher,
50
    /*cleanup=*/nullptr,
51
    /*ctrl=*/nullptr,
52
};
53
54
0
const EVP_CIPHER *EVP_rc4(void) { return &rc4; }