summaryrefslogtreecommitdiffstats
path: root/crypto/ec_signature_creator.h
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 08:06:54 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 08:06:54 +0000
commit6b2e61f991dc163278654b8461aaf3c26c000801 (patch)
tree282385d49f63da0e4bee9e2676b4b3966953e6d8 /crypto/ec_signature_creator.h
parentb10da51df81081ecaa3adf31b06dd4fd1f61d0a7 (diff)
downloadchromium_src-6b2e61f991dc163278654b8461aaf3c26c000801.zip
chromium_src-6b2e61f991dc163278654b8461aaf3c26c000801.tar.gz
chromium_src-6b2e61f991dc163278654b8461aaf3c26c000801.tar.bz2
Fix SpdySession::WriteCredentialFrame ECPrivateKey creation args.
It was passing the DER certificate instead of a SubjectPublicKeyInfo. Also adds ECSignatureCreator::SetFactoryForTesting method to allow easier testing of code that uses ECSignatureCreator. BUG=none TEST=SpdyHttpStreamTest.SendCredentialsEC Review URL: http://codereview.chromium.org/9455006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/ec_signature_creator.h')
-rw-r--r--crypto/ec_signature_creator.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/crypto/ec_signature_creator.h b/crypto/ec_signature_creator.h
index 8858eb5..610b9f0 100644
--- a/crypto/ec_signature_creator.h
+++ b/crypto/ec_signature_creator.h
@@ -14,13 +14,21 @@
namespace crypto {
class ECPrivateKey;
+class ECSignatureCreator;
+
+class CRYPTO_EXPORT ECSignatureCreatorFactory {
+ public:
+ virtual ~ECSignatureCreatorFactory() {}
+
+ virtual ECSignatureCreator* Create(ECPrivateKey* key) = 0;
+};
// Signs data using a bare private key (as opposed to a full certificate).
// We need this class because SignatureCreator is hardcoded to use
// RSAPrivateKey.
class CRYPTO_EXPORT ECSignatureCreator {
public:
- ~ECSignatureCreator();
+ virtual ~ECSignatureCreator() {}
// Create an instance. The caller must ensure that the provided PrivateKey
// instance outlives the created ECSignatureCreator.
@@ -28,23 +36,21 @@ class CRYPTO_EXPORT ECSignatureCreator {
// pass in the hash algorithm identifier.
static ECSignatureCreator* Create(ECPrivateKey* key);
+ // Set a factory to make the Create function return non-standard
+ // ECSignatureCreator objects. Because the ECDSA algorithm involves
+ // randomness, this is useful for higher-level tests that want to have
+ // deterministic mocked output to compare.
+ static void SetFactoryForTesting(ECSignatureCreatorFactory* factory);
+
// Signs |data_len| bytes from |data| and writes the results into
// |signature| as a DER encoded ECDSA-Sig-Value from RFC 3279.
//
// ECDSA-Sig-Value ::= SEQUENCE {
// r INTEGER,
// s INTEGER }
- bool Sign(const uint8* data,
- int data_len,
- std::vector<uint8>* signature);
-
- private:
- // Private constructor. Use the Create() method instead.
- explicit ECSignatureCreator(ECPrivateKey* key);
-
- ECPrivateKey* key_;
-
- DISALLOW_COPY_AND_ASSIGN(ECSignatureCreator);
+ virtual bool Sign(const uint8* data,
+ int data_len,
+ std::vector<uint8>* signature) = 0;
};
} // namespace crypto