bip151: use plaintext packet size as aad (openssh conformance).
This commit is contained in:
parent
b6dbc5f709
commit
08bc5ba0a8
@ -110,7 +110,6 @@ BIP151Stream.prototype.init = function init(publicKey) {
|
|||||||
|
|
||||||
this.chacha.init(this.k1, this.iv());
|
this.chacha.init(this.k1, this.iv());
|
||||||
this.aead.init(this.k2, this.iv());
|
this.aead.init(this.k2, this.iv());
|
||||||
this.aead.aad(this.sid);
|
|
||||||
|
|
||||||
this.lastRekey = utils.now();
|
this.lastRekey = utils.now();
|
||||||
};
|
};
|
||||||
@ -150,7 +149,6 @@ BIP151Stream.prototype.rekey = function rekey() {
|
|||||||
|
|
||||||
this.chacha.init(this.k1, this.iv());
|
this.chacha.init(this.k1, this.iv());
|
||||||
this.aead.init(this.k2, this.iv());
|
this.aead.init(this.k2, this.iv());
|
||||||
this.aead.aad(this.sid);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,7 +169,6 @@ BIP151Stream.prototype.sequence = function sequence() {
|
|||||||
// unaltered aside from the iv.
|
// unaltered aside from the iv.
|
||||||
this.chacha.init(null, this.iv());
|
this.chacha.init(null, this.iv());
|
||||||
this.aead.init(null, this.iv());
|
this.aead.init(null, this.iv());
|
||||||
this.aead.aad(this.sid);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,6 +202,7 @@ BIP151Stream.prototype.getPublicKey = function getPublicKey() {
|
|||||||
BIP151Stream.prototype.encryptSize = function encryptSize(size) {
|
BIP151Stream.prototype.encryptSize = function encryptSize(size) {
|
||||||
var data = new Buffer(4);
|
var data = new Buffer(4);
|
||||||
data.writeUInt32LE(size, 0, true);
|
data.writeUInt32LE(size, 0, true);
|
||||||
|
this.aead.aad(data);
|
||||||
return this.chacha.encrypt(data);
|
return this.chacha.encrypt(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -217,6 +215,7 @@ BIP151Stream.prototype.encryptSize = function encryptSize(size) {
|
|||||||
BIP151Stream.prototype.decryptSize = function decryptSize(data) {
|
BIP151Stream.prototype.decryptSize = function decryptSize(data) {
|
||||||
data = data.slice(0, 4);
|
data = data.slice(0, 4);
|
||||||
this.chacha.encrypt(data);
|
this.chacha.encrypt(data);
|
||||||
|
this.aead.aad(data);
|
||||||
return data.readUInt32LE(0, true);
|
return data.readUInt32LE(0, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user