Skip to content

Commit 72ddea3

Browse files
authored
Merge pull request #94 from zjkmxy/master
Fix Ed25519 signature
2 parents bf17383 + a0e2062 commit 72ddea3

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/ndn/security/signer/ed25519_signer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ def get_signature_value_size(self):
4545

4646
def write_signature_value(self, wire: VarBinaryStr, contents: list[VarBinaryStr]) -> int:
4747
# Copying is needed as cryptography library only support bytes
48-
h = SHA512.new()
49-
for blk in contents:
50-
h.update(blk)
5148
signer = eddsa.new(self.key, 'rfc8032')
52-
signature = signer.sign(h)
49+
signature = signer.sign(b''.join(contents))
5350
wire[:] = signature
5451
return len(signature)

src/ndn/security/validator/known_key_validator.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,8 @@ def _verify(cls, pub_key_bits, sig_ptrs) -> bool:
116116

117117
def verify_ed25519(pub_key: ECC.EccKey, sig_ptrs: SignaturePtrs) -> bool:
118118
verifier = eddsa.new(pub_key, 'rfc8032')
119-
h = SHA512.new()
120-
for content in sig_ptrs.signature_covered_part:
121-
h.update(content)
122119
try:
123-
verifier.verify(h, bytes(sig_ptrs.signature_value_buf))
120+
verifier.verify(b''.join(sig_ptrs.signature_covered_part), bytes(sig_ptrs.signature_value_buf))
124121
return True
125122
except ValueError:
126123
return False

0 commit comments

Comments
 (0)