android: Do not SetNeedsBeginFrame(true) multiple times
[chromium-blink-merge.git] / crypto / signature_creator.h
blob1a1d6e5ce7f6331b1bfd7fde48909a3bd011fd98
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_SIGNATURE_CREATOR_H_
6 #define CRYPTO_SIGNATURE_CREATOR_H_
8 #include "build/build_config.h"
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "crypto/crypto_export.h"
15 #if defined(USE_OPENSSL)
16 // Forward declaration for openssl/*.h
17 typedef struct env_md_ctx_st EVP_MD_CTX;
18 #elif defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX)
19 // Forward declaration.
20 struct SGNContextStr;
21 #endif
23 namespace crypto {
25 class RSAPrivateKey;
27 // Signs data using a bare private key (as opposed to a full certificate).
28 // Currently can only sign data using SHA-1 with RSA encryption.
29 class CRYPTO_EXPORT SignatureCreator {
30 public:
31 ~SignatureCreator();
33 // Create an instance. The caller must ensure that the provided PrivateKey
34 // instance outlives the created SignatureCreator.
35 static SignatureCreator* Create(RSAPrivateKey* key);
37 // Update the signature with more data.
38 bool Update(const uint8* data_part, int data_part_len);
40 // Finalize the signature.
41 bool Final(std::vector<uint8>* signature);
43 private:
44 // Private constructor. Use the Create() method instead.
45 SignatureCreator();
47 RSAPrivateKey* key_;
49 #if defined(USE_OPENSSL)
50 EVP_MD_CTX* sign_context_;
51 #elif defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX)
52 SGNContextStr* sign_context_;
53 #endif
55 DISALLOW_COPY_AND_ASSIGN(SignatureCreator);
58 } // namespace crypto
60 #endif // CRYPTO_SIGNATURE_CREATOR_H_