| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CRYPTO_SIGNATURE_CREATOR_H_ | 5 #ifndef CRYPTO_SIGNATURE_CREATOR_H_ |
| 6 #define CRYPTO_SIGNATURE_CREATOR_H_ | 6 #define CRYPTO_SIGNATURE_CREATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 12 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 11 #include "base/basictypes.h" | |
| 12 #include "crypto/crypto_export.h" | 14 #include "crypto/crypto_export.h" |
| 13 | 15 |
| 14 #if defined(USE_OPENSSL) | 16 #if defined(USE_OPENSSL) |
| 15 // Forward declaration for openssl/*.h | 17 // Forward declaration for openssl/*.h |
| 16 typedef struct env_md_ctx_st EVP_MD_CTX; | 18 typedef struct env_md_ctx_st EVP_MD_CTX; |
| 17 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) | 19 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) |
| 18 // Forward declaration. | 20 // Forward declaration. |
| 19 struct SGNContextStr; | 21 struct SGNContextStr; |
| 20 #endif | 22 #endif |
| 21 | 23 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 // Create an instance. The caller must ensure that the provided PrivateKey | 40 // Create an instance. The caller must ensure that the provided PrivateKey |
| 39 // instance outlives the created SignatureCreator. Uses the HashAlgorithm | 41 // instance outlives the created SignatureCreator. Uses the HashAlgorithm |
| 40 // specified. | 42 // specified. |
| 41 static SignatureCreator* Create(RSAPrivateKey* key, HashAlgorithm hash_alg); | 43 static SignatureCreator* Create(RSAPrivateKey* key, HashAlgorithm hash_alg); |
| 42 | 44 |
| 43 | 45 |
| 44 // Signs the precomputed |hash_alg| digest |data| using private |key| as | 46 // Signs the precomputed |hash_alg| digest |data| using private |key| as |
| 45 // specified in PKCS #1 v1.5. | 47 // specified in PKCS #1 v1.5. |
| 46 static bool Sign(RSAPrivateKey* key, | 48 static bool Sign(RSAPrivateKey* key, |
| 47 HashAlgorithm hash_alg, | 49 HashAlgorithm hash_alg, |
| 48 const uint8* data, | 50 const uint8_t* data, |
| 49 int data_len, | 51 int data_len, |
| 50 std::vector<uint8>* signature); | 52 std::vector<uint8_t>* signature); |
| 51 | 53 |
| 52 // Update the signature with more data. | 54 // Update the signature with more data. |
| 53 bool Update(const uint8* data_part, int data_part_len); | 55 bool Update(const uint8_t* data_part, int data_part_len); |
| 54 | 56 |
| 55 // Finalize the signature. | 57 // Finalize the signature. |
| 56 bool Final(std::vector<uint8>* signature); | 58 bool Final(std::vector<uint8_t>* signature); |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 // Private constructor. Use the Create() method instead. | 61 // Private constructor. Use the Create() method instead. |
| 60 SignatureCreator(); | 62 SignatureCreator(); |
| 61 | 63 |
| 62 #if defined(USE_OPENSSL) | 64 #if defined(USE_OPENSSL) |
| 63 EVP_MD_CTX* sign_context_; | 65 EVP_MD_CTX* sign_context_; |
| 64 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) | 66 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) |
| 65 SGNContextStr* sign_context_; | 67 SGNContextStr* sign_context_; |
| 66 #endif | 68 #endif |
| 67 | 69 |
| 68 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); | 70 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 } // namespace crypto | 73 } // namespace crypto |
| 72 | 74 |
| 73 #endif // CRYPTO_SIGNATURE_CREATOR_H_ | 75 #endif // CRYPTO_SIGNATURE_CREATOR_H_ |
| OLD | NEW |