| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef BASE_CRYPTO_SIGNATURE_CREATOR_H_ |  | 
| 6 #define BASE_CRYPTO_SIGNATURE_CREATOR_H_ |  | 
| 7 #pragma once |  | 
| 8 |  | 
| 9 #include "build/build_config.h" |  | 
| 10 |  | 
| 11 #if defined(USE_OPENSSL) |  | 
| 12 // Forward declaration for openssl/*.h |  | 
| 13 typedef struct env_md_ctx_st EVP_MD_CTX; |  | 
| 14 #elif defined(USE_NSS) |  | 
| 15 // Forward declaration. |  | 
| 16 struct SGNContextStr; |  | 
| 17 #elif defined(OS_MACOSX) |  | 
| 18 #include <Security/cssm.h> |  | 
| 19 #endif |  | 
| 20 |  | 
| 21 #include <vector> |  | 
| 22 |  | 
| 23 #include "base/base_api.h" |  | 
| 24 #include "base/basictypes.h" |  | 
| 25 #include "base/crypto/rsa_private_key.h" |  | 
| 26 |  | 
| 27 #if defined(OS_WIN) |  | 
| 28 #include "base/crypto/scoped_capi_types.h" |  | 
| 29 #endif |  | 
| 30 |  | 
| 31 namespace base { |  | 
| 32 |  | 
| 33 // Signs data using a bare private key (as opposed to a full certificate). |  | 
| 34 // Currently can only sign data using SHA-1 with RSA encryption. |  | 
| 35 class BASE_API SignatureCreator { |  | 
| 36  public: |  | 
| 37   ~SignatureCreator(); |  | 
| 38 |  | 
| 39   // Create an instance. The caller must ensure that the provided PrivateKey |  | 
| 40   // instance outlives the created SignatureCreator. |  | 
| 41   static SignatureCreator* Create(RSAPrivateKey* key); |  | 
| 42 |  | 
| 43   // Update the signature with more data. |  | 
| 44   bool Update(const uint8* data_part, int data_part_len); |  | 
| 45 |  | 
| 46   // Finalize the signature. |  | 
| 47   bool Final(std::vector<uint8>* signature); |  | 
| 48 |  | 
| 49  private: |  | 
| 50   // Private constructor. Use the Create() method instead. |  | 
| 51   SignatureCreator(); |  | 
| 52 |  | 
| 53   RSAPrivateKey* key_; |  | 
| 54 |  | 
| 55 #if defined(USE_OPENSSL) |  | 
| 56   EVP_MD_CTX* sign_context_; |  | 
| 57 #elif defined(USE_NSS) |  | 
| 58   SGNContextStr* sign_context_; |  | 
| 59 #elif defined(OS_MACOSX) |  | 
| 60   CSSM_CC_HANDLE sig_handle_; |  | 
| 61 #elif defined(OS_WIN) |  | 
| 62   ScopedHCRYPTHASH hash_object_; |  | 
| 63 #endif |  | 
| 64 |  | 
| 65   DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |  | 
| 66 }; |  | 
| 67 |  | 
| 68 }  // namespace base |  | 
| 69 |  | 
| 70 #endif  // BASE_CRYPTO_SIGNATURE_CREATOR_H_ |  | 
| OLD | NEW | 
|---|