const unsigned char* rawdata = "046EAF0968AA895ADDFEE599566F0B880242461D1377F4887C9B84631E13067B96DB18C41E0C208F8D12EBCC3F99F2522903AF6105833E4CBADE9D6A1D0F039187";
You've already been told that, but I am going to tell you once more: the
rawdata
variable does not contain the byte values you think it does. Because you are confounding a byte array (which is a collection of byte values) and its
string representation.
You may want to write instead:
const unsigned char* rawdata = { 0x04, 0x6E, 0xAF, 0x09, 0x68, 0xAA, 0x89, 0x5A, 0xDD, 0xFE, 0xE5, 0x99, 0x56, 0x6F, 0x0B, 0x88, 0x02, 0x42, 0x46, 0x1D, 0x13, 0x77, 0xF4, 0x88, 0x7C, 0x9B, 0x84, 0x63, 0x1E, 0x13, 0x06, 0x7B, 0x96, 0xDB, 0x18, 0xC4, 0x1E, 0x0C, 0x20, 0x8F, 0x8D, 0x12, 0xEB, 0xCC, 0x3F, 0x99, 0xF2, 0x52, 0x29, 0x03, 0xAF, 0x61, 0x05, 0x83, 0x3E, 0x4C, 0xBA, 0xDE, 0x9D, 0x6A, 0x1D, 0x0F, 0x03, 0x91, 0x87 };
In other words:
The string representation of a byte array is stored internally with a collection of bytes which are not the same as the bytes in the byte array itself.
Short example:
Take the byte array { 0x00, 0x42 }. It has 2 bytes.
It's string representation is "0042", which has 4 characters, and is stored in memory with 4 bytes ({ 0x30, 0x30, 0x34, 0x32 }, which are the ASCII codes of characters under hexadecimal representation), i.e. twice as the value it is representing.