Skip to content

Commit ce3bfbe

Browse files
authored
Added a benchmark for ChaCha20 AEAD (#7427)
1 parent 07bb910 commit ce3bfbe

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/bench/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is dual licensed under the terms of the Apache License, Version
2+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3+
# for complete details.

tests/bench/test_aead.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is dual licensed under the terms of the Apache License, Version
2+
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3+
# for complete details.
4+
5+
import pytest
6+
7+
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
8+
9+
from ..hazmat.primitives.test_aead import _aead_supported
10+
11+
12+
@pytest.mark.skipif(
13+
not _aead_supported(ChaCha20Poly1305),
14+
reason="Requires OpenSSL with ChaCha20Poly1305 support",
15+
)
16+
def test_chacha20poly1305(benchmark):
17+
chacha = ChaCha20Poly1305(b"\x00" * 32)
18+
benchmark(chacha.encrypt, b"\x00" * 12, b"hello world plaintext", b"")

0 commit comments

Comments
 (0)