OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_NSS_KEY_UTIL_H_ | 5 #ifndef CRYPTO_NSS_KEY_UTIL_H_ |
6 #define CRYPTO_NSS_KEY_UTIL_H_ | 6 #define CRYPTO_NSS_KEY_UTIL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Imports a private key from |input| into |slot|. |input| is interpreted as a | 30 // Imports a private key from |input| into |slot|. |input| is interpreted as a |
31 // DER-encoded PrivateKeyInfo block from PKCS #8. Returns nullptr on error. If | 31 // DER-encoded PrivateKeyInfo block from PKCS #8. Returns nullptr on error. If |
32 // |permanent| is true, the resulting key is permanent and is not exportable in | 32 // |permanent| is true, the resulting key is permanent and is not exportable in |
33 // plaintext form. | 33 // plaintext form. |
34 CRYPTO_EXPORT ScopedSECKEYPrivateKey | 34 CRYPTO_EXPORT ScopedSECKEYPrivateKey |
35 ImportNSSKeyFromPrivateKeyInfo(PK11SlotInfo* slot, | 35 ImportNSSKeyFromPrivateKeyInfo(PK11SlotInfo* slot, |
36 const std::vector<uint8_t>& input, | 36 const std::vector<uint8_t>& input, |
37 bool permanent); | 37 bool permanent); |
38 | 38 |
39 #if defined(USE_NSS_CERTS) | |
40 | |
41 // Decodes |input| as a DER-encoded X.509 SubjectPublicKeyInfo and searches for | 39 // Decodes |input| as a DER-encoded X.509 SubjectPublicKeyInfo and searches for |
42 // the private key half in the key database. Returns the private key on success | 40 // the private key half in the key database. Returns the private key on success |
43 // or nullptr on error. | 41 // or nullptr on error. |
44 CRYPTO_EXPORT ScopedSECKEYPrivateKey | 42 CRYPTO_EXPORT ScopedSECKEYPrivateKey |
45 FindNSSKeyFromPublicKeyInfo(const std::vector<uint8_t>& input); | 43 FindNSSKeyFromPublicKeyInfo(const std::vector<uint8_t>& input); |
46 | 44 |
47 // Decodes |input| as a DER-encoded X.509 SubjectPublicKeyInfo and searches for | 45 // Decodes |input| as a DER-encoded X.509 SubjectPublicKeyInfo and searches for |
48 // the private key half in the slot specified by |slot|. Returns the private key | 46 // the private key half in the slot specified by |slot|. Returns the private key |
49 // on success or nullptr on error. | 47 // on success or nullptr on error. |
50 CRYPTO_EXPORT ScopedSECKEYPrivateKey | 48 CRYPTO_EXPORT ScopedSECKEYPrivateKey |
51 FindNSSKeyFromPublicKeyInfoInSlot(const std::vector<uint8_t>& input, | 49 FindNSSKeyFromPublicKeyInfoInSlot(const std::vector<uint8_t>& input, |
52 PK11SlotInfo* slot); | 50 PK11SlotInfo* slot); |
53 | 51 |
54 #endif // defined(USE_NSS_CERTS) | |
55 | |
56 } // namespace crypto | 52 } // namespace crypto |
57 | 53 |
58 #endif // CRYPTO_NSS_KEY_UTIL_H_ | 54 #endif // CRYPTO_NSS_KEY_UTIL_H_ |
OLD | NEW |