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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 SHA256, | 33 SHA256, |
34 }; | 34 }; |
35 | 35 |
36 ~SignatureCreator(); | 36 ~SignatureCreator(); |
37 | 37 |
38 // Create an instance. The caller must ensure that the provided PrivateKey | 38 // Create an instance. The caller must ensure that the provided PrivateKey |
39 // instance outlives the created SignatureCreator. Uses the HashAlgorithm | 39 // instance outlives the created SignatureCreator. Uses the HashAlgorithm |
40 // specified. | 40 // specified. |
41 static SignatureCreator* Create(RSAPrivateKey* key, HashAlgorithm hash_alg); | 41 static SignatureCreator* Create(RSAPrivateKey* key, HashAlgorithm hash_alg); |
42 | 42 |
43 // Create an instance. The caller must ensure that the provided PrivateKey | |
44 // instance outlives the created SignatureCreator. Uses the HashAlgorithm | |
45 // specified. The generated signature will be in the RSA-PSS format. | |
46 static SignatureCreator* CreatePSS(RSAPrivateKey* key, | |
47 HashAlgorithm hash_alg); | |
43 | 48 |
44 // Signs the precomputed |hash_alg| digest |data| using private |key| as | 49 // Signs the precomputed |hash_alg| digest |data| using private |key| as |
45 // specified in PKCS #1 v1.5. | 50 // specified in PKCS #1 v1.5. |
Ryan Sleevi
2015/08/25 20:01:38
This of course would be inconsistent with your pro
| |
46 static bool Sign(RSAPrivateKey* key, | 51 static bool Sign(RSAPrivateKey* key, |
47 HashAlgorithm hash_alg, | 52 HashAlgorithm hash_alg, |
48 const uint8* data, | 53 const uint8* data, |
49 int data_len, | 54 int data_len, |
50 std::vector<uint8>* signature); | 55 std::vector<uint8>* signature); |
51 | 56 |
52 // Update the signature with more data. | 57 // Update the signature with more data. |
53 bool Update(const uint8* data_part, int data_part_len); | 58 bool Update(const uint8* data_part, int data_part_len); |
54 | 59 |
55 // Finalize the signature. | 60 // Finalize the signature. |
56 bool Final(std::vector<uint8>* signature); | 61 bool Final(std::vector<uint8>* signature); |
57 | 62 |
58 private: | 63 private: |
64 static SignatureCreator* CreateImpl(RSAPrivateKey* key, | |
Ryan Sleevi
2015/08/25 20:01:38
This doesn't actually need to be static, does it?
| |
65 HashAlgorithm hash_alg, | |
66 bool use_pss); | |
67 | |
59 // Private constructor. Use the Create() method instead. | 68 // Private constructor. Use the Create() method instead. |
60 SignatureCreator(); | 69 SignatureCreator(); |
61 | 70 |
62 #if defined(USE_OPENSSL) | 71 #if defined(USE_OPENSSL) |
63 EVP_MD_CTX* sign_context_; | 72 EVP_MD_CTX* sign_context_; |
64 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) | 73 #elif defined(USE_NSS_CERTS) || defined(OS_WIN) || defined(OS_MACOSX) |
65 SGNContextStr* sign_context_; | 74 SGNContextStr* sign_context_; |
66 #endif | 75 #endif |
67 | 76 |
68 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); | 77 DISALLOW_COPY_AND_ASSIGN(SignatureCreator); |
69 }; | 78 }; |
70 | 79 |
71 } // namespace crypto | 80 } // namespace crypto |
72 | 81 |
73 #endif // CRYPTO_SIGNATURE_CREATOR_H_ | 82 #endif // CRYPTO_SIGNATURE_CREATOR_H_ |
OLD | NEW |