Add AES-128 encryption algorithm#14830
Conversation
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 | ||
| ) | ||
|
|
||
| def sub_bytes(state: list[int]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file ciphers/aes_128.py, please provide doctest for the function sub_bytes
| for i in range(16): | ||
| state[i] = S_BOX[state[i]] | ||
|
|
||
| def shift_rows(state: list[int]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file ciphers/aes_128.py, please provide doctest for the function shift_rows
| # Row 3: shifted left by 3 | ||
| state[3], state[7], state[11], state[15] = state[15], state[3], state[7], state[11] | ||
|
|
||
| def galois_multiply(a: int, b: int) -> int: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file ciphers/aes_128.py, please provide doctest for the function galois_multiply
Please provide descriptive name for the parameter: a
Please provide descriptive name for the parameter: b
| b >>= 1 | ||
| return p % 256 | ||
|
|
||
| def mix_columns(state: list[int]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file ciphers/aes_128.py, please provide doctest for the function mix_columns
| galois_multiply(col[0], 3) ^ col[1] ^ col[2] ^ galois_multiply(col[3], 2) | ||
| ) | ||
|
|
||
| def add_round_key(state: list[int], round_key: list[int]) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file ciphers/aes_128.py, please provide doctest for the function add_round_key
| for i in range(16): | ||
| state[i] ^= round_key[i] | ||
|
|
||
| def key_expansion(key: bytes) -> list[int]: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file ciphers/aes_128.py, please provide doctest for the function key_expansion
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Describe your change:
This Pull Request introduces a pure Python implementation of the Advanced Encryption Standard (AES) - 128 bit block cipher encryption.
AES is a symmetric-key algorithm widely used globally to secure sensitive data. This implementation operates on the core 16-byte block level, handling key expansion, state transformation rounds (SubBytes, ShiftRows, MixColumns, AddRoundKey), and the final round sequence without relying on external cryptographic libraries like PyCryptodome or cryptography
Checklist: