chromeos: bluetooth: add BluetoothInputClient
[chromium-blink-merge.git] / crypto / ec_signature_creator.h
blob8858eb50868d99527461af68be4897024d90020f
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_
7 #pragma once
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "crypto/crypto_export.h"
14 namespace crypto {
16 class ECPrivateKey;
18 // Signs data using a bare private key (as opposed to a full certificate).
19 // We need this class because SignatureCreator is hardcoded to use
20 // RSAPrivateKey.
21 class CRYPTO_EXPORT ECSignatureCreator {
22 public:
23 ~ECSignatureCreator();
25 // Create an instance. The caller must ensure that the provided PrivateKey
26 // instance outlives the created ECSignatureCreator.
27 // TODO(rch): This is currently hard coded to use SHA1. Ideally, we should
28 // pass in the hash algorithm identifier.
29 static ECSignatureCreator* Create(ECPrivateKey* key);
31 // Signs |data_len| bytes from |data| and writes the results into
32 // |signature| as a DER encoded ECDSA-Sig-Value from RFC 3279.
34 // ECDSA-Sig-Value ::= SEQUENCE {
35 // r INTEGER,
36 // s INTEGER }
37 bool Sign(const uint8* data,
38 int data_len,
39 std::vector<uint8>* signature);
41 private:
42 // Private constructor. Use the Create() method instead.
43 explicit ECSignatureCreator(ECPrivateKey* key);
45 ECPrivateKey* key_;
47 DISALLOW_COPY_AND_ASSIGN(ECSignatureCreator);
50 } // namespace crypto
52 #endif // CRYPTO_EC_SIGNATURE_CREATOR_H_