Restore RSAES-PKCS1-V1_5 alg for backward compatibility

This commit is contained in:
Larry Joy 2020-05-15 08:20:32 -07:00
Родитель 826fa3e9a0
Коммит bbea6a421e
13 изменённых файлов: 783 добавлений и 111 удалений

Просмотреть файл

@ -17,7 +17,7 @@
//*******************************************************************************
"use strict";
var msrCryptoVersion = "1.6.0";
var msrCryptoVersion = "1.6.1";
(function(root, factory) {
@ -743,6 +743,10 @@ var msrCryptoVersion = "1.6.0";
return "A" + algorithm.length.toString() + "GCM";
},
"RSAES-PKCS1-V1_5": function(algorithm) {
return "RSA1_5";
},
"RSASSA-PKCS1-V1_5": function(algorithm) {
return "RS" + hashSize(algorithm);
},
@ -6562,6 +6566,7 @@ var msrCryptoVersion = "1.6.0";
var lHash, maskedSeed, maskeddb, seedMask;
var seed, dbMask, db;
var lHashp, i = 0;
var valid = encodedBytes[0] === 0;
if (!labelBytes) {
labelBytes = [];
@ -6569,10 +6574,6 @@ var msrCryptoVersion = "1.6.0";
lHash = hashFunction.computeHash(labelBytes);
if (encodedBytes[0] !== 0) {
throw new Error("Encryption Error");
}
maskedSeed = encodedBytes.slice(1, lHash.length + 1);
maskeddb = encodedBytes.slice(lHash.length + 1);
@ -6584,15 +6585,16 @@ var msrCryptoVersion = "1.6.0";
lHashp = db.slice(0, lHash.length);
if (!utils.arraysEqual(lHash, lHashp)) {
throw new Error("Encryption Error");
}
valid = valid && utils.arraysEqual(lHash, lHashp);
db = db.slice(lHash.length);
while (!db[i++]) {}
return db.slice(i);
return {
valid: valid,
data: db.slice(i)
};
}
return {
@ -6609,6 +6611,66 @@ var msrCryptoVersion = "1.6.0";
};
var rsaMode = rsaMode || {};
rsaMode.pkcs1Encrypt = function(keyStruct) {
var random = msrcryptoPseudoRandom,
size = keyStruct.n.length;
function pad(data) {
var randomness;
if (data.length > size - 11) {
throw new Error("message too long");
}
randomness = random.getNonZeroBytes(size - data.length - 3);
return [0, 2].concat(randomness, [0], data);
}
function validatePadding(paddedData) {
var paddingValid = paddedData[0] === 0 && paddedData[1] === 2;
for (var i = 2; i < 10; i++) {
paddingValid = paddingValid && !!paddedData[i];
}
return paddingValid;
}
function unpad(paddedData) {
var i,
paddingIsValid = validatePadding(paddedData),
startOfData = 0;
for (i = 1; i < paddedData.length; i += 1) {
startOfData = startOfData || +!paddedData[i] && i + 1;
}
startOfData = (-paddingIsValid && startOfData);
return {
data: paddedData.slice(startOfData),
valid: paddingIsValid
};
}
return {
pad: function(messageBytes) {
return pad(messageBytes);
},
unpad: function(encodedBytes) {
return unpad(encodedBytes);
}
};
};
rsaMode.pkcs1Sign = function(keyStruct, hashFunction) {
var utils = msrcryptoUtilities,
@ -6770,6 +6832,11 @@ var msrCryptoVersion = "1.6.0";
var padding;
switch (mode) {
case "RSAES-PKCS1-V1_5":
padding = rsaMode.pkcs1Encrypt(keyStruct);
break;
case "RSASSA-PKCS1-V1_5":
checkHash();
padding = rsaMode.pkcs1Sign(keyStruct, hashFunction);
@ -6826,6 +6893,12 @@ var msrCryptoVersion = "1.6.0";
if (unPaddingFunction !== null) {
decryptedData = unPaddingFunction(decryptedData, labelBytes);
if (decryptedData.valid === false) {
throw new Error("OperationError");
}
decryptedData = decryptedData.data;
} else {
decryptedData = decryptedData.slice(0);
}
@ -6885,6 +6958,12 @@ var msrCryptoVersion = "1.6.0";
var result, rsaObj, hashFunc, hashName;
switch (p.algorithm.name) {
case "RSAES-PKCS1-V1_5":
rsaObj = msrcryptoRsa(p.keyData, p.algorithm.name);
result = rsaObj.encrypt(p.buffer);
break;
case "RSA-OAEP":
hashName = p.keyHandle.algorithm.hash.name;
if (!hashName) {
@ -6906,6 +6985,12 @@ var msrCryptoVersion = "1.6.0";
var result, rsaObj, hashFunc;
switch (p.algorithm.name) {
case "RSAES-PKCS1-V1_5":
rsaObj = msrcryptoRsa(p.keyData, p.algorithm.name);
result = rsaObj.decrypt(p.buffer);
break;
case "RSA-OAEP":
var hashName = p.keyHandle.algorithm.hash.name;
if (!hashName) {
@ -7088,8 +7173,15 @@ var msrCryptoVersion = "1.6.0";
var algName = p.algorithm.name;
var rsaKeyType = algName.slice(algName.indexOf("-") + 1).toUpperCase();
var publicUsage = rsaKeyType === "OAEP" ? ["encrypt"] : ["verify"];
var privateUsage = rsaKeyType === "OAEP" ? ["decrypt"] : ["sign"];
var publicUsage, privateUsage;
if (algName === "RSASSA-PKCS1-V1_5" || algName === "RSA-PSS") {
publicUsage = ["verify"];
privateUsage = ["sign"];
} else {
publicUsage = ["encrypt"];
privateUsage = ["decrypt"];
}
return {
type: "keyGeneration",
@ -7122,18 +7214,23 @@ var msrCryptoVersion = "1.6.0";
operations.register("verify", "RSASSA-PKCS1-V1_5", msrcryptoRsa.verify);
operations.register("verify", "RSA-PSS", msrcryptoRsa.verify);
operations.register("encrypt", "RSAES-PKCS1-V1_5", msrcryptoRsa.workerEncrypt);
operations.register("decrypt", "RSAES-PKCS1-V1_5", msrcryptoRsa.workerDecrypt);
operations.register("encrypt", "RSA-OAEP", msrcryptoRsa.workerEncrypt);
operations.register("decrypt", "RSA-OAEP", msrcryptoRsa.workerDecrypt);
operations.register("importKey", "RSA-OAEP", msrcryptoRsa.importKey);
operations.register("importKey", "RSAES-PKCS1-V1_5", msrcryptoRsa.importKey);
operations.register("importKey", "RSASSA-PKCS1-V1_5", msrcryptoRsa.importKey);
operations.register("importKey", "RSA-PSS", msrcryptoRsa.importKey);
operations.register("exportKey", "RSA-OAEP", msrcryptoRsa.exportKey);
operations.register("exportKey", "RSAES-PKCS1-V1_5", msrcryptoRsa.exportKey);
operations.register("exportKey", "RSASSA-PKCS1-V1_5", msrcryptoRsa.exportKey);
operations.register("exportKey", "RSA-PSS", msrcryptoRsa.exportKey);
operations.register("generateKey", "RSA-OAEP", msrcryptoRsa.generateKeyPair);
operations.register("generateKey", "RSAES-PKCS1-V1_5", msrcryptoRsa.generateKeyPair);
operations.register("generateKey", "RSASSA-PKCS1-V1_5", msrcryptoRsa.generateKeyPair);
operations.register("generateKey", "RSA-PSS", msrcryptoRsa.generateKeyPair);
}

2
lib/msrcrypto.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -19,7 +19,7 @@
"use strict";
var msrCryptoVersion = "1.6.0";
var msrCryptoVersion = "1.6.1";
// UMD wrapper
(function(root, factory) {

Просмотреть файл

@ -68,6 +68,10 @@ var msrcryptoJwk = (function() {
return "A" + algorithm.length.toString() + "GCM";
},
"RSAES-PKCS1-V1_5": function(algorithm) {
return "RSA1_5";
},
"RSASSA-PKCS1-V1_5": function(algorithm) {
return "RS" + hashSize(algorithm);
},

Просмотреть файл

@ -70,6 +70,7 @@ rsaMode.oaep = function(keyStruct, hashFunction) {
var lHash, maskedSeed, maskeddb, seedMask;
var seed, dbMask, db;
var lHashp, i = 0;
var valid = encodedBytes[0] === 0;
if (!labelBytes) {
labelBytes = [];
@ -77,10 +78,6 @@ rsaMode.oaep = function(keyStruct, hashFunction) {
lHash = hashFunction.computeHash(labelBytes);
if (encodedBytes[0] !== 0) {
throw new Error("Encryption Error");
}
maskedSeed = encodedBytes.slice(1, lHash.length + 1);
maskeddb = encodedBytes.slice(lHash.length + 1);
@ -93,16 +90,17 @@ rsaMode.oaep = function(keyStruct, hashFunction) {
lHashp = db.slice(0, lHash.length);
// lHashp should equal lHash or 'Encryption Error'
if (!utils.arraysEqual(lHash, lHashp)) {
throw new Error("Encryption Error");
}
valid = valid && utils.arraysEqual(lHash, lHashp);
db = db.slice(lHash.length);
// There will be a bunch of zeros followed by a 1
while (!db[i++]) { /* empty */ }
return db.slice(i);
return {
valid: valid,
data: db.slice(i)
};
}
return {

Просмотреть файл

@ -17,6 +17,76 @@
//*******************************************************************************
var rsaMode = rsaMode || {};
rsaMode.pkcs1Encrypt = function(keyStruct) {
var random = msrcryptoPseudoRandom,
size = keyStruct.n.length;
function pad(data) {
var randomness;
if (data.length > size - 11) {
throw new Error("message too long");
}
// A minimum of 8 random bytes
randomness = random.getNonZeroBytes(size - data.length - 3);
return [0, 2].concat(randomness, [0], data);
}
function validatePadding(paddedData) {
// Validate the padding:
// we cannot know how much padding there should be.
// we can know that:
// a. the first two bytes should be 0,2
// b. the next eight bytes are non-zero
// validate first 2 bytes of padding are 0, 2
var paddingValid = paddedData[0] === 0 && paddedData[1] === 2;
// verify no zeros from bytes 2-10
for (var i = 2; i < 10; i++) {
paddingValid = paddingValid && !!paddedData[i];
}
return paddingValid;
}
function unpad(paddedData) {
var i,
paddingIsValid = validatePadding(paddedData),
startOfData = 0;
for (i = 1; i < paddedData.length; i += 1) {
// scan data for first zero byte
startOfData = startOfData || +!paddedData[i] && i + 1;
}
startOfData = (-paddingIsValid && startOfData);
return {
data: paddedData.slice(startOfData),
valid: paddingIsValid
};
}
return {
pad: function(messageBytes) {
return pad(messageBytes);
},
unpad: function(encodedBytes) {
return unpad(encodedBytes);
}
};
};
rsaMode.pkcs1Sign = function(keyStruct, hashFunction) {
var utils = msrcryptoUtilities,

Просмотреть файл

@ -35,6 +35,11 @@ var msrcryptoRsa = function(keyStruct, mode, /*@optional*/ hashFunction) {
var padding;
switch (mode) {
case "RSAES-PKCS1-V1_5":
padding = rsaMode.pkcs1Encrypt(keyStruct);
break;
case "RSASSA-PKCS1-V1_5":
checkHash();
padding = rsaMode.pkcs1Sign(keyStruct, hashFunction);
@ -100,6 +105,13 @@ var msrcryptoRsa = function(keyStruct, mode, /*@optional*/ hashFunction) {
///<disable>JS3053.IncorrectNumberOfArguments</disable>
decryptedData = unPaddingFunction(decryptedData, labelBytes);
///<enable>JS3053.IncorrectNumberOfArguments</enable>
if (decryptedData.valid === false) {
throw new Error("OperationError");
}
decryptedData = decryptedData.data;
} else {
decryptedData = decryptedData.slice(0);
}
@ -159,6 +171,12 @@ if (typeof operations !== "undefined") {
var result, rsaObj, hashFunc, hashName;
switch (p.algorithm.name) {
case "RSAES-PKCS1-V1_5":
rsaObj = msrcryptoRsa(p.keyData, p.algorithm.name);
result = rsaObj.encrypt(p.buffer);
break;
case "RSA-OAEP":
hashName = p.keyHandle.algorithm.hash.name; // hash is on key alg
if (!hashName) {
@ -180,6 +198,12 @@ if (typeof operations !== "undefined") {
var result, rsaObj, hashFunc;
switch (p.algorithm.name) {
case "RSAES-PKCS1-V1_5":
rsaObj = msrcryptoRsa(p.keyData, p.algorithm.name);
result = rsaObj.decrypt(p.buffer);
break;
case "RSA-OAEP":
var hashName = p.keyHandle.algorithm.hash.name; // hash is on key alg
if (!hashName) {
@ -356,7 +380,7 @@ if (typeof operations !== "undefined") {
throw new Error("invalid modulusLength");
}
// create a MongomeryMultiplier and attach to this private key
// create a MontgomeryMultiplier and attach to this private key
var pk = keyPair.privateKey;
pk.ctxp = (new cryptoMath.MontgomeryMultiplier(b2d(pk.p))).ctx;
pk.ctxq = (new cryptoMath.MontgomeryMultiplier(b2d(pk.q))).ctx;
@ -364,8 +388,15 @@ if (typeof operations !== "undefined") {
var algName = p.algorithm.name;
var rsaKeyType = algName.slice(algName.indexOf("-") + 1).toUpperCase();
var publicUsage = rsaKeyType === "OAEP" ? ["encrypt"] : ["verify"];
var privateUsage = rsaKeyType === "OAEP" ? ["decrypt"] : ["sign"];
var publicUsage, privateUsage;
if (algName === "RSASSA-PKCS1-V1_5" || algName === "RSA-PSS") {
publicUsage = ["verify"];
privateUsage = ["sign"];
} else { // OAEP, RSAES
publicUsage = ["encrypt"];
privateUsage = ["decrypt"];
}
return {
type: "keyGeneration",
@ -398,18 +429,23 @@ if (typeof operations !== "undefined") {
operations.register("verify", "RSASSA-PKCS1-V1_5", msrcryptoRsa.verify);
operations.register("verify", "RSA-PSS", msrcryptoRsa.verify);
operations.register("encrypt", "RSAES-PKCS1-V1_5", msrcryptoRsa.workerEncrypt);
operations.register("decrypt", "RSAES-PKCS1-V1_5", msrcryptoRsa.workerDecrypt);
operations.register("encrypt", "RSA-OAEP", msrcryptoRsa.workerEncrypt);
operations.register("decrypt", "RSA-OAEP", msrcryptoRsa.workerDecrypt);
operations.register("importKey", "RSA-OAEP", msrcryptoRsa.importKey);
operations.register("importKey", "RSAES-PKCS1-V1_5", msrcryptoRsa.importKey);
operations.register("importKey", "RSASSA-PKCS1-V1_5", msrcryptoRsa.importKey);
operations.register("importKey", "RSA-PSS", msrcryptoRsa.importKey);
operations.register("exportKey", "RSA-OAEP", msrcryptoRsa.exportKey);
operations.register("exportKey", "RSAES-PKCS1-V1_5", msrcryptoRsa.exportKey);
operations.register("exportKey", "RSASSA-PKCS1-V1_5", msrcryptoRsa.exportKey);
operations.register("exportKey", "RSA-PSS", msrcryptoRsa.exportKey);
operations.register("generateKey", "RSA-OAEP", msrcryptoRsa.generateKeyPair);
operations.register("generateKey", "RSAES-PKCS1-V1_5", msrcryptoRsa.generateKeyPair);
operations.register("generateKey", "RSASSA-PKCS1-V1_5", msrcryptoRsa.generateKeyPair);
operations.register("generateKey", "RSA-PSS", msrcryptoRsa.generateKeyPair);
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -17,13 +17,13 @@
//*******************************************************************************
var rsa = rsa || {};
rsa.pkcs15 = {
rsa.ssa = {
_1024: { sha1: {}, sha256: {}, sha384: {}, sha512: {} },
_2048: { sha1: {}, sha256: {}, sha384: {}, sha512: {} },
_4096: { sha1: {}, sha256: {}, sha384: {}, sha512: {} }
};
rsa.pkcs15._1024.sha1.spki = {
rsa.ssa._1024.sha1.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -43,7 +43,7 @@ rsa.pkcs15._1024.sha1.spki = {
]
};
rsa.pkcs15._1024.sha256.spki = {
rsa.ssa._1024.sha256.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -63,7 +63,7 @@ rsa.pkcs15._1024.sha256.spki = {
]
};
rsa.pkcs15._1024.sha384.spki = {
rsa.ssa._1024.sha384.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -83,7 +83,7 @@ rsa.pkcs15._1024.sha384.spki = {
]
};
rsa.pkcs15._1024.sha512.spki = {
rsa.ssa._1024.sha512.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -103,7 +103,7 @@ rsa.pkcs15._1024.sha512.spki = {
]
};
rsa.pkcs15._2048.sha1.spki = {
rsa.ssa._2048.sha1.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -123,7 +123,7 @@ rsa.pkcs15._2048.sha1.spki = {
]
};
rsa.pkcs15._2048.sha256.spki = {
rsa.ssa._2048.sha256.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -143,7 +143,7 @@ rsa.pkcs15._2048.sha256.spki = {
]
};
rsa.pkcs15._2048.sha384.spki = {
rsa.ssa._2048.sha384.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -163,7 +163,7 @@ rsa.pkcs15._2048.sha384.spki = {
]
};
rsa.pkcs15._2048.sha512.spki = {
rsa.ssa._2048.sha512.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -183,7 +183,7 @@ rsa.pkcs15._2048.sha512.spki = {
]
};
rsa.pkcs15._4096.sha1.spki = {
rsa.ssa._4096.sha1.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -203,7 +203,7 @@ rsa.pkcs15._4096.sha1.spki = {
]
};
rsa.pkcs15._4096.sha256.spki = {
rsa.ssa._4096.sha256.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -223,7 +223,7 @@ rsa.pkcs15._4096.sha256.spki = {
]
};
rsa.pkcs15._4096.sha384.spki = {
rsa.ssa._4096.sha384.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -243,7 +243,7 @@ rsa.pkcs15._4096.sha384.spki = {
]
};
rsa.pkcs15._4096.sha512.spki = {
rsa.ssa._4096.sha512.spki = {
format: "spki",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -263,7 +263,7 @@ rsa.pkcs15._4096.sha512.spki = {
]
};
rsa.pkcs15._1024.sha1.jwk = {
rsa.ssa._1024.sha1.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -287,7 +287,7 @@ rsa.pkcs15._1024.sha1.jwk = {
]
};
rsa.pkcs15._1024.sha256.jwk = {
rsa.ssa._1024.sha256.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -311,7 +311,7 @@ rsa.pkcs15._1024.sha256.jwk = {
]
};
rsa.pkcs15._1024.sha384.jwk = {
rsa.ssa._1024.sha384.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -335,7 +335,7 @@ rsa.pkcs15._1024.sha384.jwk = {
]
};
rsa.pkcs15._1024.sha512.jwk = {
rsa.ssa._1024.sha512.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -359,7 +359,7 @@ rsa.pkcs15._1024.sha512.jwk = {
]
};
rsa.pkcs15._2048.sha1.jwk = {
rsa.ssa._2048.sha1.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -383,7 +383,7 @@ rsa.pkcs15._2048.sha1.jwk = {
]
};
rsa.pkcs15._2048.sha256.jwk = {
rsa.ssa._2048.sha256.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -407,7 +407,7 @@ rsa.pkcs15._2048.sha256.jwk = {
]
};
rsa.pkcs15._2048.sha384.jwk = {
rsa.ssa._2048.sha384.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -431,7 +431,7 @@ rsa.pkcs15._2048.sha384.jwk = {
]
};
rsa.pkcs15._2048.sha512.jwk = {
rsa.ssa._2048.sha512.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -455,7 +455,7 @@ rsa.pkcs15._2048.sha512.jwk = {
]
};
rsa.pkcs15._4096.sha1.jwk = {
rsa.ssa._4096.sha1.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -479,7 +479,7 @@ rsa.pkcs15._4096.sha1.jwk = {
]
};
rsa.pkcs15._4096.sha256.jwk = {
rsa.ssa._4096.sha256.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -503,7 +503,7 @@ rsa.pkcs15._4096.sha256.jwk = {
]
};
rsa.pkcs15._4096.sha384.jwk = {
rsa.ssa._4096.sha384.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -527,7 +527,7 @@ rsa.pkcs15._4096.sha384.jwk = {
]
};
rsa.pkcs15._4096.sha512.jwk = {
rsa.ssa._4096.sha512.jwk = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -551,7 +551,7 @@ rsa.pkcs15._4096.sha512.jwk = {
]
};
rsa.pkcs15._1024.sha1.signatures = {
rsa.ssa._1024.sha1.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -575,7 +575,7 @@ rsa.pkcs15._1024.sha1.signatures = {
]
};
rsa.pkcs15._1024.sha256.signatures = {
rsa.ssa._1024.sha256.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -599,7 +599,7 @@ rsa.pkcs15._1024.sha256.signatures = {
]
};
rsa.pkcs15._1024.sha384.signatures = {
rsa.ssa._1024.sha384.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -623,7 +623,7 @@ rsa.pkcs15._1024.sha384.signatures = {
]
};
rsa.pkcs15._1024.sha512.signatures = {
rsa.ssa._1024.sha512.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -647,7 +647,7 @@ rsa.pkcs15._1024.sha512.signatures = {
]
};
rsa.pkcs15._2048.sha1.signatures = {
rsa.ssa._2048.sha1.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -671,7 +671,7 @@ rsa.pkcs15._2048.sha1.signatures = {
]
};
rsa.pkcs15._2048.sha256.signatures = {
rsa.ssa._2048.sha256.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -695,7 +695,7 @@ rsa.pkcs15._2048.sha256.signatures = {
]
};
rsa.pkcs15._2048.sha384.signatures = {
rsa.ssa._2048.sha384.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -719,7 +719,7 @@ rsa.pkcs15._2048.sha384.signatures = {
]
};
rsa.pkcs15._2048.sha512.signatures = {
rsa.ssa._2048.sha512.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -743,7 +743,7 @@ rsa.pkcs15._2048.sha512.signatures = {
]
};
rsa.pkcs15._4096.sha1.signatures = {
rsa.ssa._4096.sha1.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -767,7 +767,7 @@ rsa.pkcs15._4096.sha1.signatures = {
]
};
rsa.pkcs15._4096.sha256.signatures = {
rsa.ssa._4096.sha256.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -791,7 +791,7 @@ rsa.pkcs15._4096.sha256.signatures = {
]
};
rsa.pkcs15._4096.sha384.signatures = {
rsa.ssa._4096.sha384.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",
@ -815,7 +815,7 @@ rsa.pkcs15._4096.sha384.signatures = {
]
};
rsa.pkcs15._4096.sha512.signatures = {
rsa.ssa._4096.sha512.signatures = {
format: "jwk",
algorithm: {
name: "RSASSA-PKCS1-V1_5",

Просмотреть файл

@ -0,0 +1,256 @@
//*******************************************************************************
//
// Copyright 2020 Microsoft
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//*******************************************************************************
// NOTE:
//
// Microsoft Edge :
// does not support 32 or 64 bit tag lengths
// will fail on jwk keys with 'short' data elements (truncated leading zeros resulting in shorter data array)
// encrypt/decrypt alg with modulusLength or publicExponent will throw error (only needed on key functions)
//
// Chrome :
// does not support 192 bit AES keys
//
// tslint:disable: max-line-length
"use strict";
rsaEsTests();
function rsaEsTests() {
QUnit.module("RSAES-PKCS1-V1_5");
var ts = testShared;
var context = ts.testContext;
QUnit.test(label + " key import/export spki 1024 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.es._1024.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 2048 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.es._2048.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 4096 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.es._4096.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test( label + " key import/export jwk 1024 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.es._1024.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 2048 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.es._2048.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 4096 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.es._4096.jwk, undefined, undefined, context( iterations, assert ) );
} );
//=============================
QUnit.test( label + " generateKeyTest 1024", function( assert ) {
ts.keyGeneratePairTest(
rsaEsKeyAlg( 1024 ), ["encrypt", "decrypt"], inspectRsaEsKey, context( iterations, assert ) );
} );
slowTest( label + " generateKeyTest 2048", function( assert ) {
ts.keyGeneratePairTest(
rsaEsKeyAlg( 2048 ), ["encrypt", "decrypt"], inspectRsaEsKey, context( iterations, assert ) );
} );
slowTest( label + " generateKeyTest 4096", function( assert ) {
ts.keyGeneratePairTest(
rsaEsKeyAlg( 4096 ), ["encrypt", "decrypt"], inspectRsaEsKey, context( iterations, assert ) );
} );
//=============================
QUnit.test( label + " encrypt/decrypt 1024", function( assert ) {
ts.encryptDecryptTest( rsaEsKeyAlg( 1024 ), rsaEsEncryptAlg, context( iterations, assert ) );
} );
slowTest( label + " encrypt/decrypt 2048", function( assert ) {
ts.encryptDecryptTest( rsaEsKeyAlg( 2048 ), rsaEsEncryptAlg, context( iterations, assert ) );
} );
slowTest( label + " encrypt/decrypt 4096", function( assert ) {
ts.encryptDecryptTest( rsaEsKeyAlg( 4096 ), rsaEsEncryptAlg, context( iterations, assert ) );
} );
//=============================
QUnit.test(label + " decrypt native ciphers 1024", function(assert) {
ts.decryptNativeCiphersTest(rsa.es._1024.ciphers, context(iterations, assert));
});
QUnit.test( label + " decrypt native ciphers 2048", function( assert ) {
ts.decryptNativeCiphersTest( rsa.es._2048.ciphers, context( iterations, assert ) );
} );
slowTest( label + " decrypt native ciphers 4096", function( assert ) {
ts.decryptNativeCiphersTest( rsa.es._4096.ciphers, context( iterations, assert ) );
} );
}
function rsaEsKeyAlg(modulusLength) {
return {
name: "RSAES-PKCS1-V1_5",
modulusLength: modulusLength,
publicExponent: testShared.arr([0x01, 0x00, 0x01])
};
}
function rsaEsEncryptAlg() {
var alg = {
name: "RSAES-PKCS1-V1_5"
};
return alg;
}
var inspectRsaEsKey = {
public: function(keyObj, algorithm, usages, reason) {
// "publicKey": {
// "alg": "RSA1_5",
// "e": "AQAB",
// "ext": true,
// "key_ops": [
// "encrypt",
// ],
// "kty": "RSA",
// "n": "ush3d1BXcw3VjzD8jhff8GZD4KE5gmeJ...",
// },
var fail = [];
var expLenMax = algorithm.modulusLength / 8;
var expLenMin = expLenMax - 2;
// has alg property RSA1_5)
if (!validation.prop.string(keyObj, "alg", "RSA1_5")) {
fail.push("key.alg !== " + "RSA1_5");
}
// has ext property equal to true
if (!validation.prop.boolean(keyObj, "ext", true)) {
fail.push("key.ext !== true");
}
// has e property that is base64url
if (!validation.prop.isBase64Url(keyObj, "e")) {
fail.push("key.e !== true");
}
// has n property that is base64url
if (!validation.prop.isBase64Url(keyObj, "n", expLenMin, expLenMax)) {
fail.push("key.n !== true");
}
// has key_ops property with expected usages
if (Object.prototype.toString.call(keyObj.key_ops) !== "[object Array]") {
fail.push("key.key_ops missing or not Array");
}
if (keyObj.key_ops && !testShared.compareUsages(keyObj.key_ops, usages)) {
fail.push("key.key_ops invalid usage(s)");
}
// has kty property equal to 'RSA'
if (!validation.prop.string(keyObj, "kty", "RSA")) {
fail.push("key.kty !== RSA");
}
reason.message = fail.join("; ");
return (fail.length === 0);
},
private: function(keyObj, algorithm, usages, reason) {
// "privateKey": {
// "alg": "RSAES-PKCS1-V1_5",
// "d": "Aw88kbpBrHNKD73kLSmr8-Kg8wGBESdEA2SwRk6JLYhQjUmqwed7nW2WfR69ZY5dulPhl1BpGy...",
// "dp": "MzaNxLv5qiZ5tcXSZiQUuCr9Z1ivnNGd9HGK3xKLN4tqJGkqjEuBwThQFVaa-SkTU5bIK4o0AuX0sSRI8X26Yw",
// "dq": "hC-5kaiWpoBqWfndCNBFo7h4SVLe-g7dHSo-XN2uVCTykt-3kan_hfuzkcUNSb4WBsCvjzeSX5TySPPrDILKQQ",
// "e": "AQAB",
// "ext": true,
// "key_ops": [
// "decrypt",
// ],
// "kty": "RSA",
// "n": "ush3d1BXcw3VjzD8jhff8GZD4KE5gmeJZeA0OW03dgrAWjHZ-wykw1tvLXvFaAlePiXl0IteNXc92...",
// "p": "6l2mtx2Xdtvn-rNMPWTsrj-hXwwno8hZM5k8xV_ouiuciSGR8lgFhM0GBJapx9XADVZamb0sDEMiZRZmY4tygw",
// "q": "zAZglPR34FqV9QpbpVSuT-wB9tfCALLK-X2jA7IyNX9eRn5ZAmQT2PmpJ3ncGH-S1K9716X1oxBeO888qTXvQQ",
// "qi": "1lFKci4J7DlMzmi0J5_MdfNawjme8uJLBU4orqt_8ygqDQy9K5I3Qy5Lo6ifS9o9_yBVZmGZ-HInkTvppv82-w",
// },
var expLenMin;
var expLenMax;
this.public(keyObj, algorithm, ["decrypt"], reason);
var fail = reason.message ? reason.message.split("; ") : [];
expLenMax = algorithm.modulusLength / 8;
expLenMin = expLenMax - 2;
// d property is base64url bytes
if (!validation.prop.isBase64Url(keyObj, "d", expLenMin, expLenMax)) {
fail.push("key.d !== true");
}
expLenMax = algorithm.modulusLength / 16;
expLenMin = expLenMax - 2;
// dp property is base64url bytes
if (!validation.prop.isBase64Url(keyObj, "dp", expLenMin, expLenMax)) {
fail.push("key.dp !== true");
}
// dq property is base64url bytes
if (!validation.prop.isBase64Url(keyObj, "dq", expLenMin, expLenMax)) {
fail.push("key.dq !== true");
}
// p property is base64url bytes
if (!validation.prop.isBase64Url(keyObj, "p", expLenMin, expLenMax)) {
fail.push("key.p !== true");
}
// q property is base64url bytes
if (!validation.prop.isBase64Url(keyObj, "q", expLenMin, expLenMax)) {
fail.push("key.q !== true");
}
// qi property is base64url bytes
if (!validation.prop.isBase64Url(keyObj, "qi", expLenMin, expLenMax)) {
fail.push("key.qi fail");
}
reason.message = fail.join("; ");
return (fail.length === 0);
}
};

Просмотреть файл

@ -32,133 +32,133 @@
"use strict";
rsaPkcs15Tests();
rsaSsaTests();
function rsaPkcs15Tests() {
function rsaSsaTests() {
QUnit.module( "RSA-PKCS15" );
QUnit.module( "RSASSA-PKCS1-V1_5" );
var ts = testShared;
var context = ts.testContext;
QUnit.test(label + " key import/export spki 1024 sha-1 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._1024.sha1.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._1024.sha1.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 1024 sha-256 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._1024.sha256.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._1024.sha256.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 1024 sha-384 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._1024.sha384.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._1024.sha384.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 1024 sha-512 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._1024.sha512.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._1024.sha512.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 2048 sha-1 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._2048.sha1.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._2048.sha1.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 2048 sha-256 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._2048.sha256.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._2048.sha256.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 2048 sha-384 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._2048.sha384.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._2048.sha384.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 2048 sha-512 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._2048.sha512.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._2048.sha512.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 4096 sha-1 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._4096.sha1.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._4096.sha1.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 4096 sha-256 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._4096.sha256.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._4096.sha256.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 4096 sha-384 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._4096.sha384.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._4096.sha384.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test(label + " key import/export spki 4096 sha-512 ", function(assert) {
ts.keyImportExportTestSpki(
rsa.pkcs15._4096.sha512.spki, undefined, undefined, context(iterations, assert));
rsa.ssa._4096.sha512.spki, undefined, undefined, context(iterations, assert));
});
QUnit.test( label + " key import/export jwk 1024 sha-1 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._1024.sha1.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._1024.sha1.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 1024 sha-256 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._1024.sha256.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._1024.sha256.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 1024 sha-384 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._1024.sha384.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._1024.sha384.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 1024 sha-512 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._1024.sha512.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._1024.sha512.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 2048 sha-1 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._2048.sha1.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._2048.sha1.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 2048 sha-256 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._2048.sha256.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._2048.sha256.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 2048 sha-384 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._2048.sha384.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._2048.sha384.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 2048 sha-512 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._2048.sha512.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._2048.sha512.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 4096 sha-1 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._4096.sha1.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._4096.sha1.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 4096 sha-256 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._4096.sha256.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._4096.sha256.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 4096 sha-384 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._4096.sha384.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._4096.sha384.jwk, undefined, undefined, context( iterations, assert ) );
} );
QUnit.test( label + " key import/export jwk 4096 sha-512 ", function( assert ) {
ts.keyPairImportExportTest(
rsa.pkcs15._4096.sha512.jwk, undefined, undefined, context( iterations, assert ) );
rsa.ssa._4096.sha512.jwk, undefined, undefined, context( iterations, assert ) );
} );
//=============================
@ -277,62 +277,62 @@ function rsaPkcs15Tests() {
QUnit.test( label + " verify native signature 1024 sha-1 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._1024.sha1.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._1024.sha1.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 1024 sha-256 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._1024.sha256.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._1024.sha256.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 1024 sha-384 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._1024.sha384.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._1024.sha384.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 1024 sha-512 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._1024.sha512.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._1024.sha512.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 2048 sha-1 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._2048.sha1.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._2048.sha1.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 2048 sha-256 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._2048.sha256.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._2048.sha256.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 2048 sha-384 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._2048.sha384.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._2048.sha384.signatures, context( iterations, assert ) );
} );
QUnit.test( label + " verify native signature 2048 sha-512 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._2048.sha512.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._2048.sha512.signatures, context( iterations, assert ) );
} );
slowTest( label + " verify native signature 4096 sha-1 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._4096.sha1.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._4096.sha1.signatures, context( iterations, assert ) );
} );
slowTest( label + " verify native signature 4096 sha-256 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._4096.sha256.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._4096.sha256.signatures, context( iterations, assert ) );
} );
slowTest( label + " verify native signature 4096 sha-384 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._4096.sha384.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._4096.sha384.signatures, context( iterations, assert ) );
} );
slowTest( label + " verify native signature 4096 sha-512 ", function( assert ) {
ts.verifyNativeSignatureTest(
rsaPkcs15EncryptAlg, rsa.pkcs15._4096.sha512.signatures, context( iterations, assert ) );
rsaPkcs15EncryptAlg, rsa.ssa._4096.sha512.signatures, context( iterations, assert ) );
} );
}

Просмотреть файл

@ -229,6 +229,21 @@ var testShared = {
};
},
maxMessageLen: function(keyAlgorithm) {
if (keyAlgorithm.modulusLength) {
if (keyAlgorithm.name === "RSA-OAEP") {
return (keyAlgorithm.modulusLength / 8) - 2 * hashLengths[keyAlgorithm.hash.name] - 2;
}
if (keyAlgorithm.name === "RSAES-PKCS1-V1_5") {
return (keyAlgorithm.modulusLength / 8) - 11;
}
throw new Error("unknown algorithm.");
}
return 1000;
},
keyImportExportTestSpki: function(vectorSet, usages, keyValidationFunc, context) {
// spki tests have a public key in spki format and a verify key in jwk format
@ -441,13 +456,12 @@ var testShared = {
// alg params may be alg-generating functions or a static algorithm objects
var encAlgorithm = typeof encryptAlg === "function" ? encryptAlg(context.count) : encryptAlg;
var keyAlgorithm = typeof keyAlg === "function" ? keyAlg(context.count) : keyAlg;
var maxMessageLen = keyAlgorithm.modulusLength ?
keyAlgorithm.modulusLength / 8 - 2 * hashLengths[keyAlgorithm.hash.name] - 2 : 1000;
var maxMessageLen = testShared.maxMessageLen(keyAlg);
var plainText = testShared.getRandomBytes(1, maxMessageLen);
var cryptoKeyEncrypt;
var cryptoKeyDecrypt;
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.encryptDecryptTest(keyAlg, encryptAlg, context);
}
@ -497,7 +511,7 @@ var testShared = {
var cryptoKeyVerify;
var signature;
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.signVerifyTest(keyAlg, signAlg, context);
}
@ -540,7 +554,7 @@ var testShared = {
var algorithm = typeof signAlgorithm === "function" ?
signAlgorithm(context.count) : this.clone(signAlgorithm);
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.verifyNativeSignatureTest(signAlgorithm, vectorSet, context);
}
@ -588,7 +602,7 @@ var testShared = {
}
}
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.decryptNativeCiphersTest(vectorSet, context);
}
@ -620,7 +634,7 @@ var testShared = {
var vector = vectorSet.vectors[(context.count) % vectorSet.vectors.length];
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.deriveKeyTest(vectorSet, keyValidationFunc, context);
}
@ -674,7 +688,7 @@ var testShared = {
var vector = vectorSet.vectors[(context.count - 1) % vectorSet.vectors.length];
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.deriveBitsTest(vectorSet, context);
}
@ -726,7 +740,7 @@ var testShared = {
var vector = vectorSet.vectors[context.count - 1 % vectorSet.vectors.length];
if (--context.count > 0) { // recursivley call to start the next iteration
if (--context.count > 0) { // recursively call to start the next iteration
testShared.hashTest(vectorSet, context);
}

Просмотреть файл

@ -48,8 +48,9 @@
<script src="../scripts/testVectors/tv_ecdsa.js"></script>
<script src="../scripts/testVectors/tv_hmac.js"></script>
<script src="../scripts/testVectors/tv_sha2.js"></script>
<script src="../scripts/testVectors/tv_rsa_es.js"></script>
<script src="../scripts/testVectors/tv_rsa_oaep.js"></script>
<script src="../scripts/testVectors/tv_rsa_pkcs15.js"></script>
<script src="../scripts/testVectors/tv_rsa_ssa.js"></script>
<script src="../scripts/testVectors/tv_rsa_pss.js"></script>
<script src="../scripts/testVectors/tv_pbkdf2.js"></script>
@ -60,8 +61,9 @@
<script src="../scripts/tests/Test.Encoding.js"></script>
<script src="../scripts/tests/Test.Aes.Cbc.js"></script>
<script src="../scripts/tests/Test.Aes.Gcm.js"></script>
<script src="../scripts/tests/Test.Rsa.Es.js"></script>
<script src="../scripts/tests/Test.Rsa.Oaep.js"></script>
<script src="../scripts/tests/Test.Rsa.Pkcs15.js"></script>
<script src="../scripts/tests/Test.Rsa.Ssa.js"></script>
<script src="../scripts/tests/Test.Rsa.Pss.js"></script>
<script src="../scripts/tests/Test.Sha2.js"></script>
<script src="../scripts/tests/Test.Ecdh.js"></script>