void test_crypto_sign_open() { Console.WriteLine("Testing crypto_sign_open() ....."); byte[] message = LibSalt.StringToByteArray("test"); ulong mlen = 4; byte[] pk = new byte[crypto_sign_PUBLICKEYBYTES]; byte[] sk = new byte[crypto_sign_SECRETKEYBYTES]; byte[] pk2 = new byte[crypto_sign_PUBLICKEYBYTES]; byte[] sk2 = new byte[crypto_sign_SECRETKEYBYTES]; LibSalt.crypto_sign_keypair(pk, sk); LibSalt.crypto_sign_keypair(pk2, sk2); ulong smlen = (ulong)LibSalt.crypto_sign_BYTES() + mlen; byte[] signed_message = new byte[smlen]; LibSalt.crypto_sign(signed_message, message, sk); byte[] unsigned_message = new byte[mlen]; int success = LibSalt.crypto_sign_open(unsigned_message, signed_message, pk); int success2 = LibSalt.crypto_sign_open(unsigned_message, signed_message, pk2); // Test for sucessful decoding signed message with correct private key UnitTest.ASSERT_EQUALS(success, 0); // Test for unsucessful decoding signed message with incorrect private key UnitTest.ASSERT_DIFFERS(success2, 0); }
public void test_randombytes_random() { Console.WriteLine("Testing randombytes_random() ....."); UnitTest.ASSERT_DIFFERS(LibSalt.randombytes_random(), LibSalt.randombytes_random()); }