First public contribution.
2 * Copyright (c) 2007-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.
15 * CPKCS9ChallengePasswordAttr and CPKCS9ExtensionRequestAttr class implementation.
23 #include <pkcs9attr.h>
25 // CPKCS9ChallengePasswordAttr ////////////////////////////////////////////////////////////
27 EXPORT_C CPKCS9ChallengePasswordAttr* CPKCS9ChallengePasswordAttr::NewLC(const TDesC8& aPassword)
29 CPKCS9ChallengePasswordAttr* self = new (ELeave) CPKCS9ChallengePasswordAttr;
30 CleanupStack::PushL(self);
31 self->ConstructL(aPassword);
35 EXPORT_C CPKCS9ChallengePasswordAttr* CPKCS9ChallengePasswordAttr::NewL(const TDesC8& aPassword)
37 CPKCS9ChallengePasswordAttr* self = NewLC(aPassword);
38 CleanupStack::Pop(self);
42 EXPORT_C void CPKCS9ChallengePasswordAttr::ResetL(const TDesC8& aPassword)
46 ConstructL(aPassword);
49 CPKCS9ChallengePasswordAttr::CPKCS9ChallengePasswordAttr()
53 CPKCS9ChallengePasswordAttr::~CPKCS9ChallengePasswordAttr()
57 CASN1EncBase* CPKCS9ChallengePasswordAttr::GetEncodingLC()
59 return CPKCSAttributeBase::GetEncodingLC();
62 void CPKCS9ChallengePasswordAttr::ConstructL(const TDesC8& aPassword)
64 // Size of password string should be between bounds
65 if ((aPassword.Length() < KPkcs9StringLB) || (aPassword.Length() > KPkcs9StringUB))
67 User::Leave(KErrArgument);
70 iRoot = CASN1EncSequence::NewL();
71 CASN1EncObjectIdentifier* oid = CASN1EncObjectIdentifier::NewLC(KPkcs9ChallengePasswordAttrOID);
72 iRoot->AddAndPopChildL(oid);
73 iValueSet = CASN1EncSet::NewLC();
74 iRoot->AddAndPopChildL(iValueSet); // Takes ownership
75 CASN1EncPrintableString* value = CASN1EncPrintableString::NewLC(aPassword);
76 iValueSet->AddAndPopChildL(value);
79 // CPKCS9ExtensionRequestAttr ////////////////////////////////////////////////////////////
81 EXPORT_C CPKCS9ExtensionRequestAttr* CPKCS9ExtensionRequestAttr::NewLC(const CX509CertExtension& aExtension)
83 CPKCS9ExtensionRequestAttr* self = new (ELeave) CPKCS9ExtensionRequestAttr;
84 CleanupStack::PushL(self);
85 self->ConstructL(aExtension);
89 EXPORT_C CPKCS9ExtensionRequestAttr* CPKCS9ExtensionRequestAttr::NewL(const CX509CertExtension& aExtension)
91 CPKCS9ExtensionRequestAttr* self = NewLC(aExtension);
92 CleanupStack::Pop(self);
96 EXPORT_C void CPKCS9ExtensionRequestAttr::AddExtensionL(const CX509CertExtension& aExtension)
98 CASN1EncSequence *extension = aExtension.EncodeASN1DERLC();
99 iExtSeq->AddAndPopChildL(extension);
102 EXPORT_C void CPKCS9ExtensionRequestAttr::ResetL(const CX509CertExtension& aExtension)
106 ConstructL(aExtension);
109 CPKCS9ExtensionRequestAttr::CPKCS9ExtensionRequestAttr()
113 CPKCS9ExtensionRequestAttr::~CPKCS9ExtensionRequestAttr()
117 CASN1EncBase* CPKCS9ExtensionRequestAttr::GetEncodingLC()
119 return CPKCSAttributeBase::GetEncodingLC();
122 void CPKCS9ExtensionRequestAttr::ConstructL(const CX509CertExtension& aExtension)
124 iRoot = CASN1EncSequence::NewL();
125 CASN1EncObjectIdentifier* oid = CASN1EncObjectIdentifier::NewLC(KPkcs9ExtensionRequestAttrOID);
126 iRoot->AddAndPopChildL(oid);
127 iValueSet = CASN1EncSet::NewLC();
128 iRoot->AddAndPopChildL(iValueSet); // Takes ownership
129 iExtSeq = CASN1EncSequence::NewLC();
130 iValueSet->AddAndPopChildL(iExtSeq);
131 CASN1EncSequence *extension = aExtension.EncodeASN1DERLC();
132 iExtSeq->AddAndPopChildL(extension);