Add function names to constructors

This commit is contained in:
Robert Nelson 2014-01-02 12:50:48 -08:00
parent 17ad1f5fed
commit 3d4dfaea87
21 changed files with 77 additions and 77 deletions

View File

@ -6,7 +6,7 @@
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function localStorage() {
/** /**
* Reads the config out of the HTML5 local storage * Reads the config out of the HTML5 local storage

View File

@ -34,7 +34,7 @@ var enums = require('../enums.js'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function compressed() {
/** /**
* List of packets * List of packets
* @type {module:packet/packetlist} * @type {module:packet/packetlist}

View File

@ -31,7 +31,7 @@ var util = require('../util'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function literal() {
this.format = 'utf8'; // default format for literal data packets this.format = 'utf8'; // default format for literal data packets
this.data = ''; // literal data representation as native JavaScript string or bytes this.data = ''; // literal data representation as native JavaScript string or bytes
this.date = new Date(); this.date = new Date();
@ -42,7 +42,7 @@ module.exports = function () {
* will be normalized to \r\n and by default text is converted to UTF8 * will be normalized to \r\n and by default text is converted to UTF8
* @param {String} text Any native javascript string * @param {String} text Any native javascript string
*/ */
this.setText = function(text) { this.setText = function (text) {
// normalize EOL to \r\n // normalize EOL to \r\n
text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); text = text.replace(/\r/g, '').replace(/\n/g, '\r\n');
// encode UTF8 // encode UTF8
@ -54,7 +54,7 @@ module.exports = function () {
* with normalized end of line to \n * with normalized end of line to \n
* @return {String} literal data as text * @return {String} literal data as text
*/ */
this.getText = function() { this.getText = function () {
// decode UTF8 // decode UTF8
var text = util.decode_utf8(this.data); var text = util.decode_utf8(this.data);
// normalize EOL to \n // normalize EOL to \n
@ -66,7 +66,7 @@ module.exports = function () {
* @param {String} bytes The string of bytes * @param {String} bytes The string of bytes
* @param {utf8|binary|text} format The format of the string of bytes * @param {utf8|binary|text} format The format of the string of bytes
*/ */
this.setBytes = function(bytes, format) { this.setBytes = function (bytes, format) {
this.format = format; this.format = format;
this.data = bytes; this.data = bytes;
} }
@ -76,7 +76,7 @@ module.exports = function () {
* Get the byte sequence representing the literal packet data * Get the byte sequence representing the literal packet data
* @returns {String} A sequence of bytes * @returns {String} A sequence of bytes
*/ */
this.getBytes = function() { this.getBytes = function () {
return this.data; return this.data;
} }
@ -92,7 +92,7 @@ module.exports = function () {
* input at position * input at position
* @return {module:packet/literal} object representation * @return {module:packet/literal} object representation
*/ */
this.read = function(bytes) { this.read = function (bytes) {
// - A one-octet field that describes how the data is formatted. // - A one-octet field that describes how the data is formatted.
var format = enums.read(enums.literal, bytes.charCodeAt(0)); var format = enums.read(enums.literal, bytes.charCodeAt(0));
@ -113,7 +113,7 @@ module.exports = function () {
* @param {String} data The data to be inserted as body * @param {String} data The data to be inserted as body
* @return {String} string-representation of the packet * @return {String} string-representation of the packet
*/ */
this.write = function() { this.write = function () {
var filename = util.encode_utf8("msg.txt"); var filename = util.encode_utf8("msg.txt");
var data = this.getBytes(); var data = this.getBytes();

View File

@ -31,7 +31,7 @@
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function marker() {
/** /**
* Parsing function for a literal data packet (tag 10). * Parsing function for a literal data packet (tag 10).
* *
@ -43,7 +43,7 @@ module.exports = function () {
* input at position * input at position
* @return {module:packet/marker} Object representation * @return {module:packet/marker} Object representation
*/ */
this.read = function(bytes) { this.read = function (bytes) {
if (bytes.charCodeAt(0) == 0x50 && // P if (bytes.charCodeAt(0) == 0x50 && // P
bytes.charCodeAt(1) == 0x47 && // G bytes.charCodeAt(1) == 0x47 && // G
bytes.charCodeAt(2) == 0x50) // P bytes.charCodeAt(2) == 0x50) // P

View File

@ -35,7 +35,7 @@ var enums = require('../enums.js'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function one_pass_signature() {
this.version = null; // A one-octet version number. The current version is 3. this.version = null; // A one-octet version number. The current version is 3.
this.type = null; // A one-octet signature type. Signature types are described in RFC4880 Section 5.2.1. this.type = null; // A one-octet signature type. Signature types are described in RFC4880 Section 5.2.1.
this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See RFC4880 9.4) this.hashAlgorithm = null; // A one-octet number describing the hash algorithm used. (See RFC4880 9.4)
@ -48,7 +48,7 @@ module.exports = function () {
* @param {String} bytes payload of a tag 4 packet * @param {String} bytes payload of a tag 4 packet
* @return {module:packet/one_pass_signature} object representation * @return {module:packet/one_pass_signature} object representation
*/ */
this.read = function(bytes) { this.read = function (bytes) {
var mypos = 0; var mypos = 0;
// A one-octet version number. The current version is 3. // A one-octet version number. The current version is 3.
this.version = bytes.charCodeAt(mypos++); this.version = bytes.charCodeAt(mypos++);
@ -80,7 +80,7 @@ module.exports = function () {
* creates a string representation of a one-pass signature packet * creates a string representation of a one-pass signature packet
* @return {String} a string representation of a one-pass signature packet * @return {String} a string representation of a one-pass signature packet
*/ */
this.write = function() { this.write = function () {
var result = ""; var result = "";
result += String.fromCharCode(3); result += String.fromCharCode(3);

View File

@ -15,7 +15,7 @@ var packetParser = require('./packet.js'),
/** /**
* @constructor * @constructor
*/ */
module.exports = packetlist = function () { module.exports = function packetlist() {
/** The number of packets contained within the list. /** The number of packets contained within the list.
* @readonly * @readonly
* @type {Integer} */ * @type {Integer} */
@ -25,7 +25,7 @@ module.exports = packetlist = function () {
* Reads a stream of binary data and interprents it as a list of packets. * Reads a stream of binary data and interprents it as a list of packets.
* @param {String} A binary string of bytes. * @param {String} A binary string of bytes.
*/ */
this.read = function(bytes) { this.read = function (bytes) {
var i = 0; var i = 0;
while (i < bytes.length) { while (i < bytes.length) {
@ -46,7 +46,7 @@ module.exports = packetlist = function () {
* class instance. * class instance.
* @returns {String} A binary string of bytes containing valid openpgp packets. * @returns {String} A binary string of bytes containing valid openpgp packets.
*/ */
this.write = function() { this.write = function () {
var bytes = ''; var bytes = '';
for (var i = 0; i < this.length; i++) { for (var i = 0; i < this.length; i++) {
@ -62,7 +62,7 @@ module.exports = packetlist = function () {
* Adds a packet to the list. This is the only supported method of doing so; * Adds a packet to the list. This is the only supported method of doing so;
* writing to packetlist[i] directly will result in an error. * writing to packetlist[i] directly will result in an error.
*/ */
this.push = function(packet) { this.push = function (packet) {
if (!packet) return; if (!packet) return;
packet.packets = packet.packets || new packetlist(); packet.packets = packet.packets || new packetlist();
@ -74,7 +74,7 @@ module.exports = packetlist = function () {
/** /**
* Creates a new packetList with all packets that pass the test implemented by the provided function. * Creates a new packetList with all packets that pass the test implemented by the provided function.
*/ */
this.filter = function(callback) { this.filter = function (callback) {
var filtered = new packetlist(); var filtered = new packetlist();
@ -90,7 +90,7 @@ module.exports = packetlist = function () {
/** /**
* Creates a new packetList with all packets from the given types * Creates a new packetList with all packets from the given types
*/ */
this.filterByTag = function() { this.filterByTag = function () {
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
var filtered = new packetlist(); var filtered = new packetlist();
var that = this; var that = this;
@ -107,7 +107,7 @@ module.exports = packetlist = function () {
/** /**
* Executes the provided callback once for each element * Executes the provided callback once for each element
*/ */
this.forEach = function(callback) { this.forEach = function (callback) {
for (var i = 0; i < this.length; i++) { for (var i = 0; i < this.length; i++) {
callback(this[i]); callback(this[i]);
} }
@ -118,7 +118,7 @@ module.exports = packetlist = function () {
* @param {module:enums.packet} type The packet type * @param {module:enums.packet} type The packet type
* @return {module:packet/packet|null} * @return {module:packet/packet|null}
*/ */
this.findPacket = function(type) { this.findPacket = function (type) {
var packetlist = this.filterByTag(type); var packetlist = this.filterByTag(type);
if (packetlist.length) { if (packetlist.length) {
return packetlist[0]; return packetlist[0];
@ -137,7 +137,7 @@ module.exports = packetlist = function () {
/** /**
* Returns array of found indices by tag * Returns array of found indices by tag
*/ */
this.indexOfTag = function() { this.indexOfTag = function () {
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
var tagIndex = []; var tagIndex = [];
var that = this; var that = this;
@ -152,7 +152,7 @@ module.exports = packetlist = function () {
/** /**
* Returns slice of packetlist * Returns slice of packetlist
*/ */
this.slice = function(begin, end) { this.slice = function (begin, end) {
if (!end) { if (!end) {
end = this.length end = this.length
} }
@ -166,7 +166,7 @@ module.exports = packetlist = function () {
/** /**
* Concatenates packetlist or array of packets * Concatenates packetlist or array of packets
*/ */
this.concat = function(packetlist) { this.concat = function (packetlist) {
if (packetlist) { if (packetlist) {
for (var i = 0; i < packetlist.length; i++) { for (var i = 0; i < packetlist.length; i++) {
this.push(packetlist[i]); this.push(packetlist[i]);

View File

@ -39,7 +39,7 @@ var util = require('../util'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function public_key() {
this.version = 4; this.version = 4;
/** Key creation date. /** Key creation date.
* @type {Date} */ * @type {Date} */
@ -61,7 +61,7 @@ module.exports = function () {
* @param {String} input Input string to read the packet from * @param {String} input Input string to read the packet from
* @return {Object} This object with attributes set by the parser * @return {Object} This object with attributes set by the parser
*/ */
this.read = function(bytes) { this.read = function (bytes) {
var pos = 0; var pos = 0;
// A one-octet version number (3 or 4). // A one-octet version number (3 or 4).
this.version = bytes.charCodeAt(pos++); this.version = bytes.charCodeAt(pos++);
@ -117,7 +117,7 @@ module.exports = function () {
* @return {Object} {body: [string]OpenPGP packet body contents, * @return {Object} {body: [string]OpenPGP packet body contents,
* header: [string] OpenPGP packet header, string: [string] header+body} * header: [string] OpenPGP packet header, string: [string] header+body}
*/ */
this.write = function() { this.write = function () {
// Version // Version
var result = String.fromCharCode(this.version); var result = String.fromCharCode(this.version);
result += util.writeDate(this.created); result += util.writeDate(this.created);
@ -145,7 +145,7 @@ module.exports = function () {
/** /**
* Write an old version packet - it's used by some of the internal routines. * Write an old version packet - it's used by some of the internal routines.
*/ */
this.writeOld = function() { this.writeOld = function () {
var bytes = this.writePublicKey(); var bytes = this.writePublicKey();
return String.fromCharCode(0x99) + return String.fromCharCode(0x99) +
@ -157,7 +157,7 @@ module.exports = function () {
* Calculates the key id of the key * Calculates the key id of the key
* @return {String} A 8 byte key id * @return {String} A 8 byte key id
*/ */
this.getKeyId = function() { this.getKeyId = function () {
var keyid = new type_keyid(); var keyid = new type_keyid();
if (this.version == 4) { if (this.version == 4) {
keyid.read(this.getFingerprint().substr(12, 8)); keyid.read(this.getFingerprint().substr(12, 8));
@ -171,7 +171,7 @@ module.exports = function () {
* Calculates the fingerprint of the key * Calculates the fingerprint of the key
* @return {String} A string containing the fingerprint * @return {String} A string containing the fingerprint
*/ */
this.getFingerprint = function() { this.getFingerprint = function () {
var toHash = ''; var toHash = '';
if (this.version == 4) { if (this.version == 4) {
toHash = this.writeOld(); toHash = this.writeOld();

View File

@ -46,7 +46,7 @@ var type_keyid = require('../type/keyid.js'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function public_key_encrypted_session_key() {
this.version = 3; this.version = 3;
this.publicKeyId = new type_keyid(); this.publicKeyId = new type_keyid();
@ -67,7 +67,7 @@ module.exports = function () {
* input at position * input at position
* @return {module:packet/public_key_encrypted_session_key} Object representation * @return {module:packet/public_key_encrypted_session_key} Object representation
*/ */
this.read = function(bytes) { this.read = function (bytes) {
this.version = bytes.charCodeAt(0); this.version = bytes.charCodeAt(0);
this.publicKeyId.read(bytes.substr(1)); this.publicKeyId.read(bytes.substr(1));
@ -116,7 +116,7 @@ module.exports = function () {
* A string of randombytes representing the session key * A string of randombytes representing the session key
* @return {String} The string representation * @return {String} The string representation
*/ */
this.write = function() { this.write = function () {
var result = String.fromCharCode(this.version); var result = String.fromCharCode(this.version);
result += this.publicKeyId.write(); result += this.publicKeyId.write();
@ -130,7 +130,7 @@ module.exports = function () {
return result; return result;
}; };
this.encrypt = function(key) { this.encrypt = function (key) {
var data = String.fromCharCode( var data = String.fromCharCode(
enums.write(enums.symmetric, this.sessionKeyAlgorithm)); enums.write(enums.symmetric, this.sessionKeyAlgorithm));
@ -157,7 +157,7 @@ module.exports = function () {
* Private key with secMPIs unlocked * Private key with secMPIs unlocked
* @return {String} The unencrypted session key * @return {String} The unencrypted session key
*/ */
this.decrypt = function(key) { this.decrypt = function (key) {
var result = crypto.publicKeyDecrypt( var result = crypto.publicKeyDecrypt(
this.publicKeyAlgorithm, this.publicKeyAlgorithm,
key.mpi, key.mpi,

View File

@ -26,6 +26,6 @@ var publicKey = require('./public_key.js');
* @constructor * @constructor
* @extends module:packet/public_key * @extends module:packet/public_key
*/ */
module.exports = function () { module.exports = function public_subkey() {
publicKey.call(this); publicKey.call(this);
} }

View File

@ -42,7 +42,7 @@ var publicKey = require('./public_key.js'),
* @constructor * @constructor
* @extends module:packet/public_key * @extends module:packet/public_key
*/ */
module.exports = function () { module.exports = function secret_key() {
publicKey.call(this); publicKey.call(this);
// encrypted secret-key data // encrypted secret-key data
this.encrypted = null; this.encrypted = null;
@ -114,7 +114,7 @@ module.exports = function () {
* Internal parser for private keys as specified in RFC 4880 section 5.5.3 * Internal parser for private keys as specified in RFC 4880 section 5.5.3
* @param {String} bytes Input string to read the packet from * @param {String} bytes Input string to read the packet from
*/ */
this.read = function(bytes) { this.read = function (bytes) {
// - A Public-Key or Public-Subkey packet, as described above. // - A Public-Key or Public-Subkey packet, as described above.
var len = this.readPublicKey(bytes); var len = this.readPublicKey(bytes);
@ -146,7 +146,7 @@ module.exports = function () {
/** Creates an OpenPGP key packet for the given key. /** Creates an OpenPGP key packet for the given key.
* @return {String} A string of bytes containing the secret key OpenPGP packet * @return {String} A string of bytes containing the secret key OpenPGP packet
*/ */
this.write = function() { this.write = function () {
var bytes = this.writePublicKey(); var bytes = this.writePublicKey();
if (!this.encrypted) { if (!this.encrypted) {
@ -167,7 +167,7 @@ module.exports = function () {
* to key specifier * to key specifier
* @param {String} passphrase * @param {String} passphrase
*/ */
this.encrypt = function(passphrase) { this.encrypt = function (passphrase) {
var s2k = new type_s2k(), var s2k = new type_s2k(),
symmetric = 'aes256', symmetric = 'aes256',
@ -201,7 +201,7 @@ module.exports = function () {
* @return {Boolean} True if the passphrase was correct or MPI already * @return {Boolean} True if the passphrase was correct or MPI already
* decrypted; false if not * decrypted; false if not
*/ */
this.decrypt = function(passphrase) { this.decrypt = function (passphrase) {
if (this.isDecrypted) if (this.isDecrypted)
return true; return true;
@ -256,7 +256,7 @@ module.exports = function () {
return true; return true;
}; };
this.generate = function(bits) { this.generate = function (bits) {
this.mpi = crypto.generateMpi(this.algorithm, bits); this.mpi = crypto.generateMpi(this.algorithm, bits);
this.isDecrypted = true; this.isDecrypted = true;
}; };

View File

@ -26,6 +26,6 @@ var secretKey = require('./secret_key.js');
* @constructor * @constructor
* @extends module:packet/secret_key * @extends module:packet/secret_key
*/ */
module.exports = function () { module.exports = function secret_subkey() {
secretKey.call(this); secretKey.call(this);
} }

View File

@ -41,7 +41,7 @@ var util = require('../util'),
/** /**
* @constructor * @constructor
*/ */
module.exports = packetSignature = function () { module.exports = function signature() {
this.version = 4; this.version = 4;
this.signatureType = null; this.signatureType = null;
@ -93,7 +93,7 @@ module.exports = packetSignature = function () {
* @param {Integer} len length of the packet or the remaining length of bytes at position * @param {Integer} len length of the packet or the remaining length of bytes at position
* @return {module:packet/signature} object representation * @return {module:packet/signature} object representation
*/ */
this.read = function(bytes) { this.read = function (bytes) {
var i = 0; var i = 0;
this.version = bytes.charCodeAt(i++); this.version = bytes.charCodeAt(i++);
@ -181,7 +181,7 @@ module.exports = packetSignature = function () {
this.signature = bytes.substr(i); this.signature = bytes.substr(i);
}; };
this.write = function() { this.write = function () {
return this.signatureData + return this.signatureData +
util.writeNumber(0, 2) + // Number of unsigned subpackets. util.writeNumber(0, 2) + // Number of unsigned subpackets.
this.signedHashValue + this.signedHashValue +
@ -193,7 +193,7 @@ module.exports = packetSignature = function () {
* @param {module:packet/secret_key} key private key used to sign the message. * @param {module:packet/secret_key} key private key used to sign the message.
* @param {Object} data Contains packets to be signed. * @param {Object} data Contains packets to be signed.
*/ */
this.sign = function(key, data) { this.sign = function (key, data) {
var signatureType = enums.write(enums.signature, this.signatureType), var signatureType = enums.write(enums.signature, this.signatureType),
publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm),
hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm);
@ -227,7 +227,7 @@ module.exports = packetSignature = function () {
* Creates string of bytes with all subpacket data * Creates string of bytes with all subpacket data
* @return {String} a string-representation of a all subpacket data * @return {String} a string-representation of a all subpacket data
*/ */
this.write_all_sub_packets = function() { this.write_all_sub_packets = function () {
var sub = enums.signatureSubpacket; var sub = enums.signatureSubpacket;
var result = ''; var result = '';
var bytes = ''; var bytes = '';
@ -350,7 +350,7 @@ module.exports = packetSignature = function () {
// V4 signature sub packets // V4 signature sub packets
this.read_sub_packet = function(bytes) { this.read_sub_packet = function (bytes) {
var mypos = 0; var mypos = 0;
function read_array(prop, bytes) { function read_array(prop, bytes) {
@ -499,7 +499,7 @@ module.exports = packetSignature = function () {
break; break;
case 32: case 32:
// Embedded Signature // Embedded Signature
this.embeddedSignature = new packetSignature(); this.embeddedSignature = new signature();
this.embeddedSignature.read(bytes.substr(mypos)); this.embeddedSignature.read(bytes.substr(mypos));
break; break;
default: default:
@ -509,7 +509,7 @@ module.exports = packetSignature = function () {
}; };
// Produces data to produce signature on // Produces data to produce signature on
this.toSign = function(type, data) { this.toSign = function (type, data) {
var t = enums.signature; var t = enums.signature;
switch (type) { switch (type) {
@ -575,7 +575,7 @@ module.exports = packetSignature = function () {
} }
this.calculateTrailer = function() { this.calculateTrailer = function () {
// calculating the trailer // calculating the trailer
var trailer = ''; var trailer = '';
// V3 signatures don't have a trailer // V3 signatures don't have a trailer
@ -593,7 +593,7 @@ module.exports = packetSignature = function () {
* @param {module:packet/public_subkey|module:packet/public_key} key the public key to verify the signature * @param {module:packet/public_subkey|module:packet/public_key} key the public key to verify the signature
* @return {boolean} True if message is verified, else false. * @return {boolean} True if message is verified, else false.
*/ */
this.verify = function(key, data) { this.verify = function (key, data) {
var signatureType = enums.write(enums.signature, this.signatureType), var signatureType = enums.write(enums.signature, this.signatureType),
publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm), publicKeyAlgorithm = enums.write(enums.publicKey, this.publicKeyAlgorithm),
hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm); hashAlgorithm = enums.write(enums.hash, this.hashAlgorithm);
@ -631,7 +631,7 @@ module.exports = packetSignature = function () {
* Verifies signature expiration date * Verifies signature expiration date
* @return {Boolean} true if expired * @return {Boolean} true if expired
*/ */
this.isExpired = function() { this.isExpired = function () {
if (!this.signatureNeverExpires) { if (!this.signatureNeverExpires) {
return Date.now() > (this.created.getTime() + this.signatureExpirationTime*1000); return Date.now() > (this.created.getTime() + this.signatureExpirationTime*1000);
} }

View File

@ -35,7 +35,7 @@ var util = require('../util'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function sym_encrypted_integrity_protected() {
/** The encrypted payload. */ /** The encrypted payload. */
this.encrypted = null; // string this.encrypted = null; // string
/** /**
@ -48,7 +48,7 @@ module.exports = function () {
this.packets = null; this.packets = null;
this.read = function(bytes) { this.read = function (bytes) {
// - A one-octet version number. The only currently defined value is 1. // - A one-octet version number. The only currently defined value is 1.
var version = bytes.charCodeAt(0); var version = bytes.charCodeAt(0);
@ -62,13 +62,13 @@ module.exports = function () {
this.encrypted = bytes.substr(1); this.encrypted = bytes.substr(1);
}; };
this.write = function() { this.write = function () {
return String.fromCharCode(1) // Version return String.fromCharCode(1) // Version
+ this.encrypted; + this.encrypted;
}; };
this.encrypt = function(sessionKeyAlgorithm, key) { this.encrypt = function (sessionKeyAlgorithm, key) {
var bytes = this.packets.write() var bytes = this.packets.write()
var prefixrandom = crypto.getPrefixRandom(sessionKeyAlgorithm); var prefixrandom = crypto.getPrefixRandom(sessionKeyAlgorithm);
@ -100,7 +100,7 @@ module.exports = function () {
* @param {String} key The key of cipher blocksize length to be used * @param {String} key The key of cipher blocksize length to be used
* @return {String} The decrypted data of this packet * @return {String} The decrypted data of this packet
*/ */
this.decrypt = function(sessionKeyAlgorithm, key) { this.decrypt = function (sessionKeyAlgorithm, key) {
var decrypted = crypto.cfb.decrypt( var decrypted = crypto.cfb.decrypt(
sessionKeyAlgorithm, key, this.encrypted, false); sessionKeyAlgorithm, key, this.encrypted, false);

View File

@ -42,7 +42,7 @@ var type_s2k = require('../type/s2k.js'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function sym_encrypted_session_key() {
this.tag = 3; this.tag = 3;
this.sessionKeyEncryptionAlgorithm = null; this.sessionKeyEncryptionAlgorithm = null;
this.sessionKeyAlgorithm = 'aes256'; this.sessionKeyAlgorithm = 'aes256';

View File

@ -32,7 +32,7 @@ var crypto = require('../crypto');
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function symmetrically_encrypted() {
this.encrypted = null; this.encrypted = null;
/** Decrypted packets contained within. /** Decrypted packets contained within.
* @type {module:packet/packetlist} */ * @type {module:packet/packetlist} */

View File

@ -5,6 +5,6 @@
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function trust() {
}; };

View File

@ -41,7 +41,7 @@ var util = require('../util'),
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function user_attribute() {
this.tag = 17; this.tag = 17;
this.attributes = []; this.attributes = [];

View File

@ -32,7 +32,7 @@ var util = require('../util');
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function userid() {
/** A string containing the user id. Usually in the form /** A string containing the user id. Usually in the form
* John Doe <john@example.com> * John Doe <john@example.com>
* @type {String} * @type {String}

View File

@ -31,7 +31,7 @@ var util = require('../util');
/** /**
* @constructor * @constructor
*/ */
module.exports = function () { module.exports = function keyid() {
this.bytes = ''; this.bytes = '';

View File

@ -49,7 +49,7 @@ module.exports = function mpi() {
* @param {String} input Payload of mpi data * @param {String} input Payload of mpi data
* @return {Integer} Length of data read * @return {Integer} Length of data read
*/ */
this.read = function(bytes) { this.read = function (bytes) {
var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1); var bits = (bytes.charCodeAt(0) << 8) | bytes.charCodeAt(1);
// Additional rules: // Additional rules:
@ -70,15 +70,15 @@ module.exports = function mpi() {
return 2 + bytelen; return 2 + bytelen;
}; };
this.fromBytes = function(bytes) { this.fromBytes = function (bytes) {
this.data = new BigInteger(util.hexstrdump(bytes), 16); this.data = new BigInteger(util.hexstrdump(bytes), 16);
}; };
this.toBytes = function() { this.toBytes = function () {
return this.write().substr(2); return this.write().substr(2);
}; };
this.byteLength = function() { this.byteLength = function () {
return this.toBytes().length; return this.toBytes().length;
}; };
@ -86,15 +86,15 @@ module.exports = function mpi() {
* Converts the mpi object to a string as specified in RFC4880 3.2 * Converts the mpi object to a string as specified in RFC4880 3.2
* @return {String} mpi Byte representation * @return {String} mpi Byte representation
*/ */
this.write = function() { this.write = function () {
return this.data.toMPI(); return this.data.toMPI();
}; };
this.toBigInteger = function() { this.toBigInteger = function () {
return this.data.clone(); return this.data.clone();
}; };
this.fromBigInteger = function(bn) { this.fromBigInteger = function (bn) {
this.data = bn.clone(); this.data = bn.clone();
}; };
} }

View File

@ -51,7 +51,7 @@ module.exports = function s2k() {
// Exponent bias, defined in RFC4880 // Exponent bias, defined in RFC4880
var expbias = 6; var expbias = 6;
this.get_count = function() { this.get_count = function () {
return (16 + (this.c & 15)) << ((this.c >> 4) + expbias); return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
}; };
@ -60,7 +60,7 @@ module.exports = function s2k() {
* @param {String} input Payload of string-to-key specifier * @param {String} input Payload of string-to-key specifier
* @return {Integer} Actual length of the object * @return {Integer} Actual length of the object
*/ */
this.read = function(bytes) { this.read = function (bytes) {
var i = 0; var i = 0;
this.type = enums.read(enums.s2k, bytes.charCodeAt(i++)); this.type = enums.read(enums.s2k, bytes.charCodeAt(i++));
this.algorithm = enums.read(enums.hash, bytes.charCodeAt(i++)); this.algorithm = enums.read(enums.hash, bytes.charCodeAt(i++));
@ -110,7 +110,7 @@ module.exports = function s2k() {
* writes an s2k hash based on the inputs. * writes an s2k hash based on the inputs.
* @return {String} Produced key of hashAlgorithm hash length * @return {String} Produced key of hashAlgorithm hash length
*/ */
this.write = function() { this.write = function () {
var bytes = String.fromCharCode(enums.write(enums.s2k, this.type)); var bytes = String.fromCharCode(enums.write(enums.s2k, this.type));
bytes += String.fromCharCode(enums.write(enums.hash, this.algorithm)); bytes += String.fromCharCode(enums.write(enums.hash, this.algorithm));
@ -136,7 +136,7 @@ module.exports = function s2k() {
* @return {String} Produced key with a length corresponding to * @return {String} Produced key with a length corresponding to
* hashAlgorithm hash length * hashAlgorithm hash length
*/ */
this.produce_key = function(passphrase, numBytes) { this.produce_key = function (passphrase, numBytes) {
passphrase = util.encode_utf8(passphrase); passphrase = util.encode_utf8(passphrase);
function round(prefix, s2k) { function round(prefix, s2k) {