Now that we've got at least some SDCTR modes working (and aes256-ctr is our
[u/mdw/putty] / sshdes.c
index 14ac7f6..833c689 100644 (file)
--- a/sshdes.c
+++ b/sshdes.c
@@ -600,18 +600,6 @@ static void des_decipher(word32 * output, word32 L, word32 R,
     output[1] = R;
 }
 
-#define GET_32BIT_MSB_FIRST(cp) \
-  (((unsigned long)(unsigned char)(cp)[3]) | \
-  ((unsigned long)(unsigned char)(cp)[2] << 8) | \
-  ((unsigned long)(unsigned char)(cp)[1] << 16) | \
-  ((unsigned long)(unsigned char)(cp)[0] << 24))
-
-#define PUT_32BIT_MSB_FIRST(cp, value) do { \
-  (cp)[3] = (value); \
-  (cp)[2] = (value) >> 8; \
-  (cp)[1] = (value) >> 16; \
-  (cp)[0] = (value) >> 24; } while (0)
-
 static void des_cbc_encrypt(unsigned char *dest, const unsigned char *src,
                            unsigned int len, DESContext * sched)
 {
@@ -744,6 +732,7 @@ static void des_cbc3_decrypt(unsigned char *dest, const unsigned char *src,
     scheds->iv1 = iv1;
 }
 
+#ifdef ENABLE_3DES_SSH2_CTR
 static void des_sdctr3(unsigned char *dest, const unsigned char *src,
                             unsigned int len, DESContext * scheds)
 {
@@ -772,6 +761,7 @@ static void des_sdctr3(unsigned char *dest, const unsigned char *src,
     scheds->iv0 = iv0;
     scheds->iv1 = iv1;
 }
+#endif
 
 static void *des3_make_context(void)
 {
@@ -856,11 +846,13 @@ static void des3_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len)
     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);
 }
+#endif
 
 static void des_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len)
 {
@@ -973,15 +965,17 @@ static const struct ssh2_cipher ssh_3des_ssh2 = {
     des3_make_context, des3_free_context, des3_iv, des3_key,
     des3_ssh2_encrypt_blk, des3_ssh2_decrypt_blk,
     "3des-cbc",
-    8, 168, "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, "triple-DES SDCTR"
+    8, 168, 0, "triple-DES SDCTR"
 };
+#endif
 
 /*
  * Single DES in SSH-2. "des-cbc" is marked as HISTORIC in
@@ -995,14 +989,14 @@ static const struct ssh2_cipher ssh_des_ssh2 = {
     des_make_context, des3_free_context, des3_iv, des_key,
     des_ssh2_encrypt_blk, des_ssh2_decrypt_blk,
     "des-cbc",
-    8, 56, "single-DES CBC"
+    8, 56, SSH_CIPHER_IS_CBC, "single-DES CBC"
 };
 
 static const struct ssh2_cipher ssh_des_sshcom_ssh2 = {
     des_make_context, des3_free_context, des3_iv, des_key,
     des_ssh2_encrypt_blk, des_ssh2_decrypt_blk,
     "des-cbc@ssh.com",
-    8, 56, "single-DES CBC"
+    8, 56, SSH_CIPHER_IS_CBC, "single-DES CBC"
 };
 
 /*
@@ -1012,7 +1006,9 @@ static const struct ssh2_cipher ssh_des_sshcom_ssh2 = {
  * builds.
  */
 static const struct ssh2_cipher *const des3_list[] = {
-/*  &ssh_3des_ssh2_ctr, */
+#ifdef ENABLE_3DES_SSH2_CTR
+    &ssh_3des_ssh2_ctr,
+#endif
     &ssh_3des_ssh2
 };