blob: bca8b697f2538682014ed386e22fc6788476fb42 [file] [log] [blame]
[
// F.2.1 (CBC-AES128.Encrypt)
// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
{
"key_format": "raw",
"key": "2b7e151628aed2a6abf7158809cf4f3c",
"iv": "000102030405060708090a0b0c0d0e0f",
"plain_text": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
// Added a padding block: encryption of {0x10, 0x10, ... 0x10}) (not given by the
// NIST test vector)
"cipher_text": "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78cb82807230e1321d3fae00d18cc2012"
},
// F.2.6 CBC-AES256.Decrypt [*]
// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
//
// [*] Truncated 3 bytes off the plain text, so block 4 differs from the
// NIST vector.
{
"key_format": "raw",
"key": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
"iv": "000102030405060708090a0b0c0d0e0f",
// Truncated the last block to make it more interesting.
"plain_text": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be6",
// Last block differs from source vector (due to truncation)
"cipher_text": "f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461c9aaf02a6a54e9e242ccbf48c59daca6"
},
// Taken from encryptor_unittest.cc (EncryptorTest.EmptyEncrypt())
{
"key_format": "raw",
"key": "3132383d5369787465656e4279746573",
"iv": "5377656574205369787465656e204956",
"plain_text": "",
"cipher_text": "8518b8878d34e7185e300d0fcc426396"
},
// Fail encrypting because the IV is too small.
{
"key_format": "raw",
"key": "3132383d5369787465656e4279746573",
"iv": "5300",
"plain_text": "0000",
"encrypt_error": "OperationError: The \"iv\" has an unexpected length -- must be 16 bytes"
},
// Fail decrypting because the IV is too small.
{
"key_format": "raw",
"key": "3132383d5369787465656e4279746573",
"iv": "5300",
"cipher_text": "8518b8878d34e7185e300d0fcc426396",
"decrypt_error": "OperationError: The \"iv\" has an unexpected length -- must be 16 bytes"
},
// Fail encrypting because the IV is too large.
{
"key_format": "raw",
"key": "3132383d5369787465656e4279746573",
"iv": "5377656574205369787465656e2049560000000000000000",
"plain_text": "0000",
"encrypt_error": "OperationError: The \"iv\" has an unexpected length -- must be 16 bytes"
},
// Fail decrypting because the IV is too large.
{
"key_format": "raw",
"key": "3132383d5369787465656e4279746573",
"iv": "5377656574205369787465656e2049560000000000000000",
"cipher_text": "8518b8878d34e7185e300d0fcc426396",
"decrypt_error": "OperationError: The \"iv\" has an unexpected length -- must be 16 bytes"
},
// Fail importing the key because not enough bytes were specified.
{
"key_format": "raw",
"key": "31",
"import_error": "DataError: AES key data must be 128 or 256 bits"
},
// Fail importing because the wrong format was specified
{
"key_format": "spki",
"key": "3132383d5369787465656e4279746573",
"import_error": "NotSupported: Unsupported import key format for algorithm"
},
// Fail importing because the wrong format was specified
{
"key_format": "pkcs8",
"key": "3132383d5369787465656e4279746573",
"import_error": "NotSupported: Unsupported import key format for algorithm"
},
// Fail decrypting an empty cipher text
{
"key_format": "raw",
"key": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
"iv": "000102030405060708090a0b0c0d0e0f",
"cipher_text": "",
"decrypt_error": "OperationError"
},
// Decrypt a truncated cipher text (removed an entire block).
{
"key_format": "raw",
"key": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4",
"iv": "000102030405060708090a0b0c0d0e0f",
"cipher_text": "f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461",
"decrypt_error": "OperationError"
},
// Decrypt truncated cipher text (stripped 3 byte).
{
"key_format": "raw",
"key": "2b7e151628aed2a6abf7158809cf4f3c",
"iv": "000102030405060708090a0b0c0d0e0f",
"cipher_text": "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78cb82807230e1321d3fae00d18",
"decrypt_error": "OperationError"
},
// JWK: key_ops has duplicates
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "GADWrMRHwQfoNaXU5fZvTg",
"key_ops": [ "encrypt", "decrypt", "encrypt" ]
},
"import_error": "DataError: The \"key_ops\" member of the JWK dictionary contains duplicate usages."
},
// JWK: key_ops has (unrecognized duplicates)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "GADWrMRHwQfoNaXU5fZvTg",
"key_ops": [ "foopy", "decrypt", "foopy" ]
},
"import_error": "DataError: The \"key_ops\" member of the JWK dictionary contains duplicate usages."
},
// JWK: alg present but incorrect (expecting A128CBC).
{
"key_format": "jwk",
"key": {
"kty": "oct",
"alg": "A127CBC",
"k": "GADWrMRHwQfoNaXU5fZvTg"
},
"import_error": "DataError: The JWK \"alg\" member was inconsistent with that specified by the Web Crypto call"
},
// JWK: Invalid kty
{
"key_format": "jwk",
"key": {
"kty": "foo",
"k": "GADWrMRHwQfoNaXU5fZvTg"
},
"import_error": "DataError: The JWK \"kty\" member was not \"oct\""
},
// JWK: Missing kty.
{
"key_format": "jwk",
"key": {
"k": "GADWrMRHwQfoNaXU5fZvTg"
},
"import_error": "DataError: The required JWK member \"kty\" was missing"
},
// JWK: kty is wrong type
{
"key_format": "jwk",
"key": {
"kty": 0.1,
"k": "GADWrMRHwQfoNaXU5fZvTg"
},
"import_error": "DataError: The JWK member \"kty\" must be a string"
},
// JWK: Invalid use
{
"key_format": "jwk",
"key": {
"kty": "oct",
"use": "foo",
"k": "GADWrMRHwQfoNaXU5fZvTg"
},
"import_error": "DataError: The JWK \"use\" member could not be parsed"
},
// JWK: Invalid use (wrong type)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"use": true,
"k": "GADWrMRHwQfoNaXU5fZvTg"
},
"import_error": "DataError: The JWK member \"use\" must be a string"
},
// JWK: Invalid ext (wrong type)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "GADWrMRHwQfoNaXU5fZvTg",
"ext": 0
},
"import_error": "DataError: The JWK member \"ext\" must be a boolean"
},
// JWK: Invalid key_ops (wrong type)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "GADWrMRHwQfoNaXU5fZvTg",
"key_ops": true
},
"import_error": "DataError: The JWK member \"key_ops\" must be a list"
},
// JWK: unrecognized values in "key_ops". This is OK.
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "GADWrMRHwQfoNaXU5fZvTg",
"key_ops": ["foo", "bar", "encrypt", "decrypt"]
}
},
// JWK: non-string entry in key_ops
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "GADWrMRHwQfoNaXU5fZvTg",
"key_ops": ["encrypt", 3]
},
"import_error": "DataError: The JWK member \"key_ops[1]\" must be a string"
},
// JWK: missing k
{
"key_format": "jwk",
"key": {
"kty": "oct"
},
"import_error": "DataError: The required JWK member \"k\" was missing"
},
// JWK: Bad Base64 encoding for k
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": "Qk3f0DsytU8lfza2au #$% Htaw2xpop9GYyTuH0p5GghxTI="
},
"import_error": "DataError: The JWK member \"k\" could not be base64url decoded or contained padding"
},
// JWK: empty k
{
"key_format": "jwk",
"key": {
"kty": "oct",
"k": ""
},
"import_error": "DataError: AES key data must be 128 or 256 bits"
},
// JWK: empty k (with alg specified)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"alg": "A128CBC",
"k": ""
},
"import_error": "DataError: The JWK \"k\" member did not include the right length of key data for the given algorithm."
},
// JWK: k actual length (120 bits) inconsistent with alg (128 bits)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"alg": "A128CBC",
"k": "AVj42h0Y5aqGtE3yluKL"
},
"import_error": "DataError: The JWK \"k\" member did not include the right length of key data for the given algorithm."
},
// JWK: k actual length (192 bits) inconsistent with alg (128 bits)
{
"key_format": "jwk",
"key": {
"kty": "oct",
"alg": "A128CBC",
"k": "dGhpcyAgaXMgIDI0ICBieXRlcyBsb25n"
},
"import_error": "DataError: The JWK \"k\" member did not include the right length of key data for the given algorithm."
},
// AES 192-bit is not allowed: http://crbug.com/381829
{
"key_format": "raw",
"key": "5377656574205369787465656e2049560000000000000000",
"import_error": "OperationError: 192-bit AES keys are not supported"
},
// JWK: AES 192-bit is not allowed: http://crbug.com/381829
{
"key_format": "jwk",
"key": {
"kty": "oct",
"alg": "A192CBC",
"k": "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh"
},
"import_error": "OperationError: 192-bit AES keys are not supported"
}
]