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: #ifndef _Keytool_utils_h_ sl@0: #define _Keytool_utils_h_ sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: _LIT(KSWInstall, "SWInstall"); sl@0: _LIT(KSWInstallOCSP, "SWInstallOCSP"); sl@0: _LIT(KMidletInstall, "MidletInstall"); sl@0: _LIT(KTls, "SSL/TLS"); sl@0: _LIT(KTOcsp, "OCSP Test"); sl@0: _LIT(KUnknown, "Unknown Applicability!"); sl@0: sl@0: const TInt swinstalluid = 0x100042AB; sl@0: const TInt swinstallocspuid = 0x1000A8B6; sl@0: const TInt midletinstalluid = 0x101F9B28; sl@0: const TInt tlsuid = 0x1000183D; sl@0: const TInt tocspuid = 0x1000A405; sl@0: sl@0: const TInt KUidSecurityKeytool= 0x10281c32; sl@0: sl@0: /** sl@0: * A bunch of assorted useful functions for the keytool. sl@0: */ sl@0: class KeyToolUtils sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: * Given a CCTKeyInfo object is prints its sl@0: * contents in a human readable format. sl@0: * sl@0: * @param aKey The CCTKeyInfo hgolding the information sl@0: * we are interested in. sl@0: */ sl@0: static void PrintKeyInfoL(const CCTKeyInfo& aKey, TBool aIsDetailed = EFalse, TBool aPageWise = EFalse); sl@0: sl@0: /** sl@0: * Prints a human readable translation of the given key usage code. sl@0: * sl@0: * @param aUsage The key usage we want to print. sl@0: * @param aConsole The console where the output goes. sl@0: */ sl@0: static void PrintUsageL(TUint aUsage); sl@0: sl@0: /** sl@0: * Given a key access encoded as an integer (we are talking sl@0: * CKeyInfoBase::EKeyAccess anyway) it returns sl@0: * an equivalent human understandable descriptor. sl@0: */ sl@0: static HBufC* KeyAccessDesLC(TInt aAccess); sl@0: sl@0: /** sl@0: * Given an algorithm identifier returns an equivalent human sl@0: * readable descriptor. sl@0: */ sl@0: static HBufC* AlgorithmDesLC(CCTKeyInfo::EKeyAlgorithm aAlgorithm); sl@0: sl@0: /** sl@0: * Given a list of keys as returned from keystore->list() method sl@0: * and a label of a key we are interested in, it returns the corresponding sl@0: * key info. sl@0: */ sl@0: static CCTKeyInfo* findKey(RMPointerArray& aKeyList, TDesC& aLabel); sl@0: sl@0: /** sl@0: * Pretty prints an octet string. sl@0: * sl@0: * @param aString The octet string to be printed. sl@0: * @param aConsole The console where the output goes. sl@0: */ sl@0: static void WriteOctetStringL(const TDesC8& aString); sl@0: sl@0: /** sl@0: * Pretty prints the human readable description of a given error code. sl@0: * sl@0: * @param aError The error code we want to print. sl@0: * @param aConsole The console where the output goes. sl@0: */ sl@0: static void WriteErrorL(TInt aError); sl@0: sl@0: /** sl@0: * Parses the human understandable description of a key usage sl@0: * and returns the corresponding numeric code. sl@0: * sl@0: * @param aUsage The string containing the key usage. sl@0: * @return The corresponding code for the usage. sl@0: */ sl@0: static TKeyUsagePKCS15 ParseKeyUsage(TPtrC aUsage); sl@0: sl@0: static CCTKeyInfo::EKeyAccess ParseKeyAccess(TPtrC aAccess); sl@0: sl@0: static void PrintCertInfoL(CCTCertInfo& aCertInfo, CCertificate& aCertificate, RArray aApps, TBool aTrusted, TBool aIsDetailed = EFalse,TBool aPageWise = EFalse); sl@0: sl@0: static const TDesC& Uid2Des(TUid aUid); sl@0: sl@0: static RArray MatchKey(RMPointerArray& aKeyList, TDesC& aLabel); sl@0: sl@0: static void FilterCertsL(RMPointerArray& aCertList, TDesC& aLabel); sl@0: sl@0: static void FilterCertsL(RMPointerArray& aCertList, TCertificateOwnerType& aOwnerType); sl@0: sl@0: static void PrintInfoL(const TDesC& aValue,TBool aPageWise = EFalse); sl@0: sl@0: static void SetConsole(CConsoleBase* aConsole); sl@0: sl@0: static void SetFile(RFile* aFile); sl@0: sl@0: static TBool DoesFileExistsL(const RFs& aFs, const TDesC& aFileName); sl@0: sl@0: static CConsoleBase *iConsole; sl@0: sl@0: static RFile* iFile; sl@0: }; sl@0: #endif