--- /dev/null
+#include "testutils.h"
+#include "md2.h"
+
+int
+test_main(void)
+{
+ test_hash(&nettle_md2, 0, "",
+ H("8350e5a3e24c153df2275c9f80692773"));
+ test_hash(&nettle_md2, LDATA("a"),
+ H("32ec01ec4a6dac72c0ab96fb34c0b5d1"));
+ test_hash(&nettle_md2, LDATA("abc"),
+ H("da853b0d3f88d99b30283a69e6ded6bb"));
+ test_hash(&nettle_md2, LDATA("message digest"),
+ H("ab4f496bfb2a530b219ff33031fe06b0"));
+ test_hash(&nettle_md2, LDATA("abcdefghijklmnopqrstuvwxyz"),
+ H("4e8ddff3650292ab5a4108c3aa47940b"));
+ test_hash(&nettle_md2,
+ LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ "0123456789"),
+ H("da33def2a42df13975352846c30338cd"));
+ test_hash(&nettle_md2, LDATA("1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890"),
+ H("d5976f79d83d3a0dc9806c3c66f3efd8"));
+
+ SUCCESS();
+}
--- /dev/null
+#include "testutils.h"
+#include "md4.h"
+
+int
+test_main(void)
+{
+ test_hash(&nettle_md4, LDATA(""),
+ H("31d6cfe0d16ae931b73c59d7e0c089c0"));
+ test_hash(&nettle_md4, LDATA("a"),
+ H("bde52cb31de33e46245e05fbdbd6fb24"));
+ test_hash(&nettle_md4, LDATA("abc"),
+ H("a448017aaf21d8525fc10ae87aa6729d"));
+ test_hash(&nettle_md4, LDATA("message digest"),
+ H("d9130a8164549fe818874806e1c7014b"));
+ test_hash(&nettle_md4, LDATA("abcdefghijklmnopqrstuvwxyz"),
+ H("d79e1c308aa5bbcdeea8ed63df412da9"));
+ test_hash(&nettle_md4,
+ LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ "0123456789"),
+ H("043f8582f241db351ce627e153e7f0e4"));
+ test_hash(&nettle_md4,
+ LDATA("12345678901234567890123456789012345678901234567890"
+ "123456789012345678901234567890"),
+ H("e33b4ddc9c38f2199c3e7b164fcc0536"));
+
+ SUCCESS();
+}
--- /dev/null
+#include "testutils.h"
+
+#include "rsa.h"
+#include "knuth-lfib.h"
+
+int
+test_main(void)
+{
+#if WITH_PUBLIC_KEY
+ struct rsa_public_key pub;
+ struct rsa_private_key key;
+ struct knuth_lfib_ctx lfib;
+
+ /* FIXME: How is this spelled? */
+ const uint8_t *msg = "Squemish ossifrage";
+ unsigned msg_length;
+
+ uint8_t *decrypted;
+ unsigned decrypted_length;
+
+ mpz_t gibberish;
+
+ rsa_private_key_init(&key);
+ rsa_public_key_init(&pub);
+ mpz_init(gibberish);
+
+ knuth_lfib_init(&lfib, 17);
+
+ test_rsa_set_key_1(&pub, &key);
+ msg_length = strlen(msg);
+
+ if (verbose)
+ fprintf(stderr, "msg: `%s', length = %d\n", msg, msg_length);
+
+ ASSERT(rsa_encrypt(&pub,
+ &lfib, (nettle_random_func) knuth_lfib_random,
+ msg_length, msg,
+ gibberish));
+
+ if (verbose)
+ gmp_fprintf(stderr, "encrypted: %Zd\n", gibberish);
+
+ decrypted = alloca(msg_length + 1);
+
+ decrypted_length = msg_length - 1;
+ ASSERT(!rsa_decrypt(&key, &decrypted_length, decrypted, gibberish));
+
+ decrypted_length = msg_length;
+ ASSERT(rsa_decrypt(&key, &decrypted_length, decrypted, gibberish));
+ ASSERT(decrypted_length == msg_length);
+ ASSERT(MEMEQ(msg_length, msg, decrypted));
+
+ decrypted_length = key.size;
+ ASSERT(rsa_decrypt(&key, &decrypted_length, decrypted, gibberish));
+ ASSERT(decrypted_length == msg_length);
+ ASSERT(MEMEQ(msg_length, msg, decrypted));
+
+ rsa_private_key_clear(&key);
+ rsa_public_key_clear(&pub);
+ mpz_clear(gibberish);
+
+ SUCCESS();
+
+#else /* !WITH_PUBLIC_KEY */
+ SKIP();
+#endif /* !WITH_PUBLIC_KEY */
+}
+