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> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "crypto/crypto_export.h" | 14 #include "crypto/crypto_export.h" |
15 | 15 |
16 #if defined(USE_OPENSSL) | |
17 // Forward declaration for openssl/*.h | 16 // Forward declaration for openssl/*.h |
18 typedef struct env_md_ctx_st EVP_MD_CTX; | 17 typedef struct env_md_ctx_st EVP_MD_CTX; |
19 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) | |
20 // Forward declaration. | |
21 struct SGNContextStr; | |
22 #endif | |
23 | 18 |
24 namespace crypto { | 19 namespace crypto { |
25 | 20 |
26 class RSAPrivateKey; | 21 class RSAPrivateKey; |
27 | 22 |
28 // Signs data using a bare private key (as opposed to a full certificate). | 23 // Signs data using a bare private key (as opposed to a full certificate). |
29 // Currently can only sign data using SHA-1 or SHA-256 with RSA PKCS#1v1.5. | 24 // Currently can only sign data using SHA-1 or SHA-256 with RSA PKCS#1v1.5. |
30 class CRYPTO_EXPORT SignatureCreator { | 25 class CRYPTO_EXPORT SignatureCreator { |
31 public: | 26 public: |
32 // The set of supported hash functions. Extend as required. | 27 // The set of supported hash functions. Extend as required. |
(...skipping 21 matching lines...) Expand all Loading... |
54 // Update the signature with more data. | 49 // Update the signature with more data. |
55 bool Update(const uint8_t* data_part, int data_part_len); | 50 bool Update(const uint8_t* data_part, int data_part_len); |
56 | 51 |
57 // Finalize the signature. | 52 // Finalize the signature. |
58 bool Final(std::vector<uint8_t>* signature); | 53 bool Final(std::vector<uint8_t>* signature); |
59 | 54 |
60 private: | 55 private: |
61 // Private constructor. Use the Create() method instead. | 56 // Private constructor. Use the Create() method instead. |
62 SignatureCreator(); | 57 SignatureCreator(); |
63 | 58 |
64 #if defined(USE_OPENSSL) | |
65 EVP_MD_CTX* sign_context_; | 59 EVP_MD_CTX* sign_context_; |
66 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) | |
67 SGNContextStr* sign_context_; | |
68 #endif | |
69 | 60 |
70 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); | 61 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
71 }; | 62 }; |
72 | 63 |
73 } // namespace crypto | 64 } // namespace crypto |
74 | 65 |
75 #endif // CRYPTO_SIGNATURE_CREATOR_H_ | 66 #endif // CRYPTO_SIGNATURE_CREATOR_H_ |
OLD | NEW |