2
CCHmac(CCHmacAlgorithm algorithm, const void *key, size_t keyLength,
       const void *data, size_t dataLength, void *macOut);
  • What will be the key?
  • what will be the data?
  • what will be the macOut?
  • For example, I have API:

    https://
    somedomain/
    beta/
    men?
    key=[API KEY]&signature=[Signature]}
    

    How can I pass API key to CCHmac function and get the signature and make the complete API, e.g.:

    https://
    Somedomain/
    beta/
    men?
    key="Abcdefghi12345"&signature=jhfjkshkjfhsdkfhkshdkjfioeoiejafjnanjasbjfs="}
    

Can someone provide me good tutorial or sample code for CCHmac function? I looked on the web but I don't find anything.

honk
  • 9,137
  • 11
  • 75
  • 83
user3908542
  • 59
  • 1
  • 5

1 Answers1

1

CCHmacAlgorithm algorithm - set HMAC algorithm, for example, kCCHmacAlgSHA256;

const void *key - it's your API key (I recommend use a key-stretching function called PBKDF2 previously);

size_t keyLength - const, for example, kCCKeySizeAES128;

const void *data - some additional data, for example NSString;

size_t dataLength length of data;

void *macOut - returned hash. You can save it:

uint8_t hmac[CC_SHA256_DIGEST_LENGTH] = {0}; //Call CCHmac NSData *hmacData = [NSData dataWithBytes: hmac length: CC_SHA256_DIGEST_LENGTH];

Check code from this tutorial.

Artem Novichkov
  • 2,356
  • 2
  • 24
  • 34