From 6943229f8720fc78ae9f94a9999662a55ba0fc34 Mon Sep 17 00:00:00 2001 From: toddouska Date: Tue, 4 Sep 2012 15:56:52 -0700 Subject: [PATCH] reduce client key exchange stack use in non NTRU mode --- cyassl/internal.h | 8 ++++++++ src/internal.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cyassl/internal.h b/cyassl/internal.h index 1142528db..6bc38919a 100644 --- a/cyassl/internal.h +++ b/cyassl/internal.h @@ -474,6 +474,14 @@ enum Misc { }; +/* don't use extra 3/4k stack space unless need to */ +#ifdef HAVE_NTRU + #define MAX_ENCRYPT_SZ MAX_NTRU_ENCRYPT_SZ +#else + #define MAX_ENCRYPT_SZ ENCRYPT_LEN +#endif + + /* states */ enum states { NULL_STATE = 0, diff --git a/src/internal.c b/src/internal.c index 92041b559..d60257960 100644 --- a/src/internal.c +++ b/src/internal.c @@ -5088,7 +5088,7 @@ int SetCipherList(Suites* s, const char* list) int SendClientKeyExchange(CYASSL* ssl) { - byte encSecret[MAX_NTRU_ENCRYPT_SZ]; + byte encSecret[MAX_ENCRYPT_SZ]; word32 encSz = 0; word32 idx = 0; int ret = 0;