os/security/cryptoservices/filebasedcertificateandkeystores/source/keystore/Client/ClientOpenedKeys.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/source/keystore/Client/ClientOpenedKeys.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,243 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file 
    1.24 + @internalTechnology
    1.25 +*/
    1.26 + 
    1.27 +#ifndef __CLIENTOPENEDKEYS_H__
    1.28 +#define __CLIENTOPENEDKEYS_H__
    1.29 +
    1.30 +class CFSKeyStoreClient;
    1.31 +class CMessageDigest;
    1.32 +
    1.33 +NONSHARABLE_CLASS(COpenedKey) : protected CBase
    1.34 +	{
    1.35 + public:
    1.36 +	void SetObjectID(TInt aObjectId) 
    1.37 +		{iHandle.iObjectId = aObjectId;}
    1.38 +
    1.39 +	void SetLabel(HBufC* aLabel)
    1.40 +		{iLabel = aLabel;}
    1.41 +
    1.42 +	/**
    1.43 +	 * Virtual Release method visible though COpenedKey pointers - the
    1.44 +	 * implementation just calls the Release method from the mixin class in each
    1.45 +	 * case.
    1.46 +	 */
    1.47 +  	virtual void Release() = 0;
    1.48 +
    1.49 + protected:
    1.50 +	virtual ~COpenedKey();
    1.51 +
    1.52 + protected:
    1.53 +	TCTTokenObjectHandle iHandle;
    1.54 +	CFSKeyStoreClient* iClient;
    1.55 +	HBufC* iLabel;
    1.56 +	};
    1.57 +
    1.58 +NONSHARABLE_CLASS(CRSARepudiableSigner) : public COpenedKey, public MRSASigner
    1.59 +	{
    1.60 + public:
    1.61 +	static CRSARepudiableSigner* New(CFSKeyStoreClient* aClient);
    1.62 +
    1.63 +	/** Returns the object's human-readable label */
    1.64 +	virtual const TDesC& Label() const;
    1.65 +	/** Returns a reference to the associated token */
    1.66 +	virtual MCTToken& Token() const;
    1.67 +	/** Returns a UID representing the type of the token object. The
    1.68 +		meanings of possible UIDs should be documented in the
    1.69 +		documentation for the interface that returns them. */
    1.70 +	virtual TUid Type() const;
    1.71 +	/** Returns a handle for the object. The primary purpose of the
    1.72 +		handle is to allow token objects to be 'passed' between
    1.73 +		processes. See TCTTokenObjectHandle for more details.
    1.74 +	*/
    1.75 +	virtual TCTTokenObjectHandle Handle() const;
    1.76 +		
    1.77 +/**	Sign some data. 
    1.78 +	The data is hashed before the signature is created using the SHA-1
    1.79 +	algorithm.
    1.80 + 	@param aPlaintext The string to be signed.
    1.81 +	@param aSignature The returned signature. This remains owned
    1.82 +	by the signer, and is valid until the signer is released or
    1.83 +	until the next Sign.
    1.84 +	@param aStatus Async status notification
    1.85 +*/
    1.86 +	virtual void SignMessage(const TDesC8& aPlaintext, CRSASignature*& aSignature, 
    1.87 +			  TRequestStatus& aStatus);
    1.88 +
    1.89 +
    1.90 +/**	Perform a raw signing operation.
    1.91 +	
    1.92 +	@param aDigest The data to be signed - this should be some form of hash of
    1.93 +	the actual message to be signed.  If the data is too long, this method will
    1.94 +	return KErrOverflow through aStatus.	
    1.95 +	@param aSignature The returned signature. This remains owned
    1.96 +	by the signer, and is valid until the signer is released or
    1.97 +	until the next Sign.
    1.98 +	@param aStatus Async status notification
    1.99 +*/
   1.100 +	virtual void Sign(const TDesC8& aData, CRSASignature*& aSignature, 
   1.101 +					  TRequestStatus& aStatus);
   1.102 +
   1.103 +
   1.104 +	/// Cancel an ongoing sign
   1.105 +	virtual void CancelSign();
   1.106 +	
   1.107 +	virtual void Release();
   1.108 +
   1.109 + private:
   1.110 +	CRSARepudiableSigner(CFSKeyStoreClient* aClient);
   1.111 +	virtual ~CRSARepudiableSigner();
   1.112 +
   1.113 + private:
   1.114 +	CMessageDigest* iDigest;
   1.115 +	HBufC8* iSignature;	
   1.116 +	};
   1.117 +
   1.118 +NONSHARABLE_CLASS(CDSARepudiableSigner) : public COpenedKey, public MDSASigner
   1.119 +	{
   1.120 + public:
   1.121 +	static CDSARepudiableSigner* New(CFSKeyStoreClient* aClient);
   1.122 +	
   1.123 +	/** Returns the object's human-readable label */
   1.124 +	virtual const TDesC& Label() const;
   1.125 +	/** Returns a reference to the associated token */
   1.126 +	virtual MCTToken& Token() const;
   1.127 +	/** Returns a UID representing the type of the token object. The
   1.128 +		meanings of possible UIDs should be documented in the
   1.129 +		documentation for the interface that returns them. */
   1.130 +	virtual TUid Type() const;
   1.131 +	/** Returns a handle for the object. The primary purpose of the
   1.132 +		handle is to allow token objects to be 'passed' between
   1.133 +		processes. See TCTTokenObjectHandle for more details.
   1.134 +	*/
   1.135 +	virtual TCTTokenObjectHandle Handle() const;
   1.136 +	
   1.137 +	/**	Sign some data. 
   1.138 +
   1.139 +		@param aPlaintext The string to be signed. 
   1.140 +		@param aSignature The returned signature. This remains owned
   1.141 +		by the signer, and is valid until the signer is released or
   1.142 +		until the next Sign.
   1.143 +		@param aStatus Async status notification
   1.144 +	   */
   1.145 +	virtual void SignMessage(const TDesC8& aPlaintext, CDSASignature*& aSignature, 
   1.146 +					  TRequestStatus& aStatus);
   1.147 +
   1.148 +	/**	Perform a raw signing operation.
   1.149 +	 
   1.150 +	    This method implements a raw sign, without the SHA1 hashing
   1.151 +	    mandated by the DSA specification. 
   1.152 +
   1.153 +		@param aPlaintext The string to be signed - this should be some form of
   1.154 +		hash of the actual message to be signed.  If the data is too long, this
   1.155 +		method will return KErrOverflow through aStatus.
   1.156 +		@param aSignature The returned signature. This remains owned
   1.157 +		by the signer, and is valid until the signer is released or
   1.158 +		until the next Sign.
   1.159 +		@param aStatus Async status notification
   1.160 +	   */
   1.161 +	virtual void Sign(const TDesC8& aData, CDSASignature*& aSignature, 
   1.162 +					  TRequestStatus& aStatus);
   1.163 +	/// Cancel an ongoing sign
   1.164 +	virtual void CancelSign();
   1.165 +	
   1.166 +	virtual void Release();
   1.167 +	
   1.168 + private:
   1.169 +	CDSARepudiableSigner(CFSKeyStoreClient* aClient);
   1.170 +	virtual ~CDSARepudiableSigner();
   1.171 +
   1.172 + private:
   1.173 +	CMessageDigest* iDigest;
   1.174 +	};
   1.175 +
   1.176 +NONSHARABLE_CLASS(CFSRSADecryptor) : public COpenedKey, public MCTDecryptor
   1.177 +	{
   1.178 + public:
   1.179 +	static CFSRSADecryptor* New(CFSKeyStoreClient* aClient);
   1.180 +
   1.181 +	/** Returns the object's human-readable label */
   1.182 +	virtual const TDesC& Label() const;
   1.183 +	/** Returns a reference to the associated token */
   1.184 +	virtual MCTToken& Token() const;
   1.185 +	/** Returns a UID representing the type of the token object. The
   1.186 +		meanings of possible UIDs should be documented in the
   1.187 +		documentation for the interface that returns them. */
   1.188 +	virtual TUid Type() const;
   1.189 +	/** Returns a handle for the object. The primary purpose of the
   1.190 +		handle is to allow token objects to be 'passed' between
   1.191 +		processes. See TCTTokenObjectHandle for more details.
   1.192 +	*/
   1.193 +	virtual TCTTokenObjectHandle Handle() const;
   1.194 +	
   1.195 +	/** Do a private decrypt.
   1.196 +		@param aCiphertext The text to decrypt
   1.197 +		@param aPlaintext The returned plaintext
   1.198 +		@param aStatus Async status notification 
   1.199 +	*/
   1.200 +	virtual void Decrypt(const TDesC8& aCiphertext, TDes8& aPlaintext,
   1.201 +				 TRequestStatus& aStatus);
   1.202 +	/// Cancel an ongoing decrypt
   1.203 +	virtual void CancelDecrypt();
   1.204 +	virtual void Release();
   1.205 +
   1.206 + private:
   1.207 +	CFSRSADecryptor(CFSKeyStoreClient* aClient);
   1.208 +	virtual ~CFSRSADecryptor();
   1.209 +	};
   1.210 +
   1.211 +NONSHARABLE_CLASS(CDHAgreement) : public COpenedKey, public MCTDH
   1.212 +	{
   1.213 + public:
   1.214 +	static CDHAgreement* New(CFSKeyStoreClient* aClient);
   1.215 +
   1.216 +	/** Returns the object's human-readable label */
   1.217 +	virtual const TDesC& Label() const;
   1.218 +	/** Returns a reference to the associated token */
   1.219 +	virtual MCTToken& Token() const;
   1.220 +	/** Returns a UID representing the type of the token object. The
   1.221 +		meanings of possible UIDs should be documented in the
   1.222 +		documentation for the interface that returns them. */
   1.223 +	virtual TUid Type() const;
   1.224 +	/** Returns a handle for the object. The primary purpose of the
   1.225 +		handle is to allow token objects to be 'passed' between
   1.226 +		processes. See TCTTokenObjectHandle for more details.
   1.227 +	*/
   1.228 +	virtual TCTTokenObjectHandle Handle() const;
   1.229 +	
   1.230 +	/** Returns the public key ('Big X') for the supplied set of parameters */
   1.231 +	virtual void PublicKey(const TInteger& aN, const TInteger& aG, 
   1.232 +						   CDHPublicKey*& aX,
   1.233 +						   TRequestStatus& aStatus);
   1.234 +	/** Agrees a session key given the public key of the other party */
   1.235 +	virtual void Agree(const CDHPublicKey& iY,
   1.236 +					   HBufC8*& aAgreedKey,
   1.237 +					   TRequestStatus& aStatus);
   1.238 +	/** Cancels either a PublicKey or Agree operation */
   1.239 +	virtual void CancelAgreement();
   1.240 +	virtual void Release();
   1.241 +
   1.242 + private:
   1.243 +	CDHAgreement(CFSKeyStoreClient* aClient);
   1.244 +	virtual ~CDHAgreement();
   1.245 +	};
   1.246 +#endif