crypto/weakcrypto/inc/pkcs12kdf.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2002-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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @publishedPartner
       
    24  @released
       
    25 */
       
    26 
       
    27 
       
    28 #ifndef __PKCS12KDF_H__
       
    29 #define __PKCS12KDF_H__
       
    30 
       
    31 #include <e32std.h>
       
    32 
       
    33 class PKCS12KDF
       
    34 /**
       
    35 	Namespace class contains static functions which
       
    36 	are used to generate a key for PKCS#12 operations.
       
    37 	
       
    38 	See Section B from PKCS 12 v1.0.
       
    39  */
       
    40 	{
       
    41 public:
       
    42 	enum TIDByteType
       
    43 	/**
       
    44 		ID byte value used to generate (en|de)cryption key,
       
    45 		IV, or MAC key.  See SB.3 of spec.
       
    46 	 */
       
    47 		{
       
    48 		/** Generates a key for (en|de)cryption. */
       
    49 		EIDByteEncryptKey = 1,
       
    50 		/** Generates an initialization vector. */
       
    51 		EIDByteIV = 2,
       
    52 		/** Generates a key for MAC-ing. */
       
    53 		EIDByteMACKey = 3
       
    54 		};
       
    55 public:
       
    56 	IMPORT_C static void DeriveKeyL(
       
    57 		TDes8& aKey, TIDByteType aIDType,
       
    58 		const TDesC8& aPasswd, const TDesC8& aSalt, const TUint aIterations);
       
    59 	IMPORT_C static HBufC8* GeneratePasswordLC(const TDesC& aDes);
       
    60 
       
    61 private:
       
    62 	static void Process6cL(TDes8& Ij, const TDesC8& B, TInt v);
       
    63 
       
    64 #ifdef _DEBUG
       
    65 	enum TPanic
       
    66 		{
       
    67 		EDKEmptyPswd = 0x10, EDKOddPswdByteCount, EDKBadNullTerminator
       
    68 		};
       
    69 	static void Panic(TPanic aPanic);
       
    70 #endif
       
    71 
       
    72 	// not implemented - prevents instantiation
       
    73 	PKCS12KDF();
       
    74 	};
       
    75 
       
    76 #endif	// #ifndef __PKCS12KDF_H__