Skip to content

Commit

Permalink
FIXED_SSH_COOKIE option
Browse files Browse the repository at this point in the history
  • Loading branch information
gojimmypi committed Jan 23, 2024
1 parent 0e65ef3 commit d303bc3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ DLL Release
/ide/Espressif/**/dependencies.lock


/ide/Espressif/component-manager
/wolfssl_bin
/wolfssl_install
28 changes: 26 additions & 2 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,11 +1799,23 @@ int GenerateKey(byte hashId, byte keyId,

if (ret == WS_SUCCESS) {
if (blocks == 0) {
#ifdef WOLFSSL_ESPIDF
ESP_LOGI("sha_int", "remainder = %d", remainder);
#else
#endif
if (remainder > 0) {
byte lastBlock[WC_MAX_DIGEST_SIZE];
ret = wc_HashFinal(&hash, enmhashId, lastBlock);
ret = wc_HashFinal(&hash, enmhashId, lastBlock); /* lastBlock gets final hash */
if (ret == WS_SUCCESS)
WMEMCPY(key, lastBlock, remainder);
WMEMCPY(key, lastBlock, remainder); /* move remainder bytes (0x10) to key */
}
else {
#ifdef WOLFSSL_ESPIDF
ESP_LOGW("sha_int", "GenerateKey() remainder = 0");
#else
printf("GenerateKey() remainder = 0\n");
#endif

}
}
else {
Expand Down Expand Up @@ -9071,7 +9083,19 @@ int SendKexInit(WOLFSSH* ssh)

output[idx++] = MSGID_KEXINIT;

#define FIXED_SSH_COOKIE
#ifdef FIXED_SSH_COOKIE
ret = wc_RNG_GenerateBlock(ssh->rng, output + idx, COOKIE_SZ);
// memset(ssh->rng, 0, COOKIE_SZ);
memset(output + idx, 0, COOKIE_SZ);
#ifdef WOLFSSL_ESPIDF
ESP_LOGE("ssh", "ssh->rng cookie zeroed!");
#else
printf("ssh->rng cookie zeroed!");
#endif
#else
ret = wc_RNG_GenerateBlock(ssh->rng, output + idx, COOKIE_SZ);
#endif
}

if (ret == WS_SUCCESS) {
Expand Down

0 comments on commit d303bc3

Please sign in to comment.