| 72 |
#define CMP(a,b) memcmp(a, b, SSH_BLOCKSIZE) |
#define CMP(a,b) memcmp(a, b, SSH_BLOCKSIZE) |
| 73 |
|
|
| 74 |
|
|
| 75 |
static char FAR *get_cipher_name(int cipher); |
static char *get_cipher_name(int cipher); |
| 76 |
|
|
| 77 |
static void crc_update(uint32 FAR * a, uint32 b) |
static void crc_update(uint32 *a, uint32 b) |
| 78 |
{ |
{ |
| 79 |
b ^= *a; |
b ^= *a; |
| 80 |
*a = do_crc((unsigned char FAR *) &b, sizeof(b)); |
*a = do_crc((unsigned char *) &b, sizeof(b)); |
| 81 |
} |
} |
| 82 |
|
|
| 83 |
/* check_crc |
/* check_crc |
| 84 |
detects if a block is used in a particular pattern |
detects if a block is used in a particular pattern |
| 85 |
*/ |
*/ |
| 86 |
|
|
| 87 |
static int check_crc(unsigned char FAR * S, unsigned char FAR * buf, |
static int check_crc(unsigned char *S, unsigned char *buf, |
| 88 |
uint32 len, unsigned char FAR * IV) |
uint32 len, unsigned char *IV) |
| 89 |
{ |
{ |
| 90 |
uint32 crc; |
uint32 crc; |
| 91 |
unsigned char FAR *c; |
unsigned char *c; |
| 92 |
|
|
| 93 |
crc = 0; |
crc = 0; |
| 94 |
if (IV && !CMP(S, IV)) { |
if (IV && !CMP(S, IV)) { |
| 113 |
detect_attack |
detect_attack |
| 114 |
Detects a crc32 compensation attack on a packet |
Detects a crc32 compensation attack on a packet |
| 115 |
*/ |
*/ |
| 116 |
static int detect_attack(CRYPTDetectAttack FAR * statics, |
static int detect_attack(CRYPTDetectAttack *statics, |
| 117 |
unsigned char FAR * buf, uint32 len, |
unsigned char *buf, uint32 len, |
| 118 |
unsigned char *FAR IV) |
unsigned char *IV) |
| 119 |
{ |
{ |
| 120 |
uint32 FAR *h = statics->h; |
uint32 *h = statics->h; |
| 121 |
uint32 n = statics->n; |
uint32 n = statics->n; |
| 122 |
uint32 i, j; |
uint32 i, j; |
| 123 |
uint32 l; |
uint32 l; |
| 124 |
unsigned char FAR *c; |
unsigned char *c; |
| 125 |
unsigned char FAR *d; |
unsigned char *d; |
| 126 |
|
|
| 127 |
for (l = n; l < HASH_FACTOR(len / SSH_BLOCKSIZE); l = l << 2) { |
for (l = n; l < HASH_FACTOR(len / SSH_BLOCKSIZE); l = l << 2) { |
| 128 |
} |
} |
| 129 |
|
|
| 130 |
if (h == NULL) { |
if (h == NULL) { |
| 131 |
n = l; |
n = l; |
| 132 |
h = (uint32 FAR *) malloc(n * HASH_ENTRYSIZE); |
h = (uint32 *) malloc(n * HASH_ENTRYSIZE); |
| 133 |
} else { |
} else { |
| 134 |
if (l > n) { |
if (l > n) { |
| 135 |
n = l; |
n = l; |
| 136 |
h = (uint32 FAR *) realloc(h, n * HASH_ENTRYSIZE); |
h = (uint32 *) realloc(h, n * HASH_ENTRYSIZE); |
| 137 |
} |
} |
| 138 |
} |
} |
| 139 |
|
|
| 188 |
return DEATTACK_OK; |
return DEATTACK_OK; |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
BOOL CRYPT_detect_attack(PTInstVar pvar, unsigned char FAR * buf, |
BOOL CRYPT_detect_attack(PTInstVar pvar, unsigned char *buf, |
| 192 |
int bytes) |
int bytes) |
| 193 |
{ |
{ |
| 194 |
if (SSHv1(pvar)) { |
if (SSHv1(pvar)) { |
| 204 |
} |
} |
| 205 |
} |
} |
| 206 |
|
|
| 207 |
static void no_encrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void no_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 208 |
{ |
{ |
| 209 |
} |
} |
| 210 |
|
|
| 211 |
static void crypt_SSH2_encrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void crypt_SSH2_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 212 |
{ |
{ |
| 213 |
unsigned char *newbuf; |
unsigned char *newbuf; |
| 214 |
int block_size = pvar->ssh2_keys[MODE_OUT].enc.block_size; |
int block_size = pvar->ssh2_keys[MODE_OUT].enc.block_size; |
| 242 |
free(newbuf); |
free(newbuf); |
| 243 |
} |
} |
| 244 |
|
|
| 245 |
static void crypt_SSH2_decrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void crypt_SSH2_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 246 |
{ |
{ |
| 247 |
unsigned char *newbuf; |
unsigned char *newbuf; |
| 248 |
int block_size = pvar->ssh2_keys[MODE_IN].enc.block_size; |
int block_size = pvar->ssh2_keys[MODE_IN].enc.block_size; |
| 276 |
free(newbuf); |
free(newbuf); |
| 277 |
} |
} |
| 278 |
|
|
| 279 |
static void c3DES_encrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void c3DES_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 280 |
{ |
{ |
| 281 |
Cipher3DESState FAR *encryptstate = &pvar->crypt_state.enc.c3DES; |
Cipher3DESState *encryptstate = &pvar->crypt_state.enc.c3DES; |
| 282 |
|
|
| 283 |
DES_ncbc_encrypt(buf, buf, bytes, |
DES_ncbc_encrypt(buf, buf, bytes, |
| 284 |
&encryptstate->k1, &encryptstate->ivec1, DES_ENCRYPT); |
&encryptstate->k1, &encryptstate->ivec1, DES_ENCRYPT); |
| 288 |
&encryptstate->k3, &encryptstate->ivec3, DES_ENCRYPT); |
&encryptstate->k3, &encryptstate->ivec3, DES_ENCRYPT); |
| 289 |
} |
} |
| 290 |
|
|
| 291 |
static void c3DES_decrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void c3DES_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 292 |
{ |
{ |
| 293 |
Cipher3DESState FAR *decryptstate = &pvar->crypt_state.dec.c3DES; |
Cipher3DESState *decryptstate = &pvar->crypt_state.dec.c3DES; |
| 294 |
|
|
| 295 |
DES_ncbc_encrypt(buf, buf, bytes, |
DES_ncbc_encrypt(buf, buf, bytes, |
| 296 |
&decryptstate->k3, &decryptstate->ivec3, DES_DECRYPT); |
&decryptstate->k3, &decryptstate->ivec3, DES_DECRYPT); |
| 300 |
&decryptstate->k1, &decryptstate->ivec1, DES_DECRYPT); |
&decryptstate->k1, &decryptstate->ivec1, DES_DECRYPT); |
| 301 |
} |
} |
| 302 |
|
|
| 303 |
static void cDES_encrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void cDES_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 304 |
{ |
{ |
| 305 |
CipherDESState FAR *encryptstate = &pvar->crypt_state.enc.cDES; |
CipherDESState *encryptstate = &pvar->crypt_state.enc.cDES; |
| 306 |
|
|
| 307 |
DES_ncbc_encrypt(buf, buf, bytes, |
DES_ncbc_encrypt(buf, buf, bytes, |
| 308 |
&encryptstate->k, &encryptstate->ivec, DES_ENCRYPT); |
&encryptstate->k, &encryptstate->ivec, DES_ENCRYPT); |
| 309 |
} |
} |
| 310 |
|
|
| 311 |
static void cDES_decrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void cDES_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 312 |
{ |
{ |
| 313 |
CipherDESState FAR *decryptstate = &pvar->crypt_state.dec.cDES; |
CipherDESState *decryptstate = &pvar->crypt_state.dec.cDES; |
| 314 |
|
|
| 315 |
DES_ncbc_encrypt(buf, buf, bytes, |
DES_ncbc_encrypt(buf, buf, bytes, |
| 316 |
&decryptstate->k, &decryptstate->ivec, DES_DECRYPT); |
&decryptstate->k, &decryptstate->ivec, DES_DECRYPT); |
| 317 |
} |
} |
| 318 |
|
|
| 319 |
static void flip_endianness(unsigned char FAR * cbuf, int bytes) |
static void flip_endianness(unsigned char *cbuf, int bytes) |
| 320 |
{ |
{ |
| 321 |
uint32 FAR *buf = (uint32 FAR *) cbuf; |
uint32 *buf = (uint32 *) cbuf; |
| 322 |
int count = bytes / 4; |
int count = bytes / 4; |
| 323 |
|
|
| 324 |
while (count > 0) { |
while (count > 0) { |
| 331 |
} |
} |
| 332 |
} |
} |
| 333 |
|
|
| 334 |
static void cBlowfish_encrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void cBlowfish_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 335 |
{ |
{ |
| 336 |
CipherBlowfishState FAR *encryptstate = |
CipherBlowfishState *encryptstate = |
| 337 |
&pvar->crypt_state.enc.cBlowfish; |
&pvar->crypt_state.enc.cBlowfish; |
| 338 |
|
|
| 339 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 342 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 343 |
} |
} |
| 344 |
|
|
| 345 |
static void cBlowfish_decrypt(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
static void cBlowfish_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
| 346 |
{ |
{ |
| 347 |
CipherBlowfishState FAR *decryptstate = |
CipherBlowfishState *decryptstate = |
| 348 |
&pvar->crypt_state.dec.cBlowfish; |
&pvar->crypt_state.dec.cBlowfish; |
| 349 |
|
|
| 350 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 353 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 354 |
} |
} |
| 355 |
|
|
| 356 |
void CRYPT_set_random_data(PTInstVar pvar, unsigned char FAR * buf, int bytes) |
void CRYPT_set_random_data(PTInstVar pvar, unsigned char *buf, int bytes) |
| 357 |
{ |
{ |
| 358 |
RAND_bytes(buf, bytes); |
RAND_bytes(buf, bytes); |
| 359 |
} |
} |
| 365 |
//RAND_screen(); |
//RAND_screen(); |
| 366 |
} |
} |
| 367 |
|
|
| 368 |
static BIGNUM FAR *get_bignum(unsigned char FAR * bytes) |
static BIGNUM *get_bignum(unsigned char *bytes) |
| 369 |
{ |
{ |
| 370 |
int bits = get_ushort16_MSBfirst(bytes); |
int bits = get_ushort16_MSBfirst(bytes); |
| 371 |
|
|
| 373 |
} |
} |
| 374 |
|
|
| 375 |
// make_key()を fingerprint 生成でも利用するので、staticを削除。(2006.3.27 yutaka) |
// make_key()を fingerprint 生成でも利用するので、staticを削除。(2006.3.27 yutaka) |
| 376 |
RSA FAR *make_key(PTInstVar pvar, |
RSA *make_key(PTInstVar pvar, |
| 377 |
int bits, unsigned char FAR * exp, |
int bits, unsigned char *exp, |
| 378 |
unsigned char FAR * mod) |
unsigned char *mod) |
| 379 |
{ |
{ |
| 380 |
RSA FAR *key = RSA_new(); |
RSA *key = RSA_new(); |
| 381 |
|
|
| 382 |
if (key != NULL) { |
if (key != NULL) { |
| 383 |
key->e = get_bignum(exp); |
key->e = get_bignum(exp); |
| 405 |
} |
} |
| 406 |
} |
} |
| 407 |
|
|
| 408 |
void CRYPT_set_server_cookie(PTInstVar pvar, unsigned char FAR * cookie) |
void CRYPT_set_server_cookie(PTInstVar pvar, unsigned char *cookie) |
| 409 |
{ |
{ |
| 410 |
if (SSHv1(pvar)) { |
if (SSHv1(pvar)) { |
| 411 |
memcpy(pvar->crypt_state.server_cookie, cookie, SSH_COOKIE_LENGTH); |
memcpy(pvar->crypt_state.server_cookie, cookie, SSH_COOKIE_LENGTH); |
| 415 |
} |
} |
| 416 |
} |
} |
| 417 |
|
|
| 418 |
void CRYPT_set_client_cookie(PTInstVar pvar, unsigned char FAR * cookie) |
void CRYPT_set_client_cookie(PTInstVar pvar, unsigned char *cookie) |
| 419 |
{ |
{ |
| 420 |
if (SSHv2(pvar)) { |
if (SSHv2(pvar)) { |
| 421 |
memcpy(pvar->crypt_state.client_cookie, cookie, |
memcpy(pvar->crypt_state.client_cookie, cookie, |
| 424 |
} |
} |
| 425 |
|
|
| 426 |
BOOL CRYPT_set_server_RSA_key(PTInstVar pvar, |
BOOL CRYPT_set_server_RSA_key(PTInstVar pvar, |
| 427 |
int bits, unsigned char FAR * exp, |
int bits, unsigned char *exp, |
| 428 |
unsigned char FAR * mod) |
unsigned char *mod) |
| 429 |
{ |
{ |
| 430 |
pvar->crypt_state.server_key.RSA_key = make_key(pvar, bits, exp, mod); |
pvar->crypt_state.server_key.RSA_key = make_key(pvar, bits, exp, mod); |
| 431 |
|
|
| 433 |
} |
} |
| 434 |
|
|
| 435 |
BOOL CRYPT_set_host_RSA_key(PTInstVar pvar, |
BOOL CRYPT_set_host_RSA_key(PTInstVar pvar, |
| 436 |
int bits, unsigned char FAR * exp, |
int bits, unsigned char *exp, |
| 437 |
unsigned char FAR * mod) |
unsigned char *mod) |
| 438 |
{ |
{ |
| 439 |
pvar->crypt_state.host_key.RSA_key = make_key(pvar, bits, exp, mod); |
pvar->crypt_state.host_key.RSA_key = make_key(pvar, bits, exp, mod); |
| 440 |
|
|
| 544 |
// ※本関数は SSH2 でのみ使用される。 |
// ※本関数は SSH2 でのみ使用される。 |
| 545 |
// (2004.12.17 yutaka) |
// (2004.12.17 yutaka) |
| 546 |
BOOL CRYPT_verify_receiver_MAC(PTInstVar pvar, uint32 sequence_number, |
BOOL CRYPT_verify_receiver_MAC(PTInstVar pvar, uint32 sequence_number, |
| 547 |
char FAR * data, int len, char FAR * MAC) |
char *data, int len, char *MAC) |
| 548 |
{ |
{ |
| 549 |
HMAC_CTX c; |
HMAC_CTX c; |
| 550 |
unsigned char m[EVP_MAX_MD_SIZE]; |
unsigned char m[EVP_MAX_MD_SIZE]; |
| 605 |
|
|
| 606 |
// for SSH2 |
// for SSH2 |
| 607 |
BOOL CRYPT_build_sender_MAC(PTInstVar pvar, uint32 sequence_number, |
BOOL CRYPT_build_sender_MAC(PTInstVar pvar, uint32 sequence_number, |
| 608 |
char FAR * data, int len, char FAR * MAC) |
char *data, int len, char *MAC) |
| 609 |
{ |
{ |
| 610 |
HMAC_CTX c; |
HMAC_CTX c; |
| 611 |
static u_char m[EVP_MAX_MD_SIZE]; |
static u_char m[EVP_MAX_MD_SIZE]; |
| 697 |
} |
} |
| 698 |
|
|
| 699 |
int CRYPT_choose_session_key(PTInstVar pvar, |
int CRYPT_choose_session_key(PTInstVar pvar, |
| 700 |
unsigned char FAR * encrypted_key_buf) |
unsigned char *encrypted_key_buf) |
| 701 |
{ |
{ |
| 702 |
int server_key_bits = |
int server_key_bits = |
| 703 |
BN_num_bits(pvar->crypt_state.server_key.RSA_key->n); |
BN_num_bits(pvar->crypt_state.server_key.RSA_key->n); |
| 724 |
/* following Goldberg's code, I'm using MD5(servkey->n || hostkey->n || cookie) |
/* following Goldberg's code, I'm using MD5(servkey->n || hostkey->n || cookie) |
| 725 |
for the session ID, rather than the one specified in the RFC */ |
for the session ID, rather than the one specified in the RFC */ |
| 726 |
int session_buf_len = server_key_bytes + host_key_bytes + 8; |
int session_buf_len = server_key_bytes + host_key_bytes + 8; |
| 727 |
char FAR *session_buf = (char FAR *) malloc(session_buf_len); |
char *session_buf = (char *) malloc(session_buf_len); |
| 728 |
char session_id[16]; |
char session_id[16]; |
| 729 |
int i; |
int i; |
| 730 |
|
|
| 795 |
} |
} |
| 796 |
|
|
| 797 |
int CRYPT_generate_RSA_challenge_response(PTInstVar pvar, |
int CRYPT_generate_RSA_challenge_response(PTInstVar pvar, |
| 798 |
unsigned char FAR * challenge, |
unsigned char *challenge, |
| 799 |
int challenge_len, |
int challenge_len, |
| 800 |
unsigned char FAR * response) |
unsigned char *response) |
| 801 |
{ |
{ |
| 802 |
int server_key_bits = |
int server_key_bits = |
| 803 |
BN_num_bits(pvar->crypt_state.server_key.RSA_key->n); |
BN_num_bits(pvar->crypt_state.server_key.RSA_key->n); |
| 805 |
int server_key_bytes = (server_key_bits + 7) / 8; |
int server_key_bytes = (server_key_bits + 7) / 8; |
| 806 |
int host_key_bytes = (host_key_bits + 7) / 8; |
int host_key_bytes = (host_key_bits + 7) / 8; |
| 807 |
int session_buf_len = server_key_bytes + host_key_bytes + 8; |
int session_buf_len = server_key_bytes + host_key_bytes + 8; |
| 808 |
char FAR *session_buf = (char FAR *) malloc(session_buf_len); |
char *session_buf = (char *) malloc(session_buf_len); |
| 809 |
char decrypted_challenge[48]; |
char decrypted_challenge[48]; |
| 810 |
int decrypted_challenge_len; |
int decrypted_challenge_len; |
| 811 |
|
|
| 843 |
return 1; |
return 1; |
| 844 |
} |
} |
| 845 |
|
|
| 846 |
static void c3DES_init(char FAR * session_key, Cipher3DESState FAR * state) |
static void c3DES_init(char *session_key, Cipher3DESState *state) |
| 847 |
{ |
{ |
| 848 |
DES_set_key((const_DES_cblock FAR *) session_key, &state->k1); |
DES_set_key((const_DES_cblock *) session_key, &state->k1); |
| 849 |
DES_set_key((const_DES_cblock FAR *) (session_key + 8), &state->k2); |
DES_set_key((const_DES_cblock *) (session_key + 8), &state->k2); |
| 850 |
DES_set_key((const_DES_cblock FAR *) (session_key + 16), &state->k3); |
DES_set_key((const_DES_cblock *) (session_key + 16), &state->k3); |
| 851 |
memset(state->ivec1, 0, 8); |
memset(state->ivec1, 0, 8); |
| 852 |
memset(state->ivec2, 0, 8); |
memset(state->ivec2, 0, 8); |
| 853 |
memset(state->ivec3, 0, 8); |
memset(state->ivec3, 0, 8); |
| 854 |
} |
} |
| 855 |
|
|
| 856 |
static void cDES_init(char FAR * session_key, CipherDESState FAR * state) |
static void cDES_init(char *session_key, CipherDESState *state) |
| 857 |
{ |
{ |
| 858 |
DES_set_key((const_DES_cblock FAR *) session_key, &state->k); |
DES_set_key((const_DES_cblock *) session_key, &state->k); |
| 859 |
memset(state->ivec, 0, 8); |
memset(state->ivec, 0, 8); |
| 860 |
} |
} |
| 861 |
|
|
| 862 |
static void cBlowfish_init(char FAR * session_key, |
static void cBlowfish_init(char *session_key, |
| 863 |
CipherBlowfishState FAR * state) |
CipherBlowfishState *state) |
| 864 |
{ |
{ |
| 865 |
BF_set_key(&state->k, 32, session_key); |
BF_set_key(&state->k, 32, session_key); |
| 866 |
memset(state->ivec, 0, 8); |
memset(state->ivec, 0, 8); |
| 940 |
BOOL CRYPT_start_encryption(PTInstVar pvar, int sender_flag, int receiver_flag) |
BOOL CRYPT_start_encryption(PTInstVar pvar, int sender_flag, int receiver_flag) |
| 941 |
{ |
{ |
| 942 |
struct Enc *enc; |
struct Enc *enc; |
| 943 |
char FAR *encryption_key = pvar->crypt_state.sender_cipher_key; |
char *encryption_key = pvar->crypt_state.sender_cipher_key; |
| 944 |
char FAR *decryption_key = pvar->crypt_state.receiver_cipher_key; |
char *decryption_key = pvar->crypt_state.receiver_cipher_key; |
| 945 |
int cipher; |
int cipher; |
| 946 |
BOOL isOK = TRUE; |
BOOL isOK = TRUE; |
| 947 |
|
|
| 1061 |
HASH_MINSIZE / HASH_ENTRYSIZE; |
HASH_MINSIZE / HASH_ENTRYSIZE; |
| 1062 |
} |
} |
| 1063 |
|
|
| 1064 |
static char FAR *get_cipher_name(int cipher) |
static char *get_cipher_name(int cipher) |
| 1065 |
{ |
{ |
| 1066 |
switch (cipher) { |
switch (cipher) { |
| 1067 |
case SSH_CIPHER_NONE: |
case SSH_CIPHER_NONE: |
| 1122 |
} |
} |
| 1123 |
} |
} |
| 1124 |
|
|
| 1125 |
void CRYPT_get_cipher_info(PTInstVar pvar, char FAR * dest, int len) |
void CRYPT_get_cipher_info(PTInstVar pvar, char *dest, int len) |
| 1126 |
{ |
{ |
| 1127 |
UTIL_get_lang_msg("DLG_ABOUT_CIPHER_INFO", pvar, |
UTIL_get_lang_msg("DLG_ABOUT_CIPHER_INFO", pvar, |
| 1128 |
"%s to server, %s from server"); |
"%s to server, %s from server"); |
| 1131 |
get_cipher_name(pvar->crypt_state.receiver_cipher)); |
get_cipher_name(pvar->crypt_state.receiver_cipher)); |
| 1132 |
} |
} |
| 1133 |
|
|
| 1134 |
void CRYPT_get_server_key_info(PTInstVar pvar, char FAR * dest, int len) |
void CRYPT_get_server_key_info(PTInstVar pvar, char *dest, int len) |
| 1135 |
{ |
{ |
| 1136 |
if (SSHv1(pvar)) { |
if (SSHv1(pvar)) { |
| 1137 |
if (pvar->crypt_state.server_key.RSA_key == NULL |
if (pvar->crypt_state.server_key.RSA_key == NULL |
| 1191 |
SecureZeroMemory(&pvar->crypt_state.dec, sizeof(pvar->crypt_state.dec)); |
SecureZeroMemory(&pvar->crypt_state.dec, sizeof(pvar->crypt_state.dec)); |
| 1192 |
} |
} |
| 1193 |
|
|
| 1194 |
int CRYPT_passphrase_decrypt(int cipher, char FAR * passphrase, |
int CRYPT_passphrase_decrypt(int cipher, char *passphrase, |
| 1195 |
char FAR * buf, int bytes) |
char *buf, int bytes) |
| 1196 |
{ |
{ |
| 1197 |
unsigned char passphrase_key[16]; |
unsigned char passphrase_key[16]; |
| 1198 |
|
|
| 1202 |
case SSH_CIPHER_3DES:{ |
case SSH_CIPHER_3DES:{ |
| 1203 |
Cipher3DESState state; |
Cipher3DESState state; |
| 1204 |
|
|
| 1205 |
DES_set_key((const_DES_cblock FAR *) passphrase_key, |
DES_set_key((const_DES_cblock *) passphrase_key, |
| 1206 |
&state.k1); |
&state.k1); |
| 1207 |
DES_set_key((const_DES_cblock FAR *) (passphrase_key + 8), |
DES_set_key((const_DES_cblock *) (passphrase_key + 8), |
| 1208 |
&state.k2); |
&state.k2); |
| 1209 |
DES_set_key((const_DES_cblock FAR *) passphrase_key, |
DES_set_key((const_DES_cblock *) passphrase_key, |
| 1210 |
&state.k3); |
&state.k3); |
| 1211 |
memset(state.ivec1, 0, 8); |
memset(state.ivec1, 0, 8); |
| 1212 |
memset(state.ivec2, 0, 8); |
memset(state.ivec2, 0, 8); |