crypto: HMACSHA512 into crypto and add tests
This commit is contained in:
parent
f70ccc9215
commit
276a339d60
4 changed files with 42 additions and 17 deletions
|
@ -46,4 +46,18 @@ describe('Crypto', function() {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('HMAC SHA512', function() {
|
||||
it('matches the test vector', function() {
|
||||
fixture.before.hex.forEach(function(hex, i) {
|
||||
var data = new Buffer(hex, 'hex')
|
||||
var secret = new Buffer(fixture.after.hmacsha512.secret)
|
||||
|
||||
var actual = crypto.HmacSHA512(data, secret)
|
||||
var expected = fixture.after.hmacsha512.hash[i]
|
||||
|
||||
assert.equal(actual.toString('hex'), expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
11
test/fixtures/crypto.js
vendored
11
test/fixtures/crypto.js
vendored
|
@ -32,6 +32,15 @@ module.exports = {
|
|||
'04abc8821a06e5a30937967d11ad10221cb5ac3b5273e434f1284ee87129a061',
|
||||
'12a3ae445661ce5dee78d0650d33362dec29c4f82af05e7e57fb595bbbacf0ca',
|
||||
'a7fb8276035057ed6479c5f2305a96da100ac43f0ac10f277e5ab8c5457429da'
|
||||
]
|
||||
],
|
||||
hmacsha512: {
|
||||
secret: 'vires is numeris',
|
||||
hash: [
|
||||
'4c0595aed1f5d066ea9f797727c060eb86cb55ff29d4d4fd2cd0ad3a012386763aea604c030619c79aa7fd8d03cda1b73a9ebd17906a3d2a350108d1a98b24ac',
|
||||
'f80b90d63b804b3d2ab03b9bfb3ac94ee271352eb8bddfb6b4f5cf2a4fc9176acea35f517728e64943d1eb8af1e4674a114082c81bc8874d88b408b3b406d6a4',
|
||||
'134cf60c30a5cd412c7a5cd6c3f878279e139b47c19550b7456fa137fbf90e580ae0a923a22052f42ec801ac658db32821e271161b563eac4926285ba6b8f410',
|
||||
'7dee95aa3c462d3eb7ecb61536cb215e471d1fa73d8643a967905946e26c536588c5058abd5a049a22b987db95a7fb420f3bff12359dc53d03d7ce7df714e029'
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue