From 6e5012424cacb6eb2e7beae2456dd76f6a022023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Sun, 13 Apr 2014 21:30:27 +0200 Subject: [PATCH] Deleted rsa-compat.h and all related code. --- ChangeLog | 5 ++ Makefile.in | 4 +- NEWS | 3 + rsa-compat.c | 165 --------------------------------------------------- rsa-compat.h | 139 ------------------------------------------- 5 files changed, 10 insertions(+), 306 deletions(-) delete mode 100644 rsa-compat.c delete mode 100644 rsa-compat.h diff --git a/ChangeLog b/ChangeLog index 03d82d2e..51b355cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2014-04-13 Niels Möller <nisse@lysator.liu.se> + * rsa-compat.c: Deleted file. + * rsa-compat.h: Deleted file. + * Makefile.in (hogweed_SOURCES): Deleted rsa-compat.c. + (HEADERS): Deleted rsa-compat.h. + * examples/next-prime.c: Deleted file. * bignum-next-prime.c (nettle_next_prime): Deleted file and function. diff --git a/Makefile.in b/Makefile.in index a3e322fd..42dd190b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -146,7 +146,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \ rsa-sha256-sign.c rsa-sha256-verify.c \ rsa-sha512-sign.c rsa-sha512-verify.c \ rsa-encrypt.c rsa-decrypt.c rsa-decrypt-tr.c \ - rsa-keygen.c rsa-compat.c rsa-blind.c \ + rsa-keygen.c rsa-blind.c \ rsa2sexp.c sexp2rsa.c \ dsa.c dsa-compat.c dsa-compat-keygen.c dsa-gen-params.c \ dsa-sign.c dsa-verify.c dsa-keygen.c dsa-hash.c \ @@ -180,7 +180,7 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h bignum.h blowfish.h \ memxor.h \ nettle-meta.h nettle-types.h \ pbkdf2.h \ - pgp.h pkcs1.h realloc.h ripemd160.h rsa.h rsa-compat.h \ + pgp.h pkcs1.h realloc.h ripemd160.h rsa.h \ salsa20.h sexp.h \ serpent.h sha.h sha1.h sha2.h sha3.h twofish.h \ umac.h yarrow.h poly1305.h diff --git a/NEWS b/NEWS index dba6c8b0..0d5ad48b 100644 --- a/NEWS +++ b/NEWS @@ -80,6 +80,9 @@ NEWS for the Nettle 3.0 release * The nettle_next_prime function has been deleted. Applications should use GMP's mpz_nextprime instead. + * Deleted the RSAREF compatibility, including the header file + rsa-compat.h and everything declared therein. + Bug fixes: * Building with ./configure --disable-static now works. diff --git a/rsa-compat.c b/rsa-compat.c deleted file mode 100644 index 46057ea7..00000000 --- a/rsa-compat.c +++ /dev/null @@ -1,165 +0,0 @@ -/* rsa-compat.c - - The RSA publickey algorithm, RSAREF compatible interface. - - Copyright (C) 2001 Niels Möller - - This file is part of GNU Nettle. - - GNU Nettle is free software: you can redistribute it and/or - modify it under the terms of either: - - * the GNU Lesser General Public License as published by the Free - Software Foundation; either version 3 of the License, or (at your - option) any later version. - - or - - * the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - or both in parallel, as here. - - GNU Nettle 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 - General Public License for more details. - - You should have received copies of the GNU General Public License and - the GNU Lesser General Public License along with this program. If - not, see http://www.gnu.org/licenses/. -*/ - -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include "rsa-compat.h" - -#include "bignum.h" -#include "md5.h" - -int -R_SignInit(R_SIGNATURE_CTX *ctx, - int digestAlgorithm) -{ - if (digestAlgorithm != DA_MD5) - return RE_DIGEST_ALGORITHM; - - md5_init(&ctx->hash); - - return 0; -} - -int -R_SignUpdate(R_SIGNATURE_CTX *ctx, - const uint8_t *data, - /* Length is an unsigned char according to rsaref.txt, - * but that must be a typo. */ - unsigned length) -{ - md5_update(&ctx->hash, length, data); - - return RE_SUCCESS; -} - -int -R_SignFinal(R_SIGNATURE_CTX *ctx, - uint8_t *signature, - unsigned *length, - R_RSA_PRIVATE_KEY *key) -{ - struct rsa_private_key k; - int res; - - nettle_mpz_init_set_str_256_u(k.p, - MAX_RSA_MODULUS_LEN, key->prime[0]); - nettle_mpz_init_set_str_256_u(k.q, - MAX_RSA_MODULUS_LEN, key->prime[1]); - nettle_mpz_init_set_str_256_u(k.a, - MAX_RSA_MODULUS_LEN, key->primeExponent[0]); - nettle_mpz_init_set_str_256_u(k.b, - MAX_RSA_MODULUS_LEN, key->primeExponent[1]); - nettle_mpz_init_set_str_256_u(k.c, - MAX_RSA_MODULUS_LEN, key->coefficient); - - if (rsa_private_key_prepare(&k) && (k.size <= MAX_RSA_MODULUS_LEN)) - { - mpz_t s; - mpz_init(s); - - if (rsa_md5_sign(&k, &ctx->hash, s)) - { - nettle_mpz_get_str_256(k.size, signature, s); - *length = k.size; - - res = RE_SUCCESS; - } - else - res = RE_PRIVATE_KEY; - - mpz_clear(s); - } - else - res = RE_PRIVATE_KEY; - - mpz_clear(k.p); - mpz_clear(k.q); - mpz_clear(k.a); - mpz_clear(k.b); - mpz_clear(k.c); - - return res; -} - -int -R_VerifyInit(R_SIGNATURE_CTX *ctx, - int digestAlgorithm) -{ - return R_SignInit(ctx, digestAlgorithm); -} - -int -R_VerifyUpdate(R_SIGNATURE_CTX *ctx, - const uint8_t *data, - /* Length is an unsigned char according to rsaref.txt, - * but that must be a typo. */ - unsigned length) -{ - return R_SignUpdate(ctx, data, length); -} - -int -R_VerifyFinal(R_SIGNATURE_CTX *ctx, - uint8_t *signature, - unsigned length, - R_RSA_PUBLIC_KEY *key) -{ - struct rsa_public_key k; - int res; - - nettle_mpz_init_set_str_256_u(k.n, - MAX_RSA_MODULUS_LEN, key->modulus); - nettle_mpz_init_set_str_256_u(k.e, - MAX_RSA_MODULUS_LEN, key->exponent); - - if (rsa_public_key_prepare(&k) && (k.size == length)) - { - mpz_t s; - - nettle_mpz_init_set_str_256_u(s, - k.size, signature); - res = rsa_md5_verify(&k, &ctx->hash, s) - ? RE_SUCCESS : RE_SIGNATURE; - - mpz_clear(s); - } - else - res = RE_PUBLIC_KEY; - - mpz_clear(k.n); - mpz_clear(k.e); - - return res; -} diff --git a/rsa-compat.h b/rsa-compat.h deleted file mode 100644 index e80f9c50..00000000 --- a/rsa-compat.h +++ /dev/null @@ -1,139 +0,0 @@ -/* rsa-compat.h - - The RSA publickey algorithm, RSAREF compatible interface. - - Copyright (C) 2001 Niels Möller - - This file is part of GNU Nettle. - - GNU Nettle is free software: you can redistribute it and/or - modify it under the terms of either: - - * the GNU Lesser General Public License as published by the Free - Software Foundation; either version 3 of the License, or (at your - option) any later version. - - or - - * the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your - option) any later version. - - or both in parallel, as here. - - GNU Nettle 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 - General Public License for more details. - - You should have received copies of the GNU General Public License and - the GNU Lesser General Public License along with this program. If - not, see http://www.gnu.org/licenses/. -*/ - -#ifndef NETTLE_RSA_COMPAT_H_INCLUDED -#define NETTLE_RSA_COMPAT_H_INCLUDED - -#include "rsa.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Name mangling */ -#define R_SignInit nettle_R_SignInit -#define R_SignUpdate nettle_R_SignUpdate -#define R_SignFinal nettle_R_SignFinal -#define R_VerifyInit nettle_R_VerifyInit -#define R_VerifyUpdate nettle_R_VerifyUpdate -#define R_VerifyFinal nettle_R_VerifyFinal - -/* 256 octets or 2048 bits */ -#define MAX_RSA_MODULUS_LEN 256 - -typedef struct -{ - unsigned bits; - uint8_t modulus[MAX_RSA_MODULUS_LEN]; - uint8_t exponent[MAX_RSA_MODULUS_LEN]; -} R_RSA_PUBLIC_KEY; - -typedef struct -{ - unsigned bits; - uint8_t modulus[MAX_RSA_MODULUS_LEN]; - uint8_t publicExponent[MAX_RSA_MODULUS_LEN]; - uint8_t exponent[MAX_RSA_MODULUS_LEN]; - uint8_t prime[2][MAX_RSA_MODULUS_LEN]; - uint8_t primeExponent[2][MAX_RSA_MODULUS_LEN]; - uint8_t coefficient[MAX_RSA_MODULUS_LEN]; -} R_RSA_PRIVATE_KEY; - -/* Only MD5 is supported for now */ -typedef struct -{ - struct md5_ctx hash; -} R_SIGNATURE_CTX; - -/* Digest algorithms */ -/* DA_MD2 not implemented */ -enum { DA_MD5 = 1 }; - -/* Return values */ -enum { - RE_SUCCESS = 0, - RE_CONTENT_ENCODING, /* encryptedContent has RFC 1421 encoding error */ - RE_DATA, /* other party's private value out of range */ - RE_DIGEST_ALGORITHM, /* message-digest algorithm is invalid */ - RE_ENCODING, /* encoded block has RFC 1421 encoding error */ - RE_ENCRYPTION_ALGORITHM, /* encryption algorithm is invalid */ - RE_KEY, /* recovered data encryption key cannot decrypt */ - RE_KEY_ENCODING, /* encrypted key has RFC 1421 encoding error */ - RE_LEN, /* signatureLen out of range */ - RE_MODULUS_LEN, /* modulus length invalid */ - RE_NEED_RANDOM, /* random structure is not seeded */ - RE_PRIVATE_KEY, /* private key cannot encrypt message digest, */ - RE_PUBLIC_KEY, /* publicKey cannot decrypt signature */ - RE_SIGNATURE, /* signature is incorrect */ - RE_SIGNATURE_ENCODING, /* encodedSignature has RFC 1421 encoding error */ -}; - -int -R_SignInit(R_SIGNATURE_CTX *ctx, - int digestAlgorithm); - -int -R_SignUpdate(R_SIGNATURE_CTX *ctx, - const uint8_t *data, - /* Length is an unsigned char according to rsaref.txt, - * but that must be a typo. */ - unsigned length); - -int -R_SignFinal(R_SIGNATURE_CTX *ctx, - uint8_t *signature, - unsigned *length, - R_RSA_PRIVATE_KEY *key); - -int -R_VerifyInit(R_SIGNATURE_CTX *ctx, - int digestAlgorithm); - -int -R_VerifyUpdate(R_SIGNATURE_CTX *ctx, - const uint8_t *data, - /* Length is an unsigned char according to rsaref.txt, - * but that must be a typo. */ - unsigned length); - -int -R_VerifyFinal(R_SIGNATURE_CTX *ctx, - uint8_t *signature, - unsigned length, - R_RSA_PUBLIC_KEY *key); - -#ifdef __cplusplus -} -#endif - -#endif /* NETTLE_RSA_COMPAT_H_INCLUDED */ -- GitLab