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