HMAC Update for Protov3
This commit is contained in:
parent
b5c6e3d101
commit
3190fe97f9
2 changed files with 5 additions and 7 deletions
|
@ -315,11 +315,11 @@ window.textsecure.crypto = function() {
|
||||||
var infoBuffer = new ArrayBuffer(info.byteLength + 1 + 32);
|
var infoBuffer = new ArrayBuffer(info.byteLength + 1 + 32);
|
||||||
var infoArray = new Uint8Array(infoBuffer);
|
var infoArray = new Uint8Array(infoBuffer);
|
||||||
infoArray.set(new Uint8Array(info), 32);
|
infoArray.set(new Uint8Array(info), 32);
|
||||||
infoArray[infoArray.length - 1] = 0;
|
infoArray[infoArray.length - 1] = 1;
|
||||||
// TextSecure implements a slightly tweaked version of RFC 5869: the 0 and 1 should be 1 and 2 here
|
// TextSecure implements a slightly tweaked version of RFC 5869: the 0 and 1 should be 1 and 2 here
|
||||||
return HmacSHA256(PRK, infoBuffer.slice(32)).then(function(T1) {
|
return HmacSHA256(PRK, infoBuffer.slice(32)).then(function(T1) {
|
||||||
infoArray.set(new Uint8Array(T1));
|
infoArray.set(new Uint8Array(T1));
|
||||||
infoArray[infoArray.length - 1] = 1;
|
infoArray[infoArray.length - 1] = 2;
|
||||||
return HmacSHA256(PRK, infoBuffer).then(function(T2) {
|
return HmacSHA256(PRK, infoBuffer).then(function(T2) {
|
||||||
return [ T1, T2 ];
|
return [ T1, T2 ];
|
||||||
});
|
});
|
||||||
|
|
|
@ -218,9 +218,7 @@ textsecure.registerOnLoadFunction(function() {
|
||||||
});
|
});
|
||||||
}, "Simple Ed25519 tests");
|
}, "Simple Ed25519 tests");
|
||||||
|
|
||||||
// TextSecure implements a slightly tweaked version of RFC 5869 and thus this test fails
|
TEST(function() {
|
||||||
// If you tweak the HKDF as noted in the comment there, this test passes
|
|
||||||
/*TEST(function() {
|
|
||||||
var IKM = new Uint8Array(new ArrayBuffer(22));
|
var IKM = new Uint8Array(new ArrayBuffer(22));
|
||||||
for (var i = 0; i < 22; i++)
|
for (var i = 0; i < 22; i++)
|
||||||
IKM[i] = 11;
|
IKM[i] = 11;
|
||||||
|
@ -233,12 +231,12 @@ textsecure.registerOnLoadFunction(function() {
|
||||||
for (var i = 0; i < 10; i++)
|
for (var i = 0; i < 10; i++)
|
||||||
info[i] = 240 + i;
|
info[i] = 240 + i;
|
||||||
|
|
||||||
return textsecure.crypto.testing_only.HKDF(IKM, salt, info).then(function(OKM){
|
return textsecure.crypto.testing_only.HKDF(IKM.buffer, salt.buffer, info.buffer).then(function(OKM){
|
||||||
var T1 = hexToArrayBuffer("3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf");
|
var T1 = hexToArrayBuffer("3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf");
|
||||||
var T2 = hexToArrayBuffer("34007208d5b887185865");
|
var T2 = hexToArrayBuffer("34007208d5b887185865");
|
||||||
return (getString(OKM[0]) == getString(T1) && getString(OKM[1]).substring(0, 10) == getString(T2));
|
return (getString(OKM[0]) == getString(T1) && getString(OKM[1]).substring(0, 10) == getString(T2));
|
||||||
});
|
});
|
||||||
}, "HMAC RFC5869 Test vectors");*/
|
}, "HMAC RFC5869 Test vectors");
|
||||||
|
|
||||||
var axolotlTwoPartyTestVectorsAlice = [
|
var axolotlTwoPartyTestVectorsAlice = [
|
||||||
["sendMessage",
|
["sendMessage",
|
||||||
|
|
Loading…
Add table
Reference in a new issue