os/security/cryptoservices/filebasedcertificateandkeystores/test/keytool/keytool_utils.h
First public contribution.
2 * Copyright (c) 2004-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.
19 #ifndef _Keytool_utils_h_
20 #define _Keytool_utils_h_
23 #include <mctkeystore.h>
25 #include <cctcertinfo.h>
28 _LIT(KSWInstall, "SWInstall");
29 _LIT(KSWInstallOCSP, "SWInstallOCSP");
30 _LIT(KMidletInstall, "MidletInstall");
31 _LIT(KTls, "SSL/TLS");
32 _LIT(KTOcsp, "OCSP Test");
33 _LIT(KUnknown, "Unknown Applicability!");
35 const TInt swinstalluid = 0x100042AB;
36 const TInt swinstallocspuid = 0x1000A8B6;
37 const TInt midletinstalluid = 0x101F9B28;
38 const TInt tlsuid = 0x1000183D;
39 const TInt tocspuid = 0x1000A405;
41 const TInt KUidSecurityKeytool= 0x10281c32;
44 * A bunch of assorted useful functions for the keytool.
51 * Given a <code>CCTKeyInfo</code> object is prints its
52 * contents in a human readable format.
54 * @param aKey The <code>CCTKeyInfo</code> hgolding the information
55 * we are interested in.
57 static void PrintKeyInfoL(const CCTKeyInfo& aKey, TBool aIsDetailed = EFalse, TBool aPageWise = EFalse);
60 * Prints a human readable translation of the given key usage code.
62 * @param aUsage The key usage we want to print.
63 * @param aConsole The console where the output goes.
65 static void PrintUsageL(TUint aUsage);
68 * Given a key access encoded as an integer (we are talking
69 * <code>CKeyInfoBase::EKeyAccess</code> anyway) it returns
70 * an equivalent human understandable descriptor.
72 static HBufC* KeyAccessDesLC(TInt aAccess);
75 * Given an algorithm identifier returns an equivalent human
76 * readable descriptor.
78 static HBufC* AlgorithmDesLC(CCTKeyInfo::EKeyAlgorithm aAlgorithm);
81 * Given a list of keys as returned from keystore->list() method
82 * and a label of a key we are interested in, it returns the corresponding
85 static CCTKeyInfo* findKey(RMPointerArray<CCTKeyInfo>& aKeyList, TDesC& aLabel);
88 * Pretty prints an octet string.
90 * @param aString The octet string to be printed.
91 * @param aConsole The console where the output goes.
93 static void WriteOctetStringL(const TDesC8& aString);
96 * Pretty prints the human readable description of a given error code.
98 * @param aError The error code we want to print.
99 * @param aConsole The console where the output goes.
101 static void WriteErrorL(TInt aError);
104 * Parses the human understandable description of a key usage
105 * and returns the corresponding numeric code.
107 * @param aUsage The string containing the key usage.
108 * @return The corresponding code for the usage.
110 static TKeyUsagePKCS15 ParseKeyUsage(TPtrC aUsage);
112 static CCTKeyInfo::EKeyAccess ParseKeyAccess(TPtrC aAccess);
114 static void PrintCertInfoL(CCTCertInfo& aCertInfo, CCertificate& aCertificate, RArray<TUid> aApps, TBool aTrusted, TBool aIsDetailed = EFalse,TBool aPageWise = EFalse);
116 static const TDesC& Uid2Des(TUid aUid);
118 static RArray<CCTKeyInfo*> MatchKey(RMPointerArray<CCTKeyInfo>& aKeyList, TDesC& aLabel);
120 static void FilterCertsL(RMPointerArray<CCTCertInfo>& aCertList, TDesC& aLabel);
122 static void FilterCertsL(RMPointerArray<CCTCertInfo>& aCertList, TCertificateOwnerType& aOwnerType);
124 static void PrintInfoL(const TDesC& aValue,TBool aPageWise = EFalse);
126 static void SetConsole(CConsoleBase* aConsole);
128 static void SetFile(RFile* aFile);
130 static TBool DoesFileExistsL(const RFs& aFs, const TDesC& aFileName);
132 static CConsoleBase *iConsole;