vpnengine/vpnipsecpolparser/inc/spcrypto.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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: Security parser crypto manager.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __SPCRYPTO_H
       
    21 #define __SPCRYPTO_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <es_prot.h>
       
    25 
       
    26 const TUint KProtocolCrypto =	0x104; // A dummy assignment for now (should have
       
    27 // central registry)
       
    28 const TUint KAfCrypto = 0x0803;			// Dummy
       
    29 
       
    30 //
       
    31 //	TAlgorithmDesc (and related types)
       
    32 //
       
    33 //		A description of available algorithm
       
    34 //
       
    35 typedef TBuf8<0x20> TAlgorithmName;
       
    36 typedef enum
       
    37     {
       
    38     EAlgorithmClass_Digest,	// Message Digest algorithm
       
    39         EAlgorithmClass_Cipher,	// Symmetric Cipher algorithm
       
    40         //
       
    41         // New types are possible by adding the symbol here
       
    42         // and defining the corresponding abstract class
       
    43         // (similar to COwnMessageDigest and CSymmetricCipher)
       
    44         //
       
    45     } TAlgorithmClass;
       
    46 
       
    47 class TAlgorithmDesc
       
    48     {
       
    49     public:
       
    50         TAlgorithmName iName;	// Descriptive name
       
    51         TAlgorithmClass iAlgType;
       
    52         TUint iMinBits;			// Min Length of the key in bits (all keys total)
       
    53         TUint iMaxBits;			// Max Length of the key in bits (all keys total)
       
    54         TUint iBlock;			// Length of the block in bytes
       
    55         TUint iVector;			// Initialization Vector length (bytes)
       
    56     };
       
    57 
       
    58 
       
    59 //
       
    60 // Each of the following includes virtual destructor
       
    61 // just in case there is a need for a cleanup code
       
    62 // when the object is deleted using a pointer to
       
    63 // the base virtual class
       
    64 
       
    65 //
       
    66 //	COwnMessageDigest
       
    67 //		Base Message Digest (abstract) class
       
    68 //
       
    69 class COwnMessageDigest : public CBase
       
    70     {
       
    71     public:
       
    72         virtual void Init()=0;
       
    73         virtual void Update(const TDesC8& aMessage)=0;
       
    74         virtual void Final(TDes8& aDigest)=0;
       
    75         virtual ~COwnMessageDigest() {}
       
    76     };
       
    77 
       
    78 
       
    79 //
       
    80 //	CSymmetricCipher
       
    81 //		Base Symmetric Cipher (abstract) class
       
    82 //
       
    83 class CSymmetricCipher : public CBase
       
    84     {
       
    85     public:
       
    86         enum TAction { EEncrypt, EDecrypt };
       
    87         virtual void Setkey(const TDesC8& aKey)=0;
       
    88         virtual void InitL(const TDesC8 &anIV, TAction aMode)=0;
       
    89         //
       
    90         // ALL OutBuf's given to Update must exist up to Finish
       
    91         // call (or at least as long as at least blocksize octets
       
    92         // have been given to Update after it).
       
    93         //
       
    94         virtual void Update(TDes8& anOutBuf,const TDesC8& anInBuf)=0;
       
    95         //
       
    96         // Calling Finish is optional, it is needed if the total
       
    97         // bytes is not multiple of the blocksize, or if one wants
       
    98         // to get the final IV.
       
    99         virtual void Finish(TDes8& anIV)=0;
       
   100         virtual ~CSymmetricCipher() {}
       
   101     };
       
   102 
       
   103 //
       
   104 //	CProtocolCrypto
       
   105 //		The algorithm manager (abstract) class
       
   106 //
       
   107 class CProtocolCrypto : public CProtocolBase
       
   108     {
       
   109     public:
       
   110         virtual TUint AlgorithmList(TAlgorithmDesc *&aList) = 0;
       
   111         virtual CSymmetricCipher* SymmetricCipher(TUint anAlg)=0;
       
   112         virtual COwnMessageDigest* MessageDigest(TUint anAlg)=0;
       
   113     protected:
       
   114         virtual ~CProtocolCrypto() {}
       
   115     };
       
   116 
       
   117 #endif