mirror of
https://salsa.debian.org/gnuk-team/gnuk/gnuk.git
synced 2024-09-20 02:40:08 +00:00
polarssl: use a bigger sliding window when possible
This commit is contained in:
parent
56fb5002bf
commit
43009f39e8
@ -1666,11 +1666,18 @@ static void mpi_montsqr( size_t n, const t_uint *np, t_uint mm, t_uint *d )
|
|||||||
/*
|
/*
|
||||||
* Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
|
* Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
|
||||||
*/
|
*/
|
||||||
|
#if MEMORY_SIZE >= 32
|
||||||
|
#define MAX_WSIZE 6
|
||||||
|
#elif MEMORY_SIZE >= 24
|
||||||
|
#define MAX_WSIZE 5
|
||||||
|
#else
|
||||||
|
#define MAX_WSIZE 4
|
||||||
|
#endif
|
||||||
int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
|
int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
size_t i = mpi_msb( E );
|
size_t i = mpi_msb( E );
|
||||||
size_t wsize = ( i > 1024 ) ? 4 : /* Because of not enough memory. */
|
size_t wsize = ( i > 1024 ) ? MAX_WSIZE :
|
||||||
( i > 671 ) ? 6 : ( i > 239 ) ? 5 :
|
( i > 671 ) ? 6 : ( i > 239 ) ? 5 :
|
||||||
( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1;
|
( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1;
|
||||||
size_t wbits, one = 1;
|
size_t wbits, one = 1;
|
||||||
|
4
src/configure
vendored
4
src/configure
vendored
@ -207,6 +207,7 @@ if test "$target" = "GNU_LINUX"; then
|
|||||||
cross=""
|
cross=""
|
||||||
mcu="none"
|
mcu="none"
|
||||||
def_emulation="-DGNU_LINUX_EMULATION"
|
def_emulation="-DGNU_LINUX_EMULATION"
|
||||||
|
def_memory_size="-DMEMORY_SIZE=1024"
|
||||||
enable_hexoutput=""
|
enable_hexoutput=""
|
||||||
libs="-lpthread"
|
libs="-lpthread"
|
||||||
else
|
else
|
||||||
@ -216,6 +217,7 @@ else
|
|||||||
cross="arm-none-eabi-"
|
cross="arm-none-eabi-"
|
||||||
mcu="cortex-m3"
|
mcu="cortex-m3"
|
||||||
def_emulation=""
|
def_emulation=""
|
||||||
|
def_memory_size="-DMEMORY_SIZE=$MEMORY_SIZE"
|
||||||
enable_hexoutput=yes
|
enable_hexoutput=yes
|
||||||
libs=""
|
libs=""
|
||||||
fi
|
fi
|
||||||
@ -410,7 +412,7 @@ fi
|
|||||||
echo "EMULATION=$emulation";
|
echo "EMULATION=$emulation";
|
||||||
echo "CROSS=$cross";
|
echo "CROSS=$cross";
|
||||||
echo "MCU=$mcu";
|
echo "MCU=$mcu";
|
||||||
echo "DEFS=$use_sys3 $flash_override $def_emulation";
|
echo "DEFS=$use_sys3 $flash_override $def_emulation $def_memory_size";
|
||||||
echo "LDSCRIPT=$ldscript";
|
echo "LDSCRIPT=$ldscript";
|
||||||
echo "LIBS=$libs";
|
echo "LIBS=$libs";
|
||||||
echo "$DEBUG_MAKE_OPTION";
|
echo "$DEBUG_MAKE_OPTION";
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
#ifdef GNU_LINUX_EMULATION
|
#ifdef GNU_LINUX_EMULATION
|
||||||
#define SIZE_1 4096
|
#define SIZE_1 4096
|
||||||
#define SIZE_2 4096
|
#define SIZE_2 4096
|
||||||
#define SIZE_3 (4 * 4096)
|
#define SIZE_3 (5 * 4096)
|
||||||
#else
|
#else
|
||||||
#define SIZE_0 0x0100 /* Main */
|
#define SIZE_0 0x0100 /* Main */
|
||||||
#define SIZE_1 0x01a0 /* CCID */
|
#define SIZE_1 0x01a0 /* CCID */
|
||||||
#define SIZE_2 0x0180 /* RNG */
|
#define SIZE_2 0x0180 /* RNG */
|
||||||
|
#if MEMORY_SIZE >= 32
|
||||||
|
#define SIZE_3 0x4640 /* openpgp-card */
|
||||||
|
#elif MEMORY_SIZE >= 24
|
||||||
|
#define SIZE_3 0x2640 /* openpgp-card */
|
||||||
|
#else
|
||||||
#define SIZE_3 0x1640 /* openpgp-card */
|
#define SIZE_3 0x1640 /* openpgp-card */
|
||||||
|
#endif
|
||||||
#define SIZE_4 0x0000 /* --- */
|
#define SIZE_4 0x0000 /* --- */
|
||||||
#define SIZE_5 0x0200 /* msc */
|
#define SIZE_5 0x0200 /* msc */
|
||||||
#define SIZE_6 0x00c0 /* timer (cir) */
|
#define SIZE_6 0x00c0 /* timer (cir) */
|
||||||
|
Loading…
Reference in New Issue
Block a user