Skip to content

Commit a081a03

Browse files
add C# raw public Ed25519 key export/import test
1 parent e4b7f66 commit a081a03

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ private static void ed25519_test()
471471
IntPtr key = IntPtr.Zero;
472472
byte[] privKey;
473473
byte[] pubKey;
474+
uint pubKeySz;
474475

475476
Console.WriteLine("\nStarting ED25519 tests...");
476477

@@ -537,8 +538,33 @@ private static void ed25519_test()
537538
}
538539
Console.WriteLine("ED25519 Signature Verification test passed.");
539540

541+
/* test importing a raw public key */
542+
ret = wolfcrypt.Ed25519ExportPublic(key, pubKey, out pubKeySz);
543+
if (ret < 0 || pubKey == null) {
544+
throw new Exception("Ed25519ExportPublic failed");
545+
}
546+
Console.WriteLine("ED25519 Export Raw Public test passed.");
547+
548+
if (importedPubKey != IntPtr.Zero) {
549+
wolfcrypt.Ed25519FreeKey(importedPubKey);
550+
}
551+
ret = wolfcrypt.Ed25519ImportPublic(pubKey, pubKeySz, out importedPubKey);
552+
if (importedPubKey == IntPtr.Zero) {
553+
throw new Exception("Ed25519ImportPublic failed");
554+
}
555+
Console.WriteLine("ED25519 Import Raw Public test passed.");
556+
540557
/* Cleanup */
541-
if (key != IntPtr.Zero) wolfcrypt.Ed25519FreeKey(key);
558+
if (key != IntPtr.Zero) {
559+
wolfcrypt.Ed25519FreeKey(key);
560+
}
561+
if (importedPubKey != IntPtr.Zero) {
562+
wolfcrypt.Ed25519FreeKey(importedPubKey);
563+
}
564+
if (importedPrivKey != IntPtr.Zero) {
565+
wolfcrypt.Ed25519FreeKey(importedPrivKey);
566+
}
567+
542568
} /* END ed25519_test */
543569

544570
private static void curve25519_test()

0 commit comments

Comments
 (0)