ipappprotocols_plat/srtp_api/inc/srtpmasterkey.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004 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:    SRTP Master key class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __SRTP_MASTER_KEY_H__
       
    22 #define __SRTP_MASTER_KEY_H__
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32def.h>
       
    26 #include <e32des8.h>
       
    27 #include <e32base.h>
       
    28 #include "srtpdef.h"
       
    29 
       
    30 
       
    31 // STRUCT CLASSES
       
    32 
       
    33 /**
       
    34 * Contains an SRTP master key.
       
    35 */
       
    36 class CSRTPMasterKey : public CBase
       
    37     {
       
    38     public: // constructor
       
    39     
       
    40         /**
       
    41         * Two-phased constructor.
       
    42         * CSRTPCryptoContext takes the ownership of MasterKey and MasterSalt 
       
    43         * @param aKey  The master key value. Local copy is made.
       
    44         * @param aMKI  The master key identifier value. Local copy is made.
       
    45         *   			MKI key is optional so if there is no MKI key then 
       
    46         *				gives empty string "".
       
    47         * @param aN_E  The bit length of the encryption key
       
    48         * @param aN_A  The bit length of the authentication key
       
    49         * @leave KErrNone if success, system-wide error code otherwise
       
    50         */
       
    51         IMPORT_C static CSRTPMasterKey* NewL( const TDesC8& aKey, 
       
    52                        const TDesC8& aMKI, 
       
    53                        TUint aN_E = KSRTPDefSessionEncryptionKeyLength, 
       
    54                        TUint aN_A = KSRTPDefSessionAuthenticationKeyLength );
       
    55 
       
    56         /**
       
    57         * Two-phased constructor.
       
    58         * CSRTPCryptoContext takes the ownership of MasterKey and MasterSalt 
       
    59         * @param aKey  The master key value. Local copy is made.
       
    60         * @param aMKI  The master key identifier value. Local copy is made.
       
    61         * @param aN_E  The bit length of the encryption key
       
    62         * @param aN_A  The bit length of the authentication key
       
    63         * @leave KErrNone if success, system-wide error code otherwise
       
    64         */
       
    65         IMPORT_C static CSRTPMasterKey* NewLC( const TDesC8& aKey, 
       
    66                        const TDesC8& aMKI, 
       
    67                        TUint aN_E = KSRTPDefSessionEncryptionKeyLength, 
       
    68                        TUint aN_A = KSRTPDefSessionAuthenticationKeyLength );
       
    69         
       
    70         /**
       
    71         * Destructor
       
    72         */
       
    73         ~CSRTPMasterKey();
       
    74 
       
    75         /*
       
    76 		* Gets current master key value        
       
    77         * @return current master key value
       
    78         */                                
       
    79         IMPORT_C  const TDesC8& MasterKey() const;
       
    80         
       
    81         /*
       
    82 		* Gets current MKI
       
    83         * @return current MKI
       
    84         */                                
       
    85         IMPORT_C  const TDesC8& MKI() const;
       
    86                             
       
    87         /*
       
    88 		* Gets current encryption key length
       
    89         * @return encryption key length
       
    90         */                                
       
    91         IMPORT_C  TUint EncrKeyLength() const;
       
    92 
       
    93         /*
       
    94 		* Gets current authorization key length
       
    95         * @return authorization key length
       
    96         */                                
       
    97         IMPORT_C  TUint AuthKeyLength() const;
       
    98 
       
    99    
       
   100         /*
       
   101 		* Check the validity of the whole SRTPMasterKey
       
   102         * @return validity of this SRTPMasterKey
       
   103         */
       
   104         IMPORT_C  TBool Valid() const;                         
       
   105         
       
   106     private: //methods
       
   107     
       
   108         CSRTPMasterKey( TUint aN_E, TUint aN_A );	              
       
   109         
       
   110         void ConstructL (  const TDesC8& aKey, 
       
   111                            const TDesC8& aMKI );
       
   112     
       
   113       
       
   114         /* assignment operator */
       
   115          const CSRTPMasterKey& operator=(const CSRTPMasterKey& aKey);      
       
   116        
       
   117     private: //data
       
   118         
       
   119         /**
       
   120         * The master key value.
       
   121         * The length of the key is determined by the Size() function.
       
   122         */
       
   123         HBufC8 *iKey;
       
   124 
       
   125         /**
       
   126         * The master key identifier value
       
   127         */
       
   128         HBufC8* iMKI;
       
   129 
       
   130         /**
       
   131         * The bit length of the encryption key
       
   132         */
       
   133         TUint iN_E;
       
   134 
       
   135         /**
       
   136         * The bit length of the authentication key
       
   137         */
       
   138         TUint iN_A;
       
   139 
       
   140         friend class CSRTPCryptoContext;
       
   141  	#ifdef EUNIT_TESTING
       
   142         friend class UT_CSRTPMasterKey;
       
   143     #endif 
       
   144     };
       
   145 
       
   146 
       
   147 #endif // __SRTP_MASTER_KEY_H__