Skip to content

Commit f3a38c5

Browse files
committed
add secp112r2
1 parent 854a5fc commit f3a38c5

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

src/ecdsa/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
BRAINPOOLP384r1,
2121
BRAINPOOLP512r1,
2222
SECP112r1,
23+
SECP112r2,
2324
)
2425
from .ecdh import (
2526
ECDH,
@@ -74,5 +75,6 @@
7475
BRAINPOOLP384r1,
7576
BRAINPOOLP512r1,
7677
SECP112r1,
78+
SECP112r2,
7779
]
7880
del _hush_pyflakes

src/ecdsa/curves.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"orderlen",
1212
"Curve",
1313
"SECP112r1",
14+
"SECP112r2",
1415
"NIST192p",
1516
"NIST224p",
1617
"NIST256p",
@@ -60,6 +61,15 @@ def __repr__(self):
6061
)
6162

6263

64+
SECP112r2 = Curve(
65+
"SECP112r2",
66+
ecdsa.curve_112r2,
67+
ecdsa.generator_112r2,
68+
(1, 3, 132, 0, 7),
69+
"secp112r2",
70+
)
71+
72+
6373
# the NIST curves
6474
NIST192p = Curve(
6575
"NIST192p",
@@ -194,6 +204,7 @@ def __repr__(self):
194204
BRAINPOOLP384r1,
195205
BRAINPOOLP512r1,
196206
SECP112r1,
207+
SECP112r2,
197208
]
198209

199210

src/ecdsa/ecdsa.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,21 @@ def point_is_valid(generator, x, y):
309309
)
310310

311311

312+
# secp112r2 curve
313+
_p = int(remove_whitespace("DB7C 2ABF62E3 5E668076 BEAD208B"), 16)
314+
# s = 022757A1 114D69E 67687561 51755316 C05E0BD4
315+
_a = int(remove_whitespace("6127 C24C05F3 8A0AAAF6 5C0EF02C"), 16)
316+
_b = int(remove_whitespace("51DE F1815DB5 ED74FCC3 4C85D709"), 16)
317+
_Gx = int(remove_whitespace("4BA30AB5 E892B4E1 649DD092 8643"), 16)
318+
_Gy = int(remove_whitespace("ADCD 46F5882E 3747DEF3 6E956E97"), 16)
319+
_r = int(remove_whitespace("36DF 0AAFD8B8 D7597CA1 0520D04B"), 16)
320+
_h = 4
321+
curve_112r2 = ellipticcurve.CurveFp(_p, _a, _b, _h)
322+
generator_112r2 = ellipticcurve.PointJacobi(
323+
curve_112r2, _Gx, _Gy, 1, _r, generator=True
324+
)
325+
326+
312327
# NIST Curve P-192:
313328
_p = 6277101735386680763835789423207666416083908700390324961279
314329
_r = 6277101735386680763835789423176059013767194773182842284081

src/ecdsa/test_pyecdsa.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .curves import Curve, UnknownCurveError
2828
from .curves import (
2929
SECP112r1,
30+
SECP112r2,
3031
NIST192p,
3132
NIST224p,
3233
NIST256p,
@@ -874,6 +875,13 @@ def get_openssl_messagedigest_arg(self, hash_name):
874875
def test_from_openssl_secp112r1(self):
875876
return self.do_test_from_openssl(SECP112r1)
876877

878+
@pytest.mark.skipif(
879+
"secp112r2" not in OPENSSL_SUPPORTED_CURVES,
880+
reason="system openssl does not support secp112r2",
881+
)
882+
def test_from_openssl_secp112r2(self):
883+
return self.do_test_from_openssl(SECP112r2)
884+
877885
@pytest.mark.skipif(
878886
"prime192v1" not in OPENSSL_SUPPORTED_CURVES,
879887
reason="system openssl does not support prime192v1",
@@ -1045,6 +1053,13 @@ def do_test_from_openssl(self, curve, hash_name="SHA1"):
10451053
def test_to_openssl_secp112r1(self):
10461054
self.do_test_to_openssl(SECP112r1)
10471055

1056+
@pytest.mark.skipif(
1057+
"secp112r2" not in OPENSSL_SUPPORTED_CURVES,
1058+
reason="system openssl does not support secp112r2",
1059+
)
1060+
def test_to_openssl_secp112r2(self):
1061+
self.do_test_to_openssl(SECP112r2)
1062+
10481063
@pytest.mark.skipif(
10491064
"prime192v1" not in OPENSSL_SUPPORTED_CURVES,
10501065
reason="system openssl does not support prime192v1",

0 commit comments

Comments
 (0)