Skip to content

[feat] Add additional suites #6

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

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
*.pyc
27 changes: 27 additions & 0 deletions hpke/hpke.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ class DHKEM_P256_HKDF_SHA256(_DHKEMWeierstrass):
ID = 0x0010


class DHKEM_P384_HKDF_SHA384(_DHKEMWeierstrass):
CURVE = ec.SECP384R1()
KDF = HKDF_SHA384
NSECRET = 48
ID = 0x0011


class DHKEM_P521_HKDF_SHA512(_DHKEMWeierstrass):
CURVE = ec.SECP521R1()
KDF = HKDF_SHA512
Expand Down Expand Up @@ -571,6 +578,16 @@ class Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA256__AES_128_GCM(_Suite):
AEAD = _AES_128_GCM


class Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA256__AES_256_GCM(_Suite):
"""
This is DHKEM(P-256, HKDF-SHA256), HKDF-SHA256, AES-256-GCM
"""

KEM = DHKEM_P256_HKDF_SHA256
KDF = HKDF_SHA256
AEAD = _AES_256_GCM


class Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA512__AES_128_GCM(_Suite):
"""
This is DHKEM(P-256, HKDF-SHA256), HKDF-SHA512, AES-128-GCM
Expand All @@ -581,6 +598,16 @@ class Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA512__AES_128_GCM(_Suite):
AEAD = _AES_128_GCM


class Suite__DHKEM_P384_HKDF_SHA384__HKDF_SHA384__AES_256_GCM(_Suite):
"""
This is DHKEM(P-384, HKDF-SHA384), HKDF-SHA384, AES-256-GCM
"""

KEM = DHKEM_P384_HKDF_SHA384
KDF = HKDF_SHA384
AEAD = _AES_256_GCM


class Suite__DHKEM_P521_HKDF_SHA512__HKDF_SHA512__AES_256_GCM(_Suite):
"""
This is DHKEM(P-521, HKDF-SHA512), HKDF-SHA512, AES-256-GCM
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

aead_suites = [
hpke.Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA256__AES_128_GCM,
hpke.Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA256__AES_256_GCM,
hpke.Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA512__AES_128_GCM,
hpke.Suite__DHKEM_P384_HKDF_SHA384__HKDF_SHA384__AES_256_GCM,
hpke.Suite__DHKEM_P521_HKDF_SHA512__HKDF_SHA512__AES_256_GCM,
hpke.Suite__DHKEM_P256_HKDF_SHA256__HKDF_SHA256__ChaCha20Poly1305,
]
Expand Down