diff --git a/LICENSE b/LICENSE index a3452da..d28e44b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -ASN.1 JavaScript decoder Copyright (c) 2008-2013 Lapo Luchini +ASN.1 JavaScript decoder Copyright (c) 2008-2014 Lapo Luchini Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/asn1.js b/asn1.js index 9f94864..bc279f4 100644 --- a/asn1.js +++ b/asn1.js @@ -1,5 +1,5 @@ // ASN.1 JavaScript decoder -// Copyright (c) 2008-2013 Lapo Luchini +// Copyright (c) 2008-2014 Lapo Luchini // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above diff --git a/base64.js b/base64.js index de786ba..2dcc53e 100644 --- a/base64.js +++ b/base64.js @@ -1,86 +1,86 @@ -// Base64 JavaScript decoder -// Copyright (c) 2008-2013 Lapo Luchini - -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */ -(function (undefined) { -"use strict"; - -var Base64 = {}, - decoder; - -Base64.decode = function (a) { - var i; - if (decoder === undefined) { - var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - ignore = "= \f\n\r\t\u00A0\u2028\u2029"; - decoder = []; - for (i = 0; i < 64; ++i) - decoder[b64.charAt(i)] = i; - for (i = 0; i < ignore.length; ++i) - decoder[ignore.charAt(i)] = -1; - } - var out = []; - var bits = 0, char_count = 0; - for (i = 0; i < a.length; ++i) { - var c = a.charAt(i); - if (c == '=') - break; - c = decoder[c]; - if (c == -1) - continue; - if (c === undefined) - throw 'Illegal character at offset ' + i; - bits |= c; - if (++char_count >= 4) { - out[out.length] = (bits >> 16); - out[out.length] = (bits >> 8) & 0xFF; - out[out.length] = bits & 0xFF; - bits = 0; - char_count = 0; - } else { - bits <<= 6; - } - } - switch (char_count) { - case 1: - throw "Base64 encoding incomplete: at least 2 bits missing"; - case 2: - out[out.length] = (bits >> 10); - break; - case 3: - out[out.length] = (bits >> 16); - out[out.length] = (bits >> 8) & 0xFF; - break; - } - return out; -}; - -Base64.re = /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/; -Base64.unarmor = function (a) { - var m = Base64.re.exec(a); - if (m) { - if (m[1]) - a = m[1]; - else if (m[2]) - a = m[2]; - else - throw "RegExp out of sync"; - } - return Base64.decode(a); -}; - -// export globals -window.Base64 = Base64; -})(); +// Base64 JavaScript decoder +// Copyright (c) 2008-2014 Lapo Luchini + +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */ +(function (undefined) { +"use strict"; + +var Base64 = {}, + decoder; + +Base64.decode = function (a) { + var i; + if (decoder === undefined) { + var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + ignore = "= \f\n\r\t\u00A0\u2028\u2029"; + decoder = []; + for (i = 0; i < 64; ++i) + decoder[b64.charAt(i)] = i; + for (i = 0; i < ignore.length; ++i) + decoder[ignore.charAt(i)] = -1; + } + var out = []; + var bits = 0, char_count = 0; + for (i = 0; i < a.length; ++i) { + var c = a.charAt(i); + if (c == '=') + break; + c = decoder[c]; + if (c == -1) + continue; + if (c === undefined) + throw 'Illegal character at offset ' + i; + bits |= c; + if (++char_count >= 4) { + out[out.length] = (bits >> 16); + out[out.length] = (bits >> 8) & 0xFF; + out[out.length] = bits & 0xFF; + bits = 0; + char_count = 0; + } else { + bits <<= 6; + } + } + switch (char_count) { + case 1: + throw "Base64 encoding incomplete: at least 2 bits missing"; + case 2: + out[out.length] = (bits >> 10); + break; + case 3: + out[out.length] = (bits >> 16); + out[out.length] = (bits >> 8) & 0xFF; + break; + } + return out; +}; + +Base64.re = /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/; +Base64.unarmor = function (a) { + var m = Base64.re.exec(a); + if (m) { + if (m[1]) + a = m[1]; + else if (m[2]) + a = m[2]; + else + throw "RegExp out of sync"; + } + return Base64.decode(a); +}; + +// export globals +window.Base64 = Base64; +})(); diff --git a/hex.js b/hex.js index 573f497..125e625 100644 --- a/hex.js +++ b/hex.js @@ -1,65 +1,65 @@ -// Hex JavaScript decoder -// Copyright (c) 2008-2013 Lapo Luchini - -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */ -(function (undefined) { -"use strict"; - -var Hex = {}, - decoder; - -Hex.decode = function(a) { - var i; - if (decoder === undefined) { - var hex = "0123456789ABCDEF", - ignore = " \f\n\r\t\u00A0\u2028\u2029"; - decoder = []; - for (i = 0; i < 16; ++i) - decoder[hex.charAt(i)] = i; - hex = hex.toLowerCase(); - for (i = 10; i < 16; ++i) - decoder[hex.charAt(i)] = i; - for (i = 0; i < ignore.length; ++i) - decoder[ignore.charAt(i)] = -1; - } - var out = [], - bits = 0, - char_count = 0; - for (i = 0; i < a.length; ++i) { - var c = a.charAt(i); - if (c == '=') - break; - c = decoder[c]; - if (c == -1) - continue; - if (c === undefined) - throw 'Illegal character at offset ' + i; - bits |= c; - if (++char_count >= 2) { - out[out.length] = bits; - bits = 0; - char_count = 0; - } else { - bits <<= 4; - } - } - if (char_count) - throw "Hex encoding incomplete: 4 bits missing"; - return out; -}; - -// export globals -window.Hex = Hex; -})(); +// Hex JavaScript decoder +// Copyright (c) 2008-2014 Lapo Luchini + +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */ +(function (undefined) { +"use strict"; + +var Hex = {}, + decoder; + +Hex.decode = function(a) { + var i; + if (decoder === undefined) { + var hex = "0123456789ABCDEF", + ignore = " \f\n\r\t\u00A0\u2028\u2029"; + decoder = []; + for (i = 0; i < 16; ++i) + decoder[hex.charAt(i)] = i; + hex = hex.toLowerCase(); + for (i = 10; i < 16; ++i) + decoder[hex.charAt(i)] = i; + for (i = 0; i < ignore.length; ++i) + decoder[ignore.charAt(i)] = -1; + } + var out = [], + bits = 0, + char_count = 0; + for (i = 0; i < a.length; ++i) { + var c = a.charAt(i); + if (c == '=') + break; + c = decoder[c]; + if (c == -1) + continue; + if (c === undefined) + throw 'Illegal character at offset ' + i; + bits |= c; + if (++char_count >= 2) { + out[out.length] = bits; + bits = 0; + char_count = 0; + } else { + bits <<= 4; + } + } + if (char_count) + throw "Hex encoding incomplete: 4 bits missing"; + return out; +}; + +// export globals +window.Hex = Hex; +})();