Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark both enc and dec #7600

Merged
merged 1 commit into from
Sep 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions tests/bench/test_aead.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,84 @@
not _aead_supported(ChaCha20Poly1305),
reason="Requires OpenSSL with ChaCha20Poly1305 support",
)
def test_chacha20poly1305(benchmark):
def test_chacha20poly1305_encrypt(benchmark):
chacha = ChaCha20Poly1305(b"\x00" * 32)
benchmark(chacha.encrypt, b"\x00" * 12, b"hello world plaintext", b"")


def test_aesgcm(benchmark):
@pytest.mark.skipif(
not _aead_supported(ChaCha20Poly1305),
reason="Requires OpenSSL with ChaCha20Poly1305 support",
)
def test_chacha20poly1305_decrypt(benchmark):
chacha = ChaCha20Poly1305(b"\x00" * 32)
ct = chacha.encrypt(b"\x00" * 12, b"hello world plaintext", b"")
benchmark(chacha.decrypt, b"\x00" * 12, ct, b"")


def test_aesgcm_encrypt(benchmark):
aes = AESGCM(b"\x00" * 32)
benchmark(aes.encrypt, b"\x00" * 12, b"hello world plaintext", None)


def test_aesgcm_decrypt(benchmark):
aes = AESGCM(b"\x00" * 32)
ct = aes.encrypt(b"\x00" * 12, b"hello world plaintext", None)
benchmark(aes.decrypt, b"\x00" * 12, ct, None)


@pytest.mark.skipif(
not _aead_supported(AESSIV),
reason="Requires OpenSSL with AES-SIV support",
)
def test_aessiv(benchmark):
def test_aessiv_encrypt(benchmark):
aes = AESSIV(b"\x00" * 32)
benchmark(aes.encrypt, b"hello world plaintext", None)


@pytest.mark.skipif(
not _aead_supported(AESSIV),
reason="Requires OpenSSL with AES-SIV support",
)
def test_aessiv_decrypt(benchmark):
aes = AESSIV(b"\x00" * 32)
ct = aes.encrypt(b"hello world plaintext", None)
benchmark(aes.decrypt, ct, None)


@pytest.mark.skipif(
not _aead_supported(AESOCB3),
reason="Requires OpenSSL with AES-OCB3 support",
)
def test_aesocb3(benchmark):
def test_aesocb3_encrypt(benchmark):
aes = AESOCB3(b"\x00" * 32)
benchmark(aes.encrypt, b"\x00" * 12, b"hello world plaintext", None)


@pytest.mark.skipif(
not _aead_supported(AESOCB3),
reason="Requires OpenSSL with AES-OCB3 support",
)
def test_aesocb3_decrypt(benchmark):
aes = AESOCB3(b"\x00" * 32)
ct = aes.encrypt(b"\x00" * 12, b"hello world plaintext", None)
benchmark(aes.decrypt, b"\x00" * 12, ct, None)


@pytest.mark.skipif(
not _aead_supported(AESCCM),
reason="Requires OpenSSL with AES-CCM support",
)
def test_aesccm(benchmark):
def test_aesccm_encrypt(benchmark):
aes = AESCCM(b"\x00" * 32)
benchmark(aes.encrypt, b"\x00" * 12, b"hello world plaintext", None)


@pytest.mark.skipif(
not _aead_supported(AESCCM),
reason="Requires OpenSSL with AES-CCM support",
)
def test_aesccm_decrypt(benchmark):
aes = AESCCM(b"\x00" * 32)
ct = aes.encrypt(b"\x00" * 12, b"hello world plaintext", None)
benchmark(aes.decrypt, b"\x00" * 12, ct, None)