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