[Sumover-dev] [svn commit] r4101 - common/trunk/src

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Mon Oct 8 16:52:14 BST 2007


Author: piers
Date: Mon Oct  8 16:52:13 2007
New Revision: 4101

Modified:
   common/trunk/src/rijndael-api-fst.c

Log:
Added back the #ifndef BINARY_KEY_MATERIAL and corresponding code to deal with binary keying 
material. This was done as RAT actually supplies binary keying material and the AES fuction
makeKey() was failing because it was being provided with binary keying material, when the 
existing implementation only handled non-binary keying material. The code for binary keying 
material existed in a previous, out-dated version - this has been backported. The 
#define BINARY_KEY_MATERIAL has been added to the tope of the file.
RAT had been 'working' with AES crypto by just scrambling the first few bytes of each packet 
and not atcually encrypting them. This has now been fixed.


Modified: common/trunk/src/rijndael-api-fst.c
==============================================================================
--- common/trunk/src/rijndael-api-fst.c	(original)
+++ common/trunk/src/rijndael-api-fst.c	Mon Oct  8 16:52:13 2007
@@ -40,6 +40,7 @@
 #include "debug.h"
 #include "rijndael-api-fst.h"
 #include "rijndael-alg-fst.h"
+#define BINARY_KEY_MATERIAL 
 
 int makeKey(keyInstance *key, BYTE direction, int keyLen, BYTE *keyMaterial) {
 	int i;
@@ -68,6 +69,7 @@
 
 	/* initialize key schedule: */
 	keyMat = key->keyMaterial;
+#ifndef BINARY_KEY_MATERIAL 
  	for (i = 0; i < key->keyLen/8; i++) {
 		int t, v;
 
@@ -85,6 +87,12 @@
 		
 		cipherKey[i] = (u8)v;
 	}
+#else 
+	for (i = 0; i < key->keyLen/8; i++) { 
+		cipherKey[i] = (u8)keyMat[i];  
+	} 
+#endif /* ?BINARY_KEY_MATERIAL */ 
+
 	if (direction == DIR_ENCRYPT) {
 		key->Nr = rijndaelKeySetupEnc(key->rk, cipherKey, keyLen);
 	} else {
@@ -101,6 +109,7 @@
 		return BAD_CIPHER_MODE;
 	}
 	if (IV != NULL) {
+#ifndef BINARY_KEY_MATERIAL 
 		int i;
  		for (i = 0; i < MAX_IV_SIZE; i++) {
 			int t, j;
@@ -119,6 +128,10 @@
 			
 			cipher->IV[i] = (u8)j;
 		}
+#else 
+		memcpy(cipher->IV, IV, MAX_IV_SIZE); 
+#endif /* ?BINARY_KEY_MATERIAL */ 
+
 	} else {
 		memset(cipher->IV, 0, MAX_IV_SIZE);
 	}



More information about the Sumover-dev mailing list