From 86b558300bac533ff43cf499694b2adf4b346d65 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 23 May 2019 13:02:52 -0700 Subject: [PATCH] Sniffer Logging 1. When collecting the key size to log it, use the constant WOLFSSL_BIT_SIZE for the bytes->bits multiply. 2. When converting the size of the ECC key, break the steps out more explicitly. Also update the comment to be more accurate. --- src/sniffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sniffer.c b/src/sniffer.c index ca33f19df..db78c2c9e 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -1605,7 +1605,7 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes, } if (ret == 0) { - session->keySz = length * 8; + session->keySz = length * WOLFSSL_BIT_SIZE; /* length is the key size in bytes */ session->sslServer->arrays->preMasterSz = SECRET_LEN; @@ -1674,9 +1674,10 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes, } if (ret == 0) { - session->keySz = (length - 1) * 4; - /* The length is the key size in bytes, times 2 for the (x,y) - * coordinates, plus 1 for the type. */ + session->keySz = ((length - 1) / 2) * WOLFSSL_BIT_SIZE; + /* Length is in bytes. Subtract 1 for the ECC key type. Divide + * by two as the key is in (x,y) coordinates, where x and y are + * the same size, the key size. Convert from bytes to bits. */ session->sslServer->arrays->preMasterSz = ENCRYPT_LEN; do {