Chromium Code Reviews| Index: crypto/ec_signature_creator.h |
| diff --git a/crypto/ec_signature_creator.h b/crypto/ec_signature_creator.h |
| index 8858eb50868d99527461af68be4897024d90020f..7693ac40e141cd400c3f8651d3005bfc40b30395 100644 |
| --- a/crypto/ec_signature_creator.h |
| +++ b/crypto/ec_signature_creator.h |
| @@ -14,13 +14,19 @@ |
| namespace crypto { |
| class ECPrivateKey; |
| +class ECSignatureCreator; |
| + |
| +class CRYPTO_EXPORT ECSignatureCreatorFactory { |
| + public: |
| + virtual ECSignatureCreator* Create(ECPrivateKey* key) = 0; |
|
Ryan Hamilton
2012/02/23 04:36:12
Do you need a virtual destructor?
mattm
2012/02/23 04:44:57
yep
|
| +}; |
| // 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 +34,24 @@ 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 elliptic curve signature algorithm |
| + // involves randomness, this is useful for higher-level tests that want to |
| + // have deterministic 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_; |
| + virtual bool Sign(const uint8* data, |
| + int data_len, |
| + std::vector<uint8>* signature) = 0; |
| - DISALLOW_COPY_AND_ASSIGN(ECSignatureCreator); |
| + protected: |
| + static ECSignatureCreator* CreatePlatformImpl(ECPrivateKey* key); |
| }; |
| } // namespace crypto |