#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/containers/span.h"
#include "base/values.h"
#include "components/webcrypto/algorithm_dispatch.h"
#include "components/webcrypto/algorithms/test_helpers.h"
#include "components/webcrypto/status.h"
#include "third_party/blink/public/platform/web_crypto_algorithm_params.h"
#include "third_party/blink/public/platform/web_crypto_key_algorithm.h"
namespace webcrypto {
namespace {
blink::WebCryptoAlgorithm CreateAesCbcAlgorithm(
const std::vector<uint8_t>& iv) { … }
blink::WebCryptoAlgorithm CreateAesCbcKeyGenAlgorithm(
uint16_t key_length_bits) { … }
blink::WebCryptoKey GetTestAesCbcKey() { … }
blink::WebCryptoKey ImportRawKey(const std::vector<uint8_t>& key_bytes) { … }
std::vector<uint8_t> EncryptOrDie(blink::WebCryptoKey key,
const std::vector<uint8_t>& iv,
const std::vector<uint8_t>& plaintext) { … }
std::vector<uint8_t> DecryptOrDie(blink::WebCryptoKey key,
const std::vector<uint8_t>& iv,
const std::vector<uint8_t>& ciphertext) { … }
std::string EncryptMustFail(blink::WebCryptoKey key,
const std::vector<uint8_t>& iv,
const std::vector<uint8_t>& plaintext) { … }
std::string DecryptMustFail(blink::WebCryptoKey key,
const std::vector<uint8_t>& iv,
const std::vector<uint8_t>& ciphertext) { … }
class WebCryptoAesCbcTest : public WebCryptoTestBase { … };
TEST_F(WebCryptoAesCbcTest, InputTooLarge) { … }
TEST_F(WebCryptoAesCbcTest, ExportKeyUnsupportedFormat) { … }
struct AesCbcKnownAnswer { … };
const AesCbcKnownAnswer kAesCbcKnownAnswers[] = …;
TEST_F(WebCryptoAesCbcTest, KnownAnswers) { … }
TEST_F(WebCryptoAesCbcTest, IVIsWrongSize) { … }
TEST_F(WebCryptoAesCbcTest, ImportShortKey) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyWrongFormat) { … }
TEST_F(WebCryptoAesCbcTest, ImportAes192Key) { … }
TEST_F(WebCryptoAesCbcTest, DecryptTruncatedCiphertextFails) { … }
struct JwkImportFailureTest { … };
const JwkImportFailureTest kJwkImportFailureTests[] = …;
TEST_F(WebCryptoAesCbcTest, JwkImportFailures) { … }
TEST_F(WebCryptoAesCbcTest, GenerateKeyIsRandom) { … }
TEST_F(WebCryptoAesCbcTest, GenerateKeyBadLength) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyEmptyUsage) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyJwkEmptyKeyOps) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyJwkNoKeyOps) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyJwkKeyOpsEncryptDecrypt) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyJwkKeyOpsNotSuperset) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyJwkUseEnc) { … }
TEST_F(WebCryptoAesCbcTest, ImportJwkUnknownKeyOps) { … }
TEST_F(WebCryptoAesCbcTest, ImportJwkInvalidJson) { … }
TEST_F(WebCryptoAesCbcTest, ImportJwkKeyOpsLacksUsages) { … }
TEST_F(WebCryptoAesCbcTest, ImportExportJwk) { … }
TEST_F(WebCryptoAesCbcTest, GenerateAesCbc192) { … }
TEST_F(WebCryptoAesCbcTest, UnwrapAesCbc192) { … }
TEST_F(WebCryptoAesCbcTest, ImportKeyBadUsage_Raw) { … }
TEST_F(WebCryptoAesCbcTest, GenerateKeyBadUsages) { … }
TEST_F(WebCryptoAesCbcTest, GenerateKeyEmptyUsages) { … }
TEST_F(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) { … }
}
}