Changes

Jump to: navigation, search

DPS915 C U D A B O Y S

1,533 bytes added, 10:58, 3 November 2015
✓ Profile 0: File Encryption
=== <span style="color: green">&#x2713; Profile 0: File Encryption</span> ===
==== Description ====
This piece of software takes a file and ecrypts it one of 4 ways:
# Byte Inversion
# Byte Cycle
# Xor Cipher
# RC4 Cipher
 
Inside the byteCipher method, exists a for loop that could use optimization:
for (int i = 0; i < bufferSize; i++){
// going over every byte in the file
switch (mode) {
case 0: // inversion
buffer[i] = ~buffer[i];
break;
case 1: // cycle
buffer [i] = cycle (buffer [i]);
break;
case 2: // RC4
buffer [i] = buffer [i] ^ rc4_output();
break;
}
}
 
This for loop then can call one of two functions: <code>cycle</code> or <code>rc4_output</code>.
 
char cycle (char value) {
int leftMask = 170;
int rightMask = 85;
int iLeft = value & leftMask;
int iRight = value & rightMask;
iLeft = iLeft >> 1;
iRight = iRight << 1;
return iLeft | iRight;
}
 
unsigned char rc4_output() {
unsigned char temp;
i = (i + 1) & 0xFF;
j = (j + S[i]) & 0xFF;
temp = S[i];
S[i] = S[j];
S[j] = temp;
return S[(S[i] + S[j]) & 0xFF];
}
 
 
We need to change these two functions so they are added to the device as "device functions". We also need to convert this for loop into a kernel.
 
==== Profiling ====
=== <span style="color: red">&#x2717; Profile 1: PI Approximation</span> ===

Navigation menu