- We were using the first word of each block of keystream block twice and the
second not at all.
- We were incrementing the high-order word of the counter after every block
rather than the low-order one.
With those fixed, our 3des-ctr implementation interoperates with the one in
Moussh. Thanks to der Mouse for his help with the testing.
3des-ctr is now enabled by default.
git-svn-id: svn://svn.tartarus.org/sgt/putty@5699
cda61777-01e9-0310-a592-
d414129be87e
-#ifdef ENABLE_3DES_SSH2_CTR
static void des_sdctr3(unsigned char *dest, const unsigned char *src,
unsigned int len, DESContext * scheds)
{
static void des_sdctr3(unsigned char *dest, const unsigned char *src,
unsigned int len, DESContext * scheds)
{
src += 4;
dest += 4;
tmp = GET_32BIT_MSB_FIRST(src);
src += 4;
dest += 4;
tmp = GET_32BIT_MSB_FIRST(src);
- PUT_32BIT_MSB_FIRST(dest, tmp ^ b[0]);
+ PUT_32BIT_MSB_FIRST(dest, tmp ^ b[1]);
- if ((iv0 = (iv0 + 1) & 0xffffffff) == 0)
- iv1 = (iv1 + 1) & 0xffffffff;
+ if ((iv1 = (iv1 + 1) & 0xffffffff) == 0)
+ iv0 = (iv0 + 1) & 0xffffffff;
}
scheds->iv0 = iv0;
scheds->iv1 = iv1;
}
}
scheds->iv0 = iv0;
scheds->iv1 = iv1;
}
static void *des3_make_context(void)
{
static void *des3_make_context(void)
{
des_cbc3_decrypt(blk, blk, len, keys);
}
des_cbc3_decrypt(blk, blk, len, keys);
}
-#ifdef ENABLE_3DES_SSH2_CTR
static void des3_ssh2_sdctr(void *handle, unsigned char *blk, int len)
{
DESContext *keys = (DESContext *) handle;
des_sdctr3(blk, blk, len, keys);
}
static void des3_ssh2_sdctr(void *handle, unsigned char *blk, int len)
{
DESContext *keys = (DESContext *) handle;
des_sdctr3(blk, blk, len, keys);
}
static void des_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len)
{
static void des_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len)
{
8, 168, SSH_CIPHER_IS_CBC, "triple-DES CBC"
};
8, 168, SSH_CIPHER_IS_CBC, "triple-DES CBC"
};
-#ifdef ENABLE_3DES_SSH2_CTR
static const struct ssh2_cipher ssh_3des_ssh2_ctr = {
des3_make_context, des3_free_context, des3_iv, des3_key,
des3_ssh2_sdctr, des3_ssh2_sdctr,
"3des-ctr",
8, 168, 0, "triple-DES SDCTR"
};
static const struct ssh2_cipher ssh_3des_ssh2_ctr = {
des3_make_context, des3_free_context, des3_iv, des3_key,
des3_ssh2_sdctr, des3_ssh2_sdctr,
"3des-ctr",
8, 168, 0, "triple-DES SDCTR"
};
/*
* Single DES in SSH-2. "des-cbc" is marked as HISTORIC in
/*
* Single DES in SSH-2. "des-cbc" is marked as HISTORIC in
* builds.
*/
static const struct ssh2_cipher *const des3_list[] = {
* builds.
*/
static const struct ssh2_cipher *const des3_list[] = {
-#ifdef ENABLE_3DES_SSH2_CTR