Restructuring and more work on browserify support.
This commit is contained in:
parent
ccc0a4eb48
commit
f421dc0d72
4991
resources/openpgp.js
4991
resources/openpgp.js
File diff suppressed because one or more lines are too long
|
@ -12,6 +12,8 @@
|
||||||
* warranty of any kind.
|
* warranty of any kind.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var util = require('../../util/util.js');
|
||||||
|
|
||||||
function MD5(entree) {
|
function MD5(entree) {
|
||||||
var hex = md5(entree);
|
var hex = md5(entree);
|
||||||
var bin = util.hex2bin(hex);
|
var bin = util.hex2bin(hex);
|
16
src/crypto/index.js
Normal file
16
src/crypto/index.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
cipher: {
|
||||||
|
aes: require('./symmetric/aes.js'),
|
||||||
|
des: require('./symmetric/dessrc.js'),
|
||||||
|
cast5: require('./symmetric/cast5.js'),
|
||||||
|
twofish: require('./symmetric/twofish.js'),
|
||||||
|
blowfish: require('./symmetric/blowfish.js')
|
||||||
|
},
|
||||||
|
hash: {
|
||||||
|
md5: require('./hash/md5.js'),
|
||||||
|
sha: require('./hash/sha.js'),
|
||||||
|
ripemd: require('./hash/ripe-md.js')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
5
src/crypto/package.json
Normal file
5
src/crypto/package.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name": "openpgp-crypto",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"main": "./index.js"
|
||||||
|
}
|
|
@ -12,6 +12,8 @@
|
||||||
* materials provided with the application or distribution.
|
* materials provided with the application or distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var util = require('../../util/util.js');
|
||||||
|
|
||||||
// The round constants used in subkey expansion
|
// The round constants used in subkey expansion
|
||||||
var Rcon = [
|
var Rcon = [
|
||||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
|
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
|
|
@ -385,6 +385,8 @@ Blowfish.prototype.init = function ( key ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var util = require('../../util/util.js');
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
function BFencrypt(block,key) {
|
function BFencrypt(block,key) {
|
||||||
var bf = new Blowfish();
|
var bf = new Blowfish();
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
// CAST5 constructor
|
// CAST5 constructor
|
||||||
|
|
||||||
|
var util = require('../../util/util.js');
|
||||||
|
|
||||||
function cast5_encrypt(block, key) {
|
function cast5_encrypt(block, key) {
|
||||||
var cast5 = new openpgp_symenc_cast5();
|
var cast5 = new openpgp_symenc_cast5();
|
||||||
cast5.setKey(util.str2bin(key));
|
cast5.setKey(util.str2bin(key));
|
|
@ -21,6 +21,8 @@
|
||||||
//des
|
//des
|
||||||
//this takes the key, the message, and whether to encrypt or decrypt
|
//this takes the key, the message, and whether to encrypt or decrypt
|
||||||
|
|
||||||
|
var util = require('../../util/util.js');
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
function desede(block,key) {
|
function desede(block,key) {
|
||||||
var key1 = key.substring(0,8);
|
var key1 = key.substring(0,8);
|
|
@ -18,6 +18,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var util = require('../../util/util.js');
|
||||||
|
|
||||||
// added by Recurity Labs
|
// added by Recurity Labs
|
||||||
function TFencrypt(block, key) {
|
function TFencrypt(block, key) {
|
||||||
var block_copy = [].concat(block);
|
var block_copy = [].concat(block);
|
223
src/enum.js
Normal file
223
src/enum.js
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
module.exports = {
|
||||||
|
/** RFC4880, section 9.1
|
||||||
|
* @enum {String}
|
||||||
|
*/
|
||||||
|
openpgp.publicKey = {
|
||||||
|
rsa_encrypt_sign: 1,
|
||||||
|
rsa_encrypt: 2,
|
||||||
|
rsa_sign: 3,
|
||||||
|
elgamal: 16,
|
||||||
|
dsa: 17
|
||||||
|
};
|
||||||
|
|
||||||
|
/** RFC4880, section 9.2
|
||||||
|
* @enum {String}
|
||||||
|
*/
|
||||||
|
symmetric: {
|
||||||
|
plaintext: 0,
|
||||||
|
/** Not implemented! */
|
||||||
|
idea: 1,
|
||||||
|
tripledes: 2,
|
||||||
|
cast5: 3,
|
||||||
|
blowfish: 4,
|
||||||
|
aes128: 7,
|
||||||
|
aes192: 8,
|
||||||
|
aes256: 9,
|
||||||
|
twofish: 10
|
||||||
|
},
|
||||||
|
|
||||||
|
/** RFC4880, section 9.3
|
||||||
|
* @enum {String}
|
||||||
|
*/
|
||||||
|
compression: {
|
||||||
|
uncompressed: 0,
|
||||||
|
/** RFC1951 */
|
||||||
|
zip: 1,
|
||||||
|
/** RFC1950 */
|
||||||
|
zlib: 2,
|
||||||
|
bzip2: 3
|
||||||
|
},
|
||||||
|
|
||||||
|
/** RFC4880, section 9.4
|
||||||
|
* @enum {String}
|
||||||
|
*/
|
||||||
|
hash: {
|
||||||
|
md5: 1,
|
||||||
|
sha1: 2,
|
||||||
|
ripemd: 3,
|
||||||
|
sha256: 8,
|
||||||
|
sha384: 9,
|
||||||
|
sha512: 10,
|
||||||
|
sha224: 11
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {String}
|
||||||
|
* A list of packet types and numeric tags associated with them.
|
||||||
|
*/
|
||||||
|
packet: {
|
||||||
|
reserved: 0,
|
||||||
|
public_key_encrypted_session_key: 1,
|
||||||
|
signature: 2,
|
||||||
|
sym_encrypted_session_key: 3,
|
||||||
|
one_pass_signature: 4,
|
||||||
|
secret_key: 5,
|
||||||
|
public_key: 6,
|
||||||
|
secret_subkey: 7,
|
||||||
|
compressed: 8,
|
||||||
|
symmetrically_encrypted: 9,
|
||||||
|
marker: 10,
|
||||||
|
literal: 11,
|
||||||
|
trust: 12,
|
||||||
|
userid: 13,
|
||||||
|
public_subkey: 14,
|
||||||
|
user_attribute: 17,
|
||||||
|
sym_encrypted_integrity_protected: 18,
|
||||||
|
modification_detection_code: 19
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data types in the literal packet
|
||||||
|
* @readonly
|
||||||
|
* @enum {String}
|
||||||
|
*/
|
||||||
|
literal: {
|
||||||
|
/** Binary data */
|
||||||
|
binary: 'b'.charCodeAt(),
|
||||||
|
/** Text data */
|
||||||
|
text: 't'.charCodeAt(),
|
||||||
|
/** Utf8 data */
|
||||||
|
utf8: 'u'.charCodeAt()
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** One pass signature packet type
|
||||||
|
* @enum {String} */
|
||||||
|
signature: {
|
||||||
|
/** 0x00: Signature of a binary document. */
|
||||||
|
binary: 0,
|
||||||
|
/** 0x01: Signature of a canonical text document.
|
||||||
|
* Canonicalyzing the document by converting line endings. */
|
||||||
|
text: 1,
|
||||||
|
/** 0x02: Standalone signature.
|
||||||
|
* This signature is a signature of only its own subpacket contents.
|
||||||
|
* It is calculated identically to a signature over a zero-lengh
|
||||||
|
* binary document. Note that it doesn't make sense to have a V3
|
||||||
|
* standalone signature. */
|
||||||
|
standalone: 2,
|
||||||
|
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
||||||
|
* The issuer of this certification does not make any particular
|
||||||
|
* assertion as to how well the certifier has checked that the owner
|
||||||
|
* of the key is in fact the person described by the User ID. */
|
||||||
|
cert_generic: 16,
|
||||||
|
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
||||||
|
* The issuer of this certification has not done any verification of
|
||||||
|
* the claim that the owner of this key is the User ID specified. */
|
||||||
|
cert_persona: 17,
|
||||||
|
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
||||||
|
* The issuer of this certification has done some casual
|
||||||
|
* verification of the claim of identity. */
|
||||||
|
cert_casual: 18,
|
||||||
|
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
||||||
|
* The issuer of this certification has done substantial
|
||||||
|
* verification of the claim of identity.
|
||||||
|
*
|
||||||
|
* Most OpenPGP implementations make their "key signatures" as 0x10
|
||||||
|
* certifications. Some implementations can issue 0x11-0x13
|
||||||
|
* certifications, but few differentiate between the types. */
|
||||||
|
cert_positive: 19,
|
||||||
|
/** 0x30: Certification revocation signature
|
||||||
|
* This signature revokes an earlier User ID certification signature
|
||||||
|
* (signature class 0x10 through 0x13) or direct-key signature
|
||||||
|
* (0x1F). It should be issued by the same key that issued the
|
||||||
|
* revoked signature or an authorized revocation key. The signature
|
||||||
|
* is computed over the same data as the certificate that it
|
||||||
|
* revokes, and should have a later creation date than that
|
||||||
|
* certificate. */
|
||||||
|
cert_revocation: 48,
|
||||||
|
/** 0x18: Subkey Binding Signature
|
||||||
|
* This signature is a statement by the top-level signing key that
|
||||||
|
* indicates that it owns the subkey. This signature is calculated
|
||||||
|
* directly on the primary key and subkey, and not on any User ID or
|
||||||
|
* other packets. A signature that binds a signing subkey MUST have
|
||||||
|
* an Embedded Signature subpacket in this binding signature that
|
||||||
|
* contains a 0x19 signature made by the signing subkey on the
|
||||||
|
* primary key and subkey. */
|
||||||
|
subkey_binding: 24,
|
||||||
|
/** 0x19: Primary Key Binding Signature
|
||||||
|
* This signature is a statement by a signing subkey, indicating
|
||||||
|
* that it is owned by the primary key and subkey. This signature
|
||||||
|
* is calculated the same way as a 0x18 signature: directly on the
|
||||||
|
* primary key and subkey, and not on any User ID or other packets.
|
||||||
|
|
||||||
|
* When a signature is made over a key, the hash data starts with the
|
||||||
|
* octet 0x99, followed by a two-octet length of the key, and then body
|
||||||
|
* of the key packet. (Note that this is an old-style packet header for
|
||||||
|
* a key packet with two-octet length.) A subkey binding signature
|
||||||
|
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
||||||
|
* the subkey using the same format as the main key (also using 0x99 as
|
||||||
|
* the first octet). */
|
||||||
|
key_binding: 25,
|
||||||
|
/** 0x1F: Signature directly on a key
|
||||||
|
* This signature is calculated directly on a key. It binds the
|
||||||
|
* information in the Signature subpackets to the key, and is
|
||||||
|
* appropriate to be used for subpackets that provide information
|
||||||
|
* about the key, such as the Revocation Key subpacket. It is also
|
||||||
|
* appropriate for statements that non-self certifiers want to make
|
||||||
|
* about the key itself, rather than the binding between a key and a
|
||||||
|
* name. */
|
||||||
|
key: 31,
|
||||||
|
/** 0x20: Key revocation signature
|
||||||
|
* The signature is calculated directly on the key being revoked. A
|
||||||
|
* revoked key is not to be used. Only revocation signatures by the
|
||||||
|
* key being revoked, or by an authorized revocation key, should be
|
||||||
|
* considered valid revocation signatures.a */
|
||||||
|
key_revocation: 32,
|
||||||
|
/** 0x28: Subkey revocation signature
|
||||||
|
* The signature is calculated directly on the subkey being revoked.
|
||||||
|
* A revoked subkey is not to be used. Only revocation signatures
|
||||||
|
* by the top-level signature key that is bound to this subkey, or
|
||||||
|
* by an authorized revocation key, should be considered valid
|
||||||
|
* revocation signatures.
|
||||||
|
* Key revocation signatures (types 0x20 and 0x28)
|
||||||
|
* hash only the key being revoked. */
|
||||||
|
subkey_revocation: 40,
|
||||||
|
/** 0x40: Timestamp signature.
|
||||||
|
* This signature is only meaningful for the timestamp contained in
|
||||||
|
* it. */
|
||||||
|
timestamp: 64,
|
||||||
|
/** 0x50: Third-Party Confirmation signature.
|
||||||
|
* This signature is a signature over some other OpenPGP Signature
|
||||||
|
* packet(s). It is analogous to a notary seal on the signed data.
|
||||||
|
* A third-party signature SHOULD include Signature Target
|
||||||
|
* subpacket(s) to give easy identification. Note that we really do
|
||||||
|
* mean SHOULD. There are plausible uses for this (such as a blind
|
||||||
|
* party that only sees the signature, not the key or source
|
||||||
|
* document) that cannot include a target subpacket. */
|
||||||
|
third_party: 80
|
||||||
|
},
|
||||||
|
|
||||||
|
// Asserts validity and converts from string/integer to integer.
|
||||||
|
write: function(type, e) {
|
||||||
|
if(typeof n == 'number') {
|
||||||
|
e = this.read(type, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type[e] != undefined) {
|
||||||
|
return type[e];
|
||||||
|
} else throw new Error('Invalid enum value.');
|
||||||
|
},
|
||||||
|
// Converts from an integer to string.
|
||||||
|
read: function(type, e) {
|
||||||
|
for(var i in type)
|
||||||
|
if(type[i] == e) return type[e];
|
||||||
|
|
||||||
|
throw new Error('Invalid enum value.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -458,71 +458,8 @@ function _openpgp () {
|
||||||
|
|
||||||
var openpgp = new _openpgp();
|
var openpgp = new _openpgp();
|
||||||
|
|
||||||
/** RFC4880, section 9.1
|
var crypto = require('./crypto');
|
||||||
* @enum {Integer}
|
|
||||||
*/
|
|
||||||
openpgp.publickey = {
|
|
||||||
rsa_encrypt_sign: 1,
|
|
||||||
rsa_encrypt: 2,
|
|
||||||
rsa_sign: 3,
|
|
||||||
elgamal: 16,
|
|
||||||
dsa: 17
|
|
||||||
};
|
|
||||||
|
|
||||||
/** RFC4880, section 9.2
|
module.exports = crypto;
|
||||||
* @enum {Integer}
|
module.exports.util = require('./util/util.js');
|
||||||
*/
|
|
||||||
openpgp.symmetric = {
|
|
||||||
plaintext: 0,
|
|
||||||
/** Not implemented! */
|
|
||||||
idea: 1,
|
|
||||||
tripledes: 2,
|
|
||||||
cast5: 3,
|
|
||||||
blowfish: 4,
|
|
||||||
aes128: 7,
|
|
||||||
aes192: 8,
|
|
||||||
aes256: 9,
|
|
||||||
twofish: 10
|
|
||||||
};
|
|
||||||
|
|
||||||
/** RFC4880, section 9.3
|
|
||||||
* @enum {Integer}
|
|
||||||
*/
|
|
||||||
openpgp.compression = {
|
|
||||||
uncompressed: 0,
|
|
||||||
/** RFC1951 */
|
|
||||||
zip: 1,
|
|
||||||
/** RFC1950 */
|
|
||||||
zlib: 2,
|
|
||||||
bzip2: 3
|
|
||||||
};
|
|
||||||
|
|
||||||
/** RFC4880, section 9.4
|
|
||||||
* @enum {Integer}
|
|
||||||
*/
|
|
||||||
openpgp.hash = {
|
|
||||||
md5: 1,
|
|
||||||
sha1: 2,
|
|
||||||
ripemd: 3,
|
|
||||||
sha256: 8,
|
|
||||||
sha384: 9,
|
|
||||||
sha512: 10,
|
|
||||||
sha224: 11
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
cipher: {
|
|
||||||
aes: require('./ciphers/symmetric/aes.js'),
|
|
||||||
des: require('./ciphers/symmetric/dessrc.js'),
|
|
||||||
cast5: require('./ciphers/symmetric/cast5.js'),
|
|
||||||
twofish: require('./ciphers/symmetric/twofish.js'),
|
|
||||||
blowfish: require('./ciphers/symmetric/blowfish.js')
|
|
||||||
},
|
|
||||||
hash: {
|
|
||||||
md5: require('./ciphers/hash/md5.js'),
|
|
||||||
sha: require('./ciphers/hash/sha.js'),
|
|
||||||
ripemd: require('./ciphers/hash/ripe-md.js')
|
|
||||||
},
|
|
||||||
util: require('./util/util.js')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
var packetlist = require('./packetlist.js'),
|
||||||
|
enums = require('../enums.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
* @classdesc Implementation of the Compressed Data Packet (Tag 8)
|
* @classdesc Implementation of the Compressed Data Packet (Tag 8)
|
||||||
|
@ -25,10 +28,12 @@
|
||||||
* a Signature or One-Pass Signature packet, and contains a literal data
|
* a Signature or One-Pass Signature packet, and contains a literal data
|
||||||
* packet.
|
* packet.
|
||||||
*/
|
*/
|
||||||
function openpgp_packet_compressed() {
|
function packet_compressed() {
|
||||||
this.tag = 8;
|
/** @type {packetlist} */
|
||||||
this.packets = new openpgp_packetlist();
|
this.packets = new packetlist();
|
||||||
this.algorithm = openpgp.compression.uncompressed;
|
/** @type {compression} */
|
||||||
|
this.algorithm = 'uncompressed';
|
||||||
|
|
||||||
this.compressed = null;
|
this.compressed = null;
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +47,8 @@ function openpgp_packet_compressed() {
|
||||||
*/
|
*/
|
||||||
this.read = function(bytes) {
|
this.read = function(bytes) {
|
||||||
// One octet that gives the algorithm used to compress the packet.
|
// One octet that gives the algorithm used to compress the packet.
|
||||||
this.algorithm = bytes.charCodeAt(0);
|
this.algorithm = enums.read(enums.compression, bytes.charCodeAt(0));
|
||||||
|
|
||||||
// Compressed data, which makes up the remainder of the packet.
|
// Compressed data, which makes up the remainder of the packet.
|
||||||
this.compressed = bytes.substr(1);
|
this.compressed = bytes.substr(1);
|
||||||
|
|
||||||
|
@ -55,7 +61,8 @@ function openpgp_packet_compressed() {
|
||||||
if(this.compressed == null)
|
if(this.compressed == null)
|
||||||
this.compress();
|
this.compress();
|
||||||
|
|
||||||
return String.fromCharCode(this.type) + this.compressed;
|
return String.fromCharCode(enums.write(enums.compression, this.algorithm))
|
||||||
|
+ this.compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,12 +75,11 @@ function openpgp_packet_compressed() {
|
||||||
var decompressed;
|
var decompressed;
|
||||||
|
|
||||||
switch (this.algorithm) {
|
switch (this.algorithm) {
|
||||||
case openpgp.compression.uncompressed:
|
case 'uncompressed':
|
||||||
decompressed = this.compressed;
|
decompressed = this.compressed;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case openpgp.compression.zip:
|
case 'zip':
|
||||||
util.print_info('Decompressed packet [Type 1-ZIP]: ' + this.toString());
|
|
||||||
var compData = this.compressed;
|
var compData = this.compressed;
|
||||||
|
|
||||||
var radix = s2r(compData).replace(/\n/g,"");
|
var radix = s2r(compData).replace(/\n/g,"");
|
||||||
|
@ -83,8 +89,7 @@ function openpgp_packet_compressed() {
|
||||||
decompressed = unescape(jxg_obj.deflate()[0][0]);
|
decompressed = unescape(jxg_obj.deflate()[0][0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case openpgp.compression.zlib:
|
case 'zlib':
|
||||||
util.print_info('Decompressed packet [Type 2-ZLIB]: ' + this.toString());
|
|
||||||
//RFC 1950. Bits 0-3 Compression Method
|
//RFC 1950. Bits 0-3 Compression Method
|
||||||
var compressionMethod = this.compressed.charCodeAt(0) % 0x10;
|
var compressionMethod = this.compressed.charCodeAt(0) % 0x10;
|
||||||
|
|
||||||
|
@ -106,18 +111,16 @@ function openpgp_packet_compressed() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case openpgp.compression.bzip2:
|
case 'bzip2':
|
||||||
// TODO: need to implement this
|
// TODO: need to implement this
|
||||||
util.print_error("Compression algorithm BZip2 [BZ2] is not implemented.");
|
throw new Error('Compression algorithm BZip2 [BZ2] is not implemented.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
util.print_error("Compression algorithm unknown :"+this.type);
|
throw new Error("Compression algorithm unknown :" + this.alogrithm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
util.print_debug("decompressed:"+util.hexstrdump(decompressed));
|
|
||||||
|
|
||||||
this.packets.read(decompressed);
|
this.packets.read(decompressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,22 +131,22 @@ function openpgp_packet_compressed() {
|
||||||
* @return {String} The compressed data stored in attribute compressedData
|
* @return {String} The compressed data stored in attribute compressedData
|
||||||
*/
|
*/
|
||||||
this.compress = function() {
|
this.compress = function() {
|
||||||
switch (this.type) {
|
switch (this.algorithm) {
|
||||||
|
|
||||||
case openpgp.compression.uncompressed: // - Uncompressed
|
case 'uncompressed': // - Uncompressed
|
||||||
this.compressed = this.packets.write();
|
this.compressed = this.packets.write();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case openpgp.compression.zip: // - ZIP [RFC1951]
|
case 'zip': // - ZIP [RFC1951]
|
||||||
util.print_error("Compression algorithm ZIP [RFC1951] is not implemented.");
|
util.print_error("Compression algorithm ZIP [RFC1951] is not implemented.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case openpgp.compression.zlib: // - ZLIB [RFC1950]
|
case 'zlib': // - ZLIB [RFC1950]
|
||||||
// TODO: need to implement this
|
// TODO: need to implement this
|
||||||
util.print_error("Compression algorithm ZLIB [RFC1950] is not implemented.");
|
util.print_error("Compression algorithm ZLIB [RFC1950] is not implemented.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case openpgp.compression.bzip2: // - BZip2 [BZ2]
|
case 'bzip2': // - BZip2 [BZ2]
|
||||||
// TODO: need to implement this
|
// TODO: need to implement this
|
||||||
util.print_error("Compression algorithm BZip2 [BZ2] is not implemented.");
|
util.print_error("Compression algorithm BZip2 [BZ2] is not implemented.");
|
||||||
break;
|
break;
|
||||||
|
|
14
src/packet/index.js
Normal file
14
src/packet/index.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
var enums = require('../enums.js');
|
||||||
|
|
||||||
|
module.exports {
|
||||||
|
list: require('./packetlist.js')
|
||||||
|
}
|
||||||
|
|
||||||
|
// This need to be invoked before we do stuff with individual packets.
|
||||||
|
for(var i in enums.packets) {
|
||||||
|
var packet = require('./' + i + '.js');
|
||||||
|
|
||||||
|
// Setting the tag in one place.
|
||||||
|
packet.prototype.tag = enum.packets[i];
|
||||||
|
}
|
|
@ -22,9 +22,8 @@
|
||||||
* RFC4880 5.9: A Literal Data packet contains the body of a message; data that
|
* RFC4880 5.9: A Literal Data packet contains the body of a message; data that
|
||||||
* is not to be further interpreted.
|
* is not to be further interpreted.
|
||||||
*/
|
*/
|
||||||
function openpgp_packet_literal() {
|
function literal() {
|
||||||
this.tag = 11;
|
this.format = 'utf8';
|
||||||
this.format = openpgp_packet_literal.format.utf8;
|
|
||||||
this.data = '';
|
this.data = '';
|
||||||
this.date = new Date();
|
this.date = new Date();
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ function openpgp_packet_literal() {
|
||||||
* @param {String} str Any native javascript string
|
* @param {String} str Any native javascript string
|
||||||
* @param {openpgp_packet_literaldata.format} format
|
* @param {openpgp_packet_literaldata.format} format
|
||||||
*/
|
*/
|
||||||
this.set_data = function(str, format) {
|
this.set = function(str, format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.data = str;
|
this.data = str;
|
||||||
}
|
}
|
||||||
|
@ -47,10 +46,10 @@ function openpgp_packet_literal() {
|
||||||
* @param {String} bytes The string of bytes
|
* @param {String} bytes The string of bytes
|
||||||
* @param {openpgp_packet_literaldata.format} format
|
* @param {openpgp_packet_literaldata.format} format
|
||||||
*/
|
*/
|
||||||
this.set_data_bytes = function(bytes, format) {
|
this.setBytes = function(bytes, format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
|
|
||||||
if(format == openpgp_packet_literal.format.utf8)
|
if(format == 'utf8')
|
||||||
bytes = util.decode_utf8(bytes);
|
bytes = util.decode_utf8(bytes);
|
||||||
|
|
||||||
this.data = bytes;
|
this.data = bytes;
|
||||||
|
@ -60,8 +59,8 @@ function openpgp_packet_literal() {
|
||||||
* 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.get_data_bytes = function() {
|
this.getBytes = function() {
|
||||||
if(this.format == openpgp_packet_literal.format.utf8)
|
if(this.format == 'utf8')
|
||||||
return util.encode_utf8(this.data);
|
return util.encode_utf8(this.data);
|
||||||
else
|
else
|
||||||
return this.data;
|
return this.data;
|
||||||
|
@ -83,7 +82,7 @@ function openpgp_packet_literal() {
|
||||||
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 = bytes[0];
|
var format = enums.read(bytes[0]);
|
||||||
|
|
||||||
var filename_len = bytes.charCodeAt(1);
|
var filename_len = bytes.charCodeAt(1);
|
||||||
this.filename = util.decode_utf8(bytes.substr(2, filename_len));
|
this.filename = util.decode_utf8(bytes.substr(2, filename_len));
|
||||||
|
@ -108,38 +107,12 @@ function openpgp_packet_literal() {
|
||||||
var data = this.get_data_bytes();
|
var data = this.get_data_bytes();
|
||||||
|
|
||||||
var result = '';
|
var result = '';
|
||||||
result += this.format;
|
result += enums.write(this.format);
|
||||||
result += String.fromCharCode(filename.length);
|
result += String.fromCharCode(filename.length);
|
||||||
result += filename;
|
result += filename;
|
||||||
result += openpgp_packet_time_write(this.date);
|
result += openpgp_packet_time_write(this.date);
|
||||||
result += data;
|
result += data;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates debug output (pretty print)
|
|
||||||
*
|
|
||||||
* @return {String} String which gives some information about the keymaterial
|
|
||||||
*/
|
|
||||||
this.toString = function() {
|
|
||||||
return '5.9. Literal Data Packet (Tag 11)\n' + ' length: '
|
|
||||||
+ this.packetLength + '\n' + ' format: ' + this.format
|
|
||||||
+ '\n' + ' filename:' + this.filename + '\n'
|
|
||||||
+ ' date: ' + this.date + '\n' + ' data: |'
|
|
||||||
+ this.data + '|\n' + ' rdata: |' + this.real_data + '|\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Data types in the literal packet
|
|
||||||
* @readonly
|
|
||||||
* @enum {String}
|
|
||||||
*/
|
|
||||||
openpgp_packet_literal.format = {
|
|
||||||
/** Binary data */
|
|
||||||
binary: 'b',
|
|
||||||
/** Text data */
|
|
||||||
text: 't',
|
|
||||||
/** Utf8 data */
|
|
||||||
utf8: 'u'
|
|
||||||
};
|
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
* Such a packet MUST be ignored when received.
|
* Such a packet MUST be ignored when received.
|
||||||
*/
|
*/
|
||||||
function openpgp_packet_marker() {
|
function openpgp_packet_marker() {
|
||||||
this.tag = 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing function for a literal data packet (tag 10).
|
* Parsing function for a literal data packet (tag 10).
|
||||||
*
|
*
|
||||||
|
|
|
@ -26,8 +26,10 @@
|
||||||
* packet to be placed at the end of the message, so that the signer
|
* packet to be placed at the end of the message, so that the signer
|
||||||
* can compute the entire signed message in one pass.
|
* can compute the entire signed message in one pass.
|
||||||
*/
|
*/
|
||||||
function openpgp_packet_one_pass_signature() {
|
|
||||||
this.tag = 4;
|
var enums = require('../enums.js');
|
||||||
|
|
||||||
|
function packet_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)
|
||||||
|
@ -49,13 +51,14 @@ function openpgp_packet_one_pass_signature() {
|
||||||
|
|
||||||
// A one-octet signature type. Signature types are described in
|
// A one-octet signature type. Signature types are described in
|
||||||
// Section 5.2.1.
|
// Section 5.2.1.
|
||||||
this.type = bytes.charCodeAt(mypos++);
|
this.type = enums.read(enums.signature, bytes.charCodeAt(mypos++));
|
||||||
|
|
||||||
// A one-octet number describing the hash algorithm used.
|
// A one-octet number describing the hash algorithm used.
|
||||||
this.hashAlgorithm = bytes.charCodeAt(mypos++);
|
this.hashAlgorithm = enums.read(enums.hash, bytes.charCodeAt(mypos++));
|
||||||
|
|
||||||
// A one-octet number describing the public-key algorithm used.
|
// A one-octet number describing the public-key algorithm used.
|
||||||
this.publicKeyAlgorithm = bytes.charCodeAt(mypos++);
|
this.publicKeyAlgorithm = enums.read(enums.publicKey, bytes.charCodeAt(mypos++));
|
||||||
|
|
||||||
// An eight-octet number holding the Key ID of the signing key.
|
// An eight-octet number holding the Key ID of the signing key.
|
||||||
this.signingKeyId = new openpgp_type_keyid();
|
this.signingKeyId = new openpgp_type_keyid();
|
||||||
this.signingKeyId.read_packet(bytes,mypos);
|
this.signingKeyId.read_packet(bytes,mypos);
|
||||||
|
@ -80,13 +83,13 @@ function openpgp_packet_one_pass_signature() {
|
||||||
* that describes another signature to be applied to the same message data.
|
* that describes another signature to be applied to the same message data.
|
||||||
* @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(type, hashalgorithm, privatekey,length, nested) {
|
this.write = function(type, hashalgorithm, privatekey, length, nested) {
|
||||||
var result ="";
|
var result ="";
|
||||||
|
|
||||||
result += String.fromCharCode(3);
|
result += String.fromCharCode(3);
|
||||||
result += String.fromCharCode(type);
|
result += String.fromCharCode(enums.write(enums.signature, type));
|
||||||
result += String.fromCharCode(this.hashAlgorithm);
|
result += String.fromCharCode(enums.write(enums.hash, this.hashAlgorithm));
|
||||||
result += String.fromCharCode(privatekey.privateKeyPacket.publicKey.publicKeyAlgorithm);
|
result += String.fromCharCode(enums.write(enums.publicKey, privatekey.algorithm));
|
||||||
result += privatekey.getKeyId();
|
result += privatekey.getKeyId();
|
||||||
if (nested)
|
if (nested)
|
||||||
result += String.fromCharCode(0);
|
result += String.fromCharCode(0);
|
||||||
|
|
5
src/packet/package.json
Normal file
5
src/packet/package.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name": "openpgp-packets",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"main": "./index.js"
|
||||||
|
}
|
|
@ -15,14 +15,11 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
/**
|
var enums = require('./enum.js');
|
||||||
* @class
|
|
||||||
* @classdesc Parent openpgp packet class. Operations focus on determining
|
|
||||||
* packet types and packet header.
|
|
||||||
*/
|
|
||||||
function _openpgp_packet() {
|
|
||||||
|
|
||||||
this.read_simple_length = function(bytes) {
|
|
||||||
|
module.exports = {
|
||||||
|
readSimpleLength: function(bytes) {
|
||||||
var len = 0,
|
var len = 0,
|
||||||
offset,
|
offset,
|
||||||
type = bytes[0].charCodeAt();
|
type = bytes[0].charCodeAt();
|
||||||
|
@ -40,7 +37,7 @@ function _openpgp_packet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return { len: len, offset: offset };
|
return { len: len, offset: offset };
|
||||||
}
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes a given integer of length to the openpgp length specifier to a
|
* Encodes a given integer of length to the openpgp length specifier to a
|
||||||
|
@ -49,7 +46,7 @@ function _openpgp_packet() {
|
||||||
* @param {Integer} length The length to encode
|
* @param {Integer} length The length to encode
|
||||||
* @return {String} String with openpgp length representation
|
* @return {String} String with openpgp length representation
|
||||||
*/
|
*/
|
||||||
this.encode_length = function(length) {
|
writeSimpleLength: function(length) {
|
||||||
var result = "";
|
var result = "";
|
||||||
if (length < 192) {
|
if (length < 192) {
|
||||||
result += String.fromCharCode(length);
|
result += String.fromCharCode(length);
|
||||||
|
@ -78,7 +75,7 @@ function _openpgp_packet() {
|
||||||
* @param {Integer} length Length of the payload
|
* @param {Integer} length Length of the payload
|
||||||
* @return {String} String of the header
|
* @return {String} String of the header
|
||||||
*/
|
*/
|
||||||
this.write_packet_header = function(tag_type, length) {
|
writeHeader: function(tag_type, length) {
|
||||||
/* we're only generating v4 packet headers here */
|
/* we're only generating v4 packet headers here */
|
||||||
var result = "";
|
var result = "";
|
||||||
result += String.fromCharCode(0xC0 | tag_type);
|
result += String.fromCharCode(0xC0 | tag_type);
|
||||||
|
@ -94,7 +91,7 @@ function _openpgp_packet() {
|
||||||
* @param {Integer} length Length of the payload
|
* @param {Integer} length Length of the payload
|
||||||
* @return {String} String of the header
|
* @return {String} String of the header
|
||||||
*/
|
*/
|
||||||
this.write_old_packet_header = function(tag_type, length) {
|
writeOldHeader: function(tag_type, length) {
|
||||||
var result = "";
|
var result = "";
|
||||||
if (length < 256) {
|
if (length < 256) {
|
||||||
result += String.fromCharCode(0x80 | (tag_type << 2));
|
result += String.fromCharCode(0x80 | (tag_type << 2));
|
||||||
|
@ -299,46 +296,5 @@ function _openpgp_packet() {
|
||||||
offset: mypos + real_packet_length
|
offset: mypos + real_packet_length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {Integer}
|
|
||||||
* A list of packet type and numeric tags associated with them.
|
|
||||||
*/
|
|
||||||
this.type = {
|
|
||||||
reserved: 0,
|
|
||||||
public_key_encrypted_session_key: 1,
|
|
||||||
signature: 2,
|
|
||||||
sym_encrypted_session_key: 3,
|
|
||||||
one_pass_signature: 4,
|
|
||||||
secret_key: 5,
|
|
||||||
public_key: 6,
|
|
||||||
secret_subkey: 7,
|
|
||||||
compressed: 8,
|
|
||||||
symmetrically_encrypted: 9,
|
|
||||||
marker: 10,
|
|
||||||
literal: 11,
|
|
||||||
trust: 12,
|
|
||||||
userid: 13,
|
|
||||||
public_subkey: 14,
|
|
||||||
user_attribute: 17,
|
|
||||||
sym_encrypted_integrity_protected: 18,
|
|
||||||
modification_detection_code: 19
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
TODO Invoke this code instead of putting a tag variable
|
|
||||||
inside each and every packet class. Right now we don't
|
|
||||||
know whether or not they have been loaded yet.
|
|
||||||
|
|
||||||
for(var i in this.type) {
|
|
||||||
var classname = 'openpgp_packet_' + i;
|
|
||||||
window[classname].prototype.tag = this.type[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var openpgp_packet = new _openpgp_packet();
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Take care when iterating over it - the packets themselves
|
* Take care when iterating over it - the packets themselves
|
||||||
* are stored as numerical indices.
|
* are stored as numerical indices.
|
||||||
*/
|
*/
|
||||||
function openpgp_packetlist() {
|
function packetlist() {
|
||||||
/** The number of packets contained within the list.
|
/** The number of packets contained within the list.
|
||||||
* @readonly
|
* @readonly
|
||||||
* @type {Integer} */
|
* @type {Integer} */
|
||||||
|
@ -52,3 +52,5 @@ function openpgp_packetlist() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = packetlist;
|
||||||
|
|
|
@ -134,8 +134,3 @@ function openpgp_packet_public_key() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openpgp_packet_public_subkey() {
|
|
||||||
openpgp_packet_public_key.call(this);
|
|
||||||
this.tag = 14;
|
|
||||||
}
|
|
||||||
|
|
25
src/packet/public_subkey.js
Normal file
25
src/packet/public_subkey.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
||||||
|
// Copyright (C) 2011 Recurity Labs GmbH
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
var public_key = require('./public_key.js');
|
||||||
|
|
||||||
|
function public_subkey() {
|
||||||
|
public_key.call(this);
|
||||||
|
this.tag = 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = public_subkey;
|
|
@ -307,9 +307,3 @@ function openpgp_packet_secret_key() {
|
||||||
|
|
||||||
openpgp_packet_secret_key.prototype = new openpgp_packet_public_key();
|
openpgp_packet_secret_key.prototype = new openpgp_packet_public_key();
|
||||||
|
|
||||||
|
|
||||||
function openpgp_packet_secret_subkey() {
|
|
||||||
openpgp_packet_secret_key.call(this);
|
|
||||||
this.tag = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
25
src/packet/secret_subkey.js
Normal file
25
src/packet/secret_subkey.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
||||||
|
// Copyright (C) 2011 Recurity Labs GmbH
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
var secret_key = require('./secret_key.js');
|
||||||
|
|
||||||
|
function secret_subkey() {
|
||||||
|
secret_key.call(this);
|
||||||
|
this.tag = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = secret_subkey.js;
|
|
@ -477,110 +477,3 @@ function openpgp_packet_signature() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** One pass signature packet type
|
|
||||||
* @enum {Integer} */
|
|
||||||
openpgp_packet_signature.type = {
|
|
||||||
/** 0x00: Signature of a binary document. */
|
|
||||||
binary: 0,
|
|
||||||
/** 0x01: Signature of a canonical text document.
|
|
||||||
* Canonicalyzing the document by converting line endings. */
|
|
||||||
text: 1,
|
|
||||||
/** 0x02: Standalone signature.
|
|
||||||
* This signature is a signature of only its own subpacket contents.
|
|
||||||
* It is calculated identically to a signature over a zero-lengh
|
|
||||||
* binary document. Note that it doesn't make sense to have a V3
|
|
||||||
* standalone signature. */
|
|
||||||
standalone: 2,
|
|
||||||
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
||||||
* The issuer of this certification does not make any particular
|
|
||||||
* assertion as to how well the certifier has checked that the owner
|
|
||||||
* of the key is in fact the person described by the User ID. */
|
|
||||||
cert_generic: 16,
|
|
||||||
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
||||||
* The issuer of this certification has not done any verification of
|
|
||||||
* the claim that the owner of this key is the User ID specified. */
|
|
||||||
cert_persona: 17,
|
|
||||||
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
||||||
* The issuer of this certification has done some casual
|
|
||||||
* verification of the claim of identity. */
|
|
||||||
cert_casual: 18,
|
|
||||||
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
||||||
* The issuer of this certification has done substantial
|
|
||||||
* verification of the claim of identity.
|
|
||||||
*
|
|
||||||
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
||||||
* certifications. Some implementations can issue 0x11-0x13
|
|
||||||
* certifications, but few differentiate between the types. */
|
|
||||||
cert_positive: 19,
|
|
||||||
/** 0x30: Certification revocation signature
|
|
||||||
* This signature revokes an earlier User ID certification signature
|
|
||||||
* (signature class 0x10 through 0x13) or direct-key signature
|
|
||||||
* (0x1F). It should be issued by the same key that issued the
|
|
||||||
* revoked signature or an authorized revocation key. The signature
|
|
||||||
* is computed over the same data as the certificate that it
|
|
||||||
* revokes, and should have a later creation date than that
|
|
||||||
* certificate. */
|
|
||||||
cert_revocation: 48,
|
|
||||||
/** 0x18: Subkey Binding Signature
|
|
||||||
* This signature is a statement by the top-level signing key that
|
|
||||||
* indicates that it owns the subkey. This signature is calculated
|
|
||||||
* directly on the primary key and subkey, and not on any User ID or
|
|
||||||
* other packets. A signature that binds a signing subkey MUST have
|
|
||||||
* an Embedded Signature subpacket in this binding signature that
|
|
||||||
* contains a 0x19 signature made by the signing subkey on the
|
|
||||||
* primary key and subkey. */
|
|
||||||
subkey_binding: 24,
|
|
||||||
/** 0x19: Primary Key Binding Signature
|
|
||||||
* This signature is a statement by a signing subkey, indicating
|
|
||||||
* that it is owned by the primary key and subkey. This signature
|
|
||||||
* is calculated the same way as a 0x18 signature: directly on the
|
|
||||||
* primary key and subkey, and not on any User ID or other packets.
|
|
||||||
|
|
||||||
* When a signature is made over a key, the hash data starts with the
|
|
||||||
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
||||||
* of the key packet. (Note that this is an old-style packet header for
|
|
||||||
* a key packet with two-octet length.) A subkey binding signature
|
|
||||||
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
||||||
* the subkey using the same format as the main key (also using 0x99 as
|
|
||||||
* the first octet). */
|
|
||||||
key_binding: 25,
|
|
||||||
/** 0x1F: Signature directly on a key
|
|
||||||
* This signature is calculated directly on a key. It binds the
|
|
||||||
* information in the Signature subpackets to the key, and is
|
|
||||||
* appropriate to be used for subpackets that provide information
|
|
||||||
* about the key, such as the Revocation Key subpacket. It is also
|
|
||||||
* appropriate for statements that non-self certifiers want to make
|
|
||||||
* about the key itself, rather than the binding between a key and a
|
|
||||||
* name. */
|
|
||||||
key: 31,
|
|
||||||
/** 0x20: Key revocation signature
|
|
||||||
* The signature is calculated directly on the key being revoked. A
|
|
||||||
* revoked key is not to be used. Only revocation signatures by the
|
|
||||||
* key being revoked, or by an authorized revocation key, should be
|
|
||||||
* considered valid revocation signatures.a */
|
|
||||||
key_revocation: 32,
|
|
||||||
/** 0x28: Subkey revocation signature
|
|
||||||
* The signature is calculated directly on the subkey being revoked.
|
|
||||||
* A revoked subkey is not to be used. Only revocation signatures
|
|
||||||
* by the top-level signature key that is bound to this subkey, or
|
|
||||||
* by an authorized revocation key, should be considered valid
|
|
||||||
* revocation signatures.
|
|
||||||
* Key revocation signatures (types 0x20 and 0x28)
|
|
||||||
* hash only the key being revoked. */
|
|
||||||
subkey_revocation: 40,
|
|
||||||
/** 0x40: Timestamp signature.
|
|
||||||
* This signature is only meaningful for the timestamp contained in
|
|
||||||
* it. */
|
|
||||||
timestamp: 64,
|
|
||||||
/** 0x50: Third-Party Confirmation signature.
|
|
||||||
* This signature is a signature over some other OpenPGP Signature
|
|
||||||
* packet(s). It is analogous to a notary seal on the signed data.
|
|
||||||
* A third-party signature SHOULD include Signature Target
|
|
||||||
* subpacket(s) to give easy identification. Note that we really do
|
|
||||||
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
||||||
* party that only sees the signature, not the key or source
|
|
||||||
* document) that cannot include a target subpacket. */
|
|
||||||
third_party: 80
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
// License along with this library; if not, write to the Free Software
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
var util = require('../util/util.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
* @classdesc Implementation of the User ID Packet (Tag 13)
|
* @classdesc Implementation of the User ID Packet (Tag 13)
|
||||||
|
@ -24,13 +26,11 @@
|
||||||
* restrictions on its content. The packet length in the header
|
* restrictions on its content. The packet length in the header
|
||||||
* specifies the length of the User ID.
|
* specifies the length of the User ID.
|
||||||
*/
|
*/
|
||||||
|
function packet_userid() {
|
||||||
function openpgp_packet_userid() {
|
|
||||||
/** @type {String} A string containing the user id. Usually in the form
|
/** @type {String} A string containing the user id. Usually in the form
|
||||||
* John Doe <john@example.com>
|
* John Doe <john@example.com>
|
||||||
*/
|
*/
|
||||||
this.userid = '';
|
this.userid = '';
|
||||||
this.tag = 13;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,3 +54,5 @@ function openpgp_packet_userid() {
|
||||||
return util.encode_utf8(this.userid);
|
return util.encode_utf8(this.userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = packet_userid;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
var openpgp = require('openpgp')
|
var openpgp = require('openpgp')
|
||||||
|
|
||||||
var util = openpgp.util,
|
|
||||||
keyExpansion = openpgp.cipher.aes.keyExpansion,
|
|
||||||
AESencrypt = openpgp.cipher.aes.AESencrypt;
|
|
||||||
|
|
||||||
unittests.register("AES Rijndael cipher test with test vectors from ecb_tbl.txt", function() {
|
unittests.register("AES Rijndael cipher test with test vectors from ecb_tbl.txt", function() {
|
||||||
|
var util = openpgp.util,
|
||||||
|
keyExpansion = openpgp.cipher.aes.keyExpansion,
|
||||||
|
AESencrypt = openpgp.cipher.aes.AESencrypt;
|
||||||
|
|
||||||
var result = new Array();
|
var result = new Array();
|
||||||
function test_aes(input, key, output) {
|
function test_aes(input, key, output) {
|
||||||
return (util.hexstrdump(util.bin2str(AESencrypt(input,keyExpansion(util.bin2str(key))))) == util.hexstrdump(util.bin2str(output)));
|
return (util.hexstrdump(util.bin2str(AESencrypt(input,keyExpansion(util.bin2str(key))))) == util.hexstrdump(util.bin2str(output)));
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
</style>
|
</style>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
util.debug = true;
|
require('openpgp').util.debug = true;
|
||||||
|
|
||||||
|
|
||||||
function unit_tests() {
|
function unit_tests() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user