// -----------------------------------------------------------------------------
TestArray.addTest( "Clean failure on a mal-formed algorithm",
function() { var that = this; var alg = {
get name() {
throw new Error("Oh no, no name!");
},
};
// -----------------------------------------------------------------------------
TestArray.addTest( "Import / export round-trip with 'raw'",
function() { var that = this; var alg = "AES-GCM";
// -----------------------------------------------------------------------------
TestArray.addTest( "Import failure with format 'raw'",
function() { var that = this; var alg = "AES-GCM";
// -----------------------------------------------------------------------------
TestArray.addTest( "Proper handling of an ABV representing part of a buffer",
function() { var that = this; var alg = "AES-GCM";
var u8 = new Uint8Array([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f]); var u32 = new Uint32Array(u8.buffer, 8, 4); var out = u8.subarray(8, 24);
function doExport(x) {
return crypto.subtle.exportKey("raw", x);
}
// -----------------------------------------------------------------------------
TestArray.addTest( "Import failure with format 'pkcs8'",
function() { var that = this; var alg = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-1" };
// -----------------------------------------------------------------------------
TestArray.addTest( "Import failure with format 'spki'",
function() { var that = this; var alg = {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
};
// -----------------------------------------------------------------------------
TestArray.addTest( "Importing an ECDSA key as an RSA key should fail",
function() { var that = this; var alg = {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
};
// -----------------------------------------------------------------------------
TestArray.addTest( "Refuse to export non-extractable key",
function() { var that = this; var alg = "AES-GCM";
function doExport(x) {
return crypto.subtle.exportKey("raw", x);
}
// -----------------------------------------------------------------------------
TestArray.addTest( "IndexedDB store / retrieve round-trip",
function() { var that = this; var alg = "AES-GCM"; var importedKey; var dbname = "keyDB"; var dbstore = "keystore"; var dbversion = 1; var dbkey = 0; var db;
function doIndexedDB(x) {
importedKey = x; var req = indexedDB.deleteDatabase(dbname);
req.onerror = error(that);
req.onsuccess = doCreateDB;
}
function doCreateDB() { var req = indexedDB.open(dbname, dbversion);
req.onerror = error(that);
req.onupgradeneeded = function(e) {
db = e.target.result;
db.createObjectStore(dbstore, {keyPath: "id"});
};
req.onsuccess = doPut;
}
function doPut() { var req = db.transaction([dbstore], "readwrite")
.objectStore(dbstore)
.add({id: dbkey, val: importedKey});
req.onerror = error(that);
req.onsuccess = doGet;
}
// -----------------------------------------------------------------------------
TestArray.addTest( "Fail cleanly when NSS refuses to generate a key pair",
function() { var that = this; var alg = {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
modulusLength: 2299, // NSS does not like this key length
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
};
// -----------------------------------------------------------------------------
TestArray.addTest( "AES-CBC encrypt with wrong IV size",
function() { var that = this;
function encrypt(x, iv) {
return crypto.subtle.encrypt(
{ name: "AES-CBC", iv },
x, tv.aes_cbc_enc.data);
}
function checkPromises(promises) {
for (var promise of promises) {
if (promise.status != "rejected") {
return false;
}
if (promise.reason.name != "OperationError") {
return false;
}
}
return true;
}
crypto.subtle.importKey("raw", tv.aes_cbc_enc.key, "AES-CBC", false, ["encrypt"])
.then(function(key) { var p1 = encrypt(key, new Uint8Array(15)); var p2 = encrypt(key, new Uint8Array(17));
// -----------------------------------------------------------------------------
TestArray.addTest( "AES-CBC decrypt with wrong IV size",
function() { var that = this;
function decrypt(x, iv) {
return crypto.subtle.decrypt(
{ name: "AES-CBC", iv },
x, tv.aes_cbc_dec.data);
}
function checkPromises(promises) {
for (var promise of promises) {
if (promise.status != "rejected") {
return false;
}
if (promise.reason.name != "OperationError") {
return false;
}
}
return true;
}
crypto.subtle.importKey("raw", tv.aes_cbc_dec.key, "AES-CBC", false, ["decrypt"])
.then(function(key) { var p1 = decrypt(key, new Uint8Array(15)); var p2 = decrypt(key, new Uint8Array(17));
// -----------------------------------------------------------------------------
TestArray.addTest( "AES-CTR encryption with wrong IV size",
function() { var that = this;
function encrypt(x, iv) {
return crypto.subtle.encrypt(
{ name: "AES-CTR", counter: iv, length: 32 },
x, tv.aes_ctr_enc.data);
}
function checkPromises(promises) {
for (var promise of promises) {
if (promise.status != "rejected") {
return false;
}
if (promise.reason.name != "OperationError") {
return false;
}
}
return true;
}
crypto.subtle.importKey("raw", tv.aes_ctr_enc.key, "AES-CTR", false, ["encrypt"])
.then(function(key) { var p1 = encrypt(key, new Uint8Array(15)); var p2 = encrypt(key, new Uint8Array(17));
// -----------------------------------------------------------------------------
TestArray.addTest( "AES-CTR decryption with wrong IV size",
function() { var that = this;
function decrypt(x, iv) {
return crypto.subtle.decrypt(
{ name: "AES-CTR", counter: iv, length: 32 },
x, tv.aes_ctr_dec.data);
}
function checkPromises(promises) {
for (var promise of promises) {
if (promise.status != "rejected") {
return false;
}
if (promise.reason.name != "OperationError") {
return false;
}
}
return true;
}
crypto.subtle.importKey("raw", tv.aes_ctr_dec.key, "AES-CTR", false, ["decrypt"])
.then(function(key) { var p1 = decrypt(key, new Uint8Array(15)); var p2 = decrypt(key, new Uint8Array(17));
// -----------------------------------------------------------------------------
TestArray.addTest( "AES-GCM encryption, fail with a zero-length IV",
function() { var that = this; var alg = {
name: "AES-GCM",
iv: new Uint8Array(),
additionalData: tv.aes_gcm_enc.adata,
tagLength: 128,
};
function doEncrypt(x) {
return crypto.subtle.encrypt(alg, x, tv.aes_gcm_enc.data);
}
// -----------------------------------------------------------------------------
TestArray.addTest( "HMAC SHA-256, failing verification due to bad signature",
function() { var that = this; var alg = {
name: "HMAC",
hash: "SHA-256",
};
function doVerify(x) {
return crypto.subtle.verify("HMAC", x, tv.hmac_verify.sig_fail,
tv.hmac_verify.data);
}
// -----------------------------------------------------------------------------
TestArray.addTest( "Test that we return ArrayBuffers not ArrayBufferViews",
function() { var that = this;
// -----------------------------------------------------------------------------
TestArray.addTest( "Ensure that importing an invalid key doesn't crash",
function() { var that = this; var alg = {name: "RSA-OAEP", hash: "SHA-1"};
// -----------------------------------------------------------------------------
TestArray.addTest( "Test that we check keys before using them for encryption/signatures",
function() { var that = this;
function doCheckRSASSA() { var alg = {name: "HMAC", hash: {name: "SHA-1"}};
function doSign(x) {
return crypto.subtle.sign("RSASSA-PKCS1-v1_5", x, new Uint8Array());
}
// -----------------------------------------------------------------------------
TestArray.addTest( "Test that we're using the right globals when creating objects",
function() {
// This test isn't supported in workers.
if (window.importScripts) {
return this.complete(true);
}
var that = this; var data = crypto.getRandomValues(new Uint8Array(10)); var hmacAlg = {name: "HMAC", length: 256, hash: "SHA-1"};
var rsaAlg = {
name: "RSA-PSS",
hash: "SHA-1",
modulusLength: 1024,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
};
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.39Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.