Merge pull request #23 from ejohnstown/wc-fix

wolfCrypt Fix
pull/24/head v1.0.0-RC1
toddouska 2016-10-25 12:19:30 -07:00 committed by GitHub
commit ad80b4b613
1 changed files with 33 additions and 17 deletions

View File

@ -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. */
if (ret == 0) {
c32toa(fSz + fPad, scratchLen); c32toa(fSz + fPad, scratchLen);
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, LENGTH_SZ); ret = wc_ShaUpdate(&ssh->handshake->hash,
scratchLen, LENGTH_SZ);
}
if (ret == 0) {
if (fPad) { if (fPad) {
scratchLen[0] = 0; scratchLen[0] = 0;
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1); ret = wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1);
} }
wc_ShaUpdate(&ssh->handshake->hash, f, fSz); }
if (ret == 0)
ret = wc_ShaUpdate(&ssh->handshake->hash, f, fSz);
/* Hash in the shared secret k. */ /* Hash in the shared secret k. */
if (ret == 0) {
c32toa(ssh->kSz + kPad, scratchLen); c32toa(ssh->kSz + kPad, scratchLen);
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, LENGTH_SZ); ret = wc_ShaUpdate(&ssh->handshake->hash,
scratchLen, LENGTH_SZ);
}
if (ret == 0) {
if (kPad) { if (kPad) {
scratchLen[0] = 0; scratchLen[0] = 0;
wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1); ret = wc_ShaUpdate(&ssh->handshake->hash, scratchLen, 1);
} }
wc_ShaUpdate(&ssh->handshake->hash, ssh->k, ssh->kSz); }
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)
ret = wc_ShaFinal(&ssh->handshake->hash, ssh->h);
if (ret == 0) {
ssh->hSz = SHA_DIGEST_SIZE; ssh->hSz = SHA_DIGEST_SIZE;
if (ssh->sessionIdSz == 0) { if (ssh->sessionIdSz == 0) {
WMEMCPY(ssh->sessionId, ssh->h, ssh->hSz); WMEMCPY(ssh->sessionId, ssh->h, ssh->hSz);
ssh->sessionIdSz = ssh->hSz; ssh->sessionIdSz = ssh->hSz;
} }
}
if (ret != WS_SUCCESS) if (ret != WS_SUCCESS)
ret = WS_CRYPTO_FAILED; ret = WS_CRYPTO_FAILED;
} }