Coverage Report

Created: 2026-01-09 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/irssi/subprojects/openssl-1.1.1l/crypto/rc4/rc4_skey.c
Line
Count
Source
1
/*
2
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the OpenSSL license (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 <openssl/rc4.h>
11
#include "rc4_local.h"
12
#include <openssl/opensslv.h>
13
14
const char *RC4_options(void)
15
0
{
16
0
    if (sizeof(RC4_INT) == 1)
17
0
        return "rc4(char)";
18
0
    else
19
0
        return "rc4(int)";
20
0
}
21
22
/*-
23
 * RC4 as implemented from a posting from
24
 * Newsgroups: sci.crypt
25
 * Subject: RC4 Algorithm revealed.
26
 * Message-ID: <sternCvKL4B.Hyy@netcom.com>
27
 * Date: Wed, 14 Sep 1994 06:35:31 GMT
28
 */
29
30
void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
31
0
{
32
0
    register RC4_INT tmp;
33
0
    register int id1, id2;
34
0
    register RC4_INT *d;
35
0
    unsigned int i;
36
37
0
    d = &(key->data[0]);
38
0
    key->x = 0;
39
0
    key->y = 0;
40
0
    id1 = id2 = 0;
41
42
0
#define SK_LOOP(d,n) { \
43
0
                tmp=d[(n)]; \
44
0
                id2 = (data[id1] + tmp + id2) & 0xff; \
45
0
                if (++id1 == len) id1=0; \
46
0
                d[(n)]=d[id2]; \
47
0
                d[id2]=tmp; }
48
49
0
    for (i = 0; i < 256; i++)
50
0
        d[i] = i;
51
0
    for (i = 0; i < 256; i += 4) {
52
0
        SK_LOOP(d, i + 0);
53
0
        SK_LOOP(d, i + 1);
54
0
        SK_LOOP(d, i + 2);
55
0
        SK_LOOP(d, i + 3);
56
0
    }
57
0
}