remove readSignedContent in favor of appendSignature
This commit is contained in:
parent
5e857e131e
commit
5564b67cc8
89
npm-shrinkwrap.json
generated
89
npm-shrinkwrap.json
generated
|
@ -217,8 +217,10 @@
|
|||
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
|
||||
"dev": true
|
||||
},
|
||||
"asmcrypto-lite": {
|
||||
"version": "github:openpgpjs/asmcrypto-lite#57ef213b6677d118c1b9668a35c74b6c716a5310"
|
||||
"asmcrypto.js": {
|
||||
"version": "0.22.0",
|
||||
"resolved": "https://registry.npmjs.org/asmcrypto.js/-/asmcrypto.js-0.22.0.tgz",
|
||||
"integrity": "sha512-usgMoyXjMbx/ZPdzTSXExhMPur2FTdz/Vo5PVx2gIaBcdAAJNOFlsdgqveM8Cff7W0v+xrf9BwjOV26JSAF9qA=="
|
||||
},
|
||||
"asn1": {
|
||||
"version": "0.2.3",
|
||||
|
@ -4282,16 +4284,40 @@
|
|||
"file-sync-cmp": "0.1.1"
|
||||
}
|
||||
},
|
||||
"grunt-contrib-uglify": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-3.2.1.tgz",
|
||||
"integrity": "sha512-xBPwg8wuA/m+HiSh2uMADuadKEnFQt9N5OhEy35vIl945yG6095oY1H1Og3ucg0wBSOieIBn3raqStvIcwKqHg==",
|
||||
"grunt-contrib-uglify-es": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/grunt-contrib-uglify-es/-/grunt-contrib-uglify-es-3.3.0.tgz",
|
||||
"integrity": "sha1-wV97Ef1BMgPU4MkTf10/r1Wo34A=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "1.1.3",
|
||||
"maxmin": "1.1.0",
|
||||
"uglify-js": "3.2.0",
|
||||
"uglify-es": "3.3.9",
|
||||
"uri-path": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz",
|
||||
"integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==",
|
||||
"dev": true
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-es": {
|
||||
"version": "3.3.9",
|
||||
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz",
|
||||
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "2.13.0",
|
||||
"source-map": "0.6.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"grunt-contrib-watch": {
|
||||
|
@ -4373,12 +4399,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"grunt-keepalive": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/grunt-keepalive/-/grunt-keepalive-1.0.0.tgz",
|
||||
"integrity": "sha1-ZkyOGFoNnqGvQYoswLs/FfL4vzM=",
|
||||
"dev": true
|
||||
},
|
||||
"grunt-known-options": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-1.1.0.tgz",
|
||||
|
@ -5431,28 +5451,6 @@
|
|||
"integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==",
|
||||
"dev": true
|
||||
},
|
||||
"jwk-to-pem": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/jwk-to-pem/-/jwk-to-pem-1.2.6.tgz",
|
||||
"integrity": "sha1-1QfOzkAInFJI4J7GgmaiAwqcYyU=",
|
||||
"requires": {
|
||||
"asn1.js": "4.9.2",
|
||||
"elliptic": "github:openpgpjs/elliptic#8b8ee8475b86402b125d4ad3a863a4ccd762e48c",
|
||||
"safe-buffer": "5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"asn1.js": {
|
||||
"version": "4.9.2",
|
||||
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.2.tgz",
|
||||
"integrity": "sha512-b/OsSjvWEo8Pi8H0zsDd2P6Uqo2TK2pH8gNLSJtNLM2Db0v2QaAZ0pBQJXVjAn4gBuugeVDr7s63ZogpUIwWDg==",
|
||||
"requires": {
|
||||
"bn.js": "4.11.8",
|
||||
"inherits": "2.0.3",
|
||||
"minimalistic-assert": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||
|
@ -6967,7 +6965,8 @@
|
|||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
||||
"dev": true
|
||||
},
|
||||
"samsam": {
|
||||
"version": "1.3.0",
|
||||
|
@ -7679,24 +7678,6 @@
|
|||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.2.0.tgz",
|
||||
"integrity": "sha512-L98DlTshoPGnZGF8pr3MoE+CCo6n9joktHNHMPkckeBV8xTVc4CWtC0kGGhQsIvnX2Ug4nXFTAeE7SpTrPX2tg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "2.12.2",
|
||||
"source-map": "0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"uglify-to-browserify": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
|
||||
|
|
|
@ -582,6 +582,14 @@ Message.prototype.unwrapCompressed = function() {
|
|||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Append signature to unencrypted message object
|
||||
* @param {String|Uint8Array} detachedSignature The detached ASCII-armored or Uint8Array PGP signature
|
||||
*/
|
||||
Message.prototype.appendSignature = function(detachedSignature) {
|
||||
this.packets.read(util.isUint8Array(detachedSignature) ? detachedSignature : armor.decode(detachedSignature).data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns ASCII armored text of message
|
||||
* @return {String} ASCII armor
|
||||
|
@ -615,21 +623,6 @@ export function read(input) {
|
|||
return new Message(packetlist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a message object from signed content and a detached armored signature.
|
||||
* @param {String} content An 8 bit ascii string containing e.g. a MIME subtree with text nodes or attachments
|
||||
* @param {String} detachedSignature The detached ascii armored PGP signature
|
||||
*/
|
||||
export function readSignedContent(content, detachedSignature) {
|
||||
const literalDataPacket = new packet.Literal();
|
||||
literalDataPacket.setBytes(util.str_to_Uint8Array(content), enums.read(enums.literal, enums.literal.binary));
|
||||
const packetlist = new packet.List();
|
||||
packetlist.push(literalDataPacket);
|
||||
const input = armor.decode(detachedSignature).data;
|
||||
packetlist.read(input);
|
||||
return new Message(packetlist);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates new message object from text
|
||||
* @param {String} text
|
||||
|
|
|
@ -739,7 +739,7 @@ describe("Signature", function() {
|
|||
expect(pubKey.users[0].selfCertifications).to.eql(pubKey2.users[0].selfCertifications);
|
||||
});
|
||||
|
||||
it('Verify a detached signature using readSignedContent', function() {
|
||||
it('Verify a detached signature using appendSignature', function() {
|
||||
const detachedSig = ['-----BEGIN PGP SIGNATURE-----',
|
||||
'Version: GnuPG v1.4.13 (Darwin)',
|
||||
'Comment: GPGTools - https://gpgtools.org',
|
||||
|
@ -778,7 +778,9 @@ describe("Signature", function() {
|
|||
const publicKeyArmored = '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nVersion: OpenPGP.js v.1.20131116\r\nComment: Whiteout Mail - https://whiteout.io\r\n\r\nxsBNBFKODs4BB/9iOF4THsjQMY+WEpT7ShgKxj4bHzRRaQkqczS4nZvP0U3g\r\nqeqCnbpagyeKXA+bhWFQW4GmXtgAoeD5PXs6AZYrw3tWNxLKu2Oe6Tp9K/XI\r\nxTMQ2wl4qZKDXHvuPsJ7cmgaWqpPyXtxA4zHHS3WrkI/6VzHAcI/y6x4szSB\r\nKgSuhI3hjh3s7TybUC1U6AfoQGx/S7e3WwlCOrK8GTClirN/2mCPRC5wuIft\r\nnkoMfA6jK8d2OPrJ63shy5cgwHOjQg/xuk46dNS7tkvGmbaa+X0PgqSKB+Hf\r\nYPPNS/ylg911DH9qa8BqYU2QpNh9jUKXSF+HbaOM+plWkCSAL7czV+R3ABEB\r\nAAHNLVdoaXRlb3V0IFVzZXIgPHNhZmV3aXRobWUudGVzdHVzZXJAZ21haWwu\r\nY29tPsLAXAQQAQgAEAUCUo4O2gkQ1/uT/N+/wjwAAN2cB/9gFRmAfvEQ2qz+\r\nWubmT2EsSSnjPMxzG4uyykFoa+TaZCWo2Xa2tQghmU103kEkQb1OEjRjpgwJ\r\nYX9Kghnl8DByM686L5AXnRyHP78qRJCLXSXl0AGicboUDp5sovaa4rswQceH\r\nvcdWgZ/mgHTRoiQeJddy9k+H6MPFiyFaVcFwegVsmpc+dCcC8yT+qh8ZIbyG\r\nRJU60PmKKN7LUusP+8DbSv39zCGJCBlVVKyA4MzdF5uM+sqTdXbKzOrT5DGd\r\nCZaox4s+w16Sq1rHzZKFWfQPfKLDB9pyA0ufCVRA3AF6BUi7G3ZqhZiHNhMP\r\nNvE45V/hS1PbZcfPVoUjE2qc1Ix1\r\n=7Wpe\r\n-----END PGP PUBLIC KEY BLOCK-----';
|
||||
const publicKeys = openpgp.key.readArmored(publicKeyArmored).keys;
|
||||
|
||||
const msg = openpgp.message.readSignedContent(content, detachedSig);
|
||||
// Text
|
||||
const msg = openpgp.message.fromText(content);
|
||||
msg.appendSignature(detachedSig);
|
||||
return msg.verify(publicKeys).then(result => {
|
||||
expect(result[0].valid).to.be.true;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user