Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: crypto/signature_creator.h

Issue 560583002: Generalize crypto::SignatureCreator to allow choice of hash function, so as to support SHA256 (not … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, fix some lint issues, and a shameful missing ")" Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/cloud/policy_builder.cc ('k') | crypto/signature_creator_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/signature_creator.h
diff --git a/crypto/signature_creator.h b/crypto/signature_creator.h
index 0f3e05b5d9c2dacd52499e4042bc20ab1adf0ba6..840d1ff0b809eeec092634d82a62326e148f5320 100644
--- a/crypto/signature_creator.h
+++ b/crypto/signature_creator.h
@@ -24,18 +24,27 @@ namespace crypto {
class RSAPrivateKey;
// Signs data using a bare private key (as opposed to a full certificate).
-// Currently can only sign data using SHA-1 with RSA encryption.
+// Currently can only sign data using SHA-1 or SHA-256 with RSA PKCS#1v1.5.
class CRYPTO_EXPORT SignatureCreator {
public:
+ // The set of supported hash functions. Extend as required.
+ enum HashAlgorithm {
+ SHA1,
+ SHA256,
+ };
+
~SignatureCreator();
// Create an instance. The caller must ensure that the provided PrivateKey
- // instance outlives the created SignatureCreator.
- static SignatureCreator* Create(RSAPrivateKey* key);
+ // instance outlives the created SignatureCreator. Uses the HashAlgorithm
+ // specified.
+ static SignatureCreator* Create(RSAPrivateKey* key, HashAlgorithm hash_alg);
+
- // Signs the precomputed SHA-1 digest |data| using private |key| as
+ // Signs the precomputed |hash_alg| digest |data| using private |key| as
// specified in PKCS #1 v1.5.
static bool Sign(RSAPrivateKey* key,
+ HashAlgorithm hash_alg,
const uint8* data,
int data_len,
std::vector<uint8>* signature);
« no previous file with comments | « components/policy/core/common/cloud/policy_builder.cc ('k') | crypto/signature_creator_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698