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_
9 #include "build/build_config.h"
12 // Forward declaration.
14 #elif defined(OS_MACOSX)
15 #include <Security/cssm.h>
20 #include "base/basictypes.h"
21 #include "base/crypto/rsa_private_key.h"
24 #include "base/crypto/scoped_capi_types.h"
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
{
33 // Create an instance. The caller must ensure that the provided PrivateKey
34 // instance outlives the created SignatureCreator.
35 static SignatureCreator
* Create(RSAPrivateKey
* key
);
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
);
46 // Private constructor. Use the Create() method instead.
52 SGNContextStr
* sign_context_
;
53 #elif defined(OS_MACOSX)
54 CSSM_CC_HANDLE sig_handle_
;
56 ScopedHCRYPTHASH hash_object_
;
59 DISALLOW_COPY_AND_ASSIGN(SignatureCreator
);
64 #endif // BASE_CRYPTO_SIGNATURE_CREATOR_H_