secureswitools/makekeys/src/KeyGenerator.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-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 * Interface for the CKeyGenerator class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @internalComponent 
       
    23 */
       
    24 
       
    25 #if !defined(AFX_KEYGENERATOR_H__E70F430E_9D8C_4EA6_B2A8_1973F813312E__INCLUDED_)
       
    26 #define AFX_KEYGENERATOR_H__E70F430E_9D8C_4EA6_B2A8_1973F813312E__INCLUDED_
       
    27 
       
    28 #if _MSC_VER > 1000
       
    29 #pragma once
       
    30 #endif // _MSC_VER > 1000
       
    31 
       
    32 #define _WIN32_WINNT 0x0500
       
    33 
       
    34 #define DEFAULT_KEY_LENGTH 1024
       
    35 #define PW_LEN 32
       
    36 #define MAXLEN 256
       
    37 #define constparams __FILE__,__LINE__
       
    38 #define SYMBIAN_FREE_MEM(mem){if(!mem) free(mem); mem=NULL;}
       
    39 
       
    40 #include <stdio.h>
       
    41 #include <stdlib.h>
       
    42 #include <tchar.h>
       
    43 #include <windows.h>
       
    44 #include <wincrypt.h>
       
    45 #include "utils.h"
       
    46 
       
    47 #include "openssl/pem.h"
       
    48 #include "openssl/evp.h"
       
    49 
       
    50 
       
    51 enum TKeyType {ERSACipher, EDSACipher};
       
    52 enum TKeyGeneratorException {ErrFileOpen, ErrNULLKeyStructure};
       
    53 
       
    54 class CKeyGenerator  
       
    55 	{
       
    56 	public:
       
    57 	
       
    58 		void PrintErrorInfo(char* aMsg, TErrType aEntType, const char* aFileName, int aLineNum);
       
    59 		void SetVerbose(bool aVerbose);
       
    60 		void SetAskPassword(bool aAsk);
       
    61 		const _TCHAR* GetPassword();
       
    62 		void SetPasswordRequirement (bool aPwReq);
       
    63 		void SetPassword(_TCHAR* aPw);
       
    64 		void SetPrivateKeyFile(_TCHAR* aPk);
       
    65 		const TCHAR* GetPrivateKeyFile(void) const;
       
    66 		void SetKeyLength(int aKeyLen);
       
    67 		const int GetKeyLength() const;
       
    68 		virtual int Generate() =0;
       
    69 		CKeyGenerator();
       
    70 		virtual ~CKeyGenerator();
       
    71 
       
    72 	protected:
       
    73 
       
    74 		bool m_bVerbose;
       
    75 		TKeyType m_Cipher;
       
    76 		bool m_bPassword;
       
    77 		bool m_bAsk;
       
    78 		int GenerateSeed(int aLength, unsigned char** aBuf);
       
    79 
       
    80 	private:
       
    81 
       
    82 		_TCHAR m_sPassword[PW_LEN];
       
    83 		int m_nKeyLength;
       
    84 		_TCHAR m_PrivateKeyFile[MAXLEN];
       
    85 		
       
    86 	};
       
    87 
       
    88 #endif // !defined(AFX_KEYGENERATOR_H__E70F430E_9D8C_4EA6_B2A8_1973F813312E__INCLUDED_)