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