os/security/cryptoservices/filebasedcertificateandkeystores/source/keystore/Client/ClientOpenedKeys.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file 
    21  @internalTechnology
    22 */
    23  
    24 #ifndef __CLIENTOPENEDKEYS_H__
    25 #define __CLIENTOPENEDKEYS_H__
    26 
    27 class CFSKeyStoreClient;
    28 class CMessageDigest;
    29 
    30 NONSHARABLE_CLASS(COpenedKey) : protected CBase
    31 	{
    32  public:
    33 	void SetObjectID(TInt aObjectId) 
    34 		{iHandle.iObjectId = aObjectId;}
    35 
    36 	void SetLabel(HBufC* aLabel)
    37 		{iLabel = aLabel;}
    38 
    39 	/**
    40 	 * Virtual Release method visible though COpenedKey pointers - the
    41 	 * implementation just calls the Release method from the mixin class in each
    42 	 * case.
    43 	 */
    44   	virtual void Release() = 0;
    45 
    46  protected:
    47 	virtual ~COpenedKey();
    48 
    49  protected:
    50 	TCTTokenObjectHandle iHandle;
    51 	CFSKeyStoreClient* iClient;
    52 	HBufC* iLabel;
    53 	};
    54 
    55 NONSHARABLE_CLASS(CRSARepudiableSigner) : public COpenedKey, public MRSASigner
    56 	{
    57  public:
    58 	static CRSARepudiableSigner* New(CFSKeyStoreClient* aClient);
    59 
    60 	/** Returns the object's human-readable label */
    61 	virtual const TDesC& Label() const;
    62 	/** Returns a reference to the associated token */
    63 	virtual MCTToken& Token() const;
    64 	/** Returns a UID representing the type of the token object. The
    65 		meanings of possible UIDs should be documented in the
    66 		documentation for the interface that returns them. */
    67 	virtual TUid Type() const;
    68 	/** Returns a handle for the object. The primary purpose of the
    69 		handle is to allow token objects to be 'passed' between
    70 		processes. See TCTTokenObjectHandle for more details.
    71 	*/
    72 	virtual TCTTokenObjectHandle Handle() const;
    73 		
    74 /**	Sign some data. 
    75 	The data is hashed before the signature is created using the SHA-1
    76 	algorithm.
    77  	@param aPlaintext The string to be signed.
    78 	@param aSignature The returned signature. This remains owned
    79 	by the signer, and is valid until the signer is released or
    80 	until the next Sign.
    81 	@param aStatus Async status notification
    82 */
    83 	virtual void SignMessage(const TDesC8& aPlaintext, CRSASignature*& aSignature, 
    84 			  TRequestStatus& aStatus);
    85 
    86 
    87 /**	Perform a raw signing operation.
    88 	
    89 	@param aDigest The data to be signed - this should be some form of hash of
    90 	the actual message to be signed.  If the data is too long, this method will
    91 	return KErrOverflow through aStatus.	
    92 	@param aSignature The returned signature. This remains owned
    93 	by the signer, and is valid until the signer is released or
    94 	until the next Sign.
    95 	@param aStatus Async status notification
    96 */
    97 	virtual void Sign(const TDesC8& aData, CRSASignature*& aSignature, 
    98 					  TRequestStatus& aStatus);
    99 
   100 
   101 	/// Cancel an ongoing sign
   102 	virtual void CancelSign();
   103 	
   104 	virtual void Release();
   105 
   106  private:
   107 	CRSARepudiableSigner(CFSKeyStoreClient* aClient);
   108 	virtual ~CRSARepudiableSigner();
   109 
   110  private:
   111 	CMessageDigest* iDigest;
   112 	HBufC8* iSignature;	
   113 	};
   114 
   115 NONSHARABLE_CLASS(CDSARepudiableSigner) : public COpenedKey, public MDSASigner
   116 	{
   117  public:
   118 	static CDSARepudiableSigner* New(CFSKeyStoreClient* aClient);
   119 	
   120 	/** Returns the object's human-readable label */
   121 	virtual const TDesC& Label() const;
   122 	/** Returns a reference to the associated token */
   123 	virtual MCTToken& Token() const;
   124 	/** Returns a UID representing the type of the token object. The
   125 		meanings of possible UIDs should be documented in the
   126 		documentation for the interface that returns them. */
   127 	virtual TUid Type() const;
   128 	/** Returns a handle for the object. The primary purpose of the
   129 		handle is to allow token objects to be 'passed' between
   130 		processes. See TCTTokenObjectHandle for more details.
   131 	*/
   132 	virtual TCTTokenObjectHandle Handle() const;
   133 	
   134 	/**	Sign some data. 
   135 
   136 		@param aPlaintext The string to be signed. 
   137 		@param aSignature The returned signature. This remains owned
   138 		by the signer, and is valid until the signer is released or
   139 		until the next Sign.
   140 		@param aStatus Async status notification
   141 	   */
   142 	virtual void SignMessage(const TDesC8& aPlaintext, CDSASignature*& aSignature, 
   143 					  TRequestStatus& aStatus);
   144 
   145 	/**	Perform a raw signing operation.
   146 	 
   147 	    This method implements a raw sign, without the SHA1 hashing
   148 	    mandated by the DSA specification. 
   149 
   150 		@param aPlaintext The string to be signed - this should be some form of
   151 		hash of the actual message to be signed.  If the data is too long, this
   152 		method will return KErrOverflow through aStatus.
   153 		@param aSignature The returned signature. This remains owned
   154 		by the signer, and is valid until the signer is released or
   155 		until the next Sign.
   156 		@param aStatus Async status notification
   157 	   */
   158 	virtual void Sign(const TDesC8& aData, CDSASignature*& aSignature, 
   159 					  TRequestStatus& aStatus);
   160 	/// Cancel an ongoing sign
   161 	virtual void CancelSign();
   162 	
   163 	virtual void Release();
   164 	
   165  private:
   166 	CDSARepudiableSigner(CFSKeyStoreClient* aClient);
   167 	virtual ~CDSARepudiableSigner();
   168 
   169  private:
   170 	CMessageDigest* iDigest;
   171 	};
   172 
   173 NONSHARABLE_CLASS(CFSRSADecryptor) : public COpenedKey, public MCTDecryptor
   174 	{
   175  public:
   176 	static CFSRSADecryptor* New(CFSKeyStoreClient* aClient);
   177 
   178 	/** Returns the object's human-readable label */
   179 	virtual const TDesC& Label() const;
   180 	/** Returns a reference to the associated token */
   181 	virtual MCTToken& Token() const;
   182 	/** Returns a UID representing the type of the token object. The
   183 		meanings of possible UIDs should be documented in the
   184 		documentation for the interface that returns them. */
   185 	virtual TUid Type() const;
   186 	/** Returns a handle for the object. The primary purpose of the
   187 		handle is to allow token objects to be 'passed' between
   188 		processes. See TCTTokenObjectHandle for more details.
   189 	*/
   190 	virtual TCTTokenObjectHandle Handle() const;
   191 	
   192 	/** Do a private decrypt.
   193 		@param aCiphertext The text to decrypt
   194 		@param aPlaintext The returned plaintext
   195 		@param aStatus Async status notification 
   196 	*/
   197 	virtual void Decrypt(const TDesC8& aCiphertext, TDes8& aPlaintext,
   198 				 TRequestStatus& aStatus);
   199 	/// Cancel an ongoing decrypt
   200 	virtual void CancelDecrypt();
   201 	virtual void Release();
   202 
   203  private:
   204 	CFSRSADecryptor(CFSKeyStoreClient* aClient);
   205 	virtual ~CFSRSADecryptor();
   206 	};
   207 
   208 NONSHARABLE_CLASS(CDHAgreement) : public COpenedKey, public MCTDH
   209 	{
   210  public:
   211 	static CDHAgreement* New(CFSKeyStoreClient* aClient);
   212 
   213 	/** Returns the object's human-readable label */
   214 	virtual const TDesC& Label() const;
   215 	/** Returns a reference to the associated token */
   216 	virtual MCTToken& Token() const;
   217 	/** Returns a UID representing the type of the token object. The
   218 		meanings of possible UIDs should be documented in the
   219 		documentation for the interface that returns them. */
   220 	virtual TUid Type() const;
   221 	/** Returns a handle for the object. The primary purpose of the
   222 		handle is to allow token objects to be 'passed' between
   223 		processes. See TCTTokenObjectHandle for more details.
   224 	*/
   225 	virtual TCTTokenObjectHandle Handle() const;
   226 	
   227 	/** Returns the public key ('Big X') for the supplied set of parameters */
   228 	virtual void PublicKey(const TInteger& aN, const TInteger& aG, 
   229 						   CDHPublicKey*& aX,
   230 						   TRequestStatus& aStatus);
   231 	/** Agrees a session key given the public key of the other party */
   232 	virtual void Agree(const CDHPublicKey& iY,
   233 					   HBufC8*& aAgreedKey,
   234 					   TRequestStatus& aStatus);
   235 	/** Cancels either a PublicKey or Agree operation */
   236 	virtual void CancelAgreement();
   237 	virtual void Release();
   238 
   239  private:
   240 	CDHAgreement(CFSKeyStoreClient* aClient);
   241 	virtual ~CDHAgreement();
   242 	};
   243 #endif