| 191 |
int bytes) |
int bytes) |
| 192 |
{ |
{ |
| 193 |
if (SSHv1(pvar)) { |
if (SSHv1(pvar)) { |
| 194 |
switch (pvar->crypt_state.sender_cipher) { |
if (pvar->crypt_state.sender_cipher == SSH_CIPHER_NONE) { |
|
case SSH_CIPHER_NONE: |
|
| 195 |
return FALSE; |
return FALSE; |
| 196 |
case SSH_CIPHER_IDEA: |
} |
| 197 |
return detect_attack(&pvar->crypt_state.detect_attack_statics, |
else { |
|
buf, bytes, |
|
|
pvar->crypt_state.dec.cIDEA.ivec) == |
|
|
DEATTACK_DETECTED; |
|
|
default: |
|
| 198 |
return detect_attack(&pvar->crypt_state.detect_attack_statics, |
return detect_attack(&pvar->crypt_state.detect_attack_statics, |
| 199 |
buf, bytes, NULL) == DEATTACK_DETECTED; |
buf, bytes, NULL) == DEATTACK_DETECTED; |
| 200 |
} |
} |
| 764 |
&decryptstate->k, &decryptstate->ivec, DES_DECRYPT); |
&decryptstate->k, &decryptstate->ivec, DES_DECRYPT); |
| 765 |
} |
} |
| 766 |
|
|
|
static void cIDEA_encrypt(PTInstVar pvar, unsigned char FAR * buf, |
|
|
int bytes) |
|
|
{ |
|
|
CipherIDEAState FAR *encryptstate = &pvar->crypt_state.enc.cIDEA; |
|
|
int num = 0; |
|
|
|
|
|
idea_cfb64_encrypt(buf, buf, bytes, &encryptstate->k, |
|
|
encryptstate->ivec, &num, IDEA_ENCRYPT); |
|
|
} |
|
|
|
|
|
static void cIDEA_decrypt(PTInstVar pvar, unsigned char FAR * buf, |
|
|
int bytes) |
|
|
{ |
|
|
CipherIDEAState FAR *decryptstate = &pvar->crypt_state.dec.cIDEA; |
|
|
int num = 0; |
|
|
|
|
|
idea_cfb64_encrypt(buf, buf, bytes, &decryptstate->k, |
|
|
decryptstate->ivec, &num, IDEA_DECRYPT); |
|
|
} |
|
|
|
|
| 767 |
static void flip_endianness(unsigned char FAR * cbuf, int bytes) |
static void flip_endianness(unsigned char FAR * cbuf, int bytes) |
| 768 |
{ |
{ |
| 769 |
uint32 FAR *buf = (uint32 FAR *) cbuf; |
uint32 FAR *buf = (uint32 FAR *) cbuf; |
| 803 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 804 |
} |
} |
| 805 |
|
|
|
static void cRC4_encrypt(PTInstVar pvar, unsigned char FAR * buf, |
|
|
int bytes) |
|
|
{ |
|
|
CipherRC4State FAR *encryptstate = &pvar->crypt_state.enc.cRC4; |
|
|
int num = 0; |
|
|
|
|
|
RC4(&encryptstate->k, bytes, buf, buf); |
|
|
} |
|
|
|
|
|
static void cRC4_decrypt(PTInstVar pvar, unsigned char FAR * buf, |
|
|
int bytes) |
|
|
{ |
|
|
CipherRC4State FAR *decryptstate = &pvar->crypt_state.dec.cRC4; |
|
|
int num = 0; |
|
|
|
|
|
RC4(&decryptstate->k, bytes, buf, buf); |
|
|
} |
|
|
|
|
| 806 |
void CRYPT_set_random_data(PTInstVar pvar, unsigned char FAR * buf, |
void CRYPT_set_random_data(PTInstVar pvar, unsigned char FAR * buf, |
| 807 |
int bytes) |
int bytes) |
| 808 |
{ |
{ |
| 1310 |
memset(state->ivec, 0, 8); |
memset(state->ivec, 0, 8); |
| 1311 |
} |
} |
| 1312 |
|
|
|
static void cIDEA_init(char FAR * session_key, CipherIDEAState FAR * state) |
|
|
{ |
|
|
idea_set_encrypt_key(session_key, &state->k); |
|
|
memset(state->ivec, 0, 8); |
|
|
} |
|
|
|
|
| 1313 |
static void cBlowfish_init(char FAR * session_key, |
static void cBlowfish_init(char FAR * session_key, |
| 1314 |
CipherBlowfishState FAR * state) |
CipherBlowfishState FAR * state) |
| 1315 |
{ |
{ |
| 1538 |
pvar->crypt_state.encrypt = c3DES_encrypt; |
pvar->crypt_state.encrypt = c3DES_encrypt; |
| 1539 |
break; |
break; |
| 1540 |
} |
} |
|
case SSH_CIPHER_IDEA:{ |
|
|
cIDEA_init(encryption_key, &pvar->crypt_state.enc.cIDEA); |
|
|
pvar->crypt_state.encrypt = cIDEA_encrypt; |
|
|
break; |
|
|
} |
|
| 1541 |
case SSH_CIPHER_DES:{ |
case SSH_CIPHER_DES:{ |
| 1542 |
cDES_init(encryption_key, &pvar->crypt_state.enc.cDES); |
cDES_init(encryption_key, &pvar->crypt_state.enc.cDES); |
| 1543 |
pvar->crypt_state.encrypt = cDES_encrypt; |
pvar->crypt_state.encrypt = cDES_encrypt; |
| 1544 |
break; |
break; |
| 1545 |
} |
} |
|
case SSH_CIPHER_RC4:{ |
|
|
RC4_set_key(&pvar->crypt_state.enc.cRC4.k, 16, |
|
|
encryption_key + 16); |
|
|
pvar->crypt_state.encrypt = cRC4_encrypt; |
|
|
break; |
|
|
} |
|
| 1546 |
case SSH_CIPHER_BLOWFISH:{ |
case SSH_CIPHER_BLOWFISH:{ |
| 1547 |
cBlowfish_init(encryption_key, |
cBlowfish_init(encryption_key, |
| 1548 |
&pvar->crypt_state.enc.cBlowfish); |
&pvar->crypt_state.enc.cBlowfish); |
| 1699 |
pvar->crypt_state.decrypt = c3DES_decrypt; |
pvar->crypt_state.decrypt = c3DES_decrypt; |
| 1700 |
break; |
break; |
| 1701 |
} |
} |
|
case SSH_CIPHER_IDEA:{ |
|
|
cIDEA_init(decryption_key, &pvar->crypt_state.dec.cIDEA); |
|
|
pvar->crypt_state.decrypt = cIDEA_decrypt; |
|
|
break; |
|
|
} |
|
| 1702 |
case SSH_CIPHER_DES:{ |
case SSH_CIPHER_DES:{ |
| 1703 |
cDES_init(decryption_key, &pvar->crypt_state.dec.cDES); |
cDES_init(decryption_key, &pvar->crypt_state.dec.cDES); |
| 1704 |
pvar->crypt_state.decrypt = cDES_decrypt; |
pvar->crypt_state.decrypt = cDES_decrypt; |
| 1705 |
break; |
break; |
| 1706 |
} |
} |
|
case SSH_CIPHER_RC4:{ |
|
|
RC4_set_key(&pvar->crypt_state.dec.cRC4.k, 16, decryption_key); |
|
|
pvar->crypt_state.decrypt = cRC4_decrypt; |
|
|
break; |
|
|
} |
|
| 1707 |
case SSH_CIPHER_BLOWFISH:{ |
case SSH_CIPHER_BLOWFISH:{ |
| 1708 |
cBlowfish_init(decryption_key, |
cBlowfish_init(decryption_key, |
| 1709 |
&pvar->crypt_state.dec.cBlowfish); |
&pvar->crypt_state.dec.cBlowfish); |
| 1751 |
return "3DES (168 key bits)"; |
return "3DES (168 key bits)"; |
| 1752 |
case SSH_CIPHER_DES: |
case SSH_CIPHER_DES: |
| 1753 |
return "DES (56 key bits)"; |
return "DES (56 key bits)"; |
|
case SSH_CIPHER_IDEA: |
|
|
return "IDEA (128 key bits)"; |
|
|
case SSH_CIPHER_RC4: |
|
|
return "RC4 (128 key bits)"; |
|
| 1754 |
case SSH_CIPHER_BLOWFISH: |
case SSH_CIPHER_BLOWFISH: |
| 1755 |
return "Blowfish (256 key bits)"; |
return "Blowfish (256 key bits)"; |
| 1756 |
|
|
| 1901 |
break; |
break; |
| 1902 |
} |
} |
| 1903 |
|
|
|
case SSH_CIPHER_IDEA:{ |
|
|
CipherIDEAState state; |
|
|
int num = 0; |
|
|
|
|
|
cIDEA_init(passphrase_key, &state); |
|
|
idea_cfb64_encrypt(buf, buf, bytes, &state.k, state.ivec, |
|
|
&num, IDEA_DECRYPT); |
|
|
break; |
|
|
} |
|
|
|
|
| 1904 |
case SSH_CIPHER_DES:{ |
case SSH_CIPHER_DES:{ |
| 1905 |
CipherDESState state; |
CipherDESState state; |
| 1906 |
|
|
| 1910 |
break; |
break; |
| 1911 |
} |
} |
| 1912 |
|
|
|
case SSH_CIPHER_RC4:{ |
|
|
CipherRC4State state; |
|
|
int num = 0; |
|
|
|
|
|
RC4_set_key(&state.k, 16, passphrase_key); |
|
|
RC4(&state.k, bytes, buf, buf); |
|
|
break; |
|
|
} |
|
|
|
|
| 1913 |
case SSH_CIPHER_BLOWFISH:{ |
case SSH_CIPHER_BLOWFISH:{ |
| 1914 |
CipherBlowfishState state; |
CipherBlowfishState state; |
| 1915 |
|
|