From 1906ddfb5d3887edeedaf8e07d14ad89abbd214d Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Sun, 21 Apr 2013 15:54:15 +0000 Subject: Aborted attempt to factor out the Crypto library on its own module --- (limited to 'frontend/gamma/js/ClipperzCryptoLibrary/ECC/BinaryField/Value.js') diff --git a/frontend/gamma/js/ClipperzCryptoLibrary/ECC/BinaryField/Value.js b/frontend/gamma/js/ClipperzCryptoLibrary/ECC/BinaryField/Value.js deleted file mode 100644 index b046039..0000000 --- a/frontend/gamma/js/ClipperzCryptoLibrary/ECC/BinaryField/Value.js +++ b/dev/null @@ -1,381 +0,0 @@ -/* - -Copyright 2008-2013 Clipperz Srl - -This file is part of Clipperz, the online password manager. -For further information about its features and functionalities please -refer to http://www.clipperz.com. - -* Clipperz is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - -* Clipperz 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 Affero General Public License for more details. - -* You should have received a copy of the GNU Affero General Public - License along with Clipperz. If not, see http://www.gnu.org/licenses/. - -*/ - -//try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { -// throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; -//} -if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } -if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } -if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } -if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } - -Clipperz.Crypto.ECC.BinaryField.Value = function(aValue, aBase, aBitSize) { - if (aValue.constructor == String) { - var value; - var stringLength; - var numberOfWords; - var i,c; - - if (aBase != 16) { - throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; - } - - value = aValue.replace(/ /g, ''); - stringLength = value.length; - numberOfWords = Math.ceil(stringLength / 8); - this._value = new Array(numberOfWords); - - c = numberOfWords; - for (i=0; i>> 0); - } - - return result; -}; - -Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor = function(a, b, aFirstItemOffset) { - var i,c; - var firstItemOffset; - - firstItemOffset = aFirstItemOffset || 0; - - c = Math.max((a.length - firstItemOffset), b.length) + firstItemOffset; - for (i=firstItemOffset; i>> 0); - } -}; - -Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft = function(aWordArray, aNumberOfBitsToShift) { - var numberOfWordsToShift; - var numberOfBitsToShift; - var result; - var overflowValue; - var nextOverflowValue; - var i,c; - - numberOfWordsToShift = Math.floor(aNumberOfBitsToShift / 32); - numberOfBitsToShift = aNumberOfBitsToShift % 32; - - result = new Array(aWordArray.length + numberOfWordsToShift); - - c = numberOfWordsToShift; - for (i=0; i 0) { - nextOverflowValue = (value >>> (32 - numberOfBitsToShift)); - value = value & (0xffffffff >>> numberOfBitsToShift); - resultWord = (((value << numberOfBitsToShift) | overflowValue) >>> 0); - } else { - resultWord = value; - } - - result[i+numberOfWordsToShift] = resultWord; - overflowValue = nextOverflowValue; - } - - if (overflowValue != 0) { - result[aWordArray.length + numberOfWordsToShift] = overflowValue; - } - - return result; -}; - -Clipperz.Crypto.ECC.BinaryField.Value._overwriteShiftLeft = function(aWordArray, aNumberOfBitsToShift) { - var numberOfWordsToShift; - var numberOfBitsToShift; - var result; - var overflowValue; - var i,c; - - numberOfWordsToShift = Math.floor(aNumberOfBitsToShift / 32); - numberOfBitsToShift = aNumberOfBitsToShift % 32; - - result = new Array(aWordArray.length + numberOfWordsToShift); - - c = numberOfWordsToShift; - for (i=0; i 0) { - var nextOverflowValue; - - nextOverflowValue = (value >>> (32 - numberOfBitsToShift)); - value = value & (0xffffffff >>> numberOfBitsToShift); - resultWord = (((value << numberOfBitsToShift) | overflowValue) >>> 0); - } else { - resultWord = value; - } - - result[i+numberOfWordsToShift] = resultWord; - overflowValue = nextOverflowValue; - } - - if (overflowValue != 0) { - result[aWordArray.length + numberOfWordsToShift] = overflowValue; - } - - return result; -}; - -Clipperz.Crypto.ECC.BinaryField.Value._bitSize = function(aWordArray) { - var result; - var notNullElements; - var mostValuableWord; - var matchingBitsInMostImportantWord; - var mask; - var i,c; - - notNullElements = aWordArray.length; - - if ((aWordArray.length == 1) && (aWordArray[0] == 0)) { - result = 0; - } else { - notNullElements --; - while((notNullElements > 0) && (aWordArray[notNullElements] == 0)) { - notNullElements --; - } - - result = notNullElements * 32; - mostValuableWord = aWordArray[notNullElements]; - - matchingBits = 32; - mask = 0x80000000; - - while ((matchingBits > 0) && ((mostValuableWord & mask) == 0)) { - matchingBits --; - mask >>>= 1; - } - - result += matchingBits; - } - - return result; -}; - -Clipperz.Crypto.ECC.BinaryField.Value._isBitSet = function(aWordArray, aBitPosition) { - var result; - var byteIndex; - var bitIndexInSelectedByte; - - byteIndex = Math.floor(aBitPosition / 32); - bitIndexInSelectedByte = aBitPosition % 32; - - if (byteIndex <= aWordArray.length) { - result = ((aWordArray[byteIndex] & (1 << bitIndexInSelectedByte)) != 0); - } else { - result = false; - } - - return result; -}; - -Clipperz.Crypto.ECC.BinaryField.Value._compare = function(a,b) { - var result; - var i,c; - - result = MochiKit.Base.compare(a.length, b.length); - - c = a.length; - for (i=0; (i