Hi all,
We have a mechanism for authenticating our REST APIs at my company based on an HMAC token. This token is generated using a pre-shared key and some hashing functions, specifically SHA-256. I initially implemented the hashing of a string as:
Function computeSHA256Hash(data as String) as String
ba = CreateObject("roByteArray")
ba.FromAsciiString(data)
digest = CreateObject("roEVPDigest")
digest.Setup("sha256")
return digest.Process(ba)
End Function
The problem is that the implementation on other platforms takes TWO parameters to the SHA function, the key and the data, but this seems to only take data. For comparison, here is the iOS function (in the Common Crypto library):
- (NSData *)hmacSHA256WithKey:(NSData *)key
{
unsigned char buffer[CC_SHA256_DIGEST_LENGTH] = {0};
CCHmac(kCCHmacAlgSHA256, [key bytes], [key length],
[self cStringUsingEncoding:NSUTF8StringEncoding], [self length], buffer);
return [NSData dataWithBytes:buffer length:CC_SHA256_DIGEST_LENGTH];
}
The specifics are not important, except that as you see it takes a key and data. Is there a way on the Roku to compute an HMAC with SHA-256 in this way?