os/security/cryptoservices/filebasedcertificateandkeystores/test/tcryptotokenhai/tcryptotokenhai.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/tcryptotokenhai/tcryptotokenhai.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,93 @@
     1.4 +/*
     1.5 +* Copyright (c) 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 +* This class implements the reference Crypto Token Hardware Abstraction 
    1.19 +* Interface (HAI). It is just intended to show how operations using 
    1.20 +* device keys can be performed using crypto token framework. In the 
    1.21 +* real world scenario, this HAI should be replaced by device drivers 
    1.22 +* by the licensees. In such a case, all the operations performed by 
    1.23 +* the replacing class would be performed in Kernel Space.
    1.24 +*
    1.25 +*/
    1.26 +
    1.27 +
    1.28 +/**
    1.29 + * @file
    1.30 + * @internalComponent
    1.31 + * @released
    1.32 + */
    1.33 +#ifndef CCRYPTOTOKENHAI_H
    1.34 +#define CCRYPTOTOKENHAI_H
    1.35 +
    1.36 +#include <e32base.h>
    1.37 +#include <f32file.h>
    1.38 +#include <S32FILE.H>
    1.39 +#include <mctkeystore.h>
    1.40 +
    1.41 +class CKeyDetails;
    1.42 +class MCTToken;
    1.43 +
    1.44 +namespace CryptoSpi
    1.45 +	{
    1.46 +	class CSigner;
    1.47 +	}
    1.48 +
    1.49 +NONSHARABLE_CLASS(CCryptoTokenHai) : public CBase
    1.50 +	{
    1.51 +	public:
    1.52 +		IMPORT_C static CCryptoTokenHai* NewLC(MCTToken* aToken);
    1.53 +		IMPORT_C static CCryptoTokenHai* NewL(MCTToken* aToken);
    1.54 +		IMPORT_C ~CCryptoTokenHai();
    1.55 +		
    1.56 +	public:
    1.57 +		IMPORT_C void DecryptL(TInt aHandle,
    1.58 +								const TDesC8& aCiphertext,
    1.59 +								HBufC8*& aPlaintext );
    1.60 +	
    1.61 +		IMPORT_C void SignL( 	TInt aHandle,
    1.62 +								const TDesC8& aPlaintext,
    1.63 +								HBufC8*& aSignature );
    1.64 +	
    1.65 +		IMPORT_C TInt KeyPresent( TInt aHandle );
    1.66 +		IMPORT_C void ExportPrivateKeyL( TInt aHandle, HBufC8*& aKey );
    1.67 +		IMPORT_C void ExportPublicKeyL( TInt aHandle, HBufC8*& aKey );
    1.68 +		IMPORT_C void ImportKeyL( const TDesC& aLabel, const TDesC8& aPrivateKey, const TDesC8& aPublicKey );
    1.69 +		IMPORT_C void ListL(const TCTKeyAttributeFilter& aFilter, RPointerArray<CCTKeyInfo>& aKeys) const;
    1.70 +		
    1.71 +	private:
    1.72 +		void ConstructL();
    1.73 +		CCryptoTokenHai(MCTToken& aToken);
    1.74 +	    void OpenStoreL();
    1.75 +	    void OpenStoreInFileL(const TDesC& aFile);
    1.76 +	    void CreateStoreInFileL(const TDesC& aFile);
    1.77 +	    void MakePrivateFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut);
    1.78 +		void EnsurePathL(RFs& aFs, const TDesC& aFile);
    1.79 +		void MakePrivateROMFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut);
    1.80 +		void CopyL(RFs& aFs, const TDesC& aSouce, const TDesC& aDest);
    1.81 +		void CompactStore();
    1.82 +		static void RevertStore(TAny* aStore);
    1.83 +		void ReadKeysFromStoreL();
    1.84 +		TBool KeyMatchesFilterL(const CKeyDetails& aInfo, const TCTKeyAttributeFilter& aFilter) const;
    1.85 +		void CopyStoreFromROML(const TDesC& fullPath, TInt result);
    1.86 +		void WriteKeysToStoreL(RStoreWriteStream& aRootStream);
    1.87 +		
    1.88 +	private:
    1.89 +		RPointerArray<CKeyDetails> iKeys;
    1.90 +		RFs iFs;
    1.91 +		CPermanentFileStore* iFileStore;
    1.92 +		TStreamId iRootStreamId;
    1.93 +		MCTToken& iToken;
    1.94 +	};
    1.95 +
    1.96 +#endif	//	CCRYPTOTOKENHAI_H