os/security/cryptoservices/certificateandkeymgmt/x509/x509CertExt_v2.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/x509/x509CertExt_v2.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1617 @@
     1.4 +/*
     1.5 +* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* X509CERTEXT.CPP
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include <s32strm.h>
    1.24 +#include <x509certext.h>
    1.25 +#include <asn1dec.h>
    1.26 +#include "x509bitstring.h"
    1.27 +
    1.28 +void CX509ExtensionBase::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
    1.29 +	{
    1.30 +	TASN1DecGeneric dec(aBinaryData.Right(aBinaryData.Length() - aPos));
    1.31 +	dec.InitL();
    1.32 +	if (dec.Tag() != EASN1OctetString)
    1.33 +		{
    1.34 +		User::Leave(KErrArgument);
    1.35 +		}
    1.36 +	TInt end = aPos + dec.LengthDER();
    1.37 +	aPos += dec.LengthDERHeader();//add on header for octet string here
    1.38 +//pass in binary data with aPos set to start of contents octets of octet string
    1.39 +//we cheat a little here; since we know an octet string is just the contents octets, 
    1.40 +//we just pass in a reference to the contents octets, and save alloc'ing the whole thang
    1.41 +	DoConstructL(aBinaryData, aPos);	
    1.42 +	if (aPos != end)
    1.43 +		{
    1.44 +		User::Leave(KErrArgument);
    1.45 +		}
    1.46 +	}
    1.47 +
    1.48 +//1) basic constraints...
    1.49 +EXPORT_C CX509BasicConstraintsExt* CX509BasicConstraintsExt::NewL(const TDesC8& aBinaryData)
    1.50 +	{
    1.51 +	TInt pos = 0;
    1.52 +	return CX509BasicConstraintsExt::NewL(aBinaryData, pos);
    1.53 +	}
    1.54 +
    1.55 +EXPORT_C CX509BasicConstraintsExt* CX509BasicConstraintsExt::NewLC(const TDesC8& aBinaryData)
    1.56 +	{
    1.57 +	TInt pos = 0;
    1.58 +	return CX509BasicConstraintsExt::NewLC(aBinaryData, pos);
    1.59 +	}
    1.60 +
    1.61 +EXPORT_C CX509BasicConstraintsExt* CX509BasicConstraintsExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
    1.62 +	{
    1.63 +	CX509BasicConstraintsExt* self = CX509BasicConstraintsExt::NewLC(aBinaryData, aPos);
    1.64 +	CleanupStack::Pop();
    1.65 +	return self;
    1.66 +	}
    1.67 +
    1.68 +EXPORT_C CX509BasicConstraintsExt* CX509BasicConstraintsExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
    1.69 +	{
    1.70 +	CX509BasicConstraintsExt* self = new(ELeave) CX509BasicConstraintsExt;
    1.71 +	CleanupStack::PushL(self);
    1.72 +	self->ConstructL(aBinaryData, aPos);
    1.73 +	return self;
    1.74 +	}
    1.75 +
    1.76 +void CX509BasicConstraintsExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
    1.77 +	{
    1.78 +//sequence of 2 optional components, a bool and an int
    1.79 +	TASN1DecSequence encSeq;
    1.80 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos);
    1.81 +	TInt count = seq->Count();
    1.82 +	TInt pos = 0;
    1.83 +	if (pos < count)
    1.84 +		{
    1.85 +		TBool doneInt = EFalse;
    1.86 +		TASN1DecGeneric* curr = seq->At(pos);
    1.87 +		pos++;
    1.88 +		if (curr->Tag() == EASN1Boolean)
    1.89 +			{
    1.90 +			TASN1DecBoolean encBool;
    1.91 +			iIsCA = encBool.DecodeDERL(*curr);
    1.92 +			}
    1.93 +		else
    1.94 +			{
    1.95 +			TASN1DecInteger encInt;
    1.96 +			iMaxChainLen = encInt.DecodeDERShortL(*curr);
    1.97 +			doneInt = ETrue;
    1.98 +			}
    1.99 +		if (pos < count)
   1.100 +			{
   1.101 +			if (doneInt)
   1.102 +				{
   1.103 +				User::Leave(KErrArgument);
   1.104 +				}
   1.105 +			curr = seq->At(pos);
   1.106 +			pos++;
   1.107 +			TASN1DecInteger encInt;
   1.108 +			iMaxChainLen = encInt.DecodeDERShortL(*curr);
   1.109 +			if (iMaxChainLen < 0)
   1.110 +				{
   1.111 +				User::Leave(KErrArgument);
   1.112 +				}
   1.113 +			}
   1.114 +		}
   1.115 +	if (pos != count)
   1.116 +		{
   1.117 +		User::Leave(KErrArgument);
   1.118 +		}
   1.119 +	CleanupStack::PopAndDestroy();//seq
   1.120 +	}
   1.121 +
   1.122 +CX509BasicConstraintsExt::CX509BasicConstraintsExt()
   1.123 +	:iIsCA(EFalse), iMaxChainLen(KMaxTInt)
   1.124 +	{
   1.125 +	}
   1.126 +
   1.127 +CX509BasicConstraintsExt::~CX509BasicConstraintsExt()
   1.128 +	{
   1.129 +	}
   1.130 +
   1.131 +EXPORT_C TBool CX509BasicConstraintsExt::IsCA() const
   1.132 +	{
   1.133 +	return iIsCA;
   1.134 +	}
   1.135 +
   1.136 +EXPORT_C TInt CX509BasicConstraintsExt::MaxChainLength() const
   1.137 +	{
   1.138 +	return iMaxChainLen;
   1.139 +	}
   1.140 +	
   1.141 +//2) alt name
   1.142 +//#pragma message ("creating empty CX509AltNameExt and destroying it kills process")
   1.143 +EXPORT_C CX509AltNameExt* CX509AltNameExt::NewL(const TDesC8& aBinaryData)
   1.144 +	{
   1.145 +	TInt pos = 0;
   1.146 +	return CX509AltNameExt::NewL(aBinaryData, pos);
   1.147 +	}
   1.148 +
   1.149 +EXPORT_C CX509AltNameExt* CX509AltNameExt::NewLC(const TDesC8& aBinaryData)
   1.150 +	{
   1.151 +	TInt pos = 0;
   1.152 +	return CX509AltNameExt::NewLC(aBinaryData, pos);
   1.153 +	}
   1.154 +
   1.155 +EXPORT_C CX509AltNameExt* CX509AltNameExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.156 +	{
   1.157 +	CX509AltNameExt* self = CX509AltNameExt::NewLC(aBinaryData, aPos);
   1.158 +	CleanupStack::Pop();
   1.159 +	return self;
   1.160 +	}
   1.161 +
   1.162 +EXPORT_C CX509AltNameExt* CX509AltNameExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.163 +	{
   1.164 +	CX509AltNameExt* self = new(ELeave) CX509AltNameExt;
   1.165 +	CleanupStack::PushL(self);
   1.166 +	self->ConstructL(aBinaryData, aPos);
   1.167 +	return self;
   1.168 +	}
   1.169 +
   1.170 +void CX509AltNameExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.171 +	{
   1.172 +	// The sequence should have at least 1 name here, previously this was checked
   1.173 +	// but now zero lengths sequences are tolerated.
   1.174 +	//
   1.175 +	// RFC 3280 requires that CAs ensure that the SubjectAltName is not empty if it exists. The 
   1.176 +	// behaviour of the client is undefined if this condition occurs. Since this code will 
   1.177 +	// normally be used as a client (i.e. not the CA) and there should be no need to validate 
   1.178 +	// the SubjectAltName we do not enfore a minimum sequence length.
   1.179 +	// This avoids TLS connections being dropped unecessarily.
   1.180 +
   1.181 +	TASN1DecSequence encSeq;
   1.182 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 0, KMaxTInt);
   1.183 +	TInt count = seq->Count();
   1.184 +	iAuthorityName = new(ELeave) CArrayPtrFlat<CX509GeneralName> (1);
   1.185 +	TASN1DecGeneric* gen;
   1.186 +	for (TInt i = 0; i < count; i++)
   1.187 +		{
   1.188 +		gen = seq->At(i);
   1.189 +		CX509GeneralName* gn = CX509GeneralName::NewLC(gen->Encoding());
   1.190 +		iAuthorityName->AppendL(gn);
   1.191 +		CleanupStack::Pop();//gn
   1.192 +		}
   1.193 +	CleanupStack::PopAndDestroy();
   1.194 +	}
   1.195 +
   1.196 +CX509AltNameExt::~CX509AltNameExt()
   1.197 +	{
   1.198 +	if (iAuthorityName != NULL)
   1.199 +		{
   1.200 +		iAuthorityName->ResetAndDestroy();
   1.201 +		delete iAuthorityName;
   1.202 +		}
   1.203 +	}
   1.204 +
   1.205 +EXPORT_C const CArrayPtrFlat<CX509GeneralName>& CX509AltNameExt::AltName() const
   1.206 +	{
   1.207 +	return *iAuthorityName;
   1.208 +	}
   1.209 +
   1.210 +EXPORT_C TBool CX509AltNameExt::Match(const CX509AltNameExt& aExt) const
   1.211 +	{
   1.212 +	TBool res = EFalse;
   1.213 +	const CArrayPtrFlat<CX509GeneralName>& otherGNs = aExt.AltName();
   1.214 +	TInt otherGNCount = otherGNs.Count();
   1.215 +	TInt thisGNCount = iAuthorityName->Count();
   1.216 +	if (otherGNCount != thisGNCount)
   1.217 +		{
   1.218 +		}
   1.219 +	else
   1.220 +		{
   1.221 +		res = ETrue;
   1.222 +		for (TInt j = 0; j < otherGNCount; j++)
   1.223 +				{
   1.224 +				const CX509GeneralName* otherGN = otherGNs.At(j);
   1.225 +				const CX509GeneralName* thisGN = iAuthorityName->At(j);
   1.226 +				if (!thisGN->ExactMatch(*otherGN))
   1.227 +					{
   1.228 +					res = EFalse;
   1.229 +					}
   1.230 +				}
   1.231 +		}
   1.232 +	return res;
   1.233 +	}
   1.234 +
   1.235 +CX509AltNameExt::CX509AltNameExt()
   1.236 +	{
   1.237 +	}
   1.238 +
   1.239 +//3) key usage
   1.240 +CX509BitString::~CX509BitString()
   1.241 +	{
   1.242 +	delete iData;
   1.243 +	}
   1.244 +
   1.245 +TBool CX509BitString::IsSet(TInt aBit) const
   1.246 +	{
   1.247 +	if (aBit < iLength)//offset from zero
   1.248 +		{
   1.249 +		TPtrC8 d(iData->Des());
   1.250 +		TUint8 oct = d[(aBit/8)];
   1.251 +		TUint mask = (1 << (7-(aBit % 8)));
   1.252 +		return (oct & mask);
   1.253 +		}
   1.254 +	return EFalse;
   1.255 +	}
   1.256 +
   1.257 +CX509BitString::CX509BitString(HBufC8* aData, TInt aLength)
   1.258 +	:iData(aData), iLength(aLength)
   1.259 +	{
   1.260 +	}
   1.261 +
   1.262 +EXPORT_C CX509KeyUsageExt* CX509KeyUsageExt::NewL(const TDesC8& aBinaryData)
   1.263 +	{
   1.264 +	TInt pos = 0;
   1.265 +	return CX509KeyUsageExt::NewL(aBinaryData, pos);
   1.266 +	}
   1.267 +
   1.268 +EXPORT_C CX509KeyUsageExt* CX509KeyUsageExt::NewLC(const TDesC8& aBinaryData)
   1.269 +	{
   1.270 +	TInt pos = 0;
   1.271 +	return CX509KeyUsageExt::NewLC(aBinaryData, pos);
   1.272 +	}
   1.273 +
   1.274 +EXPORT_C CX509KeyUsageExt* CX509KeyUsageExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.275 +	{
   1.276 +	CX509KeyUsageExt* self = CX509KeyUsageExt::NewLC(aBinaryData, aPos);
   1.277 +	CleanupStack::Pop();
   1.278 +	return self;
   1.279 +	}
   1.280 +
   1.281 +EXPORT_C CX509KeyUsageExt* CX509KeyUsageExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.282 +	{
   1.283 +	CX509KeyUsageExt* self = new(ELeave) CX509KeyUsageExt;
   1.284 +	CleanupStack::PushL(self);
   1.285 +	self->ConstructL(aBinaryData, aPos);
   1.286 +	return self;
   1.287 +	}
   1.288 +
   1.289 +void CX509KeyUsageExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.290 +	{
   1.291 +	TASN1DecGeneric gen(aBinaryData.Right(aBinaryData.Length() - aPos));
   1.292 +	gen.InitL();
   1.293 +	if (gen.Tag() != EASN1BitString)
   1.294 +		{
   1.295 +		User::Leave(KErrArgument);
   1.296 +		}
   1.297 +	TPtrC8 p(gen.GetContentDER());
   1.298 +	if (p.Length() < 2)
   1.299 +		{
   1.300 +		User::Leave(KErrArgument);
   1.301 +		}
   1.302 +	TPtrC8 pData(p.Right(p.Length() - 1));
   1.303 +	TInt paddingLength = p[0];
   1.304 +	TInt bitStringLength = (pData.Length() * 8) - paddingLength;
   1.305 +	HBufC8* bitString = pData.AllocL();
   1.306 +	CleanupStack::PushL(bitString);
   1.307 +	iData = new(ELeave) CX509BitString(bitString, bitStringLength);
   1.308 +	CleanupStack::Pop();//bitstring
   1.309 +	aPos += gen.LengthDER();
   1.310 +	}
   1.311 +
   1.312 +CX509KeyUsageExt::CX509KeyUsageExt()
   1.313 +	{
   1.314 +	}
   1.315 +
   1.316 +CX509KeyUsageExt::~CX509KeyUsageExt()
   1.317 +	{
   1.318 +	delete iData;
   1.319 +	}
   1.320 +
   1.321 +EXPORT_C TBool CX509KeyUsageExt::IsSet(TX509KeyUsage aUsage) const
   1.322 +	{
   1.323 +	return iData->IsSet(aUsage);
   1.324 +	}
   1.325 +
   1.326 +//4) name constraints
   1.327 +CX509GeneralSubtree* CX509GeneralSubtree::NewL(const TDesC8& aBinaryData)
   1.328 +	{
   1.329 +	TInt pos = 0;
   1.330 +	return CX509GeneralSubtree::NewL(aBinaryData, pos);
   1.331 +	}
   1.332 +
   1.333 +CX509GeneralSubtree* CX509GeneralSubtree::NewLC(const TDesC8& aBinaryData)
   1.334 +	{
   1.335 +	TInt pos = 0;
   1.336 +	return CX509GeneralSubtree::NewLC(aBinaryData, pos);
   1.337 +	}
   1.338 +
   1.339 +CX509GeneralSubtree* CX509GeneralSubtree::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.340 +	{
   1.341 +	CX509GeneralSubtree* self = CX509GeneralSubtree::NewLC(aBinaryData, aPos);
   1.342 +	CleanupStack::Pop();
   1.343 +	return self;
   1.344 +	}
   1.345 +
   1.346 +CX509GeneralSubtree* CX509GeneralSubtree::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.347 +	{
   1.348 +	CX509GeneralSubtree* self = new(ELeave) CX509GeneralSubtree;
   1.349 +	CleanupStack::PushL(self);
   1.350 +	self->ConstructL(aBinaryData, aPos);
   1.351 +	return self;
   1.352 +	}
   1.353 +
   1.354 +void CX509GeneralSubtree::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.355 +	{
   1.356 +	TASN1DecSequence encSeq;
   1.357 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);//(seq here must have at least 1 name)
   1.358 +	TInt count = seq->Count();
   1.359 +	TInt pos = 0;
   1.360 +	TASN1DecGeneric* curr = seq->At(pos);
   1.361 +	pos++;
   1.362 +	iName = CX509GeneralName::NewL(curr->Encoding());
   1.363 +	if (pos < count)
   1.364 +		{
   1.365 +		TBool doneMax = EFalse;
   1.366 +		curr = seq->At(pos);
   1.367 +		pos++;
   1.368 +		if (curr->Class() != EContextSpecific)
   1.369 +				{
   1.370 +				User::Leave(KErrArgument);
   1.371 +				}
   1.372 +			switch(curr->Tag())
   1.373 +				{
   1.374 +				case 0:
   1.375 +					{
   1.376 +					TASN1DecInteger encInt;
   1.377 +					iMinDist = encInt.DecodeDERShortL(*curr);
   1.378 +					break;
   1.379 +					}
   1.380 +				case 1:
   1.381 +					{
   1.382 +					TASN1DecInteger encInt;
   1.383 +					iMaxDist = encInt.DecodeDERShortL(*curr);
   1.384 +					doneMax = ETrue;
   1.385 +					break;
   1.386 +					}
   1.387 +				}
   1.388 +			if (pos < count)
   1.389 +				{
   1.390 +				curr = seq->At(pos);
   1.391 +				if ((doneMax) || (curr->Class() != EContextSpecific) || (curr->Tag() != 1))
   1.392 +					{
   1.393 +					User::Leave(KErrArgument);
   1.394 +					}
   1.395 +				TASN1DecInteger encInt;
   1.396 +				iMaxDist = encInt.DecodeDERShortL(*curr);
   1.397 +				}
   1.398 +		}
   1.399 +	if (pos != count)
   1.400 +		{
   1.401 +		User::Leave(KErrArgument);
   1.402 +		}
   1.403 +	CleanupStack::PopAndDestroy();
   1.404 +	}
   1.405 +
   1.406 +CX509GeneralSubtree::~CX509GeneralSubtree()
   1.407 +	{
   1.408 +	delete iName;
   1.409 +	}
   1.410 +
   1.411 +EXPORT_C const CX509GeneralName& CX509GeneralSubtree::Name() const
   1.412 +	{
   1.413 +	return *iName;
   1.414 +	}
   1.415 +
   1.416 +EXPORT_C TInt CX509GeneralSubtree::MinDistance() const
   1.417 +	{
   1.418 +	return iMinDist;
   1.419 +	}
   1.420 +
   1.421 +EXPORT_C TInt CX509GeneralSubtree::MaxDistance() const
   1.422 +	{
   1.423 +	return iMaxDist;
   1.424 +	}
   1.425 +
   1.426 +CX509GeneralSubtree::CX509GeneralSubtree()
   1.427 +	:iMaxDist(KMaxTInt), iMinDist(0)
   1.428 +	{
   1.429 +	}
   1.430 +
   1.431 +//
   1.432 +EXPORT_C CX509NameConstraintsExt* CX509NameConstraintsExt::NewL(const TDesC8& aBinaryData)
   1.433 +	{
   1.434 +	TInt pos = 0;
   1.435 +	return CX509NameConstraintsExt::NewL(aBinaryData, pos);
   1.436 +	}
   1.437 +
   1.438 +EXPORT_C CX509NameConstraintsExt* CX509NameConstraintsExt::NewLC(const TDesC8& aBinaryData)
   1.439 +	{
   1.440 +	TInt pos = 0;
   1.441 +	return CX509NameConstraintsExt::NewLC(aBinaryData, pos);
   1.442 +	}
   1.443 +
   1.444 +EXPORT_C CX509NameConstraintsExt* CX509NameConstraintsExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.445 +	{
   1.446 +	CX509NameConstraintsExt* self = CX509NameConstraintsExt::NewLC(aBinaryData, aPos);
   1.447 +	CleanupStack::Pop();
   1.448 +	return self;
   1.449 +	}
   1.450 +
   1.451 +EXPORT_C CX509NameConstraintsExt* CX509NameConstraintsExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.452 +	{
   1.453 +	CX509NameConstraintsExt* self = new(ELeave) CX509NameConstraintsExt;
   1.454 +	CleanupStack::PushL(self);
   1.455 +	self->ConstructL(aBinaryData, aPos);
   1.456 +	return self;
   1.457 +	}
   1.458 +
   1.459 +void CX509NameConstraintsExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.460 +	{
   1.461 +	TASN1DecSequence encSeq;
   1.462 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos);
   1.463 +	TInt count = seq->Count();
   1.464 +	TInt pos = 0;
   1.465 +
   1.466 +	iExcludedSubtrees = new(ELeave) CArrayPtrFlat<CX509GeneralSubtree> (1);
   1.467 +	iPermittedSubtrees = new(ELeave) CArrayPtrFlat<CX509GeneralSubtree> (1);
   1.468 +	TBool doneExcluded = EFalse;
   1.469 +	
   1.470 +	if (pos < count)
   1.471 +		{
   1.472 +		TASN1DecGeneric* curr = seq->At(pos);
   1.473 +		pos++;
   1.474 +		if (curr->Class() != EContextSpecific)
   1.475 +			{
   1.476 +			User::Leave(KErrArgument);
   1.477 +			}
   1.478 +		switch (curr->Tag())
   1.479 +			{
   1.480 +			case 0:
   1.481 +				{
   1.482 +				AddSubtreesL(*iPermittedSubtrees, curr->Encoding());
   1.483 +				break;
   1.484 +				}
   1.485 +			case 1:
   1.486 +				{
   1.487 +				AddSubtreesL(*iExcludedSubtrees, curr->Encoding());
   1.488 +				doneExcluded = ETrue;
   1.489 +				break;
   1.490 +				}
   1.491 +			default:
   1.492 +				{
   1.493 +				User::Leave(KErrArgument);
   1.494 +				}
   1.495 +			}
   1.496 +		if (pos < count)
   1.497 +			{
   1.498 +			curr = seq->At(pos);
   1.499 +			pos++;
   1.500 +			if ((curr->Class() != EContextSpecific) || (curr->Tag() != 1) || (doneExcluded))
   1.501 +				{
   1.502 +				User::Leave(KErrArgument);
   1.503 +				}
   1.504 +			AddSubtreesL(*iExcludedSubtrees, curr->Encoding());
   1.505 +			}
   1.506 +		}
   1.507 +	CleanupStack::PopAndDestroy();//seq
   1.508 +	}
   1.509 +
   1.510 +void CX509NameConstraintsExt::AddSubtreesL(	CArrayPtrFlat<CX509GeneralSubtree>& aSubtrees,
   1.511 +											const TDesC8& aBinaryData)
   1.512 +	{
   1.513 +	TASN1DecSequence encSeq;
   1.514 +	TInt pos = 0;
   1.515 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, pos, 1, KMaxTInt);
   1.516 +	TInt count = seq->Count();
   1.517 +	TASN1DecGeneric* gen;
   1.518 +	for(TInt i = 0; i < count; i++)
   1.519 +		{
   1.520 +		gen = seq->At(i);
   1.521 +		CX509GeneralSubtree* subtree = CX509GeneralSubtree::NewLC(gen->Encoding());
   1.522 +		aSubtrees.AppendL(subtree);
   1.523 +		CleanupStack::Pop();
   1.524 +		}
   1.525 +	CleanupStack::PopAndDestroy();
   1.526 +	}
   1.527 +
   1.528 +EXPORT_C CX509NameConstraintsExt::~CX509NameConstraintsExt()
   1.529 +	{
   1.530 +	if (iExcludedSubtrees != NULL)
   1.531 +		{
   1.532 +		iExcludedSubtrees->ResetAndDestroy();
   1.533 +		delete iExcludedSubtrees;
   1.534 +		}
   1.535 +	if (iPermittedSubtrees != NULL)
   1.536 +		{
   1.537 +		iPermittedSubtrees->ResetAndDestroy();
   1.538 +		delete iPermittedSubtrees;
   1.539 +		}
   1.540 +	}
   1.541 +
   1.542 +EXPORT_C const CArrayPtrFlat<CX509GeneralSubtree>& CX509NameConstraintsExt::ExcludedSubtrees() const
   1.543 +	{
   1.544 +	return *iExcludedSubtrees;
   1.545 +	}
   1.546 +
   1.547 +EXPORT_C const CArrayPtrFlat<CX509GeneralSubtree>& CX509NameConstraintsExt::PermittedSubtrees() const
   1.548 +	{
   1.549 +	return *iPermittedSubtrees;
   1.550 +	}
   1.551 +
   1.552 +CX509NameConstraintsExt::CX509NameConstraintsExt()
   1.553 +	{
   1.554 +	}
   1.555 +
   1.556 +//5) policy constraints
   1.557 +TX509PolicyConstraint::TX509PolicyConstraint(TBool aRequired, TInt aCountdown)
   1.558 +	:iRequired(aRequired), iCountdown(aCountdown)
   1.559 +	{
   1.560 +	}
   1.561 +
   1.562 +TX509PolicyConstraint::TX509PolicyConstraint()
   1.563 +	:iRequired(EFalse), iCountdown(0)
   1.564 +	{
   1.565 +	}
   1.566 +
   1.567 +//
   1.568 +EXPORT_C CX509PolicyConstraintsExt* CX509PolicyConstraintsExt::NewL(const TDesC8& aBinaryData)
   1.569 +	{
   1.570 +	TInt pos = 0;
   1.571 +	return CX509PolicyConstraintsExt::NewL(aBinaryData, pos);
   1.572 +	}
   1.573 +
   1.574 +EXPORT_C CX509PolicyConstraintsExt* CX509PolicyConstraintsExt::NewLC(const TDesC8& aBinaryData)
   1.575 +	{
   1.576 +	TInt pos = 0;
   1.577 +	return CX509PolicyConstraintsExt::NewLC(aBinaryData, pos);
   1.578 +	}
   1.579 +
   1.580 +EXPORT_C CX509PolicyConstraintsExt* CX509PolicyConstraintsExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.581 +	{
   1.582 +	CX509PolicyConstraintsExt* self = CX509PolicyConstraintsExt::NewLC(aBinaryData, aPos);
   1.583 +	CleanupStack::Pop();
   1.584 +	return self;
   1.585 +	}
   1.586 +
   1.587 +EXPORT_C CX509PolicyConstraintsExt* CX509PolicyConstraintsExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.588 +	{
   1.589 +	CX509PolicyConstraintsExt* self = new(ELeave) CX509PolicyConstraintsExt;
   1.590 +	CleanupStack::PushL(self);
   1.591 +	self->ConstructL(aBinaryData, aPos);
   1.592 +	return self;
   1.593 +	}
   1.594 +
   1.595 +void CX509PolicyConstraintsExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.596 +	{
   1.597 +	TASN1DecSequence encSeq;
   1.598 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos);
   1.599 +	TInt count = seq->Count();
   1.600 +	TInt pos = 0;
   1.601 +	TASN1DecGeneric* curr;
   1.602 +	if (pos < count)
   1.603 +		{
   1.604 +		curr = seq->At(pos);
   1.605 +		pos++;
   1.606 +		if (curr->Class() != EContextSpecific)
   1.607 +			{
   1.608 +			User::Leave(KErrArgument);
   1.609 +			}
   1.610 +		switch (curr->Tag())
   1.611 +			{
   1.612 +			case 0:
   1.613 +				{
   1.614 +				iRequirePolicy.iRequired = ETrue;
   1.615 +				TASN1DecInteger encInt;
   1.616 +				iRequirePolicy.iCountdown = encInt.DecodeDERShortL(*curr);
   1.617 +				break;
   1.618 +				}
   1.619 +			case 1:
   1.620 +				{
   1.621 +				iInhibitPolicyMapping.iRequired = ETrue;
   1.622 +				TASN1DecInteger encInt;
   1.623 +				iInhibitPolicyMapping.iCountdown = encInt.DecodeDERShortL(*curr);
   1.624 +				break;
   1.625 +				}
   1.626 +			default:
   1.627 +				{
   1.628 +				User::Leave(KErrArgument);
   1.629 +				}
   1.630 +			}
   1.631 +		if(pos < count)
   1.632 +			{
   1.633 +			curr = seq->At(pos);
   1.634 +			pos++;
   1.635 +			if ((iInhibitPolicyMapping.iRequired) || (curr->Class() != EContextSpecific) || (curr->Tag() != 1))
   1.636 +				{
   1.637 +				User::Leave(KErrArgument);
   1.638 +				}
   1.639 +			iInhibitPolicyMapping.iRequired = ETrue;
   1.640 +			TASN1DecInteger encInt;
   1.641 +			iInhibitPolicyMapping.iCountdown = encInt.DecodeDERShortL(*curr);
   1.642 +			}
   1.643 +		}
   1.644 +	if (pos != count)
   1.645 +		{
   1.646 +		User::Leave(KErrArgument);
   1.647 +		}
   1.648 +	CleanupStack::PopAndDestroy();
   1.649 +	}
   1.650 +
   1.651 +CX509PolicyConstraintsExt::CX509PolicyConstraintsExt()
   1.652 +	{
   1.653 +	}
   1.654 +
   1.655 +EXPORT_C CX509PolicyConstraintsExt::~CX509PolicyConstraintsExt()
   1.656 +	{
   1.657 +	}
   1.658 +
   1.659 +EXPORT_C TX509PolicyConstraint CX509PolicyConstraintsExt::ExplicitPolicyRequired() const
   1.660 +	{
   1.661 +	return iRequirePolicy;
   1.662 +	}
   1.663 +
   1.664 +EXPORT_C TX509PolicyConstraint CX509PolicyConstraintsExt::InhibitPolicyMapping() const
   1.665 +	{
   1.666 +	return iInhibitPolicyMapping;
   1.667 +	}
   1.668 +
   1.669 +//6) policies
   1.670 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewL(const TDesC8& aBinaryData)
   1.671 +	{
   1.672 +	TInt pos = 0;
   1.673 +	return CX509PolicyQualifierInfo::NewL(aBinaryData, pos);
   1.674 +	}
   1.675 +
   1.676 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewLC(const TDesC8& aBinaryData)
   1.677 +	{
   1.678 +	TInt pos = 0;
   1.679 +	return CX509PolicyQualifierInfo::NewLC(aBinaryData, pos);
   1.680 +	}
   1.681 +
   1.682 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.683 +	{
   1.684 +	CX509PolicyQualifierInfo* self = CX509PolicyQualifierInfo::NewLC(aBinaryData, aPos);
   1.685 +	CleanupStack::Pop();
   1.686 +	return self;
   1.687 +	}
   1.688 +
   1.689 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.690 +	{
   1.691 +	CX509PolicyQualifierInfo* self = new(ELeave) CX509PolicyQualifierInfo;
   1.692 +	CleanupStack::PushL(self);
   1.693 +	self->ConstructL(aBinaryData, aPos);
   1.694 +	return self;
   1.695 +	}
   1.696 +
   1.697 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewL(const CX509PolicyQualifierInfo& aQualifier)
   1.698 +	{
   1.699 +	CX509PolicyQualifierInfo* self = CX509PolicyQualifierInfo::NewLC(aQualifier);
   1.700 +	CleanupStack::Pop();//self
   1.701 +	return self;
   1.702 +	}
   1.703 +
   1.704 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewLC(const CX509PolicyQualifierInfo& aQualifier)
   1.705 +	{
   1.706 +	CX509PolicyQualifierInfo* self = new(ELeave) CX509PolicyQualifierInfo;
   1.707 +	CleanupStack::PushL(self);
   1.708 +	self->ConstructL(aQualifier);
   1.709 +	return self;
   1.710 +	}
   1.711 +
   1.712 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewL(RReadStream& aStream)
   1.713 +	{
   1.714 +	CX509PolicyQualifierInfo* self = CX509PolicyQualifierInfo::NewLC(aStream);
   1.715 +	CleanupStack::Pop();
   1.716 +	return self;
   1.717 +	}
   1.718 +
   1.719 +CX509PolicyQualifierInfo* CX509PolicyQualifierInfo::NewLC(RReadStream& aStream)
   1.720 +	{
   1.721 +	CX509PolicyQualifierInfo* self = new(ELeave) CX509PolicyQualifierInfo();
   1.722 +	CleanupStack::PushL(self);
   1.723 +	self->ConstructL(aStream);
   1.724 +	return self;
   1.725 +	}
   1.726 +
   1.727 +void CX509PolicyQualifierInfo::ConstructL(RReadStream& aStream)
   1.728 +	{
   1.729 +	InternalizeL(aStream);
   1.730 +	}
   1.731 +
   1.732 +void CX509PolicyQualifierInfo::ConstructL(const CX509PolicyQualifierInfo& aQualifier)
   1.733 +	{
   1.734 +	iPolicyQualifierId = aQualifier.iPolicyQualifierId->Des().AllocL();//must be a better way to do this!!
   1.735 +	iData = aQualifier.iData->Des().AllocL();//must be a better way to do this!!
   1.736 +	}
   1.737 +
   1.738 +void CX509PolicyQualifierInfo::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.739 +	{
   1.740 +	TASN1DecSequence encSeq;
   1.741 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
   1.742 +	TInt count = seq->Count();
   1.743 +	TInt pos = 0;
   1.744 +	TASN1DecGeneric* curr = seq->At(pos);
   1.745 +	pos++;
   1.746 +	TASN1DecObjectIdentifier encOID;
   1.747 +	iPolicyQualifierId = encOID.DecodeDERL(*curr);
   1.748 +	if (pos < count)
   1.749 +		{
   1.750 +		iData = curr->Encoding().AllocL();
   1.751 +		pos++;
   1.752 +		}
   1.753 +	else
   1.754 +		{
   1.755 +		iData = HBufC8::NewL(1);
   1.756 +		*iData = KNullDesC8;
   1.757 +		}
   1.758 +	if (pos != count)
   1.759 +		{
   1.760 +		User::Leave(KErrArgument);
   1.761 +		}
   1.762 +	CleanupStack::PopAndDestroy();
   1.763 +	}
   1.764 +
   1.765 +CX509PolicyQualifierInfo::CX509PolicyQualifierInfo()
   1.766 +	{
   1.767 +	}
   1.768 +
   1.769 +CX509PolicyQualifierInfo::~CX509PolicyQualifierInfo()
   1.770 +	{
   1.771 +	delete iPolicyQualifierId;
   1.772 +	delete iData;
   1.773 +	}
   1.774 +
   1.775 +EXPORT_C TPtrC CX509PolicyQualifierInfo::Id() const
   1.776 +	{
   1.777 +	return iPolicyQualifierId->Des();
   1.778 +	}
   1.779 +
   1.780 +EXPORT_C TPtrC8 CX509PolicyQualifierInfo::Data() const
   1.781 +	{
   1.782 +	return iData->Des();
   1.783 +	}
   1.784 +
   1.785 +void CX509PolicyQualifierInfo::ExternalizeL(RWriteStream& aStream) const
   1.786 +	{
   1.787 +	//iPolicyQualifierId
   1.788 +	aStream << *iPolicyQualifierId;
   1.789 +
   1.790 +	//iData
   1.791 +	aStream << *iData;
   1.792 +	}
   1.793 +
   1.794 +void CX509PolicyQualifierInfo::InternalizeL(RReadStream& aStream)
   1.795 +	{
   1.796 +	//iPolicyQualifierId
   1.797 +	delete iPolicyQualifierId;
   1.798 +	iPolicyQualifierId=0;
   1.799 +	iPolicyQualifierId=HBufC::NewL(aStream, KMaxTInt);
   1.800 +
   1.801 +	//iData
   1.802 +	delete iData;
   1.803 +	iData=0;
   1.804 +	iData=HBufC8::NewL(aStream, KMaxTInt);
   1.805 +	}
   1.806 +
   1.807 +
   1.808 +CX509CertPolicyInfo* CX509CertPolicyInfo::NewL(const TDesC8& aBinaryData)
   1.809 +	{
   1.810 +	TInt pos = 0;
   1.811 +	return CX509CertPolicyInfo::NewL(aBinaryData, pos);
   1.812 +	}
   1.813 +
   1.814 +CX509CertPolicyInfo* CX509CertPolicyInfo::NewLC(const TDesC8& aBinaryData)
   1.815 +	{
   1.816 +	TInt pos = 0;
   1.817 +	return CX509CertPolicyInfo::NewLC(aBinaryData, pos);
   1.818 +	}
   1.819 +
   1.820 +CX509CertPolicyInfo* CX509CertPolicyInfo::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.821 +	{
   1.822 +	CX509CertPolicyInfo* self = CX509CertPolicyInfo::NewLC(aBinaryData, aPos);
   1.823 +	CleanupStack::Pop();
   1.824 +	return self;
   1.825 +	}
   1.826 +
   1.827 +CX509CertPolicyInfo* CX509CertPolicyInfo::NewLC(const TDesC8& aBinaryData, TInt& aPos)
   1.828 +	{
   1.829 +	CX509CertPolicyInfo* self = new(ELeave) CX509CertPolicyInfo;
   1.830 +	CleanupStack::PushL(self);
   1.831 +	self->ConstructL(aBinaryData, aPos);
   1.832 +	return self;
   1.833 +	}
   1.834 +
   1.835 +
   1.836 +EXPORT_C CX509CertPolicyInfo* CX509CertPolicyInfo::NewL(RReadStream& aStream)
   1.837 +	{
   1.838 +	CX509CertPolicyInfo* self = CX509CertPolicyInfo::NewLC(aStream);
   1.839 +	CleanupStack::Pop();
   1.840 +	return self;
   1.841 +	}
   1.842 + 
   1.843 +EXPORT_C CX509CertPolicyInfo* CX509CertPolicyInfo::NewLC(RReadStream& aStream)
   1.844 +	{
   1.845 +	CX509CertPolicyInfo* self = new(ELeave) CX509CertPolicyInfo();
   1.846 +	CleanupStack::PushL(self);
   1.847 +	self->ConstructL(aStream);
   1.848 +	return self;
   1.849 +	}
   1.850 +
   1.851 +EXPORT_C CX509CertPolicyInfo* CX509CertPolicyInfo::NewL(const CX509CertPolicyInfo& aInfo)
   1.852 +	{
   1.853 +	CX509CertPolicyInfo* self = CX509CertPolicyInfo::NewLC(aInfo);
   1.854 +	CleanupStack::Pop();//self
   1.855 +	return self;
   1.856 +	}
   1.857 +
   1.858 +EXPORT_C CX509CertPolicyInfo* CX509CertPolicyInfo::NewLC(const CX509CertPolicyInfo& aInfo)
   1.859 +	{
   1.860 +	CX509CertPolicyInfo* self = new(ELeave) CX509CertPolicyInfo;
   1.861 +	CleanupStack::PushL(self);
   1.862 +	self->ConstructL(aInfo);
   1.863 +	return self;
   1.864 +	}
   1.865 +
   1.866 +void CX509CertPolicyInfo::ConstructL(RReadStream& aStream)
   1.867 +	{
   1.868 +	InternalizeL(aStream);
   1.869 +	}
   1.870 +
   1.871 +void CX509CertPolicyInfo::ConstructL(const CX509CertPolicyInfo& aInfo)
   1.872 +	{
   1.873 +	iCertPolicyId = aInfo.iCertPolicyId->Des().AllocL();//must be a better way to do this!!
   1.874 +	iQualifiers = new(ELeave) CArrayPtrFlat<CX509PolicyQualifierInfo> (1);
   1.875 +	TInt count = aInfo.iQualifiers->Count();
   1.876 +	for (TInt i = 0; i < count; i++)
   1.877 +		{
   1.878 +		CX509PolicyQualifierInfo* q = CX509PolicyQualifierInfo::NewLC(*(aInfo.iQualifiers->At(i)));
   1.879 +		iQualifiers->AppendL(q);
   1.880 +		CleanupStack::Pop();//q
   1.881 +		}
   1.882 +	}
   1.883 +
   1.884 +void CX509CertPolicyInfo::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
   1.885 +	{
   1.886 +	TASN1DecSequence encSeq;
   1.887 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
   1.888 +	TInt count = seq->Count();
   1.889 +	TInt pos = 0;
   1.890 +	TASN1DecGeneric* curr = seq->At(pos);
   1.891 +	pos++;
   1.892 +
   1.893 +	TASN1DecObjectIdentifier encOID;
   1.894 +	iCertPolicyId = encOID.DecodeDERL(*curr);
   1.895 +	iQualifiers = new(ELeave) CArrayPtrFlat<CX509PolicyQualifierInfo> (1);
   1.896 +	if (pos < count)
   1.897 +		{
   1.898 +		curr = seq->At(pos);
   1.899 +		pos++;
   1.900 +		TASN1DecSequence encSeqQualifier;
   1.901 +		CArrayPtrFlat<TASN1DecGeneric>* seqQualifier = encSeqQualifier.DecodeDERLC(*curr);
   1.902 +		TInt qCount = seqQualifier->Count();
   1.903 +		for(TInt i = 0; i < qCount; i++)
   1.904 +			{
   1.905 +			TASN1DecGeneric* qGen = seqQualifier->At(i);
   1.906 +			CX509PolicyQualifierInfo* qualifier = CX509PolicyQualifierInfo::NewLC(qGen->Encoding());
   1.907 +			iQualifiers->AppendL(qualifier);
   1.908 +			CleanupStack::Pop();//qualifier
   1.909 +			}
   1.910 +		CleanupStack::PopAndDestroy();
   1.911 +		}
   1.912 +	if (pos != count)
   1.913 +		{
   1.914 +		User::Leave(KErrArgument);
   1.915 +		}
   1.916 +	CleanupStack::PopAndDestroy();
   1.917 +	}
   1.918 +
   1.919 +CX509CertPolicyInfo::~CX509CertPolicyInfo()
   1.920 +	{
   1.921 +	if (iQualifiers != NULL)
   1.922 +		{
   1.923 +		iQualifiers->ResetAndDestroy();
   1.924 +		delete iQualifiers;
   1.925 +		}
   1.926 +	delete iCertPolicyId;
   1.927 +	}
   1.928 +
   1.929 +EXPORT_C const CArrayPtrFlat<CX509PolicyQualifierInfo>& CX509CertPolicyInfo::Qualifiers() const
   1.930 +	{
   1.931 +	return *iQualifiers;
   1.932 +	}
   1.933 +
   1.934 +EXPORT_C TPtrC CX509CertPolicyInfo::Id() const
   1.935 +	{
   1.936 +	return iCertPolicyId->Des();
   1.937 +	}
   1.938 +
   1.939 +CX509CertPolicyInfo::CX509CertPolicyInfo()
   1.940 +	{
   1.941 +	}
   1.942 +
   1.943 +EXPORT_C void CX509CertPolicyInfo::ExternalizeL(RWriteStream& aStream) const
   1.944 +	{
   1.945 +	//iCertPolicyId
   1.946 + 	aStream << *iCertPolicyId;
   1.947 +
   1.948 + 	// iQualifiers
   1.949 +	aStream.WriteInt32L(iQualifiers->Count());
   1.950 +	for (TInt32 i=0;i < iQualifiers->Count(); ++i)
   1.951 +		{
   1.952 +		(*iQualifiers)[i]->ExternalizeL(aStream);
   1.953 +		}
   1.954 +	}
   1.955 +
   1.956 +EXPORT_C void CX509CertPolicyInfo::InternalizeL(RReadStream& aStream)
   1.957 +	{
   1.958 +	//iCertPolicyId
   1.959 +	delete iCertPolicyId;
   1.960 +	iCertPolicyId=0;
   1.961 +	iCertPolicyId=HBufC::NewL(aStream, KMaxTInt);
   1.962 +
   1.963 +	// iQualifiers
   1.964 +	if (iQualifiers != NULL)
   1.965 +		{
   1.966 +		iQualifiers->ResetAndDestroy();
   1.967 +		}
   1.968 +	else
   1.969 +		{
   1.970 +		iQualifiers = new(ELeave) CArrayPtrFlat<CX509PolicyQualifierInfo> (1);
   1.971 +		}
   1.972 +
   1.973 +	TInt32 count=aStream.ReadInt32L();
   1.974 +	for (TInt32 i=0;i < count; ++i)
   1.975 +		{
   1.976 +		CX509PolicyQualifierInfo* policyQualifierInfo=CX509PolicyQualifierInfo::NewLC(aStream);
   1.977 +		iQualifiers->AppendL(policyQualifierInfo);
   1.978 +		CleanupStack::Pop(policyQualifierInfo);
   1.979 +		}
   1.980 +	}
   1.981 +
   1.982 +EXPORT_C CX509CertPoliciesExt* CX509CertPoliciesExt::NewL(const TDesC8& aBinaryData)
   1.983 +	{
   1.984 +	TInt pos = 0;
   1.985 +	return CX509CertPoliciesExt::NewL(aBinaryData, pos);
   1.986 +	}
   1.987 +
   1.988 +EXPORT_C CX509CertPoliciesExt* CX509CertPoliciesExt::NewLC(const TDesC8& aBinaryData)
   1.989 +	{
   1.990 +	TInt pos = 0;
   1.991 +	return CX509CertPoliciesExt::NewLC(aBinaryData, pos);
   1.992 +	}
   1.993 +
   1.994 +EXPORT_C CX509CertPoliciesExt* CX509CertPoliciesExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
   1.995 +	{
   1.996 +	CX509CertPoliciesExt* self = CX509CertPoliciesExt::NewLC(aBinaryData, aPos);
   1.997 +	CleanupStack::Pop();
   1.998 +	return self;
   1.999 +	}
  1.1000 +
  1.1001 +EXPORT_C CX509CertPoliciesExt* CX509CertPoliciesExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1002 +	{
  1.1003 +	CX509CertPoliciesExt* self = new(ELeave) CX509CertPoliciesExt;
  1.1004 +	CleanupStack::PushL(self);
  1.1005 +	self->ConstructL(aBinaryData, aPos);
  1.1006 +	return self;
  1.1007 +	}
  1.1008 +
  1.1009 +void CX509CertPoliciesExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1010 +	{
  1.1011 +	TASN1DecSequence encSeq;
  1.1012 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
  1.1013 +	TInt count = seq->Count();
  1.1014 +	iPolicies = new(ELeave) CArrayPtrFlat<CX509CertPolicyInfo> (1);
  1.1015 +	TASN1DecGeneric* gen;
  1.1016 +	for (TInt i = 0; i < count; i++)
  1.1017 +		{
  1.1018 +		gen = seq->At(i);
  1.1019 +		CX509CertPolicyInfo* policy = CX509CertPolicyInfo::NewLC(gen->Encoding());
  1.1020 +		iPolicies->AppendL(policy);
  1.1021 +		CleanupStack::Pop();//policy
  1.1022 +		}
  1.1023 +	CleanupStack::PopAndDestroy();
  1.1024 +	}
  1.1025 +
  1.1026 +CX509CertPoliciesExt::~CX509CertPoliciesExt()
  1.1027 +	{
  1.1028 +	if (iPolicies != NULL)
  1.1029 +		{
  1.1030 +		iPolicies->ResetAndDestroy();
  1.1031 +		delete iPolicies;
  1.1032 +		}
  1.1033 +	}
  1.1034 +
  1.1035 +EXPORT_C const CArrayPtrFlat<CX509CertPolicyInfo>& CX509CertPoliciesExt::Policies() const
  1.1036 +	{
  1.1037 +	return *iPolicies;
  1.1038 +	}
  1.1039 +
  1.1040 +CX509CertPoliciesExt::CX509CertPoliciesExt()
  1.1041 +	{
  1.1042 +	}
  1.1043 +
  1.1044 +//7) policy mapping
  1.1045 +CX509PolicyMapping* CX509PolicyMapping::NewL(const TDesC8& aBinaryData)
  1.1046 +	{
  1.1047 +	TInt pos = 0;
  1.1048 +	return CX509PolicyMapping::NewL(aBinaryData, pos);
  1.1049 +	}
  1.1050 +
  1.1051 +CX509PolicyMapping* CX509PolicyMapping::NewLC(const TDesC8& aBinaryData)
  1.1052 +	{
  1.1053 +	TInt pos = 0;
  1.1054 +	return CX509PolicyMapping::NewLC(aBinaryData, pos);
  1.1055 +	}
  1.1056 +
  1.1057 +CX509PolicyMapping* CX509PolicyMapping::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1058 +	{
  1.1059 +	CX509PolicyMapping* self = CX509PolicyMapping::NewLC(aBinaryData, aPos);
  1.1060 +	CleanupStack::Pop();
  1.1061 +	return self;
  1.1062 +	}
  1.1063 +
  1.1064 +CX509PolicyMapping* CX509PolicyMapping::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1065 +	{
  1.1066 +	CX509PolicyMapping* self = new(ELeave) CX509PolicyMapping;
  1.1067 +	CleanupStack::PushL(self);
  1.1068 +	self->ConstructL(aBinaryData, aPos);
  1.1069 +	return self;
  1.1070 +	}
  1.1071 +
  1.1072 +EXPORT_C CX509PolicyMapping* CX509PolicyMapping::NewL(const CX509PolicyMapping& aMapping)
  1.1073 +	{
  1.1074 +	CX509PolicyMapping* self = CX509PolicyMapping::NewLC(aMapping);
  1.1075 +	CleanupStack::Pop();
  1.1076 +	return self;
  1.1077 +	}
  1.1078 +
  1.1079 +EXPORT_C CX509PolicyMapping* CX509PolicyMapping::NewLC(const CX509PolicyMapping& aMapping)
  1.1080 +	{
  1.1081 +	CX509PolicyMapping* self = new(ELeave) CX509PolicyMapping;
  1.1082 +	CleanupStack::PushL(self);
  1.1083 +	self->ConstructL(aMapping);
  1.1084 +	return self;
  1.1085 +	}
  1.1086 +
  1.1087 +void CX509PolicyMapping::ConstructL(const CX509PolicyMapping& aMapping)
  1.1088 +	{
  1.1089 +	iIssuerPolicy = aMapping.iIssuerPolicy->AllocL();
  1.1090 +	iSubjectPolicy = aMapping.iSubjectPolicy->AllocL();
  1.1091 +	}
  1.1092 +
  1.1093 +void CX509PolicyMapping::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1094 +	{
  1.1095 +	TASN1DecSequence encSeq;
  1.1096 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos);
  1.1097 +	if (seq->Count() < 2)
  1.1098 +		{
  1.1099 +		User::Leave(KErrArgument);
  1.1100 +		}
  1.1101 +	TASN1DecObjectIdentifier encOID;
  1.1102 +	iIssuerPolicy = encOID.DecodeDERL(*(seq->At(0)));
  1.1103 +	iSubjectPolicy = encOID.DecodeDERL(*(seq->At(1)));
  1.1104 +	CleanupStack::PopAndDestroy();
  1.1105 +	}
  1.1106 +
  1.1107 +CX509PolicyMapping::~CX509PolicyMapping()
  1.1108 +	{
  1.1109 +	delete iIssuerPolicy;
  1.1110 +	delete iSubjectPolicy;
  1.1111 +	}
  1.1112 +
  1.1113 +EXPORT_C TPtrC CX509PolicyMapping::IssuerPolicy() const
  1.1114 +	{
  1.1115 +	return iIssuerPolicy->Des();
  1.1116 +	}
  1.1117 +
  1.1118 +EXPORT_C TPtrC CX509PolicyMapping::SubjectPolicy() const
  1.1119 +	{
  1.1120 +	return iSubjectPolicy->Des();
  1.1121 +	}
  1.1122 +
  1.1123 +CX509PolicyMapping::CX509PolicyMapping()
  1.1124 +	{
  1.1125 +	}
  1.1126 +
  1.1127 +EXPORT_C CX509PolicyMappingExt* CX509PolicyMappingExt::NewL(const TDesC8& aBinaryData)
  1.1128 +	{
  1.1129 +	TInt pos = 0;
  1.1130 +	return CX509PolicyMappingExt::NewL(aBinaryData, pos);
  1.1131 +	}
  1.1132 +
  1.1133 +EXPORT_C CX509PolicyMappingExt* CX509PolicyMappingExt::NewLC(const TDesC8& aBinaryData)
  1.1134 +	{
  1.1135 +	TInt pos = 0;
  1.1136 +	return CX509PolicyMappingExt::NewLC(aBinaryData, pos);
  1.1137 +	}
  1.1138 +
  1.1139 +EXPORT_C CX509PolicyMappingExt* CX509PolicyMappingExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1140 +	{
  1.1141 +	CX509PolicyMappingExt* self = CX509PolicyMappingExt::NewLC(aBinaryData, aPos);
  1.1142 +	CleanupStack::Pop();
  1.1143 +	return self;
  1.1144 +	}
  1.1145 +
  1.1146 +EXPORT_C CX509PolicyMappingExt* CX509PolicyMappingExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1147 +	{
  1.1148 +	CX509PolicyMappingExt* self = new(ELeave) CX509PolicyMappingExt;
  1.1149 +	CleanupStack::PushL(self);
  1.1150 +	self->ConstructL(aBinaryData, aPos);
  1.1151 +	return self;
  1.1152 +	}
  1.1153 +
  1.1154 +void CX509PolicyMappingExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1155 +	{
  1.1156 +	TASN1DecSequence encSeq;
  1.1157 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
  1.1158 +	TInt count = seq->Count();
  1.1159 +
  1.1160 +	iPolicies = new(ELeave) CArrayPtrFlat<CX509PolicyMapping> (1);
  1.1161 +	TASN1DecGeneric* gen;
  1.1162 +	for (TInt i = 0; i < count; i++)
  1.1163 +		{
  1.1164 +		gen = seq->At(i);
  1.1165 +		CX509PolicyMapping* policy = CX509PolicyMapping::NewLC(gen->Encoding());
  1.1166 +		iPolicies->AppendL(policy);
  1.1167 +		CleanupStack::Pop();//policy
  1.1168 +		}
  1.1169 +	CleanupStack::PopAndDestroy();
  1.1170 +	}
  1.1171 +
  1.1172 +CX509PolicyMappingExt::~CX509PolicyMappingExt()
  1.1173 +	{
  1.1174 +	if (iPolicies != NULL)
  1.1175 +		{
  1.1176 +		iPolicies->ResetAndDestroy();
  1.1177 +		delete iPolicies;
  1.1178 +		}
  1.1179 +	}
  1.1180 +
  1.1181 +EXPORT_C const CArrayPtrFlat<CX509PolicyMapping>& CX509PolicyMappingExt::Mappings() const
  1.1182 +	{
  1.1183 +	return *iPolicies;
  1.1184 +	}
  1.1185 +
  1.1186 +CX509PolicyMappingExt::CX509PolicyMappingExt()
  1.1187 +	{
  1.1188 +	}
  1.1189 +
  1.1190 +//8) authority key ID
  1.1191 +EXPORT_C CX509AuthorityKeyIdExt* CX509AuthorityKeyIdExt::NewL(const TDesC8& aBinaryData)
  1.1192 +	{
  1.1193 +	TInt pos = 0;
  1.1194 +	return CX509AuthorityKeyIdExt::NewL(aBinaryData, pos);
  1.1195 +	}
  1.1196 +
  1.1197 +EXPORT_C CX509AuthorityKeyIdExt* CX509AuthorityKeyIdExt::NewLC(const TDesC8& aBinaryData)
  1.1198 +	{
  1.1199 +	TInt pos = 0;
  1.1200 +	return CX509AuthorityKeyIdExt::NewLC(aBinaryData, pos);
  1.1201 +	}
  1.1202 +
  1.1203 +EXPORT_C CX509AuthorityKeyIdExt* CX509AuthorityKeyIdExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1204 +	{
  1.1205 +	CX509AuthorityKeyIdExt* self = CX509AuthorityKeyIdExt::NewLC(aBinaryData, aPos);
  1.1206 +	CleanupStack::Pop();
  1.1207 +	return self;
  1.1208 +	}
  1.1209 +
  1.1210 +EXPORT_C CX509AuthorityKeyIdExt* CX509AuthorityKeyIdExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1211 +	{
  1.1212 +	CX509AuthorityKeyIdExt* self = new(ELeave) CX509AuthorityKeyIdExt;
  1.1213 +	CleanupStack::PushL(self);
  1.1214 +	self->ConstructL(aBinaryData, aPos);
  1.1215 +	return self;
  1.1216 +	}
  1.1217 +
  1.1218 +void CX509AuthorityKeyIdExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1219 +	{
  1.1220 +	TASN1DecSequence encSeq;
  1.1221 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos);
  1.1222 +	TInt count = seq->Count();
  1.1223 +	TInt pos = 0;
  1.1224 +
  1.1225 +	iAuthorityName = new(ELeave) CArrayPtrFlat<CX509GeneralName> (1);
  1.1226 +	TASN1DecGeneric* curr;
  1.1227 +	if (pos < count)
  1.1228 +		{
  1.1229 +		curr = seq->At(pos);
  1.1230 +		pos++;
  1.1231 +		if (curr->Class() != EContextSpecific)
  1.1232 +			{
  1.1233 +			User::Leave(KErrArgument);
  1.1234 +			}
  1.1235 +		switch(curr->Tag())
  1.1236 +			{
  1.1237 +			case 0:
  1.1238 +				{
  1.1239 +				DecodeKeyIdL(curr->Encoding());
  1.1240 +				break;
  1.1241 +				}
  1.1242 +			case 1:
  1.1243 +				{
  1.1244 +				DecodeNameL(curr->Encoding());
  1.1245 +				break;
  1.1246 +				}
  1.1247 +			case 2:
  1.1248 +				{
  1.1249 +				DecodeSerialNoL(curr->Encoding());
  1.1250 +				break;
  1.1251 +				}
  1.1252 +			default:
  1.1253 +				{
  1.1254 +				User::Leave(KErrArgument);
  1.1255 +				}
  1.1256 +			}
  1.1257 +		if (pos < count)
  1.1258 +			{
  1.1259 +			curr = seq->At(pos);
  1.1260 +			pos++;
  1.1261 +			if (curr->Class() != EContextSpecific)
  1.1262 +				{
  1.1263 +				User::Leave(KErrArgument);
  1.1264 +				}
  1.1265 +			switch(curr->Tag())
  1.1266 +				{
  1.1267 +				case 1:
  1.1268 +					{
  1.1269 +					DecodeNameL(curr->Encoding());
  1.1270 +					break;
  1.1271 +					}
  1.1272 +				case 2:
  1.1273 +					{
  1.1274 +					DecodeSerialNoL(curr->Encoding());
  1.1275 +					break;
  1.1276 +					}
  1.1277 +				default:
  1.1278 +					{
  1.1279 +					User::Leave(KErrArgument);
  1.1280 +					}
  1.1281 +				}
  1.1282 +			if (pos < count)
  1.1283 +				{
  1.1284 +				curr = seq->At(pos);
  1.1285 +				pos++;
  1.1286 +				if ((curr->Class() != EContextSpecific) || (curr->Tag() != 2))
  1.1287 +					{
  1.1288 +					User::Leave(KErrArgument);
  1.1289 +					}
  1.1290 +				DecodeSerialNoL(curr->Encoding());
  1.1291 +				}
  1.1292 +			}
  1.1293 +		}
  1.1294 +	if (!iKeyIdentifier)
  1.1295 +		{
  1.1296 +		iKeyIdentifier = HBufC8::NewL(1);
  1.1297 +		*iKeyIdentifier = KNullDesC8;
  1.1298 +		}
  1.1299 +	if (!iAuthorityCertSerialNumber)
  1.1300 +		{
  1.1301 +		iAuthorityCertSerialNumber = HBufC8::NewL(1);
  1.1302 +		*iAuthorityCertSerialNumber = KNullDesC8;
  1.1303 +		}
  1.1304 +	CleanupStack::PopAndDestroy();
  1.1305 +	}
  1.1306 +
  1.1307 +void CX509AuthorityKeyIdExt::DecodeNameL(const TDesC8& aBinaryData)
  1.1308 +	{
  1.1309 +	TASN1DecSequence encSeq;
  1.1310 +	TInt pos = 0;
  1.1311 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, pos, 1, KMaxTInt);
  1.1312 +	TInt count = seq->Count();
  1.1313 +	TASN1DecGeneric* gen;
  1.1314 +	for (TInt i = 0; i < count; i++)
  1.1315 +		{
  1.1316 +		gen = seq->At(i);
  1.1317 +		CX509GeneralName* gn = CX509GeneralName::NewLC(gen->Encoding());
  1.1318 +		iAuthorityName->AppendL(gn);
  1.1319 +		CleanupStack::Pop();//gn
  1.1320 +		}
  1.1321 +	CleanupStack::PopAndDestroy();
  1.1322 +	}
  1.1323 +
  1.1324 +void CX509AuthorityKeyIdExt::DecodeKeyIdL(const TDesC8& aBinaryData)
  1.1325 +	{
  1.1326 +	TASN1DecGeneric gen(aBinaryData);
  1.1327 +	gen.InitL();
  1.1328 +	if (iKeyIdentifier != NULL)
  1.1329 +		{
  1.1330 +		User::Leave(KErrArgument);
  1.1331 +		}
  1.1332 +	iKeyIdentifier = gen.GetContentDER().AllocL();
  1.1333 +	}
  1.1334 +
  1.1335 +void CX509AuthorityKeyIdExt::DecodeSerialNoL(const TDesC8& aBinaryData)
  1.1336 +	{
  1.1337 +	TASN1DecGeneric gen(aBinaryData);
  1.1338 +	gen.InitL();
  1.1339 +	if (iAuthorityCertSerialNumber != NULL)
  1.1340 +		{
  1.1341 +		User::Leave(KErrArgument);
  1.1342 +		}
  1.1343 +	iAuthorityCertSerialNumber = gen.GetContentDER().AllocL();
  1.1344 +	}
  1.1345 +
  1.1346 +CX509AuthorityKeyIdExt::~CX509AuthorityKeyIdExt()
  1.1347 +	{
  1.1348 +	if (iAuthorityName != NULL)
  1.1349 +		{
  1.1350 +		iAuthorityName->ResetAndDestroy();
  1.1351 +		}
  1.1352 +	delete iAuthorityName;
  1.1353 +	delete iAuthorityCertSerialNumber;
  1.1354 +	delete iKeyIdentifier;
  1.1355 +	}
  1.1356 +
  1.1357 +EXPORT_C const CArrayPtrFlat<CX509GeneralName>& CX509AuthorityKeyIdExt::AuthorityName() const
  1.1358 +	{
  1.1359 +	return *iAuthorityName;
  1.1360 +	}
  1.1361 +
  1.1362 +EXPORT_C TPtrC8 CX509AuthorityKeyIdExt::AuthorityCertSerialNumber() const
  1.1363 +	{
  1.1364 +	return iAuthorityCertSerialNumber->Des();
  1.1365 +	}
  1.1366 +
  1.1367 +EXPORT_C TPtrC8 CX509AuthorityKeyIdExt::KeyId() const
  1.1368 +	{
  1.1369 +	return iKeyIdentifier->Des();
  1.1370 +	}
  1.1371 +
  1.1372 +CX509AuthorityKeyIdExt::CX509AuthorityKeyIdExt()
  1.1373 +	{
  1.1374 +	}
  1.1375 +
  1.1376 +//9) subject key ID
  1.1377 +EXPORT_C CX509SubjectKeyIdExt* CX509SubjectKeyIdExt::NewL(const TDesC8& aBinaryData)
  1.1378 +	{
  1.1379 +	TInt pos = 0;
  1.1380 +	return CX509SubjectKeyIdExt::NewL(aBinaryData, pos);
  1.1381 +	}
  1.1382 +
  1.1383 +EXPORT_C CX509SubjectKeyIdExt* CX509SubjectKeyIdExt::NewLC(const TDesC8& aBinaryData)
  1.1384 +	{
  1.1385 +	TInt pos = 0;
  1.1386 +	return CX509SubjectKeyIdExt::NewLC(aBinaryData, pos);
  1.1387 +	}
  1.1388 +
  1.1389 +EXPORT_C CX509SubjectKeyIdExt* CX509SubjectKeyIdExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1390 +	{
  1.1391 +	CX509SubjectKeyIdExt* self = CX509SubjectKeyIdExt::NewLC(aBinaryData, aPos);
  1.1392 +	CleanupStack::Pop();
  1.1393 +	return self;
  1.1394 +	}
  1.1395 +
  1.1396 +EXPORT_C CX509SubjectKeyIdExt* CX509SubjectKeyIdExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1397 +	{
  1.1398 +	CX509SubjectKeyIdExt* self = new(ELeave) CX509SubjectKeyIdExt;
  1.1399 +	CleanupStack::PushL(self);
  1.1400 +	self->ConstructL(aBinaryData, aPos);
  1.1401 +	return self;
  1.1402 +	}
  1.1403 +
  1.1404 +void CX509SubjectKeyIdExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1405 +	{
  1.1406 +	TASN1DecOctetString octetStr;
  1.1407 +	iKeyIdentifier = octetStr.DecodeDERL(aBinaryData, aPos);
  1.1408 +	}
  1.1409 +
  1.1410 +EXPORT_C CX509SubjectKeyIdExt::~CX509SubjectKeyIdExt()
  1.1411 +	{
  1.1412 +	delete iKeyIdentifier;
  1.1413 +	}
  1.1414 +
  1.1415 +EXPORT_C TPtrC8 CX509SubjectKeyIdExt::KeyId() const
  1.1416 +	{
  1.1417 +	return iKeyIdentifier->Des();
  1.1418 +	}
  1.1419 +
  1.1420 +CX509SubjectKeyIdExt::CX509SubjectKeyIdExt()
  1.1421 +	{
  1.1422 +	}
  1.1423 +
  1.1424 +//10) extended key usage
  1.1425 +EXPORT_C CX509ExtendedKeyUsageExt* CX509ExtendedKeyUsageExt::NewL(const TDesC8& aBinaryData)
  1.1426 +	{
  1.1427 +	TInt pos = 0;
  1.1428 +	return CX509ExtendedKeyUsageExt::NewL(aBinaryData, pos);
  1.1429 +	}
  1.1430 +
  1.1431 +EXPORT_C CX509ExtendedKeyUsageExt* CX509ExtendedKeyUsageExt::NewLC(const TDesC8& aBinaryData)
  1.1432 +	{
  1.1433 +	TInt pos = 0;
  1.1434 +	return CX509ExtendedKeyUsageExt::NewLC(aBinaryData, pos);
  1.1435 +	}
  1.1436 +
  1.1437 +EXPORT_C CX509ExtendedKeyUsageExt* CX509ExtendedKeyUsageExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1438 +	{
  1.1439 +	CX509ExtendedKeyUsageExt* self = CX509ExtendedKeyUsageExt::NewLC(aBinaryData, aPos);
  1.1440 +	CleanupStack::Pop();
  1.1441 +	return self;
  1.1442 +	}
  1.1443 +
  1.1444 +EXPORT_C CX509ExtendedKeyUsageExt* CX509ExtendedKeyUsageExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1445 +	{
  1.1446 +	CX509ExtendedKeyUsageExt* self = new(ELeave) CX509ExtendedKeyUsageExt;
  1.1447 +	CleanupStack::PushL(self);
  1.1448 +	self->ConstructL(aBinaryData, aPos);
  1.1449 +	return self;
  1.1450 +	}
  1.1451 +
  1.1452 +void CX509ExtendedKeyUsageExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1453 +	{
  1.1454 +	TASN1DecSequence encSeq;
  1.1455 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
  1.1456 +	TInt count = seq->Count();
  1.1457 +
  1.1458 +	iKeyUsages = new(ELeave) CArrayPtrFlat<HBufC> (1);
  1.1459 +	TASN1DecGeneric* gen;
  1.1460 +	for (TInt i = 0; i < count; i++)
  1.1461 +		{
  1.1462 +		gen = seq->At(i);
  1.1463 +		TASN1DecObjectIdentifier encOID;
  1.1464 +		HBufC* usage = encOID.DecodeDERL(*gen);
  1.1465 +		CleanupStack::PushL(usage);
  1.1466 +		iKeyUsages->AppendL(usage);
  1.1467 +		CleanupStack::Pop();
  1.1468 +		}
  1.1469 +	CleanupStack::PopAndDestroy();
  1.1470 +	}
  1.1471 +
  1.1472 +EXPORT_C CX509ExtendedKeyUsageExt::~CX509ExtendedKeyUsageExt()
  1.1473 +	{
  1.1474 +	if (iKeyUsages != NULL)
  1.1475 +		{
  1.1476 +		iKeyUsages->ResetAndDestroy();
  1.1477 +		delete iKeyUsages;
  1.1478 +		}
  1.1479 +	}
  1.1480 +
  1.1481 +EXPORT_C const CArrayPtrFlat<HBufC>& CX509ExtendedKeyUsageExt::KeyUsages() const
  1.1482 +	{
  1.1483 +	return *iKeyUsages;
  1.1484 +	}
  1.1485 +
  1.1486 +CX509ExtendedKeyUsageExt::CX509ExtendedKeyUsageExt()
  1.1487 +	{
  1.1488 +	}
  1.1489 +
  1.1490 +//12) authority information access - CX509AccessDescription
  1.1491 +
  1.1492 +CX509AccessDescription* CX509AccessDescription::NewL(const TDesC8& aBinaryData)
  1.1493 +	{
  1.1494 +	TInt pos = 0;
  1.1495 +	return NewL(aBinaryData, pos);
  1.1496 +	}
  1.1497 +
  1.1498 +CX509AccessDescription* CX509AccessDescription::NewLC(const TDesC8& aBinaryData)
  1.1499 +	{
  1.1500 +	TInt pos = 0;
  1.1501 +	return NewLC(aBinaryData, pos);
  1.1502 +	}
  1.1503 +
  1.1504 +CX509AccessDescription* CX509AccessDescription::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1505 +	{
  1.1506 +	CX509AccessDescription* self = NewLC(aBinaryData, aPos);
  1.1507 +	CleanupStack::Pop(self);
  1.1508 +	return self;
  1.1509 +	}
  1.1510 +
  1.1511 +CX509AccessDescription* CX509AccessDescription::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1512 +	{
  1.1513 +	CX509AccessDescription* self = new (ELeave) CX509AccessDescription;
  1.1514 +	CleanupStack::PushL(self);
  1.1515 +	self->ConstructL(aBinaryData, aPos);
  1.1516 +	return self;
  1.1517 +	}
  1.1518 +
  1.1519 +CX509AccessDescription::CX509AccessDescription()
  1.1520 +	{
  1.1521 +	// empty
  1.1522 +	}
  1.1523 +
  1.1524 +void CX509AccessDescription::ConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1525 +	{
  1.1526 +	TASN1DecSequence encSeq;
  1.1527 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 2, 2);
  1.1528 +
  1.1529 +	TASN1DecGeneric* curr = seq->At(0);
  1.1530 +	TASN1DecObjectIdentifier encOID;
  1.1531 +	iMethodId = encOID.DecodeDERL(*curr);
  1.1532 +
  1.1533 +	curr = seq->At(1);
  1.1534 +	iLocation = CX509GeneralName::NewL(curr->Encoding());	
  1.1535 +
  1.1536 +	CleanupStack::PopAndDestroy(seq);
  1.1537 +	}
  1.1538 +
  1.1539 +CX509AccessDescription::~CX509AccessDescription()
  1.1540 +	{
  1.1541 +	delete iMethodId;
  1.1542 +	delete iLocation;
  1.1543 +	}
  1.1544 +
  1.1545 +EXPORT_C TPtrC CX509AccessDescription::Method() const
  1.1546 +	{
  1.1547 +	return *iMethodId;
  1.1548 +	}
  1.1549 +
  1.1550 +EXPORT_C const CX509GeneralName& CX509AccessDescription::Location() const
  1.1551 +	{
  1.1552 +	return *iLocation;
  1.1553 +	}
  1.1554 +
  1.1555 +//12) authority information access - CX509AuthInfoAccessExt
  1.1556 +
  1.1557 +EXPORT_C CX509AuthInfoAccessExt* CX509AuthInfoAccessExt::NewL(const TDesC8& aBinaryData)
  1.1558 +	{
  1.1559 +	TInt pos = 0;
  1.1560 +	return NewL(aBinaryData, pos);
  1.1561 +	}
  1.1562 +
  1.1563 +EXPORT_C CX509AuthInfoAccessExt* CX509AuthInfoAccessExt::NewLC(const TDesC8& aBinaryData)
  1.1564 +	{
  1.1565 +	TInt pos = 0;
  1.1566 +	return NewLC(aBinaryData, pos);
  1.1567 +	}
  1.1568 +
  1.1569 +EXPORT_C CX509AuthInfoAccessExt* CX509AuthInfoAccessExt::NewL(const TDesC8& aBinaryData, TInt& aPos)
  1.1570 +	{
  1.1571 +	CX509AuthInfoAccessExt* self = NewLC(aBinaryData, aPos);
  1.1572 +	CleanupStack::Pop(self);
  1.1573 +	return self;
  1.1574 +	}
  1.1575 +
  1.1576 +EXPORT_C CX509AuthInfoAccessExt* CX509AuthInfoAccessExt::NewLC(const TDesC8& aBinaryData, TInt& aPos)
  1.1577 +	{
  1.1578 +	CX509AuthInfoAccessExt* self = new (ELeave) CX509AuthInfoAccessExt;
  1.1579 +	CleanupStack::PushL(self);
  1.1580 +	self->ConstructL(aBinaryData, aPos);
  1.1581 +	return self;
  1.1582 +	}
  1.1583 +
  1.1584 +CX509AuthInfoAccessExt::CX509AuthInfoAccessExt()
  1.1585 +	{
  1.1586 +	// empty
  1.1587 +	}
  1.1588 +
  1.1589 +void CX509AuthInfoAccessExt::DoConstructL(const TDesC8& aBinaryData, TInt& aPos)
  1.1590 + 	{
  1.1591 +	TASN1DecSequence encSeq;
  1.1592 +	CArrayPtrFlat<TASN1DecGeneric>* seq = encSeq.DecodeDERLC(aBinaryData, aPos, 1, KMaxTInt);
  1.1593 +	TInt count = seq->Count();
  1.1594 +
  1.1595 +	iAccessDescs = new (ELeave) CArrayPtrFlat<CX509AccessDescription>(1);
  1.1596 +
  1.1597 +	for (TInt i = 0 ; i < count ; ++i)
  1.1598 +		{
  1.1599 +		TASN1DecGeneric* curr = seq->At(i);
  1.1600 +		CX509AccessDescription* desc = CX509AccessDescription::NewLC(curr->Encoding());
  1.1601 +		iAccessDescs->AppendL(desc);
  1.1602 +		CleanupStack::Pop(desc);
  1.1603 +		}
  1.1604 +
  1.1605 +	CleanupStack::PopAndDestroy(seq);
  1.1606 +	}
  1.1607 +
  1.1608 +EXPORT_C CX509AuthInfoAccessExt::~CX509AuthInfoAccessExt()
  1.1609 +	{
  1.1610 +	if (iAccessDescs)
  1.1611 +		{
  1.1612 +		iAccessDescs->ResetAndDestroy();
  1.1613 +		delete iAccessDescs;
  1.1614 +		}
  1.1615 +	}
  1.1616 +
  1.1617 +EXPORT_C const CArrayPtrFlat<CX509AccessDescription>& CX509AuthInfoAccessExt::AccessDescriptions() const
  1.1618 +	{
  1.1619 +	return *iAccessDescs;
  1.1620 +	}