mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
make style
This commit is contained in:
parent
0d9223a547
commit
0373696662
483 changed files with 56514 additions and 52451 deletions
34
common/tea.c
34
common/tea.c
|
@ -11,54 +11,56 @@
|
|||
#define DELTA 0x9E3779B9
|
||||
#define SUM 0xC6EF3720
|
||||
|
||||
void tea_encrypt(uint8_t *v, uint8_t *key) {
|
||||
void tea_encrypt(uint8_t *v, uint8_t *key)
|
||||
{
|
||||
|
||||
uint32_t a=0,b=0,c=0,d=0,y=0,z=0;
|
||||
uint32_t a = 0, b = 0, c = 0, d = 0, y = 0, z = 0;
|
||||
uint32_t sum = 0;
|
||||
uint8_t n = ROUNDS;
|
||||
|
||||
//key
|
||||
a = bytes_to_num(key, 4);
|
||||
b = bytes_to_num(key+4, 4);
|
||||
c = bytes_to_num(key+8, 4);
|
||||
d = bytes_to_num(key+12, 4);
|
||||
b = bytes_to_num(key + 4, 4);
|
||||
c = bytes_to_num(key + 8, 4);
|
||||
d = bytes_to_num(key + 12, 4);
|
||||
|
||||
//input
|
||||
y = bytes_to_num(v, 4);
|
||||
z = bytes_to_num(v+4, 4);
|
||||
z = bytes_to_num(v + 4, 4);
|
||||
|
||||
while ( n-- > 0 ) {
|
||||
while (n-- > 0) {
|
||||
sum += DELTA;
|
||||
y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b);
|
||||
z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d);
|
||||
}
|
||||
|
||||
num_to_bytes(y, 4, v);
|
||||
num_to_bytes(z, 4, v+4);
|
||||
num_to_bytes(z, 4, v + 4);
|
||||
}
|
||||
|
||||
void tea_decrypt(uint8_t *v, uint8_t *key) {
|
||||
void tea_decrypt(uint8_t *v, uint8_t *key)
|
||||
{
|
||||
|
||||
uint32_t a=0,b=0,c=0,d=0,y=0,z=0;
|
||||
uint32_t a = 0, b = 0, c = 0, d = 0, y = 0, z = 0;
|
||||
uint32_t sum = SUM;
|
||||
uint8_t n = ROUNDS;
|
||||
|
||||
//key
|
||||
a = bytes_to_num(key, 4);
|
||||
b = bytes_to_num(key+4, 4);
|
||||
c = bytes_to_num(key+8, 4);
|
||||
d = bytes_to_num(key+12, 4);
|
||||
b = bytes_to_num(key + 4, 4);
|
||||
c = bytes_to_num(key + 8, 4);
|
||||
d = bytes_to_num(key + 12, 4);
|
||||
|
||||
//input
|
||||
y = bytes_to_num(v, 4);
|
||||
z = bytes_to_num(v+4, 4);
|
||||
z = bytes_to_num(v + 4, 4);
|
||||
|
||||
/* sum = delta<<5, in general sum = delta * n */
|
||||
while ( n-- > 0 ) {
|
||||
while (n-- > 0) {
|
||||
z -= ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d);
|
||||
y -= ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b);
|
||||
sum -= DELTA;
|
||||
}
|
||||
num_to_bytes(y, 4, v);
|
||||
num_to_bytes(z, 4, v+4);
|
||||
num_to_bytes(z, 4, v + 4);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue