Skip to content

Instantly share code, notes, and snippets.

@isaacs
Last active December 12, 2015 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/4684623 to your computer and use it in GitHub Desktop.
Save isaacs/4684623 to your computer and use it in GitHub Desktop.
CryptoStream.prototype._read = function(n, cb) {
// XXX replace this with a public function so that we
// don't have to delve into stuff here. Inappropriate intimacy!
// need some data!
try {
cb(null, this._out());
} catch (er) {
cb(er);
}
};
CryptoStream.prototype._write = function(chunk, cb) {
try {
this._in(chunk, 0, chunk.length);
// cycle!
this.pair.encrypted.read(0);
this.pair.cleartext.read(0);
cb();
} catch (er) {
cb(er);
}
};
EncryptedStream.prototype._out = function() {
return this.pair.ssl.encOut();
};
EncryptedStream.prototype._in = function() {
return this.pair.ssl.encIn();
};
CleartextStream.prototype._out = function() {
return this.pair.ssl.clearOut();
};
CleartextStream.prototype._in = function() {
return this.pair.ssl.clearIn();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment