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

Unified Diff: net/base/keygen_handler_openssl.cc

Issue 5541002: Implements keygen handler for openssl, but without private key persistence (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wtc comment Created 10 years 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 | « no previous file | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/keygen_handler_openssl.cc
diff --git a/net/base/keygen_handler_openssl.cc b/net/base/keygen_handler_openssl.cc
index ecbd6837560b14d1ab01936c9c4ca1addbc1ccba..0ce87cc90ecedf626eca8e5bf8a64b02cb91f193 100644
--- a/net/base/keygen_handler_openssl.cc
+++ b/net/base/keygen_handler_openssl.cc
@@ -4,14 +4,41 @@
#include "net/base/keygen_handler.h"
+#include <openssl/ssl.h>
+#include <openssl/x509.h>
+
+#include "base/crypto/rsa_private_key.h"
#include "base/logging.h"
+#include "base/openssl_util.h"
+#include "base/scoped_ptr.h"
namespace net {
std::string KeygenHandler::GenKeyAndSignChallenge() {
- // TODO(bulach): implement me.
- NOTIMPLEMENTED();
- return "";
+ scoped_ptr<base::RSAPrivateKey> key(
+ base::RSAPrivateKey::Create(key_size_in_bits_));
+ DCHECK(key != NULL);
bulach 2010/12/07 10:59:53 I think we don't normally DCHECK if we're de-refer
joth 2010/12/07 12:11:42 Done.
+ EVP_PKEY* pkey = key->key();
+
+ if (stores_key_) {
+ // TODO(joth): Add an abstraction for persisting OpenSSL private keys.
bulach 2010/12/07 10:59:53 you may want to update http://crbug.com/64917 and
joth 2010/12/07 12:11:42 Done.
+ NOTIMPLEMENTED();
+ }
+
+ base::ScopedOpenSSL<NETSCAPE_SPKI, NETSCAPE_SPKI_free> spki(
+ NETSCAPE_SPKI_new());
+ ASN1_STRING_set(spki.get()->spkac->challenge,
+ challenge_.data(), challenge_.size());
+ NETSCAPE_SPKI_set_pubkey(spki.get(), pkey);
+ // Using MD5 as this is what is required in HTML5, even though the SPKI
+ // structure does allow the use of a SHA-1 signature.
+ NETSCAPE_SPKI_sign(spki.get(), pkey, EVP_md5());
+ char* spkistr = NETSCAPE_SPKI_b64_encode(spki.get());
+
+ std::string result(spkistr);
+ OPENSSL_free(spkistr);
+
+ return result;
}
} // namespace net
« no previous file with comments | « no previous file | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698