OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
| 6 #define BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
| 7 |
| 8 #if defined(OS_WIN) |
| 9 #include <windows.h> |
| 10 #include <wincrypt.h> |
| 11 #else |
| 12 // TODO(PORT) |
| 13 #endif |
| 14 |
| 15 #include <vector> |
| 16 |
| 17 #include "base/basictypes.h" |
| 18 #include "base/crypto/rsa_private_key.h" |
| 19 |
| 20 namespace base { |
| 21 |
| 22 // 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. |
| 24 class SignatureCreator { |
| 25 public: |
| 26 // Create an instance. The caller must ensure that the provided PrivateKey |
| 27 // instance outlives the created SignatureCreator. |
| 28 static SignatureCreator* Create(RSAPrivateKey* key); |
| 29 |
| 30 ~SignatureCreator(); |
| 31 |
| 32 // Update the signature with more data. |
| 33 bool Update(const uint8* data_part, int data_part_len); |
| 34 |
| 35 // Finalize the signature. |
| 36 bool Final(std::vector<uint8>* signature); |
| 37 |
| 38 private: |
| 39 // Private constructor. Use the Create() method instead. |
| 40 SignatureCreator() {} |
| 41 |
| 42 RSAPrivateKey* key_; |
| 43 |
| 44 #if defined(OS_WIN) |
| 45 HCRYPTHASH hash_object_; |
| 46 #endif |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
| 49 }; |
| 50 |
| 51 } // namespace base |
| 52 |
| 53 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_ |
OLD | NEW |