secureswitools/makekeys/src/PARSECMD.H
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Handles parsing of makekeys command line args
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @internalComponent 
       
    23 */
       
    24 
       
    25 #ifndef __PARSE_CMD_H_
       
    26 #define __PARSE_CMD_H_
       
    27 
       
    28 #include <stdio.h>
       
    29 #include <iostream>
       
    30 #include "utils.h"
       
    31 #include "KeyGenerator.h"
       
    32 #include "CertificateGenerator.h"
       
    33 
       
    34 //undefined by default, the ability to generate keys on its own is useful for testing
       
    35 //and maybe in the real-world too
       
    36 #define KEYS
       
    37 //some work that's already been done, thats planned as optional so may or may not be needed
       
    38 #define OPTIONAL
       
    39 
       
    40 
       
    41 // ===========================================================================
       
    42 // CONSTANTS
       
    43 // ===========================================================================
       
    44 
       
    45 
       
    46 #define MAXLEN 256
       
    47 #define DEFAULTKEYLEN 1024
       
    48 #define DEFAULTCERTEXPIRYDAYS 365
       
    49 
       
    50 
       
    51 //These constants are temporarily file names. They will be changed
       
    52 //with original ones at the end of the program 
       
    53 #define KEYFILENAME "mytempkey.key"
       
    54 #define CERTFILENAME "mytempcert.cer"
       
    55 #define REQUESTFILENAME "mytemprequest.p10"
       
    56 
       
    57 enum TCommandLineException
       
    58 	{ErrInsufficientArgs,
       
    59 	ErrTooManyArgs,
       
    60 	ErrBadReqCommand,
       
    61 	ErrBadCommandFlag,
       
    62 	ErrUnknownCommandFlag,
       
    63 	ErrCantViewCertificate,
       
    64 	ErrMalformedCommand,
       
    65 	ErrUnsupportedCP,
       
    66 	ErrInvalidPassword
       
    67 	}; 
       
    68 
       
    69 enum Mode
       
    70 	{EKeys = 1,
       
    71 	ECert,
       
    72 	EReq,
       
    73 	EChain,
       
    74 	EView,
       
    75 	EPassword,
       
    76 	EDname,
       
    77 	ERSA,
       
    78 	EDSA,
       
    79 	EUnknown
       
    80 	};
       
    81 
       
    82 enum TOptions
       
    83 	{EOptVerbose  = 0x01,
       
    84 	};
       
    85 		
       
    86 
       
    87 
       
    88 #define MIN_VIEW_ARGS 3
       
    89 #define MIN_CERT_ARGS 6
       
    90 #define MIN_REQ_ARGS 7
       
    91 
       
    92 
       
    93 // ===========================================================================
       
    94 // CLASS DEFINITION
       
    95 // ===========================================================================
       
    96 
       
    97 class CParseCmd
       
    98 // Responsable for processing and maintaining the command line options
       
    99 	{
       
   100 	public:
       
   101 		TKeyType GetKeyType();
       
   102 		bool GetPasswordEnabled();
       
   103 		
       
   104 		_TCHAR* GetPassword();
       
   105 		_TCHAR* GetPrivateName();
       
   106 		_TCHAR* GetPublicName();
       
   107 		_TCHAR* GetRequestName();
       
   108 		_TCHAR* GetDNameString();
       
   109 		bool GetVerbose();
       
   110 
       
   111 		int GetCMDKeyLen();
       
   112 		int GetCMDCertExpiryInDays();
       
   113 		CParseCmd();
       
   114 		
       
   115 		ParseCommandLine(const int argc, const _TCHAR *argv[], Mode* aApp);
       
   116 		
       
   117 		BOOL  ShowSyntax()			const { return m_fShowSyntax; }
       
   118 		DWORD Flags()				const { return m_dwOptions;   }
       
   119 
       
   120 	private:
       
   121 		bool m_bVerbose;
       
   122 		void SetVerbose(const bool bVerbose);
       
   123 		
       
   124 		DWORD m_dwKeyLen;
       
   125 		DWORD m_dwCertExpiryInDays;
       
   126 		
       
   127 		DWORD m_dwOptions;
       
   128 		BOOL  m_fShowSyntax;
       
   129 		TKeyType m_CMDKey;
       
   130 		bool m_bPassword;
       
   131 
       
   132 		_TCHAR m_password[MAXLEN];
       
   133 		_TCHAR m_dname[512];
       
   134 		_TCHAR m_privateKeyFile[MAX_PATH];
       
   135 		_TCHAR m_publicKeyFile[MAX_PATH];
       
   136 		_TCHAR m_requestFile[MAX_PATH];
       
   137 		_TCHAR m_KeyLenStr[MAXLEN];
       
   138 		_TCHAR m_CertExpiryInDaysStr[MAXLEN];
       
   139 
       
   140 	};
       
   141 
       
   142 #endif // __PARSE_CMD_H_