From 91a5ea3ac0283067d167e257da801bd9f98da096 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 19 Mar 2013 15:59:00 +0900 Subject: [PATCH] minimum change for PolarSSL --- README | 30 ++++++++++++++++++++---------- polarssl/library/aes.c | 2 -- polarssl/library/bignum.c | 2 -- polarssl/library/rsa.c | 12 ++---------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/README b/README index 91bc504..0a22d37 100644 --- a/README +++ b/README @@ -231,26 +231,36 @@ External source code Gnuk is distributed with external source code. -* ChibiOS_2.0.8/ -- ChibiOS/RT 2.0.8 +* chibios/ -- ChibiOS/RT 2.4.3 + + Source code taken from: http://chibios.sourceforge.net/ - Taken from http://chibios.sourceforge.net/ - Note that CRLF is converted to LF in this repository. We use ChibiOS/RT as the kernel for Gnuk. -* polarssl-0.14.0/ -- PolarSSL 0.14.0 - Taken from http://polarssl.org/ +* polarssl/ -- PolarSSL 1.2.6 + + Souce code taken from: http://polarssl.org/ + We use PolarSSL for RSA computation, AES encryption/decryption. The file include/polarssl/bn_mul.h is heavily modified for ARM Cortex-M3. - The files include/polarssl/rsa.h, library/rsa.c, - include/polarssl/bignum.h, and library/bignum.c are modified so that - f_rng function returns unsigned char. + The function rsa_private in polarssl/library/rsa.c is modified so + that it doesn't check T against N. The function rsa_pkcs1_sign is + modified to avoid warnings in case of !POLARSSL_PKCS1_V21. - The file library/rsa.c is modified so that it only computes things - needed for Gnuk. + The functions rsa_pkcs1_verify and rsa_rsassa_pkcs1_v15_verify in + include/polarssl/rsa.h and polarssl/library/rsa.c are modified + (fixed) for last argument SIG, as the memory at SIG aren't modified + by those routines. + + The constant POLARSSL_MPI_MAX_SIZE in include/polarssl/bignum.h is + modified for 2048-bit keys only Gnuk. + + The function mpi_mul_hlp in library/bignum.c is modified for more + optimization for ARM Cortex-M3. The file library/aes.c is modified so that some constants can go to .sys section. diff --git a/polarssl/library/aes.c b/polarssl/library/aes.c index aae0b6c..ece7ee5 100644 --- a/polarssl/library/aes.c +++ b/polarssl/library/aes.c @@ -767,7 +767,6 @@ int aes_crypt_ecb( aes_context *ctx, return( 0 ); } -#if 0 /* * AES-CBC buffer encryption/decryption */ @@ -831,7 +830,6 @@ int aes_crypt_cbc( aes_context *ctx, return( 0 ); } -#endif #if defined(POLARSSL_CIPHER_MODE_CFB) /* diff --git a/polarssl/library/bignum.c b/polarssl/library/bignum.c index 05f7d81..bab7c99 100644 --- a/polarssl/library/bignum.c +++ b/polarssl/library/bignum.c @@ -249,7 +249,6 @@ size_t mpi_size( const mpi *X ) return( ( mpi_msb( X ) + 7 ) >> 3 ); } -#if 0 /* * Convert an ASCII character to digit value */ @@ -432,7 +431,6 @@ cleanup: return( ret ); } -#endif #if defined(POLARSSL_FS_IO) /* diff --git a/polarssl/library/rsa.c b/polarssl/library/rsa.c index 01e606a..ecaaf6b 100644 --- a/polarssl/library/rsa.c +++ b/polarssl/library/rsa.c @@ -132,7 +132,6 @@ cleanup: #endif -#if 0 /* * Check a public RSA key */ @@ -217,7 +216,6 @@ cleanup: return( 0 ); } -#endif /* * Do an RSA public key operation @@ -438,7 +436,6 @@ int rsa_rsaes_oaep_encrypt( rsa_context *ctx, } #endif /* POLARSSL_PKCS1_V21 */ -#if 0 /* * Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-ENCRYPT function */ @@ -526,7 +523,6 @@ int rsa_pkcs1_encrypt( rsa_context *ctx, return( POLARSSL_ERR_RSA_INVALID_PADDING ); } } -#endif #if defined(POLARSSL_PKCS1_V21) /* @@ -713,7 +709,6 @@ int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx, return( 0 ); } -#if 0 /* * Do an RSA operation, then remove the message padding */ @@ -739,7 +734,6 @@ int rsa_pkcs1_decrypt( rsa_context *ctx, return( POLARSSL_ERR_RSA_INVALID_PADDING ); } } -#endif #if defined(POLARSSL_PKCS1_V21) /* @@ -982,7 +976,6 @@ int rsa_rsassa_pkcs1_v15_sign( rsa_context *ctx, : rsa_private( ctx, sig, sig ) ); } -#if 0 /* * Do an RSA operation to sign the message digest */ @@ -995,6 +988,8 @@ int rsa_pkcs1_sign( rsa_context *ctx, const unsigned char *hash, unsigned char *sig ) { + (void)f_rng; + (void)p_rng; switch( ctx->padding ) { case RSA_PKCS_V15: @@ -1011,7 +1006,6 @@ int rsa_pkcs1_sign( rsa_context *ctx, return( POLARSSL_ERR_RSA_INVALID_PADDING ); } } -#endif #if defined(POLARSSL_PKCS1_V21) /* @@ -1253,7 +1247,6 @@ int rsa_rsassa_pkcs1_v15_verify( rsa_context *ctx, return( POLARSSL_ERR_RSA_INVALID_PADDING ); } -#if 0 /* * Do an RSA operation and check the message digest */ @@ -1280,7 +1273,6 @@ int rsa_pkcs1_verify( rsa_context *ctx, return( POLARSSL_ERR_RSA_INVALID_PADDING ); } } -#endif /* * Free the components of an RSA key