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); |
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.
| |
21 EVP_PKEY* pkey = key->key(); | |
22 | |
23 if (stores_key_) { | |
24 // 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.
| |
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 // Using MD5 as this is what is required in HTML5, even though the SPKI | |
34 // structure does allow the use of a SHA-1 signature. | |
35 NETSCAPE_SPKI_sign(spki.get(), pkey, EVP_md5()); | |
36 char* spkistr = NETSCAPE_SPKI_b64_encode(spki.get()); | |
37 | |
38 std::string result(spkistr); | |
39 OPENSSL_free(spkistr); | |
40 | |
41 return result; | |
15 } | 42 } |
16 | 43 |
17 } // namespace net | 44 } // namespace net |
18 | 45 |
OLD | NEW |