version 1.43, 2001/02/04 15:32:23 |
version 1.44, 2001/05/28 22:51:10 |
|
|
void |
void |
des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) |
des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) |
{ |
{ |
|
memset(cc->u.des3.iv1, 0, sizeof(cc->u.des3.iv1)); |
memset(cc->u.des3.iv2, 0, sizeof(cc->u.des3.iv2)); |
memset(cc->u.des3.iv2, 0, sizeof(cc->u.des3.iv2)); |
memset(cc->u.des3.iv3, 0, sizeof(cc->u.des3.iv3)); |
memset(cc->u.des3.iv3, 0, sizeof(cc->u.des3.iv3)); |
if (iv == NULL) |
if (iv == NULL) |
|
|
des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, |
des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, |
u_int len) |
u_int len) |
{ |
{ |
des_cblock iv1; |
des_ncbc_encrypt(src, dest, len, cc->u.des3.key1, &cc->u.des3.iv1, |
des_cblock *iv2 = &cc->u.des3.iv2; |
DES_ENCRYPT); |
des_cblock *iv3 = &cc->u.des3.iv3; |
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, &cc->u.des3.iv2, |
|
DES_DECRYPT); |
memcpy(&iv1, iv2, 8); |
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, &cc->u.des3.iv3, |
|
DES_ENCRYPT); |
des_ncbc_encrypt(src, dest, len, cc->u.des3.key1, &iv1, DES_ENCRYPT); |
|
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, iv2, DES_DECRYPT); |
|
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, iv3, DES_ENCRYPT); |
|
} |
} |
void |
void |
des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, |
des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, |
u_int len) |
u_int len) |
{ |
{ |
des_cblock iv1; |
des_ncbc_encrypt(src, dest, len, cc->u.des3.key3, &cc->u.des3.iv3, |
des_cblock *iv2 = &cc->u.des3.iv2; |
DES_DECRYPT); |
des_cblock *iv3 = &cc->u.des3.iv3; |
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, &cc->u.des3.iv2, |
|
DES_ENCRYPT); |
memcpy(&iv1, iv2, 8); |
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key1, &cc->u.des3.iv1, |
|
DES_DECRYPT); |
des_ncbc_encrypt(src, dest, len, cc->u.des3.key3, iv3, DES_DECRYPT); |
|
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key2, iv2, DES_ENCRYPT); |
|
des_ncbc_encrypt(dest, dest, len, cc->u.des3.key1, &iv1, DES_DECRYPT); |
|
} |
} |
|
|
/* Blowfish */ |
/* Blowfish */ |