Skip to content
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
67 changes: 66 additions & 1 deletion src/ecdsa/test_pyecdsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import subprocess
import pytest
from binascii import hexlify, unhexlify
from hashlib import sha1, sha256, sha512
from hashlib import sha1, sha256, sha384, sha512
import hashlib
from functools import partial

Expand Down Expand Up @@ -1378,3 +1378,68 @@ def test_brainpoolP512r1(self):
y_Z=int("7DB71C3DEF63212841C463E881BDCF055523BD368240E6C3143BD8DEF8"
"B3B3223B95E0F53082FF5E412F4222537A43DF1C6D25729DDB51620A83"
"2BE6A26680A2", 16))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.python.org/dev/peps/pep-0008/: "Surround top-level function and class definitions with two blank lines."


# https://tools.ietf.org/html/rfc4754#page-5
@pytest.mark.parametrize("w, gwx, gwy, k, msg, md, r, s, curve",
[pytest.param(
"DC51D3866A15BACDE33D96F992FCA99DA7E6EF0934E7097559C27F1614C88A7F",
"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970",
"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D",
"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1D5A6DECE",
b"abc",
sha256,
"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C",
"86FA3BB4E26CAD5BF90B7F81899256CE7594BB1EA0C89212748BFF3B3D5B0315",
NIST256p,
id="ECDSA-256"),
pytest.param(
"0BEB646634BA87735D77AE4809A0EBEA865535DE4C1E1DCB692E84708E81A5AF"
"62E528C38B2A81B35309668D73524D9F",
"96281BF8DD5E0525CA049C048D345D3082968D10FEDF5C5ACA0C64E6465A97EA"
"5CE10C9DFEC21797415710721F437922",
"447688BA94708EB6E2E4D59F6AB6D7EDFF9301D249FE49C33096655F5D502FAD"
"3D383B91C5E7EDAA2B714CC99D5743CA",
"B4B74E44D71A13D568003D7489908D564C7761E229C58CBFA18950096EB7463B"
"854D7FA992F934D927376285E63414FA",
b'abc',
sha384,
"FB017B914E29149432D8BAC29A514640B46F53DDAB2C69948084E2930F1C8F7E"
"08E07C9C63F2D21A07DCB56A6AF56EB3",
"B263A1305E057F984D38726A1B46874109F417BCA112674C528262A40A629AF1"
"CBB9F516CE0FA7D2FF630863A00E8B9F",
NIST384p,
id="ECDSA-384"),
pytest.param(
"0065FDA3409451DCAB0A0EAD45495112A3D813C17BFD34BDF8C1209D7DF58491"
"20597779060A7FF9D704ADF78B570FFAD6F062E95C7E0C5D5481C5B153B48B37"
"5FA1",
"0151518F1AF0F563517EDD5485190DF95A4BF57B5CBA4CF2A9A3F6474725A35F"
"7AFE0A6DDEB8BEDBCD6A197E592D40188901CECD650699C9B5E456AEA5ADD190"
"52A8",
"006F3B142EA1BFFF7E2837AD44C9E4FF6D2D34C73184BBAD90026DD5E6E85317"
"D9DF45CAD7803C6C20035B2F3FF63AFF4E1BA64D1C077577DA3F4286C58F0AEA"
"E643",
"00C1C2B305419F5A41344D7E4359933D734096F556197A9B244342B8B62F46F9"
"373778F9DE6B6497B1EF825FF24F42F9B4A4BD7382CFC3378A540B1B7F0C1B95"
"6C2F",
b'abc',
sha512,
"0154FD3836AF92D0DCA57DD5341D3053988534FDE8318FC6AAAAB68E2E6F4339"
"B19F2F281A7E0B22C269D93CF8794A9278880ED7DBB8D9362CAEACEE54432055"
"2251",
"017705A7030290D1CEB605A9A1BB03FF9CDD521E87A696EC926C8C10C8362DF4"
"975367101F67D1CF9BCCBF2F3D239534FA509E70AAC851AE01AAC68D62F86647"
"2660",
NIST521p,
id="ECDSA-521")
])
def test_RFC4754_vectors(w, gwx, gwy, k, msg, md, r, s, curve):
sk = SigningKey.from_string(unhexlify(w), curve)
vk = VerifyingKey.from_string(unhexlify(gwx + gwy), curve)
assert sk.verifying_key == vk
sig = sk.sign(msg, hashfunc=md, sigencode=sigencode_strings, k=int(k, 16))

assert sig == (unhexlify(r), unhexlify(s))

assert vk.verify(sig, msg, md, sigdecode_strings)