First public contribution.
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Declares key helper classes for PKCS#10 that perform the algorithm dependant work.
26 #ifndef __PKCS10KEYHELPER_H__
27 #define __PKCS10KEYHELPER_H__
29 #include <mctkeystore.h>
31 #include "x509keyencoder.h"
34 class CASN1EncSequence;
35 class CASN1EncBitString;
38 * Abstract base class defines the interface for PKCS#10 key helpers.
40 * This class is fairly dumb, and provides a generic interface for various
41 * keystore functionality. The methods are called from the RunL of
44 * The implementation decodes the public key to create a public key object -
45 * this is pretty wasteful, as the first thing we're going to do is re-encode it
46 * again, mostly in exactly the same format. However it's simpler and less
47 * error-prome to do it this way.
49 class CPKCS10KeyHelper : public CBase
54 * Create appropriate subclass of CPKCS10KeyHelper depending on key
57 * @param aKeyStore The keystore to use - this object takes ownership.
58 * @param aKeyInfo The key to use.
60 static CPKCS10KeyHelper* CreateKeyHelperL(MCTKeyStore& aKeyStore,
61 const CCTKeyInfo& aKeyInfo,
62 const TDesC8& aExportedKey,
63 const TAlgorithmId aDigestId);
65 virtual ~CPKCS10KeyHelper();
69 void FetchPublicKey(TRequestStatus& aStatus);
70 void CancelFetchPublicKey();
72 virtual void OpenSigner(TRequestStatus& aStatus) = 0;
73 virtual void CancelOpenSigner() = 0;
75 virtual void SignDigestL(const TDesC8& aDigest, TRequestStatus& aStatus) = 0;
76 virtual void CancelSignDigest() = 0;
78 virtual CASN1EncBase* EncodeKeyLC();
79 virtual CASN1EncSequence* EncodeSignatureAlgorithmLC();
80 virtual CASN1EncBitString* EncodeSignatureLC() = 0;
84 CPKCS10KeyHelper(MCTKeyStore& aKeyStore, const CCTKeyInfo& aKeyInfo);
86 virtual void CreateKeyEncoderL(const TDesC8& aExportedKey,
87 const TAlgorithmId aDigestId) = 0;
89 CASN1EncBase* DigestInfoLC(const TDesC8& digest);
93 MCTKeyStore& iKeyStore;
94 const CCTKeyInfo& iKeyInfo;
95 TX509KeyEncoder* iKeyEncoder;
99 * Implementation of PKCS#10 key helper for RSA keys.
101 class CPKCS10RSAKeyHelper : public CPKCS10KeyHelper
105 CPKCS10RSAKeyHelper(MCTKeyStore& aKeyStore, const CCTKeyInfo& aKeyInfo);
106 virtual ~CPKCS10RSAKeyHelper();
110 virtual void OpenSigner(TRequestStatus& aStatus);
111 virtual void CancelOpenSigner();
113 virtual void SignDigestL(const TDesC8& aDigest, TRequestStatus& aStatus);
114 virtual void CancelSignDigest();
116 virtual void CreateKeyEncoderL(const TDesC8& aExportedKey, const TAlgorithmId aDigestId);
117 virtual CASN1EncBitString* EncodeSignatureLC();
121 CRSAPublicKey* iPublicKey;
122 MRSASigner* iRSASigner;
123 CRSASignature* iRSASignature;
128 * Implementation of PKCS#10 key helper for DSA keys.
130 class CPKCS10DSAKeyHelper : public CPKCS10KeyHelper
134 CPKCS10DSAKeyHelper(MCTKeyStore& aKeyStore, const CCTKeyInfo& aKeyInfo);
135 virtual ~CPKCS10DSAKeyHelper();
139 virtual void OpenSigner(TRequestStatus& aStatus);
140 virtual void CancelOpenSigner();
142 virtual void SignDigestL(const TDesC8& aDigest, TRequestStatus& aStatus);
143 virtual void CancelSignDigest();
145 virtual void CreateKeyEncoderL(const TDesC8& aExportedKey, const TAlgorithmId aDigestId);
146 virtual CASN1EncSequence* EncodeSignatureAlgorithmLC();
147 virtual CASN1EncBitString* EncodeSignatureLC();
151 CDSAPublicKey* iPublicKey;
152 MDSASigner* iDSASigner;
153 CDSASignature* iDSASignature;