Merge zip.js and inflate.js into zip.js due to dependency in execution order. Remove inflate.js. Add import for zlib compression to test/encryption.html
This commit is contained in:
parent
0ce9a0587d
commit
028ee46d81
|
@ -219,12 +219,6 @@ function _openpgp () {
|
|||
if (first_packet.tagType == 8) {
|
||||
util.print_error("A directly compressed message is currently not supported");
|
||||
break;
|
||||
} else
|
||||
// Literal Message
|
||||
// TODO: needs to be implemented. From a security perspective: this message is plaintext anyway.
|
||||
if (first_packet.tagType == 11) {
|
||||
util.print_error("A direct literal message is currently not supported.");
|
||||
break;
|
||||
} else
|
||||
// Marker Packet (Obsolete Literal Packet) (Tag 10)
|
||||
// "Such a packet MUST be ignored when received." see http://tools.ietf.org/html/rfc4880#section-5.8
|
||||
|
@ -234,6 +228,12 @@ function _openpgp () {
|
|||
// continue with next packet
|
||||
mypos += first_packet.packetLength + first_packet.headerLength;
|
||||
l -= (first_packet.packetLength + first_packet.headerLength);
|
||||
} else
|
||||
// Literal Message
|
||||
// TODO: needs to be implemented. From a security perspective: this message is plaintext anyway.
|
||||
if (first_packet.tagType == 11) {
|
||||
util.print_error("A direct literal message is currently not supported.");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
util.print_error('no message found!');
|
||||
|
@ -4700,8 +4700,8 @@ var util = new Util();
|
|||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
|
@ -4719,11 +4719,19 @@ var util = new Util();
|
|||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
(function(obj) {
|
||||
|
||||
obj.zip = {
|
||||
useWebWorkers : false
|
||||
};
|
||||
|
||||
})(this);
|
||||
|
||||
// include inflate.js
|
||||
|
||||
/*
|
||||
* This program is based on JZlib 1.0.2 ymnk, JCraft,Inc.
|
||||
* JZlib is based on zlib-1.1.3, so all credit should go authors
|
||||
* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
* and contributors of zlib.
|
||||
* zip.js and include.js are merged in one file because of a dependency in the
|
||||
* execution order: zip.Inflater is only defined if inflate.js is executed after zip.js
|
||||
*/
|
||||
|
||||
(function(obj) {
|
||||
|
@ -6860,41 +6868,7 @@ var util = new Util();
|
|||
}
|
||||
|
||||
})(this);
|
||||
/*
|
||||
Copyright (c) 2012 Gildas Lormeau. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The names of the authors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
(function(obj) {
|
||||
|
||||
obj.zip = {
|
||||
useWebWorkers : false
|
||||
};
|
||||
|
||||
})(this);
|
||||
// GPG4Browsers - An OpenPGP implementation in javascript
|
||||
// Copyright (C) 2011 Recurity Labs GmbH
|
||||
//
|
||||
|
|
6
resources/openpgp.min.js
vendored
6
resources/openpgp.min.js
vendored
|
@ -7,7 +7,7 @@ a,d);return openpgp_encoding_armor(3,c,null,null)};this.write_encrypted_message=
|
|||
g.MPIs,g.publicKeyAlgorithm,openpgp.config.config.encryption_cipher,d)}e=openpgp.config.config.integrity_protect?e+(new openpgp_packet_encryptedintegrityprotecteddata).write_packet(openpgp.config.config.encryption_cipher,d,c):e+(new openpgp_packet_encrypteddata).write_packet(openpgp.config.config.encryption_cipher,d,c);return openpgp_encoding_armor(3,e,null,null)};this.read_message=function(a){var b;try{b=openpgp_encoding_deArmor(a.replace(/\r/g,""))}catch(c){return util.print_error("no message found!"),
|
||||
null}for(var a=b.openpgp,d=[],e=0,f=0,g=a.length;f<a.length;){var h=openpgp_packet.read_packet(a,f,g);if(1==h.tagType||2==h.tagType&&16>h.signatureType||3==h.tagType||8==h.tagType||9==h.tagType||10==h.tagType||11==h.tagType||18==h.tagType||19==h.tagType)if(d[d.length]=new openpgp_msg_message,d[e].messagePacket=h,d[e].type=b.type,9==h.tagType||1==h.tagType||3==h.tagType||18==h.tagType)if(9==h.tagType){util.print_error("unexpected openpgp packet");break}else if(1==h.tagType){util.print_debug("session key found:\n "+
|
||||
h.toString());var k=!0;d[e].sessionKeys=[];for(var j=0;k;)d[e].sessionKeys[j]=h,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength,h=openpgp_packet.read_packet(a,f,g),1!=h.tagType&&3!=h.tagType&&(k=!1),j++;18==h.tagType||9==h.tagType?(util.print_debug("encrypted data found:\n "+h.toString()),d[e].encryptedData=h,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength,e++):util.print_debug("something is wrong: "+h.tagType)}else{if(18==h.tagType){util.print_debug("symmetric encrypted data");
|
||||
break}}else if(2==h.tagType&&3>h.signatureType){d[e].text=b.text;d[e].signature=h;break}else if(8==h.tagType){util.print_error("A directly compressed message is currently not supported");break}else if(11==h.tagType){util.print_error("A direct literal message is currently not supported.");break}else{if(10==h.tagType)d.length=0,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength}else return util.print_error("no message found!"),null}return d};this.read_publicKey=function(a){for(var b=
|
||||
break}}else if(2==h.tagType&&3>h.signatureType){d[e].text=b.text;d[e].signature=h;break}else if(8==h.tagType){util.print_error("A directly compressed message is currently not supported");break}else if(10==h.tagType)d.length=0,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength;else{if(11==h.tagType){util.print_error("A direct literal message is currently not supported.");break}}else return util.print_error("no message found!"),null}return d};this.read_publicKey=function(a){for(var b=
|
||||
0,c=[],d=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,e=a.length;b!=a.length;){var f=openpgp_packet.read_packet(a,b,e);if(153==a[b].charCodeAt()||6==f.tagType)c[d]=new openpgp_msg_publickey,c[d].header=a.substring(b,b+3),153==a[b].charCodeAt()?(b++,e=a[b++].charCodeAt()<<8|a[b++].charCodeAt(),c[d].publicKeyPacket=new openpgp_packet_keymaterial,c[d].publicKeyPacket.header=c[d].header,c[d].publicKeyPacket.read_tag6(a,b,e),b+=c[d].publicKeyPacket.packetLength,b+=c[d].read_nodes(c[d].publicKeyPacket,
|
||||
a,b,a.length-b)):(c[d]=new openpgp_msg_publickey,c[d].publicKeyPacket=f,b+=f.headerLength+f.packetLength,b+=c[d].read_nodes(f,a,b,a.length-b));else return util.print_error("no public key found!"),null;c[d].data=a.substring(0,b);d++}return c};this.read_privateKey=function(a){for(var b=[],c=0,d=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,e=a.length;d!=a.length;){var f=openpgp_packet.read_packet(a,d,e);if(5==f.tagType)b[b.length]=new openpgp_msg_privatekey,d+=f.headerLength+f.packetLength,
|
||||
d+=b[c].read_nodes(f,a,d,e);else return util.print_error("no block packet found!"),null;b[c].data=a.substring(0,d);c++}return b};this.init=function(){this.config=new openpgp_config;this.config.read();this.keyring=new openpgp_keyring;this.keyring.init()}}var openpgp=new _openpgp;
|
||||
|
@ -138,7 +138,7 @@ function(a){for(var b=new Uint8Array(new ArrayBuffer(a.length)),c=0;c<a.length;c
|
|||
a.replace(/\n/g,"<br>")+"</p></tt>"))};this.print_debug_hexstr_dump=function(a,b){openpgp.config.debug&&(a+=this.hexstrdump(b),a=openpgp_encoding_html_encode(a),showMessages('<tt><p style="background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;">'+a.replace(/\n/g,"<br>")+"</p></tt>"))};this.print_error=function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #FF8888; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>ERROR:</b></span>\t'+
|
||||
a.replace(/\n/g,"<br>")+"</p>")};this.print_info=function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #88FF88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>INFO:</b></span>\t'+a.replace(/\n/g,"<br>")+"</p>")};this.print_warning=function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #FFAA88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>WARNING:</b></span>\t'+
|
||||
a.replace(/\n/g,"<br>")+"</p>")};this.getLeftNBits=function(a,b){var c=b%8;return 0==c?a.substring(0,b/8):this.shiftRight(a.substring(0,(b-c)/8+1),8-c)};this.shiftRight=function(a,b){var c=util.str2bin(a);if(0!=b%8)for(var d=c.length-1;0<=d;d--)c[d]>>=b%8,0<d&&(c[d]|=c[d-1]<<8-b%8&255);else return a;return util.bin2str(c)};this.get_hashAlgorithmString=function(a){switch(a){case 1:return"MD5";case 2:return"SHA1";case 3:return"RIPEMD160";case 8:return"SHA256";case 9:return"SHA384";case 10:return"SHA512";
|
||||
case 11:return"SHA224"}return"unknown"}},util=new Util;
|
||||
case 11:return"SHA224"}return"unknown"}},util=new Util;(function(a){a.zip={useWebWorkers:!1}})(this);
|
||||
(function(a){function b(){function a(b,c,d,Ea,j,O,t,x,Q,o,p){var l,ga,s,q,u,r,U,z,y,V;U=0;s=d;do e[b[c+U]]++,U++,s--;while(0!==s);if(e[0]==d)return t[0]=-1,x[0]=0,h;r=x[0];for(q=1;q<=W&&!(0!==e[q]);q++);u=q;r<q&&(r=q);for(s=W;0!==s&&!(0!==e[s]);s--);ga=s;r>s&&(r=s);x[0]=r;for(x=1<<q;q<s;q++,x<<=1)if(0>(x-=e[q]))return w;if(0>(x-=e[s]))return w;e[s]+=x;k[1]=q=0;U=1;for(z=2;0!==--s;)k[z]=q+=e[U],z++,U++;U=s=0;do{if(0!==(q=b[c+U]))p[k[q]++]=s;U++}while(++s<d);d=k[ga];U=k[0]=s=0;c=-1;y=-r;for(V=z=g[0]=
|
||||
0;u<=ga;u++)for(b=e[u];0!==b--;){for(;u>y+r;){c++;y+=r;V=ga-y;V=V>r?r:V;if((l=1<<(q=u-y))>b+1)if(l-=b+1,z=u,q<V)for(;++q<V&&!((l<<=1)<=e[++z]);)l-=e[z];V=1<<q;if(o[0]+V>ba)return w;g[c]=z=o[0];o[0]+=V;0!==c?(k[c]=s,f[0]=q,f[1]=r,q=s>>>y-r,f[2]=z-g[c-1]-q,Q.set(f,3*(g[c-1]+q))):t[0]=z}f[1]=u-y;U>=d?f[0]=192:p[U]<Ea?(f[0]=256>p[U]?0:96,f[2]=p[U++]):(f[0]=O[p[U]-Ea]+16+64,f[2]=j[p[U++]-Ea]);l=1<<u-y;for(q=s>>>y;q<V;q+=l)Q.set(f,3*(z+q));for(q=1<<u-1;0!==(s&q);q>>>=1)s^=q;s^=q;for(q=(1<<y)-1;(s&q)!=k[c];)c--,
|
||||
y-=r,q=(1<<y)-1}return 0!==x&&1!=ga?v:h}function b(a){var h;c||(c=[],d=[],e=new Int32Array(W+1),f=[],g=new Int32Array(W),k=new Int32Array(W+1));d.length<a&&(d=[]);for(h=0;h<a;h++)d[h]=0;for(h=0;h<W+1;h++)e[h]=0;for(h=0;3>h;h++)f[h]=0;g.set(e.subarray(0,W),0);k.set(e.subarray(0,W+1),0)}var c,d,e,f,g,k;this.inflate_trees_bits=function(e,f,h,g,k){b(19);c[0]=0;e=a(e,0,19,19,null,null,h,f,g,c,d);if(e==w)k.msg="oversubscribed dynamic bit lengths tree";else if(e==v||0===f[0])k.msg="incomplete dynamic bit lengths tree",
|
||||
|
@ -183,7 +183,7 @@ j.push(new Uint8Array(c)):j.push(new Uint8Array(c.subarray(0,a.next_out_index)))
|
|||
5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],ma=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],la=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],ia=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ja=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],W=15;b.inflate_trees_fixed=function(a,b,c,d){a[0]=
|
||||
9;b[0]=5;c[0]=D;d[0]=m;return h};var L=0,Z=1,oa=2,ea=3,aa=4,pa=5,O=6,Q=7,ga=8,U=9,ua=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],R=0,na=1,qa=2,Ca=3,Ga=4,T=5,Da=6,z=7,va=8,ha=9,da=32,Ha=8,wa=0,ca=1,xa=2,ya=3,za=4,Aa=5,sa=6,ra=7,Ba=12,ka=13,r=[0,0,255,255];f.prototype={inflateInit:function(a){this.istate=new e;a||(a=15);return this.istate.inflateInit(this,a)},inflate:function(a){return!this.istate?l:this.istate.inflate(this,a)},inflateEnd:function(){if(!this.istate)return l;var a=this.istate.inflateEnd(this);
|
||||
this.istate=null;return a},inflateSync:function(){return!this.istate?l:this.istate.inflateSync(this)},inflateSetDictionary:function(a,b){return!this.istate?l:this.istate.inflateSetDictionary(this,a,b)},read_byte:function(a){return this.next_in.subarray(a,a+1)[0]},read_buf:function(a,b){return this.next_in.subarray(a,a+b)}};var ta;a.zip?a.zip.Inflater=g:(ta=new g,a.addEventListener("message",function(b){b=b.data;b.append&&a.postMessage({onappend:!0,data:ta.append(b.data,function(b){a.postMessage({progress:!0,
|
||||
current:b})})});b.flush&&(ta.flush(),a.postMessage({onflush:!0}))},!1))})(this);(function(a){a.zip={useWebWorkers:!1}})(this);
|
||||
current:b})})});b.flush&&(ta.flush(),a.postMessage({onflush:!0}))},!1))})(this);
|
||||
function openpgp_crypto_symmetricEncrypt(a,b,c,d,e){switch(b){case 0:return d;case 2:return openpgp_cfb_encrypt(a,desede,d,8,c,e).substring(0,d.length+10);case 3:return openpgp_cfb_encrypt(a,cast5_encrypt,d,8,c,e).substring(0,d.length+10);case 4:return openpgp_cfb_encrypt(a,BFencrypt,d,8,c,e).substring(0,d.length+10);case 7:case 8:case 9:return openpgp_cfb_encrypt(a,AESencrypt,d,16,keyExpansion(c),e).substring(0,d.length+18);case 10:return openpgp_cfb_encrypt(a,TFencrypt,d,16,c,e).substring(0,d.length+
|
||||
18);case 1:return util.print_error("IDEA Algorithm not implemented"),null;default:return null}}
|
||||
function openpgp_crypto_symmetricDecrypt(a,b,c,d){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+a+"\nencrypteddata:",c);var e=0;d||(e=2);switch(a){case 0:return c;case 2:return openpgp_cfb_decrypt(desede,8,b,c,d).substring(e,c.length+e-10);case 3:return openpgp_cfb_decrypt(cast5_encrypt,8,b,c,d).substring(e,c.length+e-10);case 4:return openpgp_cfb_decrypt(BFencrypt,8,b,c,d).substring(e,c.length+e-10);case 7:case 8:case 9:return openpgp_cfb_decrypt(AESencrypt,16,keyExpansion(b),
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -25,6 +25,7 @@
|
|||
<script type="text/javascript" src="../src/ciphers/openpgp.cfb.js"></script>
|
||||
|
||||
<!-- compression -->
|
||||
<script type="text/javascript" src="../src/compression/zip/zip.js"></script>
|
||||
|
||||
<!-- encoding -->
|
||||
<script type="text/javascript" src="../src/encoding/base64.js"></script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user