cryptoservices/certificateandkeymgmt/tpkcs12intgrtn/inc/tpkcs12data.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2005-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 * This file contains the classes CPfxHeader,CSafeBagAttribute ,CSafeContentBag ,CSafeBagData.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file 
       
    24  @internalTechnology
       
    25 */
       
    26 #ifndef __TPKCS12DATA_H
       
    27 #define __TPKCS12DATA_H
       
    28 //System Include
       
    29 #include <e32base.h> 
       
    30 #include <pkcs12.h>
       
    31 #include <asnpkcs.h>
       
    32 
       
    33 using namespace PKCS12;
       
    34 
       
    35 /** 
       
    36 To store the PKCS12 file details
       
    37 */
       
    38 class CPfxHeader : public CBase
       
    39 	{
       
    40 
       
    41 public:
       
    42 
       
    43 	/** creates a CPfxHeader object*/
       
    44 	static CPfxHeader* NewL(const CDecPkcs12& aDecPkcs12 , TInt aError);
       
    45 	/** creates a CPfxHeader object, push it on Cleanupstack*/
       
    46 	static CPfxHeader* NewLC(const CDecPkcs12& aDecPkcs12 , TInt aError);
       
    47 	/** destructor*/
       
    48 	~CPfxHeader();
       
    49 	/**  to set the contentinfo count */
       
    50 	inline void SetContentInfoCount(TInt aContentInfoCount){iContentInfoCount = aContentInfoCount;}
       
    51 	/** to increment the keybagcount */
       
    52 	inline void IncrementKeyBagCount(){iKeyBagCount++ ;}
       
    53 	/** to increment the shroudedskeybagcount */
       
    54 	inline void IncrementShroudedKeyBagCount(){iShroudedKeyBagCount++ ;}
       
    55 	/** to increment the certbagcount */
       
    56 	inline void IncrementCertBagCount(){iCertBagCount++;}
       
    57 	/** to increment the crlbagcount */
       
    58 	inline void IncrementCrlBagCount(){iCrlBagCount++;}
       
    59 	/** to increment the secretbagcount */
       
    60 	inline void IncrementSecretBagCount(){iSecretBagCount++;}
       
    61 	/** to increment the safecontentbagcount */
       
    62 	inline void IncrementSafecontentBagCount(){iSafeContentsBagCount++;}
       
    63 	/**  to set the pkcs12 Main Class ExpectedError */
       
    64 	inline void SetPkcs12ActualError(TInt aPkcs12ActualError){iPkcs12ActualError = aPkcs12ActualError;}	
       
    65 	/**  to get the version number*/
       
    66 	inline TInt Version(){return iVersion;}
       
    67 	/**  to get the integrity mode*/
       
    68 	inline CDecPkcs12::TIntegrityMode IntegrityMode(){return iIntegrityMode;}
       
    69 	/**  to get the mac data presence */
       
    70 	inline TBool MacData(){return iIsMacDataPresent;}
       
    71 	/**  to get the mac Id */
       
    72 	inline  TDesC8& MacId(){return *iMac;}
       
    73 	/** to get the mac salt */ 
       
    74 	inline TDesC8& MacSalt(){return *iMacSalt;}
       
    75 	/**  to get the iteration count */
       
    76 	inline TInt	IterationCount(){return iIterationCount;}
       
    77 	/**  to get the contentinfo count */
       
    78 	inline TInt ContentInfoCount(){return iContentInfoCount;}
       
    79 	/** to get the keybagcount */
       
    80 	inline TInt KeyBagCount(){return iKeyBagCount;}
       
    81 
       
    82 	/** to get the shroudedskeybagcount */
       
    83 	inline TInt ShroudedKeyBagCount(){return iShroudedKeyBagCount;}
       
    84 	/** to get the certbagcount */
       
    85 	inline TInt CertBagCount(){return iCertBagCount;}
       
    86 	/** to get the crlbagcount */
       
    87 	inline TInt CrlBagCount(){return iCrlBagCount;}
       
    88 	/** to append the secretbagcount */
       
    89 	inline TInt SecretBagCount(){return iSecretBagCount;}
       
    90 	/** to append the safecontentbagcount */
       
    91 	inline TInt SafecontentBagCount(){return iSafeContentsBagCount;}
       
    92 	inline TInt TotalSafeBagCount(){return (iKeyBagCount+iShroudedKeyBagCount+
       
    93 											iCertBagCount+iCrlBagCount+iSecretBagCount);}
       
    94 		
       
    95 	/**  to get the pkcs12 Main Class ExpectedError */
       
    96 	inline TInt Pkcs12ActualError(){return iPkcs12ActualError;}	
       
    97 private:
       
    98 	void ConstructL(const CDecPkcs12& aDecPkcs12 , TInt aError);	
       
    99 	
       
   100 	/**  contains the version number of the PKCS#12 file */
       
   101 	TInt iVersion ;
       
   102 	/**  contains the integrity mode of the PKCS#12 file */
       
   103 	CDecPkcs12::TIntegrityMode iIntegrityMode;
       
   104 	/**  contains 1 if macData is present else 0 */ 
       
   105 	TBool iIsMacDataPresent;
       
   106 	/**  contains the mac ID */ 
       
   107 	HBufC8* iMac;
       
   108 	/**  contains the mac salt */ 
       
   109 	HBufC8* iMacSalt;
       
   110 	/**  contains the iteration count */ 
       
   111 	TInt iIterationCount ;			
       
   112 	/**  contains the total content info count in the PKCS#12 file */
       
   113 	TInt iContentInfoCount;			 
       
   114 	/**  contains the total keybag count in the PKCS#12 file */ 
       
   115 	TInt iKeyBagCount;				
       
   116 	/**  contains the total shroudedkeybag count in the PKCS#12 file */ 
       
   117 	TInt iShroudedKeyBagCount;		
       
   118 	/**  contains the total certbag count in the PKCS#12 file */ 
       
   119 	TInt iCertBagCount;				
       
   120 	/**  contains the total crlbag count in the PKCS#12 file */ 
       
   121 	TInt iCrlBagCount;				
       
   122 	/**  contains the total secretbag count in the PKCS#12 file */ 
       
   123 	TInt iSecretBagCount;	
       
   124 	/**  contains the total safecontent bag count in the PKCS#12 file */
       
   125 	TInt iSafeContentsBagCount;	
       
   126 	/** contains PKCS12 main class error */
       
   127 	TInt iPkcs12ActualError;	 
       
   128 	
       
   129 	/* Constructor */
       
   130 	CPfxHeader();	
       
   131 };
       
   132 
       
   133 /*
       
   134 To store the safecag attribute details
       
   135 */
       
   136 
       
   137 class CSafeBagAttribute : public CBase
       
   138 	{
       
   139 public:	
       
   140 	/** destructor*/
       
   141 	~CSafeBagAttribute();	
       
   142 	/** creates a CSafeBagAttribute object*/
       
   143 	static CSafeBagAttribute* NewL(const CDecPkcs12Attribute& aAttribute);	
       
   144 	/** creates a CSafeBagAttribute object, push it on Cleanupstack*/
       
   145 	static CSafeBagAttribute* NewLC(const CDecPkcs12Attribute& aAttribute);
       
   146 
       
   147 	/**  to set the Attribute Id */
       
   148 	inline  void SetAttributeId(const TDesC& aAttributeId){iAttrId = aAttributeId.AllocL();}
       
   149 	/**  to set the Attribute value count */
       
   150 	inline  void SetAttributeValueCount(TInt aAttributeValCount){iAttrValCount = aAttributeValCount;}
       
   151 	
       
   152 	/**  to get the Attribute Id */
       
   153 	inline  const TDesC& AttributeId(){return *iAttrId;}
       
   154 	/**  to get the Attribute value count */
       
   155 	inline  TInt AttributeValueCount(){return iAttrValCount;}
       
   156 	
       
   157 private:
       
   158 /** constructor */
       
   159 	CSafeBagAttribute();
       
   160 	void ConstructL(const CDecPkcs12Attribute& aAttribute);
       
   161 	/**contains the attribute id*/
       
   162 	HBufC*	iAttrId;
       
   163 	/**contains the attributes count*/		
       
   164 	TInt	iAttrValCount;
       
   165 	};
       
   166 
       
   167 /* 
       
   168 To store the safecontent bag details
       
   169 */ 
       
   170 class CSafeContentBag : public CBase
       
   171 	{
       
   172 public:
       
   173 
       
   174 	/** creates a CSafeContentBag object*/	
       
   175 	static CSafeContentBag* NewL();
       
   176 	/** creates a CSafeContentBag object, push it on Cleanupstack*/	
       
   177 	static CSafeContentBag* NewLC();
       
   178 	
       
   179 	/** to set the safecontent bag number */
       
   180 	inline void SetBagNumber(TInt aBagNumber){iBagNumber = aBagNumber;}
       
   181 	/** to set the safebagcount in the safecontent bag*/
       
   182 	inline void SetSafeBagCount(TInt aSafeBagCount){iSafeBagCount = aSafeBagCount;}
       
   183 	
       
   184 	/** to get the safecontent bag number */
       
   185 	inline TInt BagNumber(){return iBagNumber;}
       
   186 	/** to get the safebagcount in the safecontent bag*/
       
   187 	inline TInt SafeBagCount(){return iSafeBagCount;}
       
   188 	
       
   189 	
       
   190 private:
       
   191 	/* constructor */
       
   192 	CSafeContentBag();	
       
   193 	/** contains the safecontent bag number in the PKCS#12 file*/
       
   194 	TInt	iBagNumber ;	
       
   195 	/** contains the safebag count in the safecontent bag*/
       
   196 	TInt	iSafeBagCount;		
       
   197 	/** Unit Test */
       
   198 	TInt iExpectedError;
       
   199 	
       
   200 	};
       
   201 
       
   202 /** 
       
   203 To store the Safebag details 
       
   204 */
       
   205 class CSafeBagData : public CBase
       
   206 	{  
       
   207 public: 
       
   208 	/** creates a CSafeBagData object */	
       
   209 	static CSafeBagData* NewL();	
       
   210 	/** creates a CSafeBagData object, push it on Cleanupstack*/
       
   211 	static CSafeBagData* NewLC();
       
   212 	/*destructor*/
       
   213 	~CSafeBagData();
       
   214 	
       
   215 	/** to set the contentinfo number corresponding to the bag*/
       
   216 	inline void SetContentInfoNumber(TInt aContentInfo){iContentInfo = aContentInfo;}
       
   217 	/** to set the contenttype  corresponding to the bag*/
       
   218 	inline void SetContentInfoType(TInt aContentType){iContentType = aContentType;}
       
   219 	/** to set the bag number corresponding to the bag*/
       
   220 	inline void SetBagNumber(TInt aBagNumber){iBagNumber = aBagNumber;}
       
   221 	/** to set the PrivateKeyInfoVersion corresponding to the bag*/
       
   222 	inline void SetPrivateKeyInfoVersion(TInt aPrivateKeyInfoVersion){iPrivateKeyInfoVersion = aPrivateKeyInfoVersion;}
       
   223 	/** to set the bag id corresponding to the bag*/
       
   224 	inline void SetBagType(CDecPkcs12SafeBag::TBagId aBagId){iBagId = aBagId;}
       
   225 	/** to set the bag value corresponding to the bag*/
       
   226 	inline void SetBagValue(const TDesC8& aBagValue){iBagValue = aBagValue.AllocL();}
       
   227 	/** to set the Algorithem id corresponding to the bag*/
       
   228 	inline void SetAlgorithmId(const TDesC& aAlgorithmId){iAlgorithmID = aAlgorithmId.AllocL();}
       
   229 	/** to set the Certificate id corresponding to the certbag*/
       
   230 	inline void SetCertificateId(const TDesC& aCertificateID){iCertificateID = aCertificateID.AllocL();}
       
   231 	/** to set the key type corresponding to the bag*/
       
   232 	inline void SetKeyType(TAlgorithmId aKeyType){iKeyType = aKeyType;}
       
   233 		
       
   234 	/** to set the X509Certificate corresponding to the bag*/
       
   235 	inline void SetX509Certificate(const CX509Certificate* aX509Certificate){iX509certificate = aX509Certificate;}
       
   236 	/** to set the DerEncodedShroudedKey */
       
   237 	inline void SetEncodedShroudedKey(const TDesC8& aEncodedShroudedKey){iEncodedShroudedKey = aEncodedShroudedKey.AllocL();}
       
   238 	
       
   239 	/** to get the contentinfo number corresponding to the bag*/
       
   240 	inline TInt ContentInfoNumber(){return iContentInfo;}
       
   241 	/** to get the contenttype  corresponding to the bag*/
       
   242 	inline TInt ContentInfoType(){return iContentType ;}
       
   243 	/** to get the bag number corresponding to the bag*/
       
   244 	inline TInt BagNumber(){return iBagNumber;}
       
   245 	/** to get the PrivateKeyInfoVersion corresponding to the bag*/
       
   246 	inline TInt PrivateKeyInfoVersion(){return iPrivateKeyInfoVersion;}
       
   247 	/** to get the bag id corresponding to the bag*/
       
   248 	inline CDecPkcs12SafeBag::TBagId BagType(){return iBagId;}
       
   249 	/** to get the bag value corresponding to the bag*/
       
   250 	inline const TDesC8& BagValue(){return *iBagValue;}
       
   251 	/** to get the Algorithem id corresponding to the bag*/
       
   252 	inline const TDesC& AlgorithmId(){return *iAlgorithmID ;}
       
   253 	/** to get the Certificate id corresponding to the certbag*/
       
   254 	inline const TDesC& CertificateId(){return *iCertificateID ;}
       
   255 	/** to get the key type corresponding to the bag*/
       
   256 	inline TAlgorithmId KeyType(){return iKeyType;}
       
   257 	/** to get the X509Certificate corresponding to the bag*/
       
   258 	inline const CX509Certificate& X509Certificate(){return *iX509certificate;}
       
   259 	/** to get the DerEncodedShroudedKey*/
       
   260 	inline TDesC8& EncodedShroudedKey(){return *iEncodedShroudedKey;}
       
   261 	
       
   262 	/**  contains the attribute IDs and attribute values count*/	
       
   263 	RPointerArray<CSafeBagAttribute> iAttributeIDs;	
       
   264 	/**  contains the attribute values */	
       
   265 	RPointerArray<HBufC8> iAttributeValues;
       
   266 private:
       
   267 	
       
   268 	/**  contains the content info number of the safebag */ 
       
   269 	TInt	iContentInfo;	
       
   270 	/**  contains the content type of the safebag */ 
       
   271 	TInt	iContentType ;	
       
   272 	/** contains the bag number of the safebag */ 
       
   273 	TInt	iBagNumber;
       
   274 	/** contains the privatekey info version of the safebag */ 
       
   275 	TInt iPrivateKeyInfoVersion ;	
       
   276 	/**  contains the bag ID of the safebag */ 
       
   277 	CDecPkcs12SafeBag::TBagId	iBagId;	
       
   278 	/**  contains the bag value of the safebag */ 
       
   279 	HBufC8*	iBagValue;	
       
   280 	/**  contains the algorithem ID */	
       
   281 	HBufC* iAlgorithmID;	
       
   282 	/**  contains the certificate ID */	
       
   283 	HBufC* iCertificateID;	
       
   284 	/**  contains the key type */	
       
   285 	TAlgorithmId  iKeyType;			
       
   286 
       
   287 	/**  contains the X509Certificate */			
       
   288 	const CX509Certificate* iX509certificate;
       
   289 	/*contains the der encoded shrouded key */
       
   290 	HBufC8*	iEncodedShroudedKey;	
       
   291 
       
   292 	/** Unit Test */
       
   293 	TInt iVersion;
       
   294 
       
   295 	TAlgorithmId iAlgortihmId;
       
   296 
       
   297 	TInt iExpectedError;
       
   298 	/*Constructor*/
       
   299 	CSafeBagData();
       
   300 	
       
   301 	};
       
   302 
       
   303 #endif