Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1429)

Unified Diff: content/child/webcrypto/algorithm_registry.cc

Issue 1077273002: html_viewer: Move webcrypto to a place where html_viewer can use it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webcrypto/algorithm_registry.h ('k') | content/child/webcrypto/crypto_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/algorithm_registry.cc
diff --git a/content/child/webcrypto/algorithm_registry.cc b/content/child/webcrypto/algorithm_registry.cc
deleted file mode 100644
index 5828a0c8d9bdce0e44bdee97f2535db27693c429..0000000000000000000000000000000000000000
--- a/content/child/webcrypto/algorithm_registry.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/child/webcrypto/algorithm_registry.h"
-
-#include "base/lazy_instance.h"
-#include "content/child/webcrypto/algorithm_implementation.h"
-#include "content/child/webcrypto/platform_crypto.h"
-#include "content/child/webcrypto/status.h"
-
-namespace content {
-
-namespace webcrypto {
-
-namespace {
-
-// This class is used as a singleton. All methods must be threadsafe.
-class AlgorithmRegistry {
- public:
- AlgorithmRegistry()
- : sha_(CreatePlatformShaImplementation()),
- aes_gcm_(CreatePlatformAesGcmImplementation()),
- aes_cbc_(CreatePlatformAesCbcImplementation()),
- aes_ctr_(CreatePlatformAesCtrImplementation()),
- aes_kw_(CreatePlatformAesKwImplementation()),
- hmac_(CreatePlatformHmacImplementation()),
- rsa_ssa_(CreatePlatformRsaSsaImplementation()),
- rsa_oaep_(CreatePlatformRsaOaepImplementation()),
- rsa_pss_(CreatePlatformRsaPssImplementation()),
- ecdsa_(CreatePlatformEcdsaImplementation()),
- ecdh_(CreatePlatformEcdhImplementation()),
- hkdf_(CreatePlatformHkdfImplementation()),
- pbkdf2_(CreatePlatformPbkdf2Implementation()) {
- PlatformInit();
- }
-
- const AlgorithmImplementation* GetAlgorithm(
- blink::WebCryptoAlgorithmId id) const {
- switch (id) {
- case blink::WebCryptoAlgorithmIdSha1:
- case blink::WebCryptoAlgorithmIdSha256:
- case blink::WebCryptoAlgorithmIdSha384:
- case blink::WebCryptoAlgorithmIdSha512:
- return sha_.get();
- case blink::WebCryptoAlgorithmIdAesGcm:
- return aes_gcm_.get();
- case blink::WebCryptoAlgorithmIdAesCbc:
- return aes_cbc_.get();
- case blink::WebCryptoAlgorithmIdAesCtr:
- return aes_ctr_.get();
- case blink::WebCryptoAlgorithmIdAesKw:
- return aes_kw_.get();
- case blink::WebCryptoAlgorithmIdHmac:
- return hmac_.get();
- case blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
- return rsa_ssa_.get();
- case blink::WebCryptoAlgorithmIdRsaOaep:
- return rsa_oaep_.get();
- case blink::WebCryptoAlgorithmIdRsaPss:
- return rsa_pss_.get();
- case blink::WebCryptoAlgorithmIdEcdsa:
- return ecdsa_.get();
- case blink::WebCryptoAlgorithmIdEcdh:
- return ecdh_.get();
- case blink::WebCryptoAlgorithmIdHkdf:
- return hkdf_.get();
- case blink::WebCryptoAlgorithmIdPbkdf2:
- return pbkdf2_.get();
- default:
- return NULL;
- }
- }
-
- private:
- const scoped_ptr<AlgorithmImplementation> sha_;
- const scoped_ptr<AlgorithmImplementation> aes_gcm_;
- const scoped_ptr<AlgorithmImplementation> aes_cbc_;
- const scoped_ptr<AlgorithmImplementation> aes_ctr_;
- const scoped_ptr<AlgorithmImplementation> aes_kw_;
- const scoped_ptr<AlgorithmImplementation> hmac_;
- const scoped_ptr<AlgorithmImplementation> rsa_ssa_;
- const scoped_ptr<AlgorithmImplementation> rsa_oaep_;
- const scoped_ptr<AlgorithmImplementation> rsa_pss_;
- const scoped_ptr<AlgorithmImplementation> ecdsa_;
- const scoped_ptr<AlgorithmImplementation> ecdh_;
- const scoped_ptr<AlgorithmImplementation> hkdf_;
- const scoped_ptr<AlgorithmImplementation> pbkdf2_;
-};
-
-} // namespace
-
-base::LazyInstance<AlgorithmRegistry>::Leaky g_algorithm_registry =
- LAZY_INSTANCE_INITIALIZER;
-
-Status GetAlgorithmImplementation(blink::WebCryptoAlgorithmId id,
- const AlgorithmImplementation** impl) {
- *impl = g_algorithm_registry.Get().GetAlgorithm(id);
- if (*impl)
- return Status::Success();
- return Status::ErrorUnsupported();
-}
-
-} // namespace webcrypto
-
-} // namespace content
« no previous file with comments | « content/child/webcrypto/algorithm_registry.h ('k') | content/child/webcrypto/crypto_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698