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