Move shared DES definitions into a header file
authorJouni Malinen <j@w1.fi>
Sat, 17 Oct 2009 09:53:27 +0000 (12:53 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 17 Oct 2009 09:53:27 +0000 (12:53 +0300)
src/crypto/crypto_internal.c
src/crypto/des-internal.c
src/crypto/des_i.h [new file with mode: 0644]

index 7593996..41ec8bc 100644 (file)
 #include "tls/pkcs8.h"
 #include "sha1_i.h"
 #include "md5_i.h"
+#include "des_i.h"
 
 #ifdef CONFIG_TLS_INTERNAL
 
-/* from des.c */
-struct des3_key_s {
-       u32 ek[3][32];
-       u32 dk[3][32];
-};
-
-void des3_key_setup(const u8 *key, struct des3_key_s *dkey);
-void des3_encrypt(const u8 *plain, const struct des3_key_s *key, u8 *crypt);
-void des3_decrypt(const u8 *crypt, const struct des3_key_s *key, u8 *plain);
-
-void des_key_setup(const u8 *key, u32 *ek, u32 *dk);
-void des_block_encrypt(const u8 *plain, const u32 *ek, u8 *crypt);
-void des_block_decrypt(const u8 *crypt, const u32 *dk, u8 *plain);
-
-
 struct MD5Context {
        u32 buf[4];
        u32 bits[2];
index 543cee4..ccea950 100644 (file)
@@ -2,7 +2,7 @@
  * DES and 3DES-EDE ciphers
  *
  * Modifications to LibTomCrypt implementation:
- * Copyright (c) 2006, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -18,6 +18,7 @@
 
 #include "common.h"
 #include "crypto.h"
+#include "des_i.h"
 
 /*
  * This implementation is based on a DES implementation included in
@@ -458,11 +459,6 @@ void des_block_decrypt(const u8 *crypt, const u32 *dk, u8 *plain)
 }
 
 
-struct des3_key_s {
-       u32 ek[3][32];
-       u32 dk[3][32];
-};
-
 void des3_key_setup(const u8 *key, struct des3_key_s *dkey)
 {
        deskey(key, 0, dkey->ek[0]);
diff --git a/src/crypto/des_i.h b/src/crypto/des_i.h
new file mode 100644 (file)
index 0000000..6f27414
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * DES and 3DES-EDE ciphers
+ * Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#ifndef DES_I_H
+#define DES_I_H
+
+struct des3_key_s {
+       u32 ek[3][32];
+       u32 dk[3][32];
+};
+
+void des_key_setup(const u8 *key, u32 *ek, u32 *dk);
+void des_block_encrypt(const u8 *plain, const u32 *ek, u8 *crypt);
+void des_block_decrypt(const u8 *crypt, const u32 *dk, u8 *plain);
+
+void des3_key_setup(const u8 *key, struct des3_key_s *dkey);
+void des3_encrypt(const u8 *plain, const struct des3_key_s *key, u8 *crypt);
+void des3_decrypt(const u8 *crypt, const struct des3_key_s *key, u8 *plain);
+
+#endif /* DES_I_H */