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 "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Signs data using a bare private key (as opposed to a full certificate). | 27 // Signs data using a bare private key (as opposed to a full certificate). |
28 // Currently can only sign data using SHA-1 with RSA encryption. | 28 // Currently can only sign data using SHA-1 with RSA encryption. |
29 class CRYPTO_EXPORT SignatureCreator { | 29 class CRYPTO_EXPORT SignatureCreator { |
30 public: | 30 public: |
31 ~SignatureCreator(); | 31 ~SignatureCreator(); |
32 | 32 |
33 // Create an instance. The caller must ensure that the provided PrivateKey | 33 // Create an instance. The caller must ensure that the provided PrivateKey |
34 // instance outlives the created SignatureCreator. | 34 // instance outlives the created SignatureCreator. |
35 static SignatureCreator* Create(RSAPrivateKey* key); | 35 static SignatureCreator* Create(RSAPrivateKey* key); |
36 | 36 |
| 37 // Signs the precomputed SHA-1 digest |data| using private |key| as |
| 38 // specified in PKCS #1 v1.5. |
| 39 static bool Sign(RSAPrivateKey* key, |
| 40 const uint8* data, |
| 41 int data_len, |
| 42 std::vector<uint8>* signature); |
| 43 |
37 // Update the signature with more data. | 44 // Update the signature with more data. |
38 bool Update(const uint8* data_part, int data_part_len); | 45 bool Update(const uint8* data_part, int data_part_len); |
39 | 46 |
40 // Finalize the signature. | 47 // Finalize the signature. |
41 bool Final(std::vector<uint8>* signature); | 48 bool Final(std::vector<uint8>* signature); |
42 | 49 |
43 private: | 50 private: |
44 // Private constructor. Use the Create() method instead. | 51 // Private constructor. Use the Create() method instead. |
45 SignatureCreator(); | 52 SignatureCreator(); |
46 | 53 |
47 RSAPrivateKey* key_; | 54 RSAPrivateKey* key_; |
48 | 55 |
49 #if defined(USE_OPENSSL) | 56 #if defined(USE_OPENSSL) |
50 EVP_MD_CTX* sign_context_; | 57 EVP_MD_CTX* sign_context_; |
51 #elif defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX) | 58 #elif defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX) |
52 SGNContextStr* sign_context_; | 59 SGNContextStr* sign_context_; |
53 #endif | 60 #endif |
54 | 61 |
55 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); | 62 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
56 }; | 63 }; |
57 | 64 |
58 } // namespace crypto | 65 } // namespace crypto |
59 | 66 |
60 #endif // CRYPTO_SIGNATURE_CREATOR_H_ | 67 #endif // CRYPTO_SIGNATURE_CREATOR_H_ |
OLD | NEW |