Commit 2c5a6003 authored by Niels Möller's avatar Niels Möller

rsa.h is now obsolete.

Rev: src/lsh-decode-key.c:1.16
Rev: src/lsh-keygen.c:1.11
Rev: src/lsh-writekey.c:1.23
Rev: src/nettle/hmac-md5.h:1.1
Rev: src/nettle/rsa.h:1.5
Rev: src/nettle/rsa_md5.c:1.3
Rev: src/nettle/rsa_sha1.c:1.3
Rev: src/nettle/testsuite/Makefile.am:1.18
Rev: src/nettle/testsuite/aes-test.c:1.2
Rev: src/nettle/testsuite/arcfour-test.c:1.2
Rev: src/nettle/testsuite/bignum-test.c:1.2
Rev: src/nettle/testsuite/blowfish-test.c:1.2
Rev: src/nettle/testsuite/cast128-test.c:1.2
Rev: src/nettle/testsuite/cbc-test.c:1.2
Rev: src/nettle/testsuite/des-compat-test.c:1.3
Rev: src/nettle/testsuite/des-test.c:1.2
Rev: src/nettle/testsuite/des3-test.c:1.2
Rev: src/nettle/testsuite/md5-compat-test.c:1.2
Rev: src/nettle/testsuite/md5-test.c:1.2
Rev: src/nettle/testsuite/serpent-test.c:1.2
Rev: src/nettle/testsuite/sha1-test.c:1.2
Rev: src/nettle/testsuite/sha256-test.c:1.2
Rev: src/nettle/testsuite/testutils.c:1.6
Rev: src/nettle/testsuite/testutils.h:1.4
Rev: src/nettle/testsuite/twofish-test.c:1.2
Rev: src/nettle/testsuite/yarrow-test.c:1.11
Rev: src/rsa.h:1.4
Rev: src/server_authorization.c:1.17
Rev: src/testsuite/Makefile.am:1.41
Rev: src/testsuite/conv-2-test:1.3
parent b801e2f4
......@@ -12,7 +12,6 @@
#include "lsh_argp.h"
#include "publickey_crypto.h"
#include "read_file.h"
#include "rsa.h"
#include "sexp.h"
#include "spki.h"
#include "version.h"
......
......@@ -32,7 +32,6 @@
#include "io.h"
#include "publickey_crypto.h"
#include "randomness.h"
#include "rsa.h"
#include "sexp.h"
#include "version.h"
#include "werror.h"
......
......@@ -29,7 +29,7 @@
#include "format.h"
#include "io_commands.h"
#include "interact.h"
#include "rsa.h"
#include "publickey_crypto.h"
#include "sexp.h"
#include "spki.h"
#include "version.h"
......
/* hmac-md5.h
*
* HMAC message authentication code.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Mller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef NETTLE_HMAC_MD5_H_INCLUDED
#define NETTLE_HMAC_MD5_H_INCLUDED
#include "hmac.h"
#include "md5.h"
struct hmac_md5_ctx HMAC_CTX(struct md5_ctx);
void
hmac_md5_set_key(struct hmac_md5_ctx *ctx,
unsigned key_length, const uint8_t *key);
void
hmac_md5_update(struct hmac_md5_ctx *ctx,
unsigned length, const uint8_t *data);
void
hmac_md5_digest(struct hmac_md5_ctx *ctx,
unsigned length, uint8_t *digest);
#endif /* NETTLE_HMAC_MD5_H_INCLUDED */
......@@ -137,5 +137,14 @@ rsa_sha1_verify(struct rsa_public_key *key,
void
rsa_compute_root(struct rsa_private_key *key, mpz_t x, const mpz_t m);
#define RSA_SIGN(key, algorithm, ctx, length, data, signature) ( \
algorithm##_update(ctx, length, data), \
rsa_##algorithm##_sign(key, ctx, signature) \
)
#define RSA_VERIFY(key, algorithm, ctx, length, data, signature) ( \
algorithm##_update(ctx, length, data), \
rsa_##algorithm##_verify(key, ctx, signature) \
)
#endif /* NETTLE_RSA_H_INCLUDED */
......@@ -90,7 +90,8 @@ rsa_md5_verify(struct rsa_public_key *key,
* md5Identifier ::= AlgorithmIdentifier {md5, NULL}
*/
static const uint8_t md5_prefix[] =
static const uint8_t
md5_prefix[] =
{
/* 18 octets prefix, 16 octets hash, 34 total. */
0x30, 32, /* SEQUENCE */
......
......@@ -90,7 +90,8 @@ rsa_sha1_verify(struct rsa_public_key *key,
* sha1Identifier ::= AlgorithmIdentifier {id-sha1, NULL}
*/
static const uint8_t sha1_prefix[] =
static const uint8_t
sha1_prefix[] =
{
/* 15 octets prefix, 20 octets hash, total 35 */
0x30, 33, /* SEQUENCE */
......@@ -102,8 +103,6 @@ static const uint8_t sha1_prefix[] =
/* Here comes the raw hash value */
};
static void
pkcs1_encode_sha1(mpz_t m, unsigned length, struct sha1_ctx *hash)
{
......
......@@ -5,7 +5,7 @@ TS_PROGS = aes-test arcfour-test blowfish-test cast128-test \
des-test des3-test des-compat-test \
md5-test md5-compat-test sha1-test sha256-test \
serpent-test twofish-test \
cbc-test bignum-test yarrow-test
cbc-test rsa-test bignum-test yarrow-test
# M4_FILES = aes-test.m4 arcfour-test.m4 blowfish-test.m4 cast128-test.m4 \
# des-test.m4 des3-test.m4 \
......
......@@ -2,7 +2,7 @@
#include "aes.h"
int
main(int argc, char **argv)
test_main(void)
{
/* 128 bit keys */
test_cipher(&nettle_aes128,
......
......@@ -2,7 +2,7 @@
#include "arcfour.h"
int
main(int argc, char **argv)
test_main(void)
{
test_cipher(&nettle_arcfour128,
HL("01234567 89ABCDEF 00000000 00000000"),
......
......@@ -4,12 +4,12 @@
#include "config.h"
#endif
#if HAVE_LIBGMP
#include "bignum.h"
#include <stdlib.h>
#include <string.h>
#if HAVE_LIBGMP
#include "bignum.h"
static void
test_bignum(const char *hex, unsigned length, const uint8_t *base256)
{
......@@ -38,7 +38,7 @@ test_bignum(const char *hex, unsigned length, const uint8_t *base256)
#endif /* HAVE_LIBGMP */
int
main(int argc, char **argv)
test_main(void)
{
#if HAVE_LIBGMP
test_bignum("0", 0, "");
......
......@@ -3,7 +3,7 @@
#include "blowfish.h"
int
main(int argc, char **argv)
test_main(void)
{
/* 208 bit key. Test from GNUPG. */
test_cipher(&nettle_blowfish128,
......
......@@ -2,7 +2,7 @@
#include "cast128.h"
int
main(int argc, char **argv)
test_main(void)
{
/* Test vectors from B.1. Single Plaintext-Key-Ciphertext Sets, RFC
* 2144 */
......
......@@ -3,7 +3,7 @@
#include "cbc.h"
int
main(int argc, char **argv)
test_main(void)
{
uint8_t msg[2 * AES_BLOCK_SIZE] = "Listen, I'll say this only once!";
......
......@@ -62,6 +62,7 @@
#include <string.h>
#include "des-compat.h"
#include "testutils.h"
#define C_Block des_cblock
#define Key_schedule des_key_schedule
......@@ -300,7 +301,8 @@ static int cfb64_test();
static int ede_cfb64_test();
#endif
int main(int argc, char **argv)
int
test_main(void)
{
int i,j,err=0;
des_cblock in,out,outin,iv3;
......
......@@ -3,7 +3,7 @@
#include "des.h"
int
main(int argc, char **argv)
test_main(void)
{
struct des_ctx ctx;
......
......@@ -3,7 +3,7 @@
#include "des.h"
int
main(int argc, char **argv)
test_main(void)
{
/* Intermediate values:
* After first DES encryption: "cd ea 2a 20 c2 e0 9e 48"
......
......@@ -2,7 +2,7 @@
#include "md5-compat.h"
int
main(int argc, char **argv)
test_main(void)
{
MD5_CTX ctx;
unsigned char digest[MD5_DIGEST_SIZE];
......
......@@ -2,7 +2,7 @@
#include "md5.h"
int
main(int argc, char **argv)
test_main(void)
{
test_hash(&nettle_md5, 0, "",
H("D41D8CD98F00B204 E9800998ECF8427E"));
......
......@@ -2,7 +2,7 @@
#include "serpent.h"
int
main(int argc, char **argv)
test_main(void)
{
/* The first test for each key size from the ecb_vk.txt and ecb_vt.txt
* files in the serpent package. */
......
......@@ -2,7 +2,7 @@
#include "sha.h"
int
main(int argc, char **argv)
test_main(void)
{
test_hash(&nettle_sha1, 0, "",
H("DA39A3EE5E6B4B0D 3255BFEF95601890 AFD80709"));
......
......@@ -2,7 +2,7 @@
#include "sha.h"
int
main(int argc, char **argv)
test_main(void)
{
test_hash(&nettle_sha256, 3, "abc",
H("ba7816bf8f01cfea 414140de5dae2223"
......
......@@ -5,9 +5,13 @@
#include "cbc.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* For getopt() */
#include <unistd.h>
/* -1 means invalid */
const signed char hex_digits[0x100] =
{
......@@ -103,6 +107,33 @@ decode_hex_dup(const char *hex)
}
}
int verbose = 0;
int
main(int argc, char **argv)
{
int c;
while ((c = getopt (argc, argv, "v")) != -1)
switch (c)
{
case 'v':
verbose = 1;
break;
case '?':
if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf (stderr,
"Unknown option character `\\x%x'.\n",
optopt);
default:
abort();
}
return test_main();
}
void
test_cipher(const struct nettle_cipher *cipher,
unsigned key_length,
......
......@@ -20,6 +20,12 @@ decode_hex(uint8_t *dst, const char *hex);
const uint8_t *
decode_hex_dup(const char *hex);
/* The main program */
int
test_main(void);
extern int verbose;
void
test_cipher(const struct nettle_cipher *cipher,
unsigned key_length,
......@@ -42,7 +48,7 @@ test_hash(const struct nettle_hash *hash,
unsigned length,
const uint8_t *data,
const uint8_t *digest);
#define H2(d, s) decode_hex((d), (s))
#define H(x) decode_hex_dup(x)
#define HL(x) decode_hex_length(x), decode_hex_dup(x)
......
......@@ -2,7 +2,7 @@
#include "twofish.h"
int
main(int argc, char **argv)
test_main(void)
{
/* 128 bit key */
test_cipher(&nettle_twofish128,
......
......@@ -9,8 +9,6 @@
#include <stdlib.h>
#include <string.h>
static int verbose = 0;
/* Lagged fibonacci sequence as described in Knuth 3.6 */
#define KK 100
......@@ -166,7 +164,7 @@ open_file(const char *name)
}
int
main(int argc, char **argv)
test_main(void)
{
FILE *input;
......@@ -200,11 +198,6 @@ main(int argc, char **argv)
static const char zeroes[100];
if ((argc == 2)
&& (argv[1][0] == '-')
&& (argv[1][1] == 'v'))
verbose = 1;
yarrow256_init(&yarrow, 2, sources);
memset(&yarrow.seed_file, 0, sizeof(yarrow.seed_file));
......
......@@ -22,22 +22,22 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#warning rsa.h is obsolete
#ifndef LSH_RSA_H_INCLUDED
#define LSH_RSA_H_INCLUDED
#include "bignum.h"
#include "publickey_crypto.h"
#if 0
#define GABA_DECLARE
#include "rsa.h.x"
#undef GABA_DECLARE
#endif
/* We don't allow keys larger than 5000 bits (i.e. 625 octets). Note
* that allowing really large keys opens for Denial-of-service
* attacks. */
#define RSA_MAX_SIZE 625
#if 0
/* GABA:
(class
(name rsa_algorithm)
......@@ -58,6 +58,7 @@ make_rsa_algorithm(struct hash_algorithm *hash,
int name,
UINT32 prefix_length,
const UINT8 *prefix);
#endif
extern struct rsa_algorithm rsa_md5_algorithm;
extern struct rsa_algorithm rsa_sha1_algorithm;
......
......@@ -27,7 +27,7 @@
#include "dsa.h"
#include "format.h"
#include "rsa.h"
#include "publickey_crypto.h"
#include "server_userauth.h"
#include "sexp.h"
#include "spki.h"
......
......@@ -8,7 +8,8 @@ TS_PROGS = arcfour-test aes-test blowfish-test cast128-test
serpent-test twofish-test \
md5-test sha1-test rsa-test dsa-test spki-tag-test \
string-test
TS_SH = conv-1-test conv-2-test export-1-test keygen-1-test keygen-2-test \
TS_SH = conv-1-test conv-2-test conv-3-test \
export-1-test keygen-1-test keygen-2-test \
write-key-1-test write-key-2-test seed-test
TS_SOME = $(TS_PROGS) $(TS_SH)
......
......@@ -24,12 +24,12 @@ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEApUmWhj0f4TD/XcDW88zcKo1ZYBn09jT0RzP1aoPwKuzF
EOF
cat >test.out2 <<EOF
(public-key (rsa-pkcs1-sha1 (n |pUmWhj0f4TD/XcDW88zcKo1ZYBn09jT0RzP1aoPw
KuzFbvupfbvKjPB3SC6r8cXTH0OY60EdfcQs1Ymt
eIJNMEnWEvV9ZHPJYanU6dVSlajnbKwEhqrFMLlR
uS4UKJQ67A5NFt0WV9DjYaLIzY5RmPJYci/C8bo+
Pawj8r/j1As=|)
(e "#")))
(public-key (rsa-pkcs1 (n |pUmWhj0f4TD/XcDW88zcKo1ZYBn09jT0RzP1aoPw
KuzFbvupfbvKjPB3SC6r8cXTH0OY60EdfcQs1Ymt
eIJNMEnWEvV9ZHPJYanU6dVSlajnbKwEhqrFMLlR
uS4UKJQ67A5NFt0WV9DjYaLIzY5RmPJYci/C8bo+
Pawj8r/j1As=|)
(e "#")))
EOF
compare_output "conv-2-test"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment