Output data about media requests to the netlog too.
[chromium-blink-merge.git] / base / crypto / signature_creator.h
blob38e327b6291060715d62b7cf63baaaffbd938799
1 // Copyright (c) 2009 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 BASE_CRYPTO_SIGNATURE_CREATOR_H_
6 #define BASE_CRYPTO_SIGNATURE_CREATOR_H_
7 #pragma once
9 #include "build/build_config.h"
11 #if defined(USE_NSS)
12 // Forward declaration.
13 struct SGNContextStr;
14 #elif defined(OS_MACOSX)
15 #include <Security/cssm.h>
16 #endif
18 #include <vector>
20 #include "base/basictypes.h"
21 #include "base/crypto/rsa_private_key.h"
23 #if defined(OS_WIN)
24 #include "base/crypto/scoped_capi_types.h"
25 #endif
27 namespace base {
29 // Signs data using a bare private key (as opposed to a full certificate).
30 // Currently can only sign data using SHA-1 with RSA encryption.
31 class SignatureCreator {
32 public:
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 ~SignatureCreator();
39 // Update the signature with more data.
40 bool Update(const uint8* data_part, int data_part_len);
42 // Finalize the signature.
43 bool Final(std::vector<uint8>* signature);
45 private:
46 // Private constructor. Use the Create() method instead.
47 SignatureCreator();
49 RSAPrivateKey* key_;
51 #if defined(USE_NSS)
52 SGNContextStr* sign_context_;
53 #elif defined(OS_MACOSX)
54 CSSM_CC_HANDLE sig_handle_;
55 #elif defined(OS_WIN)
56 ScopedHCRYPTHASH hash_object_;
57 #endif
59 DISALLOW_COPY_AND_ASSIGN(SignatureCreator);
62 } // namespace base
64 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_