WebKit GIT trees - WebKit-https.git/blob - Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cppRename CryptoAlgorithmParameters to CryptoAlgorithmParametersDeprecated[WebKit-https.git] / Source / WebCore / crypto / algorithms / CryptoAlgorithmAES_KW.cpp27 #include "CryptoAlgorithmAES_KW.h"31 #include "CryptoAlgorithmAesKeyGenParamsDeprecated.h"33 #include "CryptoKeyDataOctetSequence.h"34 #include "ExceptionCode.h"38 const char* const CryptoAlgorithmAES_KW::s_name = "AES-KW";40 CryptoAlgorithmAES_KW::CryptoAlgorithmAES_KW()44 CryptoAlgorithmAES_KW::~CryptoAlgorithmAES_KW()48 Ref<CryptoAlgorithm> CryptoAlgorithmAES_KW::create()50 return adoptRef(*new CryptoAlgorithmAES_KW);53 CryptoAlgorithmIdentifier CryptoAlgorithmAES_KW::identifier() const55 return s_identifier;58 bool CryptoAlgorithmAES_KW::keyAlgorithmMatches(const CryptoKey& key) const60 if (key.algorithmIdentifier() != s_identifier)62 ASSERT(is<CryptoKeyAES>(key));67 void CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)69 if (!keyAlgorithmMatches(key)) {70 ec = NOT_SUPPORTED_ERR;74 platformEncrypt(downcast<CryptoKeyAES>(key), data, WTFMove(callback), WTFMove(failureCallback), ec);77 void CryptoAlgorithmAES_KW::decryptForUnwrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)79 if (!keyAlgorithmMatches(key)) {80 ec = NOT_SUPPORTED_ERR;84 platformDecrypt(downcast<CryptoKeyAES>(key), data, WTFMove(callback), WTFMove(failureCallback), ec);87 void CryptoAlgorithmAES_KW::generateKey(const CryptoAlgorithmParametersDeprecated& parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback&& callback, VoidCallback&& failureCallback, ExceptionCode&)89 const CryptoAlgorithmAesKeyGenParamsDeprecated& aesParameters = downcast<CryptoAlgorithmAesKeyGenParamsDeprecated>(parameters);91 RefPtr<CryptoKeyAES> result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, aesParameters.length, extractable, usages);92 if (!result) {93 failureCallback();97 callback(result.get(), nullptr);100 void CryptoAlgorithmAES_KW::importKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKeyData& keyData, bool extractable, CryptoKeyUsage usage, KeyCallback&& callback, VoidCallback&&, ExceptionCode& ec)102 if (!is<CryptoKeyDataOctetSequence>(keyData)) {103 ec = NOT_SUPPORTED_ERR;106 const CryptoKeyDataOctetSequence& keyDataOctetSequence = downcast<CryptoKeyDataOctetSequence>(keyData);107 RefPtr<CryptoKeyAES> result = CryptoKeyAES::create(CryptoAlgorithmIdentifier::AES_KW, keyDataOctetSequence.octetSequence(), extractable, usage);108 callback(*result);113 #endif // ENABLE(SUBTLE_CRYPTO)
