mirror of https://github.com/nodejs/node.git
Add some comments to securepair
parent
7515360951
commit
d722c8df73
|
@ -215,12 +215,19 @@ SecurePair.prototype._cycle = function () {
|
||||||
var chunk = null;
|
var chunk = null;
|
||||||
var pool = null;
|
var pool = null;
|
||||||
|
|
||||||
|
// Pull in incoming encrypted data from the socket.
|
||||||
|
// This arrives via some code like this:
|
||||||
|
//
|
||||||
|
// socket.on('data', function (d) {
|
||||||
|
// pair.encrypted.write(d)
|
||||||
|
// });
|
||||||
|
//
|
||||||
while (this._encInPending.length > 0) {
|
while (this._encInPending.length > 0) {
|
||||||
tmp = this._encInPending.shift();
|
tmp = this._encInPending.shift();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
debug('writng from encIn');
|
debug('writing from encIn');
|
||||||
rv = this._ssl.encIn(tmp, 0, tmp.length);
|
rv = this._ssl.encIn(tmp, 0, tmp.length);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return this._error(e);
|
return this._error(e);
|
||||||
}
|
}
|
||||||
|
@ -233,6 +240,11 @@ SecurePair.prototype._cycle = function () {
|
||||||
assert(rv === tmp.length);
|
assert(rv === tmp.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pull in any clear data coming from the application.
|
||||||
|
// This arrives via some code like this:
|
||||||
|
//
|
||||||
|
// pair.cleartext.write("hello world");
|
||||||
|
//
|
||||||
while (this._clearInPending.length > 0) {
|
while (this._clearInPending.length > 0) {
|
||||||
tmp = this._clearInPending.shift();
|
tmp = this._clearInPending.shift();
|
||||||
try {
|
try {
|
||||||
|
@ -280,6 +292,9 @@ SecurePair.prototype._cycle = function () {
|
||||||
} while (checker(bytesRead));
|
} while (checker(bytesRead));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move decryptoed, clear data out into the application.
|
||||||
|
// From the user's perspective this occurs as a 'data' event
|
||||||
|
// on the pair.cleartext.
|
||||||
mover(
|
mover(
|
||||||
function (pool, offset, length) {
|
function (pool, offset, length) {
|
||||||
debug('reading from clearOut');
|
debug('reading from clearOut');
|
||||||
|
@ -292,6 +307,14 @@ SecurePair.prototype._cycle = function () {
|
||||||
return bytesRead > 0 && self._cleartextWriteState === true;
|
return bytesRead > 0 && self._cleartextWriteState === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Move encrypted data to the stream. From the user's perspective this
|
||||||
|
// occurs as a 'data' event on the pair.encrypted. Usually the application
|
||||||
|
// will have some code which pipes the stream to a socket:
|
||||||
|
//
|
||||||
|
// pair.encrypted.on('data', function (d) {
|
||||||
|
// socket.write(d);
|
||||||
|
// });
|
||||||
|
//
|
||||||
mover(
|
mover(
|
||||||
function (pool, offset, length) {
|
function (pool, offset, length) {
|
||||||
debug('reading from encOut');
|
debug('reading from encOut');
|
||||||
|
|
Loading…
Reference in New Issue