mirror of https://github.com/wolfSSL/wolfssh.git
commit
ad80b4b613
|
@ -3424,30 +3424,46 @@ int SendKexDhReply(WOLFSSH* ssh)
|
||||||
wc_FreeDhKey(&dhKey);
|
wc_FreeDhKey(&dhKey);
|
||||||
|
|
||||||
/* Hash in the server's DH f-value. */
|
/* Hash in the server's DH f-value. */
|
||||||
c32toa(fSz + fPad, scratchLen);
|
if (ret == 0) {
|
||||||
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, LENGTH_SZ);
|
c32toa(fSz + fPad, scratchLen);
|
||||||
if (fPad) {
|
ret = wc_ShaUpdate(&ssh->handshake->hash,
|
||||||
scratchLen[0] = 0;
|
scratchLen, LENGTH_SZ);
|
||||||
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1);
|
|
||||||
}
|
}
|
||||||
wc_ShaUpdate(&ssh->handshake->hash, f, fSz);
|
if (ret == 0) {
|
||||||
|
if (fPad) {
|
||||||
|
scratchLen[0] = 0;
|
||||||
|
ret = wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_ShaUpdate(&ssh->handshake->hash, f, fSz);
|
||||||
|
|
||||||
/* Hash in the shared secret k. */
|
/* Hash in the shared secret k. */
|
||||||
c32toa(ssh->kSz + kPad, scratchLen);
|
if (ret == 0) {
|
||||||
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, LENGTH_SZ);
|
c32toa(ssh->kSz + kPad, scratchLen);
|
||||||
if (kPad) {
|
ret = wc_ShaUpdate(&ssh->handshake->hash,
|
||||||
scratchLen[0] = 0;
|
scratchLen, LENGTH_SZ);
|
||||||
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1);
|
|
||||||
}
|
}
|
||||||
wc_ShaUpdate(&ssh->handshake->hash, ssh->k, ssh->kSz);
|
if (ret == 0) {
|
||||||
|
if (kPad) {
|
||||||
|
scratchLen[0] = 0;
|
||||||
|
ret = wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_ShaUpdate(&ssh->handshake->hash, ssh->k, ssh->kSz);
|
||||||
|
|
||||||
/* Save the handshake hash value h, and session ID. */
|
/* Save the handshake hash value h, and session ID. */
|
||||||
wc_ShaFinal(&ssh->handshake->hash, ssh->h);
|
if (ret == 0)
|
||||||
ssh->hSz = SHA_DIGEST_SIZE;
|
ret = wc_ShaFinal(&ssh->handshake->hash, ssh->h);
|
||||||
if (ssh->sessionIdSz == 0) {
|
if (ret == 0) {
|
||||||
WMEMCPY(ssh->sessionId, ssh->h, ssh->hSz);
|
ssh->hSz = SHA_DIGEST_SIZE;
|
||||||
ssh->sessionIdSz = ssh->hSz;
|
if (ssh->sessionIdSz == 0) {
|
||||||
|
WMEMCPY(ssh->sessionId, ssh->h, ssh->hSz);
|
||||||
|
ssh->sessionIdSz = ssh->hSz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != WS_SUCCESS)
|
if (ret != WS_SUCCESS)
|
||||||
ret = WS_CRYPTO_FAILED;
|
ret = WS_CRYPTO_FAILED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue