OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
8 #if defined(OS_WIN) | 8 #include "build/build_config.h" |
| 9 |
| 10 #if defined(USE_NSS) |
| 11 #include <cryptoht.h> |
| 12 #elif defined(OS_MACOSX) |
| 13 // TODO(port) |
| 14 #elif defined(OS_WIN) |
9 #include <windows.h> | 15 #include <windows.h> |
10 #include <wincrypt.h> | 16 #include <wincrypt.h> |
11 #else | |
12 // TODO(PORT) | |
13 #endif | 17 #endif |
14 | 18 |
15 #include <vector> | 19 #include <vector> |
16 | 20 |
17 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
18 #include "base/crypto/rsa_private_key.h" | 22 #include "base/crypto/rsa_private_key.h" |
19 | 23 |
20 namespace base { | 24 namespace base { |
21 | 25 |
22 // Signs data using a bare private key (as opposed to a full certificate). | 26 // Signs data using a bare private key (as opposed to a full certificate). |
23 // Currently can only sign data using SHA-1 with RSA encryption. | 27 // Currently can only sign data using SHA-1 with RSA encryption. |
24 class SignatureCreator { | 28 class SignatureCreator { |
25 public: | 29 public: |
26 // Create an instance. The caller must ensure that the provided PrivateKey | 30 // Create an instance. The caller must ensure that the provided PrivateKey |
27 // instance outlives the created SignatureCreator. | 31 // instance outlives the created SignatureCreator. |
28 static SignatureCreator* Create(RSAPrivateKey* key); | 32 static SignatureCreator* Create(RSAPrivateKey* key); |
29 | 33 |
30 ~SignatureCreator(); | 34 ~SignatureCreator(); |
31 | 35 |
32 // Update the signature with more data. | 36 // Update the signature with more data. |
33 bool Update(const uint8* data_part, int data_part_len); | 37 bool Update(const uint8* data_part, int data_part_len); |
34 | 38 |
35 // Finalize the signature. | 39 // Finalize the signature. |
36 bool Final(std::vector<uint8>* signature); | 40 bool Final(std::vector<uint8>* signature); |
37 | 41 |
38 private: | 42 private: |
39 // Private constructor. Use the Create() method instead. | 43 // Private constructor. Use the Create() method instead. |
40 SignatureCreator() {} | 44 SignatureCreator(); |
41 | 45 |
42 RSAPrivateKey* key_; | 46 RSAPrivateKey* key_; |
43 | 47 |
44 #if defined(OS_WIN) | 48 #if defined(USE_NSS) |
| 49 SGNContext* sign_context_; |
| 50 #elif defined(OS_MACOSX) |
| 51 // TODO(port) |
| 52 #elif defined(OS_WIN) |
45 HCRYPTHASH hash_object_; | 53 HCRYPTHASH hash_object_; |
46 #endif | 54 #endif |
47 | 55 |
48 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); | 56 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
49 }; | 57 }; |
50 | 58 |
51 } // namespace base | 59 } // namespace base |
52 | 60 |
53 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_ | 61 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
OLD | NEW |