Bug 1368859 - Test that the Web Crypto API rejects 0-length AES-GCM IVs r=keeler

This commit is contained in:
Tim Taubert 2017-06-21 12:48:04 +02:00
Родитель a89aab3e1d
Коммит ea139d953e
1 изменённых файлов: 88 добавлений и 0 удалений

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

@ -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",