diff --git a/ChangeLog b/ChangeLog
index 856bd8f2e6c5ce40e81f141f0e7be876456ba535..b772d2deae386136cf5b6663523a6c47ef70fa6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2001-10-30  Niels M�ller  <nisse@ehand.com>
+
+	* configure.in: Check for libgmp. Deleted tests for SIZEOF_INT and
+	friends. 
+
+	* rsa_sha1.c: New file, PKCS#1 rsa-sha1 signatures. 
+	* rsa_md5.c: New file, PKCS#1 rsa-md5 signatures.
+
+	* rsa.c: New file with general rsa functions.
+
+	* Makefile.am (libnettle_a_SOURCES): Added rsa and bignum files.
+
+	* bignum.c, bignum.h: New file, with base256 functions missing in
+	gmp. 
+
+	* testsuite/Makefile.am: Added bignum-test.
+
+	* testsuite/run-tests (test_program): Check the xit code more
+	carefully, and treat 77 as skip. This convention was borrowed from
+	autotest. 
+
+	* testsuite/macros.m4: New macro SKIP which exits with code 77.
+
+	* testsuite/bignum-test.m4: New file.
+
 2001-10-15  Niels M�ller  <nisse@ehand.com>
 
 	* testsuite/Makefile.am (EXTRA_DIST): Include rfc1750.txt in the
diff --git a/rsa.h b/rsa.h
index 105970efdd477b087041beba8785f0deef8aa3b4..52c6d94ce8785e215fef00856002ede9937ad256 100644
--- a/rsa.h
+++ b/rsa.h
@@ -27,19 +27,95 @@
 #define NETTLE_RSA_H_INCLUDED
 
 #include <inttypes.h>
-
 #include <gmp.h>
 
+#include "md5.h"
+#include "sha.h"
+
 struct rsa_public_key
 {
+  /* Size of the modulo, in octets. This is also the size of all
+   * signatures that are created or verified with this key. */
+  unsigned size;
+  
+  /* Modulo */
   mpz_t n;
+
+  /* Public exponent */
   mpz_t e;
 };
 
 struct rsa_private_key
 {
+  struct rsa_public_key pub;
   
+  /* Secret exponent */
+  mpz_t d;
+
+  /* The two factors */
+  mpz_t p; mpz_t q;
+
+  /* d % (p-1), i.e. a e = 1 (mod (p-1)) */
+  mpz_t a;
+
+  /* d % (q-1), i.e. b e = 1 (mod (q-1)) */
+  mpz_t b;
+
+  /* modular inverse of q , i.e. c q = 1 (mod p) */
+  mpz_t c;
 };
 
+/* Signing a message works as follows:
+ *
+ * Store the private key in a rsa_private_key struct.
+ *
+ * Call rsa_init_private_key. This initializes the size attribute
+ * to the length of a signature.
+ *
+ * Initialize a hashing context, by callling
+ *   md5_init
+ *
+ * Hash the message by calling
+ *   md5_update
+ *
+ * Finally, call
+ *   rsa_md5_sign
+ *
+ * The final call stores the signature, of length size, in the supplied buffer,
+ * and resets the hashing context.
+ */
+
+int
+rsa_init_public_key(struct rsa_public_key *key);
+
+int
+rsa_init_private_key(struct rsa_private_key *key);
+
+/* PKCS#1 style signatures */
+void
+rsa_md5_sign(struct rsa_private_key *key,
+             struct md5_ctx *hash,
+             uint8_t *signature);
+
+
+int
+rsa_md5_verify(struct rsa_public_key *key,
+               struct md5_ctx *hash,
+               const uint8_t *signature);
+
+void
+rsa_sha1_sign(struct rsa_private_key *key,
+              struct sha1_ctx *hash,
+              uint8_t *signature);
+
+int
+rsa_sha1_verify(struct rsa_public_key *key,
+                struct sha1_ctx *hash,
+                const uint8_t *signature);
+
+/* Compute x, the d:th root of m. Calling it with x == m is allowed. */
+void
+rsa_compute_root(struct rsa_private_key *key, mpz_t x, mpz_t m);
+
 
-#endif NETTLE_RSA_H_INCLUDED
+#endif /* NETTLE_RSA_H_INCLUDED */
diff --git a/testsuite/.cvsignore b/testsuite/.cvsignore
index 3c17f38714ef6f7071c94e480710582e0ae1773d..64c77d5f3ae1168283695e647d3932752b15c966 100644
--- a/testsuite/.cvsignore
+++ b/testsuite/.cvsignore
@@ -5,6 +5,8 @@ aes-test
 aes-test.c
 arcfour-test
 arcfour-test.c
+bignum-test
+bignum-test.c
 blowfish-test
 blowfish-test.c
 cast128-test
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 29d40cb4de16839c9df7b43054626b369fbe3a27..e5c287dd6e0c98b25ad89f666315ad1fe907d4e4 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -5,6 +5,8 @@
 /aes-test.c
 /arcfour-test
 /arcfour-test.c
+/bignum-test
+/bignum-test.c
 /blowfish-test
 /blowfish-test.c
 /cast128-test