Skip to content

Commit c32ba17

Browse files
committed
Test Python fallback for ed25519 verification
Ensure the pure Python fallback for ed25519 signature validation is tested by adding it to the check_public_interfaces test module which is run in an environment without any of the cryptographic library dependencies installed. Signed-off-by: Joshua Lock <jlock@vmware.com>
1 parent f11bf87 commit c32ba17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/check_public_interfaces.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,20 @@ def test_keys(self):
180180
securesystemslib.exceptions.UnsupportedLibraryError):
181181
securesystemslib.keys.import_ecdsakey_from_private_pem(priv)
182182

183+
def test_purepy_ed25519(self):
184+
data = b'The quick brown fox jumps over the lazy dog'
185+
pub = b'\xbe\xb7\\&\x82\x06UN\x96<E\xdc\xbf<\x00A@\xd1\xcbi\xbb\xfe\x93p\xefso\x198\x8c\x9b&'
186+
sig = b'.\xc7\xa5\xe2\x95\xfabe\xe1\x0f=\xa7\xf1\xa42\xe7t/\x04\x1f\x08\x1bO\xae\xca\xb3\xa1+\xf0\xfc\x8f6l\x91\x9c\x90\xc2g\xe9\xed\x1d\xfd\xebzuV\xb9Y\xa9m\xd0\xdc\xfe\xa1}\xa3Xb-9\xaf6\xbf\t'
187+
188+
valid = securesystemslib.ed25519_keys.verify_signature(
189+
pub, 'ed25519', sig, data)
190+
self.assertEqual(True, valid)
191+
192+
bsig = b'\xd3/\x7f\x7f\xa5;6Pq\x14f]\x8b\x0e@\x8a:\xc2\xa1\xb8\xee\x11\xef\x06s\x12\xa9\x0b0\xe9@\xd5Q\xb6\xf7\xe7\xb9\xf6\xc7J\x99_L\x01\xf7\xcdi\x05\xea\xdf\x05D\x12\x1f\xeeT\xe1y\xb1\x9a\x8e\xebS\x04'
193+
invalid = securesystemslib.ed25519_keys.verify_signature(
194+
pub, 'ed25519', bsig, data)
195+
self.assertEqual(False, invalid)
196+
183197

184198
if __name__ == '__main__':
185199
suite = unittest.TestLoader().loadTestsFromTestCase(TestPublicInterfaces)

0 commit comments

Comments
 (0)