DavidAW
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2016
10:56 AM
Help with SHA-256 (roEVPDigest)
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:
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):
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?
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?
2 REPLIES 2


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2016
11:16 AM
Re: Help with SHA-256 (roEVPDigest)
It sounds like you want look at roHMAC (https://sdkdocs.roku.com/display/sdkdoc/roHMAC).
DavidAW
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2016
11:25 AM
Re: Help with SHA-256 (roEVPDigest)
Perfect, thanks! Now iOS and Roku are in sync on the HMAC output.