diff options
author | Niels Möller <nisse@lysator.liu.se> | 2002-02-11 18:54:35 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2002-02-11 18:54:35 +0100 |
commit | 3a3d2d8659d33746cb6fbed8a390fdc5d2c66541 (patch) | |
tree | 1a6498f473367b7006404fc44ca5f8a943d14d9c /rsa.h | |
parent | f1127d57420aaf9fcb00871e87bfeae3c16f3cce (diff) | |
download | nettle-3a3d2d8659d33746cb6fbed8a390fdc5d2c66541.tar.gz |
New files for rsa pkcs#1
encryption.
Rev: src/nettle/rsa-decrypt.c:1.1
Rev: src/nettle/rsa-encrypt.c:1.1
Rev: src/nettle/rsa.h:1.10
Diffstat (limited to 'rsa.h')
-rw-r--r-- | rsa.h | 37 |
1 files changed, 32 insertions, 5 deletions
@@ -32,6 +32,13 @@ #include "md5.h" #include "sha.h" +/* Randomness function. This typedef doesn't really belong here, but + * so far it's used only by rsa functions (encryption and key + * generation) */ +typedef void (*nettle_random_func)(void *ctx, + unsigned length, uint8_t *dst); + + /* For PKCS#1 to make sense, the size of the modulo, in octets, must * be at least 11 + the length of the DER-encoded Digest Info. * @@ -144,6 +151,31 @@ rsa_sha1_verify(struct rsa_public_key *key, struct sha1_ctx *hash, const mpz_t signature); + +/* RSA encryption, using PKCS#1 */ +/* FIXME: These functions uses the v1.5 padding. What should the v2 + * (OAEP) functions be called? */ + +/* Returns 1 on success, 0 on failure, which happens if the + * message is too long for the key. */ +int +rsa_encrypt(struct rsa_public_key *key, + /* For padding */ + void *random_ctx, nettle_random_func random, + unsigned length, const uint8_t *message, + mpz_t gibbberish); + +/* Message must point to a buffer of size *LENGTH. KEY->size is enough + * for all valid messages. On success, *LENGTH is updated to reflect + * the actual length of the message. Returns 1 on success, 0 on + * failure, which happens if decryption failed or if the message + * didn't fit. */ +int +rsa_decrypt(struct rsa_private_key *key, + unsigned *length, uint8_t *message, + const mpz_t gibberish); + + /* Compute x, the e:th root of m. Calling it with x == m is allowed. */ void rsa_compute_root(struct rsa_private_key *key, mpz_t x, const mpz_t m); @@ -151,11 +183,6 @@ rsa_compute_root(struct rsa_private_key *key, mpz_t x, const mpz_t m); /* Key generation */ -/* Randomness function. This typedef doesn't really belong here, but - * so far it's used only by the rsa key generator. */ -typedef void (*nettle_random_func)(void *ctx, - unsigned length, uint8_t *dst); - /* Progress report function. */ typedef void (*nettle_progress_func)(void *ctx, int c); |