Skip to content

Commit 36e2e92

Browse files
committed
add secp112r1
1 parent e0d1c05 commit 36e2e92

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

src/ecdsa/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
BRAINPOOLP320r1,
2020
BRAINPOOLP384r1,
2121
BRAINPOOLP512r1,
22+
SECP112r1,
2223
)
2324
from .ecdh import (
2425
ECDH,
@@ -72,5 +73,6 @@
7273
BRAINPOOLP320r1,
7374
BRAINPOOLP384r1,
7475
BRAINPOOLP512r1,
76+
SECP112r1,
7577
]
7678
del _hush_pyflakes

src/ecdsa/curves.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"UnknownCurveError",
1111
"orderlen",
1212
"Curve",
13+
"SECP112r1",
1314
"NIST192p",
1415
"NIST224p",
1516
"NIST256p",
@@ -49,6 +50,16 @@ def __repr__(self):
4950
return self.name
5051

5152

53+
# the SEC curves
54+
SECP112r1 = Curve(
55+
"SECP112r1",
56+
ecdsa.curve_112r1,
57+
ecdsa.generator_112r1,
58+
(1, 3, 132, 0, 6),
59+
"secp112r1",
60+
)
61+
62+
5263
# the NIST curves
5364
NIST192p = Curve(
5465
"NIST192p",
@@ -167,6 +178,7 @@ def __repr__(self):
167178
)
168179

169180

181+
# no order in particular, but keep previously added curves first
170182
curves = [
171183
NIST192p,
172184
NIST224p,
@@ -181,6 +193,7 @@ def __repr__(self):
181193
BRAINPOOLP320r1,
182194
BRAINPOOLP384r1,
183195
BRAINPOOLP512r1,
196+
SECP112r1,
184197
]
185198

186199

src/ecdsa/ecdsa.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ def point_is_valid(generator, x, y):
294294
return True
295295

296296

297+
# secp112r1 curve
298+
_p = int(remove_whitespace("DB7C 2ABF62E3 5E668076 BEAD208B"), 16)
299+
# s = 00F50B02 8E4D696E 67687561 51752904 72783FB1
300+
_a = int(remove_whitespace("DB7C 2ABF62E3 5E668076 BEAD2088"), 16)
301+
_b = int(remove_whitespace("659E F8BA0439 16EEDE89 11702B22"), 16)
302+
_Gx = int(remove_whitespace("09487239 995A5EE7 6B55F9C2 F098"), 16)
303+
_Gy = int(remove_whitespace("A89C E5AF8724 C0A23E0E 0FF77500"), 16)
304+
_r = int(remove_whitespace("DB7C 2ABF62E3 5E7628DF AC6561C5"), 16)
305+
_h = 1
306+
curve_112r1 = ellipticcurve.CurveFp(_p, _a, _b, _h)
307+
generator_112r1 = ellipticcurve.PointJacobi(
308+
curve_112r1, _Gx, _Gy, 1, _r, generator=True
309+
)
310+
311+
297312
# NIST Curve P-192:
298313
_p = 6277101735386680763835789423207666416083908700390324961279
299314
_r = 6277101735386680763835789423176059013767194773182842284081

src/ecdsa/test_pyecdsa.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .util import number_to_string, encoded_oid_ecPublicKey, MalformedSignature
2727
from .curves import Curve, UnknownCurveError
2828
from .curves import (
29+
SECP112r1,
2930
NIST192p,
3031
NIST224p,
3132
NIST256p,
@@ -866,6 +867,13 @@ def get_openssl_messagedigest_arg(self, hash_name):
866867
# vk: 3:OpenSSL->python 4:python->OpenSSL
867868
# sig: 5:OpenSSL->python 6:python->OpenSSL
868869

870+
@pytest.mark.skipif(
871+
"secp112r1" not in OPENSSL_SUPPORTED_CURVES,
872+
reason="system openssl does not support secp112r1",
873+
)
874+
def test_from_openssl_secp112r1(self):
875+
return self.do_test_from_openssl(SECP112r1)
876+
869877
@pytest.mark.skipif(
870878
"prime192v1" not in OPENSSL_SUPPORTED_CURVES,
871879
reason="system openssl does not support prime192v1",
@@ -1030,6 +1038,13 @@ def do_test_from_openssl(self, curve, hash_name="SHA1"):
10301038
sk_from_p8 = SigningKey.from_pem(privkey_p8_pem)
10311039
self.assertEqual(sk, sk_from_p8)
10321040

1041+
@pytest.mark.skipif(
1042+
"secp112r1" not in OPENSSL_SUPPORTED_CURVES,
1043+
reason="system openssl does not support secp112r1",
1044+
)
1045+
def test_to_openssl_secp112r1(self):
1046+
self.do_test_to_openssl(SECP112r1)
1047+
10331048
@pytest.mark.skipif(
10341049
"prime192v1" not in OPENSSL_SUPPORTED_CURVES,
10351050
reason="system openssl does not support prime192v1",

0 commit comments

Comments
 (0)