vpnengine/ikev2lib/inc/ikecrypto.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-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 "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:   Cryptographic Intermediate Layer to use and change any crypto library easily.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __IKECRYPTO_H_
       
    19 #define __IKECRYPTO_H__
       
    20 
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "utlcrypto.h"
       
    24 
       
    25 NONSHARABLE_CLASS(CDHKeys) : public CBase
       
    26 {
       
    27 public:
       
    28     static CDHKeys* NewL(const TDesC8& aN,const TDesC8& aG);
       
    29 	static CDHKeys* CreateDHKeyL(TUint aGroupDesc);
       
    30 	HBufC8* ComputeAgreedKeyL(const TDesC8 &aPeerPublicKey);
       
    31     HBufC8* GetPubKey();
       
    32     void XValueL(); 
       
    33     inline const HBufC8* KValueL(const TDesC8& aY) const {return iDHKey->CompleteKL(aY);}
       
    34 	inline TInt ModulusLength() {return iModuluslength;}
       
    35     ~CDHKeys();
       
    36 private:
       
    37     CUtlDiffieHellman* iDHKey;
       
    38     const HBufC8*      iPubKey;
       
    39 	TInt               iModuluslength;
       
    40 };
       
    41 
       
    42 
       
    43 class IkeCrypto
       
    44 {
       
    45 public:
       
    46 	static void DecryptL(const TUint8* aInputPayload, TUint8* aOutputPayload, TInt aLength, TUint8* aIV, 
       
    47                          const TDesC8& aKey, TUint16 aEncrAlg);
       
    48 	static void EncryptL(const TDesC8& aInput, TPtr8& aOutput, const TDesC8& aIv, const TDesC8& aKey, TUint16 aEncrAlg);
       
    49 	static TInt IntegHMACL(const TDesC8& aInput, TDes8& aChecksum, const TDesC8& aKeyData, TUint16 aIntegAlg);	
       
    50 	static HBufC8* PrfhmacL(const TDesC8& aInput, const TDesC8& aKeyData, TUint16 aPrfAlg);
       
    51 	static HBufC8* PrfL(const TDesC8& aInput, TUint16 aPrfAlg);	
       
    52 	static TInt AlgorithmInfo(TUint16 aTransform, TUint16 aAlgCode, TInt* aBlockLth=NULL,
       
    53 							  TUtlCrypto::TUtlSymmetricCipherId* aCipherId=NULL,
       
    54 							  TUtlCrypto::TUtlMessageDigestId*   aDigestId=NULL);
       
    55 	static HBufC8* GenerateKeyingMaterialL(const TDesC8& aK, const TDesC8& aS, TInt aKeyMatLth, TUint16 aPRFAlg);			
       
    56 };
       
    57 	
       
    58 #endif