author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-06 00:36:10 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-06 00:36:10 (UTC) |
commit | 6ba274c79e60e417132b260bd0117c5a68121387 (patch) (unidiff) | |
tree | 57c1f95d0fbf9b80312c5c6b6f4a4f951e31c770 /frontend/beta/js/Clipperz/ByteArray.js | |
parent | 13ebf1b1987a1566d081ff1ba89b4dca197b7d2e (diff) | |
download | clipperz-6ba274c79e60e417132b260bd0117c5a68121387.zip clipperz-6ba274c79e60e417132b260bd0117c5a68121387.tar.gz clipperz-6ba274c79e60e417132b260bd0117c5a68121387.tar.bz2 |
Fixed the copyright headers
Diffstat (limited to 'frontend/beta/js/Clipperz/ByteArray.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/ByteArray.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/ByteArray.js b/frontend/beta/js/Clipperz/ByteArray.js index 2275087..a69aa43 100644 --- a/frontend/beta/js/Clipperz/ByteArray.js +++ b/frontend/beta/js/Clipperz/ByteArray.js | |||
@@ -1,152 +1,149 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | 27 | ||
31 | //============================================================================= | 28 | //============================================================================= |
32 | 29 | ||
33 | Clipperz.ByteArray_abstract = function(args) { | 30 | Clipperz.ByteArray_abstract = function(args) { |
34 | return this; | 31 | return this; |
35 | } | 32 | } |
36 | 33 | ||
37 | Clipperz.ByteArray_abstract.prototype = MochiKit.Base.update(null, { | 34 | Clipperz.ByteArray_abstract.prototype = MochiKit.Base.update(null, { |
38 | 35 | ||
39 | //------------------------------------------------------------------------- | 36 | //------------------------------------------------------------------------- |
40 | 37 | ||
41 | 'toString': function() { | 38 | 'toString': function() { |
42 | return "Clipperz.ByteArray_abstract"; | 39 | return "Clipperz.ByteArray_abstract"; |
43 | }, | 40 | }, |
44 | 41 | ||
45 | //------------------------------------------------------------------------- | 42 | //------------------------------------------------------------------------- |
46 | 43 | ||
47 | 'equals': function(aValue) { | 44 | 'equals': function(aValue) { |
48 | return (this.compare(aValue) == 0); | 45 | return (this.compare(aValue) == 0); |
49 | }, | 46 | }, |
50 | 47 | ||
51 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
52 | 49 | ||
53 | 'compare': function(aValue) { | 50 | 'compare': function(aValue) { |
54 | var result; | 51 | var result; |
55 | var i; | 52 | var i; |
56 | 53 | ||
57 | result = MochiKit.Base.compare(this.length(), aValue.length()); | 54 | result = MochiKit.Base.compare(this.length(), aValue.length()); |
58 | i = this.length(); | 55 | i = this.length(); |
59 | 56 | ||
60 | while ((result == 0) && (i>0)) { | 57 | while ((result == 0) && (i>0)) { |
61 | i--; | 58 | i--; |
62 | result = MochiKit.Base.compare(this.byteAtIndex(i), aValue.byteAtIndex(i)); | 59 | result = MochiKit.Base.compare(this.byteAtIndex(i), aValue.byteAtIndex(i)); |
63 | } | 60 | } |
64 | 61 | ||
65 | return result; | 62 | return result; |
66 | }, | 63 | }, |
67 | 64 | ||
68 | //------------------------------------------------------------------------- | 65 | //------------------------------------------------------------------------- |
69 | 66 | ||
70 | 'clone': function() { | 67 | 'clone': function() { |
71 | throw Clipperz.Base.exception.AbstractMethod; | 68 | throw Clipperz.Base.exception.AbstractMethod; |
72 | }, | 69 | }, |
73 | 70 | ||
74 | //------------------------------------------------------------------------- | 71 | //------------------------------------------------------------------------- |
75 | 72 | ||
76 | 'newInstance': function() { | 73 | 'newInstance': function() { |
77 | throw Clipperz.Base.exception.AbstractMethod; | 74 | throw Clipperz.Base.exception.AbstractMethod; |
78 | }, | 75 | }, |
79 | 76 | ||
80 | //------------------------------------------------------------------------- | 77 | //------------------------------------------------------------------------- |
81 | 78 | ||
82 | 'reset': function() { | 79 | 'reset': function() { |
83 | throw Clipperz.Base.exception.AbstractMethod; | 80 | throw Clipperz.Base.exception.AbstractMethod; |
84 | }, | 81 | }, |
85 | 82 | ||
86 | //------------------------------------------------------------------------- | 83 | //------------------------------------------------------------------------- |
87 | 84 | ||
88 | 'length': function() { | 85 | 'length': function() { |
89 | throw Clipperz.Base.exception.AbstractMethod; | 86 | throw Clipperz.Base.exception.AbstractMethod; |
90 | }, | 87 | }, |
91 | 88 | ||
92 | //------------------------------------------------------------------------- | 89 | //------------------------------------------------------------------------- |
93 | 90 | ||
94 | 'checkValue': function(aValue) { | 91 | 'checkValue': function(aValue) { |
95 | if ((aValue & 0xff) != aValue) { | 92 | if ((aValue & 0xff) != aValue) { |
96 | MochiKit.Logging.logError("Clipperz.ByteArray.appendByte: the provided value (0x" + aValue.toString(16) + ") is not a byte value."); | 93 | MochiKit.Logging.logError("Clipperz.ByteArray.appendByte: the provided value (0x" + aValue.toString(16) + ") is not a byte value."); |
97 | throw Clipperz.ByteArray.exception.InvalidValue; | 94 | throw Clipperz.ByteArray.exception.InvalidValue; |
98 | } | 95 | } |
99 | }, | 96 | }, |
100 | 97 | ||
101 | //------------------------------------------------------------------------- | 98 | //------------------------------------------------------------------------- |
102 | 99 | ||
103 | 'xorMergeWithBlock': function(aBlock, anAllignment, paddingMode) { | 100 | 'xorMergeWithBlock': function(aBlock, anAllignment, paddingMode) { |
104 | var result; | 101 | var result; |
105 | var a, b; | 102 | var a, b; |
106 | var aLength; | 103 | var aLength; |
107 | var bLength; | 104 | var bLength; |
108 | var i, c; | 105 | var i, c; |
109 | 106 | ||
110 | if (this.length() > aBlock.length()) { | 107 | if (this.length() > aBlock.length()) { |
111 | a = this; | 108 | a = this; |
112 | b = aBlock; | 109 | b = aBlock; |
113 | } else { | 110 | } else { |
114 | a = aBlock; | 111 | a = aBlock; |
115 | b = this; | 112 | b = this; |
116 | } | 113 | } |
117 | 114 | ||
118 | aLength = a.length(); | 115 | aLength = a.length(); |
119 | bLength = b.length(); | 116 | bLength = b.length(); |
120 | 117 | ||
121 | if (aLength != bLength) { | 118 | if (aLength != bLength) { |
122 | if (paddingMode == 'truncate') { | 119 | if (paddingMode == 'truncate') { |
123 | if (anAllignment == 'left') { | 120 | if (anAllignment == 'left') { |
124 | a = a.split(0, bLength); | 121 | a = a.split(0, bLength); |
125 | } else { | 122 | } else { |
126 | a = a.split(aLength - bLength); | 123 | a = a.split(aLength - bLength); |
127 | } | 124 | } |
128 | } else { | 125 | } else { |
129 | var ii, cc; | 126 | var ii, cc; |
130 | var padding; | 127 | var padding; |
131 | 128 | ||
132 | // padding = new Clipperz.ByteArray(); | 129 | // padding = new Clipperz.ByteArray(); |
133 | padding = this.newInstance(); | 130 | padding = this.newInstance(); |
134 | cc = aLength - bLength; | 131 | cc = aLength - bLength; |
135 | for (ii=0; ii<cc; ii++) { | 132 | for (ii=0; ii<cc; ii++) { |
136 | padding.appendByte(0); | 133 | padding.appendByte(0); |
137 | } | 134 | } |
138 | 135 | ||
139 | if (anAllignment == 'left') { | 136 | if (anAllignment == 'left') { |
140 | b = b.appendBlock(padding); | 137 | b = b.appendBlock(padding); |
141 | } else { | 138 | } else { |
142 | b = padding.appendBlock(b); | 139 | b = padding.appendBlock(b); |
143 | } | 140 | } |
144 | } | 141 | } |
145 | } | 142 | } |
146 | 143 | ||
147 | 144 | ||
148 | // result = new Clipperz.ByteArray(); | 145 | // result = new Clipperz.ByteArray(); |
149 | result = this.newInstance(); | 146 | result = this.newInstance(); |
150 | c = a.length(); | 147 | c = a.length(); |
151 | for (i=0; i<c; i++) { | 148 | for (i=0; i<c; i++) { |
152 | result.appendByte(a.byteAtIndex(i) ^ b.byteAtIndex(i)); | 149 | result.appendByte(a.byteAtIndex(i) ^ b.byteAtIndex(i)); |