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

Unified Diff: Source/modules/crypto/RsaKeyAlgorithm.cpp

Issue 179353002: [webcrypto] Add the KeyAlgorithm interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Inline the empty trace() Created 6 years, 10 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
Index: Source/modules/crypto/RsaKeyAlgorithm.cpp
diff --git a/Source/modules/crypto/Algorithm.cpp b/Source/modules/crypto/RsaKeyAlgorithm.cpp
similarity index 62%
rename from Source/modules/crypto/Algorithm.cpp
rename to Source/modules/crypto/RsaKeyAlgorithm.cpp
index f3cc089a18e78eb9944fc5dcb88a638aa1a811c3..025d6246ab816d71fa964bb25077cde843983093 100644
--- a/Source/modules/crypto/Algorithm.cpp
+++ b/Source/modules/crypto/RsaKeyAlgorithm.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,48 @@
*/
#include "config.h"
-#include "modules/crypto/Algorithm.h"
+#include "modules/crypto/RsaKeyAlgorithm.h"
#include "modules/crypto/NormalizeAlgorithm.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Uint8Array.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
-DEFINE_GC_INFO(Algorithm);
+RsaKeyAlgorithm::~RsaKeyAlgorithm()
+{
+}
-PassRefPtrWillBeRawPtr<Algorithm> Algorithm::create(const blink::WebCryptoAlgorithm& algorithm)
+PassRefPtrWillBeRawPtr<RsaKeyAlgorithm> RsaKeyAlgorithm::create(const blink::WebCryptoKeyAlgorithm& algorithm)
{
- return adoptRefWillBeNoop(new Algorithm(algorithm));
+ return adoptRefWillBeNoop(new RsaKeyAlgorithm(algorithm));
}
-Algorithm::Algorithm(const blink::WebCryptoAlgorithm& algorithm)
- : m_algorithm(algorithm)
+unsigned RsaKeyAlgorithm::modulusLength()
{
- ScriptWrappable::init(this);
+ return m_algorithm.rsaParams()->modulusLengthBits();
+}
+
+Uint8Array* RsaKeyAlgorithm::publicExponent()
+{
+ if (!m_publicExponent.get()) {
+ const blink::WebVector<unsigned char>& exponent = m_algorithm.rsaParams()->publicExponent();
+ m_publicExponent = Uint8Array::create(exponent.data(), exponent.size());
+ }
+ return m_publicExponent.get();
}
-String Algorithm::name()
+void RsaKeyAlgorithm::trace(Visitor* visitor)
{
- return algorithmIdToName(m_algorithm.id());
+ KeyAlgorithm::trace(visitor);
+}
+
+RsaKeyAlgorithm::RsaKeyAlgorithm(const blink::WebCryptoKeyAlgorithm& algorithm)
+ : KeyAlgorithm(algorithm)
+{
+ ASSERT(algorithm.rsaParams());
+ ScriptWrappable::init(this);
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698