sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __CLIENTOPENEDKEYS_H__ sl@0: #define __CLIENTOPENEDKEYS_H__ sl@0: sl@0: class CFSKeyStoreClient; sl@0: class CMessageDigest; sl@0: sl@0: NONSHARABLE_CLASS(COpenedKey) : protected CBase sl@0: { sl@0: public: sl@0: void SetObjectID(TInt aObjectId) sl@0: {iHandle.iObjectId = aObjectId;} sl@0: sl@0: void SetLabel(HBufC* aLabel) sl@0: {iLabel = aLabel;} sl@0: sl@0: /** sl@0: * Virtual Release method visible though COpenedKey pointers - the sl@0: * implementation just calls the Release method from the mixin class in each sl@0: * case. sl@0: */ sl@0: virtual void Release() = 0; sl@0: sl@0: protected: sl@0: virtual ~COpenedKey(); sl@0: sl@0: protected: sl@0: TCTTokenObjectHandle iHandle; sl@0: CFSKeyStoreClient* iClient; sl@0: HBufC* iLabel; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CRSARepudiableSigner) : public COpenedKey, public MRSASigner sl@0: { sl@0: public: sl@0: static CRSARepudiableSigner* New(CFSKeyStoreClient* aClient); sl@0: sl@0: /** Returns the object's human-readable label */ sl@0: virtual const TDesC& Label() const; sl@0: /** Returns a reference to the associated token */ sl@0: virtual MCTToken& Token() const; sl@0: /** Returns a UID representing the type of the token object. The sl@0: meanings of possible UIDs should be documented in the sl@0: documentation for the interface that returns them. */ sl@0: virtual TUid Type() const; sl@0: /** Returns a handle for the object. The primary purpose of the sl@0: handle is to allow token objects to be 'passed' between sl@0: processes. See TCTTokenObjectHandle for more details. sl@0: */ sl@0: virtual TCTTokenObjectHandle Handle() const; sl@0: sl@0: /** Sign some data. sl@0: The data is hashed before the signature is created using the SHA-1 sl@0: algorithm. sl@0: @param aPlaintext The string to be signed. sl@0: @param aSignature The returned signature. This remains owned sl@0: by the signer, and is valid until the signer is released or sl@0: until the next Sign. sl@0: @param aStatus Async status notification sl@0: */ sl@0: virtual void SignMessage(const TDesC8& aPlaintext, CRSASignature*& aSignature, sl@0: TRequestStatus& aStatus); sl@0: sl@0: sl@0: /** Perform a raw signing operation. sl@0: sl@0: @param aDigest The data to be signed - this should be some form of hash of sl@0: the actual message to be signed. If the data is too long, this method will sl@0: return KErrOverflow through aStatus. sl@0: @param aSignature The returned signature. This remains owned sl@0: by the signer, and is valid until the signer is released or sl@0: until the next Sign. sl@0: @param aStatus Async status notification sl@0: */ sl@0: virtual void Sign(const TDesC8& aData, CRSASignature*& aSignature, sl@0: TRequestStatus& aStatus); sl@0: sl@0: sl@0: /// Cancel an ongoing sign sl@0: virtual void CancelSign(); sl@0: sl@0: virtual void Release(); sl@0: sl@0: private: sl@0: CRSARepudiableSigner(CFSKeyStoreClient* aClient); sl@0: virtual ~CRSARepudiableSigner(); sl@0: sl@0: private: sl@0: CMessageDigest* iDigest; sl@0: HBufC8* iSignature; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CDSARepudiableSigner) : public COpenedKey, public MDSASigner sl@0: { sl@0: public: sl@0: static CDSARepudiableSigner* New(CFSKeyStoreClient* aClient); sl@0: sl@0: /** Returns the object's human-readable label */ sl@0: virtual const TDesC& Label() const; sl@0: /** Returns a reference to the associated token */ sl@0: virtual MCTToken& Token() const; sl@0: /** Returns a UID representing the type of the token object. The sl@0: meanings of possible UIDs should be documented in the sl@0: documentation for the interface that returns them. */ sl@0: virtual TUid Type() const; sl@0: /** Returns a handle for the object. The primary purpose of the sl@0: handle is to allow token objects to be 'passed' between sl@0: processes. See TCTTokenObjectHandle for more details. sl@0: */ sl@0: virtual TCTTokenObjectHandle Handle() const; sl@0: sl@0: /** Sign some data. sl@0: sl@0: @param aPlaintext The string to be signed. sl@0: @param aSignature The returned signature. This remains owned sl@0: by the signer, and is valid until the signer is released or sl@0: until the next Sign. sl@0: @param aStatus Async status notification sl@0: */ sl@0: virtual void SignMessage(const TDesC8& aPlaintext, CDSASignature*& aSignature, sl@0: TRequestStatus& aStatus); sl@0: sl@0: /** Perform a raw signing operation. sl@0: sl@0: This method implements a raw sign, without the SHA1 hashing sl@0: mandated by the DSA specification. sl@0: sl@0: @param aPlaintext The string to be signed - this should be some form of sl@0: hash of the actual message to be signed. If the data is too long, this sl@0: method will return KErrOverflow through aStatus. sl@0: @param aSignature The returned signature. This remains owned sl@0: by the signer, and is valid until the signer is released or sl@0: until the next Sign. sl@0: @param aStatus Async status notification sl@0: */ sl@0: virtual void Sign(const TDesC8& aData, CDSASignature*& aSignature, sl@0: TRequestStatus& aStatus); sl@0: /// Cancel an ongoing sign sl@0: virtual void CancelSign(); sl@0: sl@0: virtual void Release(); sl@0: sl@0: private: sl@0: CDSARepudiableSigner(CFSKeyStoreClient* aClient); sl@0: virtual ~CDSARepudiableSigner(); sl@0: sl@0: private: sl@0: CMessageDigest* iDigest; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CFSRSADecryptor) : public COpenedKey, public MCTDecryptor sl@0: { sl@0: public: sl@0: static CFSRSADecryptor* New(CFSKeyStoreClient* aClient); sl@0: sl@0: /** Returns the object's human-readable label */ sl@0: virtual const TDesC& Label() const; sl@0: /** Returns a reference to the associated token */ sl@0: virtual MCTToken& Token() const; sl@0: /** Returns a UID representing the type of the token object. The sl@0: meanings of possible UIDs should be documented in the sl@0: documentation for the interface that returns them. */ sl@0: virtual TUid Type() const; sl@0: /** Returns a handle for the object. The primary purpose of the sl@0: handle is to allow token objects to be 'passed' between sl@0: processes. See TCTTokenObjectHandle for more details. sl@0: */ sl@0: virtual TCTTokenObjectHandle Handle() const; sl@0: sl@0: /** Do a private decrypt. sl@0: @param aCiphertext The text to decrypt sl@0: @param aPlaintext The returned plaintext sl@0: @param aStatus Async status notification sl@0: */ sl@0: virtual void Decrypt(const TDesC8& aCiphertext, TDes8& aPlaintext, sl@0: TRequestStatus& aStatus); sl@0: /// Cancel an ongoing decrypt sl@0: virtual void CancelDecrypt(); sl@0: virtual void Release(); sl@0: sl@0: private: sl@0: CFSRSADecryptor(CFSKeyStoreClient* aClient); sl@0: virtual ~CFSRSADecryptor(); sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CDHAgreement) : public COpenedKey, public MCTDH sl@0: { sl@0: public: sl@0: static CDHAgreement* New(CFSKeyStoreClient* aClient); sl@0: sl@0: /** Returns the object's human-readable label */ sl@0: virtual const TDesC& Label() const; sl@0: /** Returns a reference to the associated token */ sl@0: virtual MCTToken& Token() const; sl@0: /** Returns a UID representing the type of the token object. The sl@0: meanings of possible UIDs should be documented in the sl@0: documentation for the interface that returns them. */ sl@0: virtual TUid Type() const; sl@0: /** Returns a handle for the object. The primary purpose of the sl@0: handle is to allow token objects to be 'passed' between sl@0: processes. See TCTTokenObjectHandle for more details. sl@0: */ sl@0: virtual TCTTokenObjectHandle Handle() const; sl@0: sl@0: /** Returns the public key ('Big X') for the supplied set of parameters */ sl@0: virtual void PublicKey(const TInteger& aN, const TInteger& aG, sl@0: CDHPublicKey*& aX, sl@0: TRequestStatus& aStatus); sl@0: /** Agrees a session key given the public key of the other party */ sl@0: virtual void Agree(const CDHPublicKey& iY, sl@0: HBufC8*& aAgreedKey, sl@0: TRequestStatus& aStatus); sl@0: /** Cancels either a PublicKey or Agree operation */ sl@0: virtual void CancelAgreement(); sl@0: virtual void Release(); sl@0: sl@0: private: sl@0: CDHAgreement(CFSKeyStoreClient* aClient); sl@0: virtual ~CDHAgreement(); sl@0: }; sl@0: #endif