blob: bb7842a4ec84569085438b49e4f6ba0b90b9b5d6 [file] [log] [blame]
Test that HMAC operations only work when hash functions match between invocation and key.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Importing a raw HMAC SHA-1 key from string literal...
Done
PASS crypto.subtle.sign({name: 'hmac', hash: {name: 'sha-1'}}, key, asciiToUint8Array('foo')) did not throw exception.
PASS crypto.subtle.sign({name: 'hmac', hash: {name: 'sha-256'}}, key, asciiToUint8Array('foo')) threw exception Error: NotSupportedError: DOM Exception 9.
PASS crypto.subtle.verify({name: 'hmac', hash: {name: 'sha-1'}}, key, asciiToUint8Array('fake signature'), asciiToUint8Array('foo')) did not throw exception.
PASS crypto.subtle.verify({name: 'hmac', hash: {name: 'sha-256'}}, key, asciiToUint8Array('fake signature'), asciiToUint8Array('foo')) threw exception Error: NotSupportedError: DOM Exception 9.
PASS successfullyParsed is true
TEST COMPLETE