os/security/cryptoservices/filebasedcertificateandkeystores/test/tcryptotokenhai/tcryptotokenhai.h
Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * This class implements the reference Crypto Token Hardware Abstraction
16 * Interface (HAI). It is just intended to show how operations using
17 * device keys can be performed using crypto token framework. In the
18 * real world scenario, this HAI should be replaced by device drivers
19 * by the licensees. In such a case, all the operations performed by
20 * the replacing class would be performed in Kernel Space.
30 #ifndef CCRYPTOTOKENHAI_H
31 #define CCRYPTOTOKENHAI_H
36 #include <mctkeystore.h>
46 NONSHARABLE_CLASS(CCryptoTokenHai) : public CBase
49 IMPORT_C static CCryptoTokenHai* NewLC(MCTToken* aToken);
50 IMPORT_C static CCryptoTokenHai* NewL(MCTToken* aToken);
51 IMPORT_C ~CCryptoTokenHai();
54 IMPORT_C void DecryptL(TInt aHandle,
55 const TDesC8& aCiphertext,
56 HBufC8*& aPlaintext );
58 IMPORT_C void SignL( TInt aHandle,
59 const TDesC8& aPlaintext,
60 HBufC8*& aSignature );
62 IMPORT_C TInt KeyPresent( TInt aHandle );
63 IMPORT_C void ExportPrivateKeyL( TInt aHandle, HBufC8*& aKey );
64 IMPORT_C void ExportPublicKeyL( TInt aHandle, HBufC8*& aKey );
65 IMPORT_C void ImportKeyL( const TDesC& aLabel, const TDesC8& aPrivateKey, const TDesC8& aPublicKey );
66 IMPORT_C void ListL(const TCTKeyAttributeFilter& aFilter, RPointerArray<CCTKeyInfo>& aKeys) const;
70 CCryptoTokenHai(MCTToken& aToken);
72 void OpenStoreInFileL(const TDesC& aFile);
73 void CreateStoreInFileL(const TDesC& aFile);
74 void MakePrivateFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut);
75 void EnsurePathL(RFs& aFs, const TDesC& aFile);
76 void MakePrivateROMFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut);
77 void CopyL(RFs& aFs, const TDesC& aSouce, const TDesC& aDest);
79 static void RevertStore(TAny* aStore);
80 void ReadKeysFromStoreL();
81 TBool KeyMatchesFilterL(const CKeyDetails& aInfo, const TCTKeyAttributeFilter& aFilter) const;
82 void CopyStoreFromROML(const TDesC& fullPath, TInt result);
83 void WriteKeysToStoreL(RStoreWriteStream& aRootStream);
86 RPointerArray<CKeyDetails> iKeys;
88 CPermanentFileStore* iFileStore;
89 TStreamId iRootStreamId;
93 #endif // CCRYPTOTOKENHAI_H