OLD | NEW |
1 // Copyright (c) 2009 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 BASE_CRYPTO_SIGNATURE_CREATOR_H_ | 5 #ifndef BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
6 #define BASE_CRYPTO_SIGNATURE_CREATOR_H_ | 6 #define BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #if defined(USE_OPENSSL) | 11 #if defined(USE_OPENSSL) |
(...skipping 14 matching lines...) Expand all Loading... |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include "base/crypto/scoped_capi_types.h" | 27 #include "base/crypto/scoped_capi_types.h" |
28 #endif | 28 #endif |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 | 31 |
32 // Signs data using a bare private key (as opposed to a full certificate). | 32 // Signs data using a bare private key (as opposed to a full certificate). |
33 // Currently can only sign data using SHA-1 with RSA encryption. | 33 // Currently can only sign data using SHA-1 with RSA encryption. |
34 class SignatureCreator { | 34 class SignatureCreator { |
35 public: | 35 public: |
| 36 ~SignatureCreator(); |
| 37 |
36 // Create an instance. The caller must ensure that the provided PrivateKey | 38 // Create an instance. The caller must ensure that the provided PrivateKey |
37 // instance outlives the created SignatureCreator. | 39 // instance outlives the created SignatureCreator. |
38 static SignatureCreator* Create(RSAPrivateKey* key); | 40 static SignatureCreator* Create(RSAPrivateKey* key); |
39 | 41 |
40 ~SignatureCreator(); | |
41 | |
42 // Update the signature with more data. | 42 // Update the signature with more data. |
43 bool Update(const uint8* data_part, int data_part_len); | 43 bool Update(const uint8* data_part, int data_part_len); |
44 | 44 |
45 // Finalize the signature. | 45 // Finalize the signature. |
46 bool Final(std::vector<uint8>* signature); | 46 bool Final(std::vector<uint8>* signature); |
47 | 47 |
48 private: | 48 private: |
49 // Private constructor. Use the Create() method instead. | 49 // Private constructor. Use the Create() method instead. |
50 SignatureCreator(); | 50 SignatureCreator(); |
51 | 51 |
52 RSAPrivateKey* key_; | 52 RSAPrivateKey* key_; |
53 | 53 |
54 #if defined(USE_OPENSSL) | 54 #if defined(USE_OPENSSL) |
55 EVP_MD_CTX* sign_context_; | 55 EVP_MD_CTX* sign_context_; |
56 #elif defined(USE_NSS) | 56 #elif defined(USE_NSS) |
57 SGNContextStr* sign_context_; | 57 SGNContextStr* sign_context_; |
58 #elif defined(OS_MACOSX) | 58 #elif defined(OS_MACOSX) |
59 CSSM_CC_HANDLE sig_handle_; | 59 CSSM_CC_HANDLE sig_handle_; |
60 #elif defined(OS_WIN) | 60 #elif defined(OS_WIN) |
61 ScopedHCRYPTHASH hash_object_; | 61 ScopedHCRYPTHASH hash_object_; |
62 #endif | 62 #endif |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); | 64 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace base | 67 } // namespace base |
68 | 68 |
69 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_ | 69 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
OLD | NEW |