OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // 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 |
29 // 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. |
30 // TODO(mattm): make this and RSAPrivateKey implement some PrivateKey interface. | 30 // TODO(mattm): make this and RSAPrivateKey implement some PrivateKey interface. |
31 // (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 |
32 // tricky.) | 32 // tricky.) |
33 class CRYPTO_EXPORT ECPrivateKey { | 33 class CRYPTO_EXPORT ECPrivateKey { |
34 public: | 34 public: |
35 ~ECPrivateKey(); | 35 ~ECPrivateKey(); |
36 | 36 |
37 // Returns whether the system supports elliptic curve cryptography. | |
38 static bool IsSupported(); | |
39 | |
40 // Creates a new random instance. Can return NULL if initialization fails. | 37 // Creates a new random instance. Can return NULL if initialization fails. |
41 // The created key will use the NIST P-256 curve. | 38 // The created key will use the NIST P-256 curve. |
42 // TODO(mattm): Add a curve parameter. | 39 // TODO(mattm): Add a curve parameter. |
43 static ECPrivateKey* Create(); | 40 static ECPrivateKey* Create(); |
44 | 41 |
45 // Creates a new instance by importing an existing key pair. | 42 // Creates a new instance by importing an existing key pair. |
46 // The key pair is given as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo | 43 // The key pair is given as an ASN.1-encoded PKCS #8 EncryptedPrivateKeyInfo |
47 // block and an X.509 SubjectPublicKeyInfo block. | 44 // block and an X.509 SubjectPublicKeyInfo block. |
48 // Returns NULL if initialization fails. | 45 // Returns NULL if initialization fails. |
49 static ECPrivateKey* CreateFromEncryptedPrivateKeyInfo( | 46 static ECPrivateKey* CreateFromEncryptedPrivateKeyInfo( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 SECKEYPublicKey* public_key_; | 106 SECKEYPublicKey* public_key_; |
110 #endif | 107 #endif |
111 | 108 |
112 DISALLOW_COPY_AND_ASSIGN(ECPrivateKey); | 109 DISALLOW_COPY_AND_ASSIGN(ECPrivateKey); |
113 }; | 110 }; |
114 | 111 |
115 | 112 |
116 } // namespace crypto | 113 } // namespace crypto |
117 | 114 |
118 #endif // CRYPTO_EC_PRIVATE_KEY_H_ | 115 #endif // CRYPTO_EC_PRIVATE_KEY_H_ |
OLD | NEW |