This source file includes following definitions.
- create
- createHash
- name
- isAesKeyAlgorithm
- isHmacKeyAlgorithm
- isRsaHashedKeyAlgorithm
- isRsaKeyAlgorithm
- trace
#include "config.h"
#include "modules/crypto/KeyAlgorithm.h"
#include "modules/crypto/AesKeyAlgorithm.h"
#include "modules/crypto/HmacKeyAlgorithm.h"
#include "modules/crypto/NormalizeAlgorithm.h"
#include "modules/crypto/RsaHashedKeyAlgorithm.h"
#include "modules/crypto/RsaKeyAlgorithm.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
KeyAlgorithm::~KeyAlgorithm()
{
}
PassRefPtrWillBeRawPtr<KeyAlgorithm> KeyAlgorithm::create(const blink::WebCryptoKeyAlgorithm& algorithm)
{
switch (algorithm.paramsType()) {
case blink::WebCryptoKeyAlgorithmParamsTypeNone:
return adoptRefWillBeNoop(new KeyAlgorithm(algorithm));
case blink::WebCryptoKeyAlgorithmParamsTypeAes:
return AesKeyAlgorithm::create(algorithm);
case blink::WebCryptoKeyAlgorithmParamsTypeHmac:
return HmacKeyAlgorithm::create(algorithm);
case blink::WebCryptoKeyAlgorithmParamsTypeRsa:
return RsaKeyAlgorithm::create(algorithm);
case blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed:
return RsaHashedKeyAlgorithm::create(algorithm);
}
ASSERT_NOT_REACHED();
return nullptr;
}
PassRefPtrWillBeRawPtr<KeyAlgorithm> KeyAlgorithm::createHash(const blink::WebCryptoAlgorithm& hash)
{
ASSERT(hash.paramsType() == blink::WebCryptoAlgorithmParamsTypeNone);
return adoptRefWillBeNoop(new KeyAlgorithm(blink::WebCryptoKeyAlgorithm(hash.id(), nullptr)));
}
KeyAlgorithm::KeyAlgorithm(const blink::WebCryptoKeyAlgorithm& algorithm)
: m_algorithm(algorithm)
{
ScriptWrappable::init(this);
}
String KeyAlgorithm::name()
{
return algorithmIdToName(m_algorithm.id());
}
bool KeyAlgorithm::isAesKeyAlgorithm() const
{
return m_algorithm.paramsType() == blink::WebCryptoKeyAlgorithmParamsTypeAes;
}
bool KeyAlgorithm::isHmacKeyAlgorithm() const
{
return m_algorithm.paramsType() == blink::WebCryptoKeyAlgorithmParamsTypeHmac;
}
bool KeyAlgorithm::isRsaHashedKeyAlgorithm() const
{
return m_algorithm.paramsType() == blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed;
}
bool KeyAlgorithm::isRsaKeyAlgorithm() const
{
return m_algorithm.paramsType() == blink::WebCryptoKeyAlgorithmParamsTypeRsa;
}
void KeyAlgorithm::trace(Visitor*)
{
}
}