зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1368859 - Test that the Web Crypto API rejects 0-length AES-GCM IVs r=keeler
This commit is contained in:
Родитель
a89aab3e1d
Коммит
ea139d953e
|
@ -722,6 +722,94 @@ TestArray.addTest(
|
|||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("raw", tv.aes_gcm_enc.key, "AES-GCM", false, ['encrypt'])
|
||||
.then(doEncrypt)
|
||||
.then(error(that), complete(that));
|
||||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"AES-GCM encryption, accept an all-zero IV (1 byte)",
|
||||
function () {
|
||||
var that = this;
|
||||
var alg = {
|
||||
name: "AES-GCM",
|
||||
iv: new Uint8Array(1),
|
||||
additionalData: tv.aes_gcm_enc.adata,
|
||||
tagLength: 128
|
||||
};
|
||||
|
||||
function doEncrypt(x) {
|
||||
return crypto.subtle.encrypt(alg, x, tv.aes_gcm_enc.data);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("raw", tv.aes_gcm_enc.key, "AES-GCM", false, ['encrypt'])
|
||||
.then(doEncrypt)
|
||||
.then(complete(that), error(that));
|
||||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"AES-GCM encryption, accept an all-zero IV (12 bytes)",
|
||||
function () {
|
||||
var that = this;
|
||||
var alg = {
|
||||
name: "AES-GCM",
|
||||
iv: new Uint8Array(12),
|
||||
additionalData: tv.aes_gcm_enc.adata,
|
||||
tagLength: 128
|
||||
};
|
||||
|
||||
function doEncrypt(x) {
|
||||
return crypto.subtle.encrypt(alg, x, tv.aes_gcm_enc.data);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("raw", tv.aes_gcm_enc.key, "AES-GCM", false, ['encrypt'])
|
||||
.then(doEncrypt)
|
||||
.then(complete(that), error(that));
|
||||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"AES-GCM encryption, accept an all-zero IV (16 bytes)",
|
||||
function () {
|
||||
var that = this;
|
||||
var alg = {
|
||||
name: "AES-GCM",
|
||||
iv: new Uint8Array(16),
|
||||
additionalData: tv.aes_gcm_enc.adata,
|
||||
tagLength: 128
|
||||
};
|
||||
|
||||
function doEncrypt(x) {
|
||||
return crypto.subtle.encrypt(alg, x, tv.aes_gcm_enc.data);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("raw", tv.aes_gcm_enc.key, "AES-GCM", false, ['encrypt'])
|
||||
.then(doEncrypt)
|
||||
.then(complete(that), error(that));
|
||||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"HMAC SHA-256 sign",
|
||||
|
|
Загрузка…
Ссылка в новой задаче