Skip to content

Instantly share code, notes, and snippets.

@pharaoh1
Forked from Halo-Michael/ApNonce (arm64 only).c
Created March 14, 2021 23:27
Show Gist options
  • Save pharaoh1/9a432c28ca4970c7547208befcf2150d to your computer and use it in GitHub Desktop.
Save pharaoh1/9a432c28ca4970c7547208befcf2150d to your computer and use it in GitHub Desktop.
//A7~A9, use SHA1 algorithm to generate apnonce.
unsigned long buf = 0x1111111111111111;
unsigned char result[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(&buf, sizeof(buf), result);
for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
printf("%02" PRIx32, result[i]);
putchar('\n');
//A10~A11, use SHA384 algorithm, but only take the first 32 bits to generate apnonce.
unsigned long buf = 0x1111111111111111;
unsigned char result[CC_SHA384_DIGEST_LENGTH];
CC_SHA384(&buf, sizeof(buf), result);
for (int i = 0; i < MIN(CC_SHA384_DIGEST_LENGTH, 32); i++)
printf("%02" PRIx32, result[i]);
putchar('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment