Skip to content

Instantly share code, notes, and snippets.

@miura1729
Created March 1, 2020 09:35
Show Gist options
  • Save miura1729/37d4c1477cd04e394421cffd6a010e40 to your computer and use it in GitHub Desktop.
Save miura1729/37d4c1477cd04e394421cffd6a010e40 to your computer and use it in GitHub Desktop.
#include <stdio.h>
main()
{
unsigned char base[] = {0x03, 0x10, 0x21, 0x44, 0xf0, 0xe1, 0x98, 0x21};
unsigned char keys[8] = {0, 0, 0, 0, 0, 0, 0, 0};
unsigned char key = 0xf0;
unsigned char kt;
unsigned char tmp = 0xff;
int i;
int j;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
keys[i] |= (base[j] & (1 << i) ? 1 << j : 0);
}
}
printf("%x \n", keys[0]);
printf("%x \n", keys[1]);
printf("%x \n", keys[2]);
printf("%x \n", keys[3]);
kt = key;
tmp &= (keys[0] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[1] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[2] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[3] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[4] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[5] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[6] ^ ~(-(kt & 1)));
kt >>= 1;
tmp &= (keys[7] ^ ~(-(kt & 1)));
kt >>= 1;
printf("%x \n", tmp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment