Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/keygen_handler.h" | 5 #include "net/base/keygen_handler.h" |
| 6 | 6 |
| 7 #include <openssl/ssl.h> | |
| 8 #include <openssl/x509.h> | |
| 9 | |
| 10 #include "base/crypto/rsa_private_key.h" | |
| 7 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/openssl_util.h" | |
| 13 #include "base/scoped_ptr.h" | |
| 8 | 14 |
| 9 namespace net { | 15 namespace net { |
| 10 | 16 |
| 11 std::string KeygenHandler::GenKeyAndSignChallenge() { | 17 std::string KeygenHandler::GenKeyAndSignChallenge() { |
| 12 // TODO(bulach): implement me. | 18 scoped_ptr<base::RSAPrivateKey> key( |
| 13 NOTIMPLEMENTED(); | 19 base::RSAPrivateKey::Create(key_size_in_bits_)); |
| 14 return ""; | 20 DCHECK(key != NULL); |
| 21 EVP_PKEY* pkey = key->key(); | |
| 22 | |
| 23 if (stores_key_) { | |
| 24 // TODO(joth): Add an abstraction for persisting OpenSSL private keys. | |
| 25 NOTIMPLEMENTED(); | |
| 26 } | |
| 27 | |
| 28 base::ScopedOpenSSL<NETSCAPE_SPKI, NETSCAPE_SPKI_free> spki( | |
| 29 NETSCAPE_SPKI_new()); | |
| 30 ASN1_STRING_set(spki.get()->spkac->challenge, | |
| 31 challenge_.data(), challenge_.size()); | |
| 32 NETSCAPE_SPKI_set_pubkey(spki.get(), pkey); | |
| 33 NETSCAPE_SPKI_sign(spki.get(), pkey, EVP_md5()); | |
|
wtc
2010/12/03 19:15:44
Please add a comment to note that you're using MD5
joth
2010/12/06 18:04:20
Done.
| |
| 34 char* spkistr = NETSCAPE_SPKI_b64_encode(spki.get()); | |
| 35 | |
| 36 std::string result(spkistr); | |
| 37 OPENSSL_free(spkistr); | |
| 38 | |
| 39 return result; | |
| 15 } | 40 } |
| 16 | 41 |
| 17 } // namespace net | 42 } // namespace net |
| 18 | 43 |
| OLD | NEW |