Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "pkcs12attribute.h"
21 using namespace PKCS12;
23 CDecPkcs12Attribute::CDecPkcs12Attribute()
27 EXPORT_C CDecPkcs12Attribute* CDecPkcs12Attribute::NewL(const TDesC8& aBagAttributes)
29 CDecPkcs12Attribute* self = new (ELeave) CDecPkcs12Attribute;
30 CleanupStack::PushL(self);
31 self->ConstructL(aBagAttributes);
32 CleanupStack::Pop(self);
36 CDecPkcs12Attribute::~CDecPkcs12Attribute()
39 iAttributeValue.ResetAndDestroy();
40 iAttributeValue.Close();
43 void CDecPkcs12Attribute::ConstructL(const TDesC8& aBagAttributes)
45 TASN1DecGeneric seqGen(aBagAttributes);
48 // Check if this is a Sequence
49 if (seqGen.Tag() != EASN1Sequence || seqGen.Class() != EUniversal)
51 User::Leave(KErrArgument);
55 CArrayPtrFlat<TASN1DecGeneric>* attributeSet = seq.DecodeDERLC(seqGen);
56 const TASN1DecGeneric* attributeSetAt0 = attributeSet->At(0);
57 if(attributeSetAt0->Tag() != EASN1ObjectIdentifier || attributeSetAt0->Class() != EUniversal)
59 User::Leave(KErrArgument);
62 // Decode the ObjectIdentifier
63 TASN1DecObjectIdentifier oid;
64 iAttributeId = oid.DecodeDERL(*attributeSetAt0);
66 const TASN1DecGeneric* attributeSetAt1 = attributeSet->At(1);
67 if(attributeSetAt1->Tag() != EASN1Set || attributeSetAt1->Class() != EUniversal)
69 User::Leave(KErrArgument);
74 CArrayPtrFlat<TASN1DecGeneric>* attributeValues = decSet.NewDERLC(attributeSetAt1->Encoding());
76 TInt attributeCount = attributeValues->Count();
78 for(TInt index = 0; index < attributeCount; ++index)
80 const TASN1DecGeneric* attributeValuesAt = attributeValues->At(index);
81 TASN1DecGeneric seqGen(*attributeValuesAt);
83 TPtrC8 attrValue = seqGen.Encoding();
84 TDesC8* attributeVal = attrValue.AllocL();
85 CleanupStack::PushL(attributeVal);
86 iAttributeValue.AppendL(attributeVal);
87 CleanupStack::Pop(attributeVal);
89 CleanupStack::PopAndDestroy(2,attributeSet); // attributeSet,attributeValues
93 EXPORT_C const TDesC& CDecPkcs12Attribute::AttributeId() const
98 EXPORT_C const RPointerArray<TDesC8>& CDecPkcs12Attribute::AttributeValue() const
100 return iAttributeValue;