Commit 89ce0ebb authored by YUSHIQIAN's avatar YUSHIQIAN

change 8 and 6 to parameters

parent d19b08d5
......@@ -42,6 +42,7 @@ information see the LICENCE-fr.txt or LICENSE-en.txt files.
#include <des.h>
#include <km.h>
#include <pcc.h>
#include <math.h>
uint64_t pt; /* Plain text. */
uint64_t *ct; /* Array of cipher texts. */
......@@ -105,8 +106,8 @@ main (int argc, char **argv)
uint64_t r15; /* Right half of 15 round. */
uint64_t tmpExpR = 0x0ULL;
uint8_t *expR[8]; /*Expanded R, i.e. E(R) permutation of DES*/
int *hw[8]; /* haming weight of input (4 bits) of permutation*/
uint8_t *expR[nBytes]; /*Expanded R, i.e. E(R) permutation of DES*/
int *hw[nBytes]; /* haming weight of input (4 bits) of permutation*/
for (iByte=0; iByte<nBytes; iByte++){
expR[iByte] = malloc (n * sizeof (uint8_t));
hw[iByte] = malloc(n * sizeof (int));
......@@ -122,7 +123,7 @@ main (int argc, char **argv)
tmpExpR = des_e (r15);
for (iByte=0; iByte<nBytes; iByte++){
expR[iByte][iEnc] = (tmpExpR >> (nBytes - iByte - 1)*6) & (keyCandidates-1);
expR[iByte][iEnc] = (tmpExpR >> (nBytes - iByte - 1)*(unsigned int)log2(keyCandidates)) & (keyCandidates-1);
}
}
......@@ -165,7 +166,7 @@ main (int argc, char **argv)
}
}
subkey = subkey | ((uint64_t)key << ((nBytes-iByte-1) * 6));
subkey = subkey | ((uint64_t)key << ((nBytes-iByte-1) * (unsigned int)log2(keyCandidates)));
pcc_free (ctx);
}/*iByte*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment