| Index: Source/modules/crypto/KeyAlgorithm.cpp
|
| diff --git a/Source/modules/crypto/Algorithm.cpp b/Source/modules/crypto/KeyAlgorithm.cpp
|
| similarity index 53%
|
| copy from Source/modules/crypto/Algorithm.cpp
|
| copy to Source/modules/crypto/KeyAlgorithm.cpp
|
| index f3cc089a18e78eb9944fc5dcb88a638aa1a811c3..64ca0654bcd01fd6aa2077f075d2b3cbd10993ff 100644
|
| --- a/Source/modules/crypto/Algorithm.cpp
|
| +++ b/Source/modules/crypto/KeyAlgorithm.cpp
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2013 Google Inc. All rights reserved.
|
| + * Copyright (C) 2014 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -29,29 +29,56 @@
|
| */
|
|
|
| #include "config.h"
|
| -#include "modules/crypto/Algorithm.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 {
|
|
|
| -DEFINE_GC_INFO(Algorithm);
|
| +DEFINE_GC_INFO(KeyAlgorithm);
|
|
|
| -PassRefPtrWillBeRawPtr<Algorithm> Algorithm::create(const blink::WebCryptoAlgorithm& algorithm)
|
| +PassRefPtrWillBeRawPtr<KeyAlgorithm> KeyAlgorithm::create(const blink::WebCryptoKeyAlgorithm& algorithm)
|
| {
|
| - return adoptRefWillBeNoop(new Algorithm(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);
|
| + }
|
| }
|
|
|
| -Algorithm::Algorithm(const blink::WebCryptoAlgorithm& algorithm)
|
| +PassRefPtrWillBeRawPtr<KeyAlgorithm> KeyAlgorithm::createHash(const blink::WebCryptoAlgorithm& hash)
|
| +{
|
| + // Assume that none of the hash algorithms have any parameters.
|
| + 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 Algorithm::name()
|
| +String KeyAlgorithm::name()
|
| {
|
| return algorithmIdToName(m_algorithm.id());
|
| }
|
|
|
| +blink::WebCryptoKeyAlgorithmParamsType KeyAlgorithm::type() const
|
| +{
|
| + return m_algorithm.paramsType();
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|