Don't consider a Bluetooth adapter present until it has an address.
[chromium-blink-merge.git] / crypto / ec_signature_creator.h
blobb557daaf7b0193d8708fd705e77475572251f823
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
3 // found in the LICENSE file.
5 #ifndef CRYPTO_EC_SIGNATURE_CREATOR_H_
6 #define CRYPTO_EC_SIGNATURE_CREATOR_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "crypto/crypto_export.h"
13 namespace crypto {
15 class ECPrivateKey;
16 class ECSignatureCreator;
18 class CRYPTO_EXPORT ECSignatureCreatorFactory {
19 public:
20 virtual ~ECSignatureCreatorFactory() {}
22 virtual ECSignatureCreator* Create(ECPrivateKey* key) = 0;
25 // Signs data using a bare private key (as opposed to a full certificate).
26 // We need this class because SignatureCreator is hardcoded to use
27 // RSAPrivateKey.
28 class CRYPTO_EXPORT ECSignatureCreator {
29 public:
30 virtual ~ECSignatureCreator() {}
32 // Create an instance. The caller must ensure that the provided PrivateKey
33 // instance outlives the created ECSignatureCreator.
34 // TODO(rch): This is currently hard coded to use SHA1. Ideally, we should
35 // pass in the hash algorithm identifier.
36 static ECSignatureCreator* Create(ECPrivateKey* key);
38 // Set a factory to make the Create function return non-standard
39 // ECSignatureCreator objects. Because the ECDSA algorithm involves
40 // randomness, this is useful for higher-level tests that want to have
41 // deterministic mocked output to compare.
42 static void SetFactoryForTesting(ECSignatureCreatorFactory* factory);
44 // Signs |data_len| bytes from |data| and writes the results into
45 // |signature| as a DER encoded ECDSA-Sig-Value from RFC 3279.
47 // ECDSA-Sig-Value ::= SEQUENCE {
48 // r INTEGER,
49 // s INTEGER }
50 virtual bool Sign(const uint8* data,
51 int data_len,
52 std::vector<uint8>* signature) = 0;
55 } // namespace crypto
57 #endif // CRYPTO_EC_SIGNATURE_CREATOR_H_