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

Side by Side Diff: crypto/ec_private_key.h

Issue 8662036: Support EC certs in OriginBoundCertService and OriginBoundCertStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CRYPTO_EC_PRIVATE_KEY_H_ 5 #ifndef CRYPTO_EC_PRIVATE_KEY_H_
6 #define CRYPTO_EC_PRIVATE_KEY_H_ 6 #define CRYPTO_EC_PRIVATE_KEY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "crypto/crypto_export.h" 14 #include "crypto/crypto_export.h"
15 15
16 #if defined(USE_OPENSSL) 16 #if defined(USE_OPENSSL)
17 // Forward declaration for openssl/*.h 17 // Forward declaration for openssl/*.h
18 typedef struct evp_pkey_st EVP_PKEY; 18 typedef struct evp_pkey_st EVP_PKEY;
19 #else 19 #else
20 // Forward declaration. 20 // Forward declaration.
21 typedef struct CERTSubjectPublicKeyInfoStr CERTSubjectPublicKeyInfo;
21 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; 22 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
22 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; 23 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
23 #endif 24 #endif
24 25
25 namespace crypto { 26 namespace crypto {
26 27
27 // Encapsulates an elliptic curve (EC) private key. Can be used to generate new 28 // Encapsulates an elliptic curve (EC) private key. Can be used to generate new
28 // keys, export keys to other formats, or to extract a public key. 29 // keys, export keys to other formats, or to extract a public key.
29 // TODO(mattm): make this and RSAPrivateKey implement some PrivateKey interface. 30 // TODO(mattm): make this and RSAPrivateKey implement some PrivateKey interface.
30 // (The difference in types of key() and public_key() make this a little 31 // (The difference in types of key() and public_key() make this a little
(...skipping 27 matching lines...) Expand all
58 // block and an X.509 SubjectPublicKeyInfo block. 59 // block and an X.509 SubjectPublicKeyInfo block.
59 // This can return NULL if initialization fails. The created key is permanent 60 // This can return NULL if initialization fails. The created key is permanent
60 // and is not exportable in plaintext form. 61 // and is not exportable in plaintext form.
61 // 62 //
62 // NOTE: Currently only available if USE_NSS is defined. 63 // NOTE: Currently only available if USE_NSS is defined.
63 static ECPrivateKey* CreateSensitiveFromEncryptedPrivateKeyInfo( 64 static ECPrivateKey* CreateSensitiveFromEncryptedPrivateKeyInfo(
64 const std::string& password, 65 const std::string& password,
65 const std::vector<uint8>& encrypted_private_key_info, 66 const std::vector<uint8>& encrypted_private_key_info,
66 const std::vector<uint8>& subject_public_key_info); 67 const std::vector<uint8>& subject_public_key_info);
67 68
69 #if !defined(USE_OPENSSL)
70 // Import the key pair and return in |public_key| and |key|.
wtc 2011/12/02 22:06:59 Nit: Import => Imports return => returns
mattm 2011/12/05 22:19:20 Done.
71 // Shortcut for code that need to keep a ref directly to NSS types without
72 // having to create a ECPrivateKey object and make a copy of them.
73 static bool ImportFromEncryptedPrivateKeyInfo(
wtc 2011/12/02 22:06:59 DESIGN: this function probably should be moved to
mattm 2011/12/05 22:19:20 Added TODO.
74 const std::string& password,
75 const std::vector<uint8>& encrypted_private_key_info,
76 CERTSubjectPublicKeyInfo* decoded_spki,
77 bool permanent,
78 bool sensitive,
79 SECKEYPrivateKey** key,
80 SECKEYPublicKey** public_key);
81 #endif
82
68 #if defined(USE_OPENSSL) 83 #if defined(USE_OPENSSL)
69 EVP_PKEY* key() { return key_; } 84 EVP_PKEY* key() { return key_; }
70 #else 85 #else
71 SECKEYPrivateKey* key() { return key_; } 86 SECKEYPrivateKey* key() { return key_; }
72 SECKEYPublicKey* public_key() { return public_key_; } 87 SECKEYPublicKey* public_key() { return public_key_; }
73 #endif 88 #endif
74 89
75 // Exports the private key as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo 90 // Exports the private key as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo
76 // block and the public key as an X.509 SubjectPublicKeyInfo block. 91 // block and the public key as an X.509 SubjectPublicKeyInfo block.
77 // The |password| and |iterations| are used as inputs to the key derivation 92 // The |password| and |iterations| are used as inputs to the key derivation
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 SECKEYPublicKey* public_key_; 130 SECKEYPublicKey* public_key_;
116 #endif 131 #endif
117 132
118 DISALLOW_COPY_AND_ASSIGN(ECPrivateKey); 133 DISALLOW_COPY_AND_ASSIGN(ECPrivateKey);
119 }; 134 };
120 135
121 136
122 } // namespace crypto 137 } // namespace crypto
123 138
124 #endif // CRYPTO_EC_PRIVATE_KEY_H_ 139 #endif // CRYPTO_EC_PRIVATE_KEY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698