Skip to content

Commit

Permalink
Merge pull request #321 from tlsfuzzer/twisted-brainpool
Browse files Browse the repository at this point in the history
add support for twisted Brainpool curves
  • Loading branch information
tomato42 committed May 31, 2023
2 parents 2457dc7 + 33a4114 commit 74f8879
Show file tree
Hide file tree
Showing 5 changed files with 419 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
tox-env: py311
- name: py3.12
os: ubuntu-latest
python-version: '3.12.0-alpha.5'
python-version: '3.12.0-beta.1'
tox-env: py312
- name: pypy
os: ubuntu-latest
Expand Down
14 changes: 14 additions & 0 deletions src/ecdsa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
SECP160r1,
Ed25519,
Ed448,
BRAINPOOLP160t1,
BRAINPOOLP192t1,
BRAINPOOLP224t1,
BRAINPOOLP256t1,
BRAINPOOLP320t1,
BRAINPOOLP384t1,
BRAINPOOLP512t1,
)
from .ecdh import (
ECDH,
Expand Down Expand Up @@ -84,6 +91,13 @@
Ed25519,
Ed448,
six.b(""),
BRAINPOOLP160t1,
BRAINPOOLP192t1,
BRAINPOOLP224t1,
BRAINPOOLP256t1,
BRAINPOOLP320t1,
BRAINPOOLP384t1,
BRAINPOOLP512t1,
]
del _hush_pyflakes

Expand Down
77 changes: 77 additions & 0 deletions src/ecdsa/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@
"curve_by_name",
"SECP256k1",
"BRAINPOOLP160r1",
"BRAINPOOLP160t1",
"BRAINPOOLP192r1",
"BRAINPOOLP192t1",
"BRAINPOOLP224r1",
"BRAINPOOLP224t1",
"BRAINPOOLP256r1",
"BRAINPOOLP256t1",
"BRAINPOOLP320r1",
"BRAINPOOLP320t1",
"BRAINPOOLP384r1",
"BRAINPOOLP384t1",
"BRAINPOOLP512r1",
"BRAINPOOLP512t1",
"PRIME_FIELD_OID",
"CHARACTERISTIC_TWO_FIELD_OID",
"Ed25519",
Expand Down Expand Up @@ -375,6 +382,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP160t1 = Curve(
"BRAINPOOLP160t1",
ecdsa.curve_brainpoolp160t1,
ecdsa.generator_brainpoolp160t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 2),
"brainpoolP160t1",
)


BRAINPOOLP192r1 = Curve(
"BRAINPOOLP192r1",
ecdsa.curve_brainpoolp192r1,
Expand All @@ -384,6 +400,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP192t1 = Curve(
"BRAINPOOLP192t1",
ecdsa.curve_brainpoolp192t1,
ecdsa.generator_brainpoolp192t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 4),
"brainpoolP192t1",
)


BRAINPOOLP224r1 = Curve(
"BRAINPOOLP224r1",
ecdsa.curve_brainpoolp224r1,
Expand All @@ -393,6 +418,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP224t1 = Curve(
"BRAINPOOLP224t1",
ecdsa.curve_brainpoolp224t1,
ecdsa.generator_brainpoolp224t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 6),
"brainpoolP224t1",
)


BRAINPOOLP256r1 = Curve(
"BRAINPOOLP256r1",
ecdsa.curve_brainpoolp256r1,
Expand All @@ -402,6 +436,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP256t1 = Curve(
"BRAINPOOLP256t1",
ecdsa.curve_brainpoolp256t1,
ecdsa.generator_brainpoolp256t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 8),
"brainpoolP256t1",
)


BRAINPOOLP320r1 = Curve(
"BRAINPOOLP320r1",
ecdsa.curve_brainpoolp320r1,
Expand All @@ -411,6 +454,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP320t1 = Curve(
"BRAINPOOLP320t1",
ecdsa.curve_brainpoolp320t1,
ecdsa.generator_brainpoolp320t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 10),
"brainpoolP320t1",
)


BRAINPOOLP384r1 = Curve(
"BRAINPOOLP384r1",
ecdsa.curve_brainpoolp384r1,
Expand All @@ -420,6 +472,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP384t1 = Curve(
"BRAINPOOLP384t1",
ecdsa.curve_brainpoolp384t1,
ecdsa.generator_brainpoolp384t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 12),
"brainpoolP384t1",
)


BRAINPOOLP512r1 = Curve(
"BRAINPOOLP512r1",
ecdsa.curve_brainpoolp512r1,
Expand All @@ -429,6 +490,15 @@ def from_pem(cls, string, valid_encodings=None):
)


BRAINPOOLP512t1 = Curve(
"BRAINPOOLP512t1",
ecdsa.curve_brainpoolp512t1,
ecdsa.generator_brainpoolp512t1,
(1, 3, 36, 3, 3, 2, 8, 1, 1, 14),
"brainpoolP512t1",
)


Ed25519 = Curve(
"Ed25519",
eddsa.curve_ed25519,
Expand Down Expand Up @@ -466,6 +536,13 @@ def from_pem(cls, string, valid_encodings=None):
SECP160r1,
Ed25519,
Ed448,
BRAINPOOLP160t1,
BRAINPOOLP192t1,
BRAINPOOLP224t1,
BRAINPOOLP256t1,
BRAINPOOLP320t1,
BRAINPOOLP384t1,
BRAINPOOLP512t1,
]


Expand Down

0 comments on commit 74f8879

Please sign in to comment.