New CRC32 implementation, from scratch, not copyrighted by somebody else!
[u/mdw/putty] / sshdes.c
index 66e7041..83d4d26 100644 (file)
--- a/sshdes.c
+++ b/sshdes.c
@@ -16,26 +16,6 @@ information.
 
 */
 
-/*
- * $Id: sshdes.c,v 1.2 1999/01/08 13:10:15 simon Exp $
- * $Log: sshdes.c,v $
- * Revision 1.2  1999/01/08 13:10:15  simon
- * John Sullivan's patches plus more fixes:
- *   - Stop using the identifier `environ' as some platforms make it a macro
- *   - Fix silly error box at end of connection in FWHACK mode
- *   - Fix GPF on maximise-then-restore
- *   - Use SetCapture to allow drag-selecting outside the window
- *   - Correctly update window title when iconic and in win_name_always mode
- *
- * Revision 1.1.1.1  1996/02/18 21:38:11  ylo
- *     Imported ssh-1.2.13.
- *
- * Revision 1.2  1995/07/13  01:22:57  ylo
- *     Added cvs log.
- *
- * $Endlog$
- */
-
 typedef struct
 {
   word32 key_schedule[32];
@@ -115,26 +95,6 @@ cryptography and data security, including the following:
 
 */
 
-/*
- * $Id: sshdes.c,v 1.2 1999/01/08 13:10:15 simon Exp $
- * $Log: sshdes.c,v $
- * Revision 1.2  1999/01/08 13:10:15  simon
- * John Sullivan's patches plus more fixes:
- *   - Stop using the identifier `environ' as some platforms make it a macro
- *   - Fix silly error box at end of connection in FWHACK mode
- *   - Fix GPF on maximise-then-restore
- *   - Use SetCapture to allow drag-selecting outside the window
- *   - Correctly update window title when iconic and in win_name_always mode
- *
- * Revision 1.1.1.1  1996/02/18 21:38:11  ylo
- *     Imported ssh-1.2.13.
- *
- * Revision 1.2  1995/07/13  01:22:25  ylo
- *     Added cvs log.
- *
- * $Endlog$
- */
-
 /* Table for key generation.  This used to be in sk.h. */
 /* Copyright (C) 1993 Eric Young - see README for more details */
 static const word32 des_skb[8][64]={
@@ -697,6 +657,7 @@ static void des3_sesskey(unsigned char *key) {
     memset(div1, 0, sizeof(div1));
     memset(div2, 0, sizeof(div2));
     memset(div3, 0, sizeof(div3));
+    logevent("Initialised triple-DES encryption");
 }
 
 static void des3_encrypt_blk(unsigned char *blk, int len) {
@@ -713,6 +674,28 @@ struct ssh_cipher ssh_3des = {
     des3_decrypt_blk
 };
 
+static void des_sesskey(unsigned char *key) {
+    des_set_key(key, &ekey1);
+    memset(eiv1, 0, sizeof(eiv1));
+    des_set_key(key, &dkey1);
+    memset(div1, 0, sizeof(div1));
+    logevent("Initialised single-DES encryption");
+}
+
+static void des_encrypt_blk(unsigned char *blk, int len) {
+    des_cbc_encrypt(&ekey1, eiv1, blk, blk, len);
+}
+
+static void des_decrypt_blk(unsigned char *blk, int len) {
+    des_cbc_decrypt(&dkey1, div1, blk, blk, len);
+}
+
+struct ssh_cipher ssh_des = {
+    des_sesskey,
+    des_encrypt_blk,
+    des_decrypt_blk
+};
+
 #ifdef DES_TEST
 
 void des_encrypt_buf(DESContext *ks, unsigned char *out,