tags:

views:

167

answers:

1

I am new to hmac-sha1. I have a couple of questions about the sample.

/* inputs: NSData *keyData; NSData *clearTextData */

uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};

CCHmacContext hmacContext; CCHmacInit(&hmacContext, kCCHmacAlgSHA1, keyData.bytes, keyData.length); CCHmacUpdate(&hmacContext, clearTextData.bytes, clearTextData.length); CCHmacFinal(&hmacContext, digest);

NSData *out = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];

  1. What is clearTextData? Is it the source string in NSData object form?
  2. What is kData? Is it the source data to be encoded?
  3. Where is the secret key? (Is that kData?)

Thank you for any help you can provide.

+1  A: 

Here is a good discussion of what you are trying to do.

fuzzy lollipop