Incorporate integration test changes from signature branch
This commit is contained in:
parent
8110782633
commit
e9b8b0efb9
|
@ -7422,7 +7422,7 @@ function openpgp_config() {
|
|||
keyserver: "keyserver.linux.it" // "pgp.mit.edu:11371"
|
||||
};
|
||||
|
||||
this.versionstring ="OpenPGP.js v.1.20131202";
|
||||
this.versionstring ="OpenPGP.js v.1.20131204";
|
||||
this.commentstring ="http://openpgpjs.org";
|
||||
/**
|
||||
* Reads the config out of the HTML5 local storage
|
||||
|
|
2
resources/openpgp.min.js
vendored
2
resources/openpgp.min.js
vendored
|
@ -286,7 +286,7 @@ JXG.Util.asciiCharCodeAt=function(b,a){var c=b.charCodeAt(a);if(255<c)switch(c){
|
|||
151;break;case 732:c=152;break;case 8482:c=153;break;case 353:c=154;break;case 8250:c=155;break;case 339:c=156;break;case 382:c=158;break;case 376:c=159}return c};
|
||||
JXG.Util.utf8Decode=function(b){var a=[],c=0,d=0,e=0,f;if(!JXG.exists(b))return"";for(;c<b.length;)d=b.charCodeAt(c),128>d?(a.push(String.fromCharCode(d)),c++):191<d&&224>d?(e=b.charCodeAt(c+1),a.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=b.charCodeAt(c+1),f=b.charCodeAt(c+2),a.push(String.fromCharCode((d&15)<<12|(e&63)<<6|f&63)),c+=3);return a.join("")};
|
||||
JXG.Util.genUUID=function(){for(var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),a=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?a[e]="-":14==e?a[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,a[e]=b[19==e?d&3|8:d]);return a.join("")};
|
||||
function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:8,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20131202";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config",
|
||||
function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:8,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20131204";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config",
|
||||
JSON.stringify(this.config))}}var b64s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
function s2r(b){var a,c,d,e="",f=0,g=0,h=b.length;for(d=0;d<h;d++)c=b.charCodeAt(d),0==g?(e+=b64s.charAt(c>>2&63),a=(c&3)<<4):1==g?(e+=b64s.charAt(a|c>>4&15),a=(c&15)<<2):2==g&&(e+=b64s.charAt(a|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),g+=1,3==g&&(g=0);0<g&&(e+=b64s.charAt(a),f+=1,0==f%60&&(e+="\n"),e+="=",f+=1);1==g&&(0==f%60&&(e+="\n"),e+="=");"\n"===e.charAt(e.length-1)&&(e=e.slice(0,-1));return e}
|
||||
function r2s(b){var a,c,d="",e=0,f=0,g=b.length;for(c=0;c<g;c++)a=b64s.indexOf(b.charAt(c)),0<=a&&(e&&(d+=String.fromCharCode(f|a>>6-e&255)),e=e+2&7,f=a<<e&255);return d}
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
require.config({
|
||||
baseUrl: './',
|
||||
paths: {
|
||||
openpgp: '../../resources/openpgp.min'
|
||||
openpgp: '../../resources/openpgp',
|
||||
jquery: '../../resources/jquery.min'
|
||||
},
|
||||
shim: {
|
||||
openpgp: {
|
||||
exports: 'window'
|
||||
},
|
||||
jquery: {
|
||||
exports: 'window'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -22,4 +26,4 @@ require(
|
|||
// require modules loaded -> run tests
|
||||
mocha.run();
|
||||
}
|
||||
);
|
||||
);
|
||||
|
|
|
@ -132,7 +132,7 @@ define(function(require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Encrypt', function() {
|
||||
describe('Encrypt and Sign', function() {
|
||||
it('should work', function(done) {
|
||||
pgp.encrypt(message, [pubkey], function(err, ct) {
|
||||
expect(err).to.not.exist;
|
||||
|
@ -143,11 +143,12 @@ define(function(require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Decrypt', function() {
|
||||
describe('Decrypt and Verify', function() {
|
||||
it('should work', function(done) {
|
||||
pgp.decrypt(ciphertext, pubkey, function(err, pt) {
|
||||
expect(err).to.not.exist;
|
||||
expect(pt).to.equal(message);
|
||||
expect(pt.text).to.equal(message);
|
||||
expect(pt.validSignatures[0]).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -156,4 +157,4 @@ define(function(require) {
|
|||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
/**
|
||||
* High level crypto api that handles all calls to OpenPGP.js
|
||||
*/
|
||||
function showMessages(str) {
|
||||
}
|
||||
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var openpgp = require('openpgp').openpgp,
|
||||
util = require('openpgp').util;
|
||||
util = require('openpgp').util,
|
||||
jquery = require('jquery').jquery;
|
||||
|
||||
var PGP = function() {
|
||||
openpgp.init();
|
||||
|
@ -131,7 +135,8 @@ define(function(require) {
|
|||
*/
|
||||
PGP.prototype.decrypt = function(ciphertext, senderKey, callback) {
|
||||
var privateKey = openpgp.keyring.exportPrivateKey(0).obj;
|
||||
senderKey = openpgp.read_publicKey(senderKey)[0];
|
||||
var publicKey = openpgp.read_publicKey(senderKey)[0];
|
||||
var pubKeys = [ { armored: senderKey, obj: publicKey, keyId: publicKey.getKeyId() } ];
|
||||
|
||||
var msg = openpgp.read_message(ciphertext)[0];
|
||||
var keymat = null;
|
||||
|
@ -159,8 +164,8 @@ define(function(require) {
|
|||
}
|
||||
}
|
||||
if (keymat !== null) {
|
||||
var decrypted = msg.decryptAndVerifySignature(keymat, sesskey, senderKey);
|
||||
callback(null, decrypted.text);
|
||||
var decrypted = msg.decryptAndVerifySignature(keymat, sesskey, pubKeys);
|
||||
callback(null, decrypted);
|
||||
|
||||
} else {
|
||||
callback({
|
||||
|
@ -170,4 +175,4 @@ define(function(require) {
|
|||
};
|
||||
|
||||
return PGP;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user