1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

crypto.hmac: implement hmac.equal/2 too

This commit is contained in:
Delyan Angelov
2020-10-14 17:21:43 +03:00
parent 9355c60b4d
commit d1e52620c7
4 changed files with 138 additions and 0 deletions

View File

@ -152,6 +152,17 @@ fn test_hmac_sha512() {
}
}
fn test_hmac_equal() {
mac1_1 := '7641c48a3b4aa8f887c07b3e83f96affb89c978fed8c96fcbbf4ad596eebfe496f9f16da6cd080ba393c6f365ad72b50d15c71bfb1d6b81f66a911786c6ce932'.bytes()
mac1_2 := '7641c48a3b4aa8f887c07b3e83f96affb89c978fed8c96fcbbf4ad596eebfe496f9f16da6cd080ba393c6f365ad72b50d15c71bfb1d6b81f66a911786c6ce932'.bytes()
mac2_1 := '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737'.bytes()
mac2_2 := '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737'.bytes()
assert hmac.equal(mac1_1, mac1_2)
assert hmac.equal(mac2_1, mac2_2)
assert !hmac.equal(mac1_1, mac2_1)
assert !hmac.equal(mac1_1, mac2_2)
}
// not yet supported by crypto module
// sha3_224_expected_results := [
// 'f68da7f7bf577de799bb1224b7acfef9e8de015a63475ed5904a4693'