• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Synss / python-mbedtls / 15400568096

02 Jun 2025 07:03PM UTC coverage: 85.758% (-1.7%) from 87.47%
15400568096

Pull #127

github

pre-commit-ci[bot]
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
Pull Request #127: [pre-commit.ci] pre-commit autoupdate

2523 of 2942 relevant lines covered (85.76%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/src/mbedtls/cipher/ARC4.py
1
# SPDX-License-Identifier: MIT
2
# Copyright (c) 2016, Elaborated Networks GmbH
3
# Copyright (c) 2019, Mathias Laurin
4

5
"""Alleged River Cipher 4 cipher (ARC4 or ARCFOUR) designed in 1987
1✔
6
at RSA Security."""
7

8
from __future__ import annotations
1✔
9

10
from typing import Final, Literal, Optional, Union
11

12
from mbedtls.exceptions import TLSError
1✔
13

14
from ._cipher import Cipher, Mode
1✔
15

16
__all__ = ["block_size", "key_size", "new"]
1✔
17

18
block_size: Final = 1
1✔
19
key_size: Final = 16
1✔
20

21

22
def new(
1✔
23
    key: bytes,
24
    mode: Optional[Union[int, Literal[Mode.STREAM]]] = None,
25
    iv: Optional[bytes] = None,
26
) -> Cipher:
27
    """Return a `Cipher` object that can perform ARC4 encryption and
28
    decryption.
29

30
    Alleged River Cipher 4 cipher (ARC4 or ARCFOUR) designed in 1987
31
    at RSA Security.
32

33
    Parameters:
34
        key: The key to encrypt decrypt.  If None,
35
            encryption and decryption are unavailable.
36
        mode: The feedback mode is ignored for ARC4.
37
        iv: ARC4 does not use IV.
38

39
    """
40
    if len(key) != key_size:
1✔
41
        raise TLSError(
×
42
            msg="key size must be %i bytes, got %i" % (key_size, len(key))
43
        )
44
    if mode not in {None, Mode.STREAM}:
1✔
45
        raise TLSError(msg="unsupported mode %r" % mode)
1✔
46
    name = ("ARC4-%i" % (len(key) * 8)).encode("ascii")
1✔
47
    return Cipher(name, key, Mode.STREAM, iv)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc