First public contribution.
2 * Copyright (c) 2003-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 "pkcs7signerinfo.h"
20 #include "pkcs7issuerserial.h"
21 #include "pkcs7asn1.h"
26 CPKCS7SignerInfo* CPKCS7SignerInfo::NewL(const TDesC8& aRawData)
28 CPKCS7SignerInfo* self = new (ELeave) CPKCS7SignerInfo();
29 CleanupStack::PushL(self);
30 self->ConstructL(aRawData);
31 CleanupStack::Pop(self);
35 CPKCS7SignerInfo::~CPKCS7SignerInfo(void)
37 delete iIssuerAndSerialNumber;
38 delete iDigestAlgorithm;
39 delete iDigestEncryptionAlgorithm;
40 delete iEncryptedDigest;
43 CPKCS7SignerInfo::CPKCS7SignerInfo(void)
47 EXPORT_C TInt CPKCS7SignerInfo::Version() const
52 EXPORT_C const CPKCS7IssuerAndSerialNumber& CPKCS7SignerInfo::IssuerAndSerialNumber() const
54 return *iIssuerAndSerialNumber;
57 EXPORT_C const CX509AlgorithmIdentifier& CPKCS7SignerInfo::DigestAlgorithm() const
59 return *iDigestAlgorithm;
62 EXPORT_C const CX509AlgorithmIdentifier& CPKCS7SignerInfo::DigestEncryptionAlgorithm() const
64 return *iDigestEncryptionAlgorithm;
67 EXPORT_C const TPtrC8 CPKCS7SignerInfo::EncryptedDigest() const
69 return *iEncryptedDigest;
73 void CPKCS7SignerInfo::ConstructL(const TDesC8& aRawData)
75 CArrayPtr<TASN1DecGeneric>* signerInfo = PKCS7ASN1::DecodeSequenceLC(aRawData, 5, 7);
76 TASN1DecInteger decInt;
80 iVersion = decInt.DecodeDERShortL(*signerInfo->At(0));
82 iIssuerAndSerialNumber = CPKCS7IssuerAndSerialNumber::NewL(signerInfo->At(1)->Encoding());
84 iDigestAlgorithm = CX509AlgorithmIdentifier::NewL(signerInfo->At(2)->Encoding());
86 if(signerInfo->At(pos)->Tag() == 0)
88 // authenticated attributes not supported at this time
91 iDigestEncryptionAlgorithm = CX509AlgorithmIdentifier::NewL(signerInfo->At(pos++)->Encoding());
92 DecodeEncryptedDigestL(signerInfo->At(pos++)->Encoding());
94 if(pos < signerInfo->Count() && (signerInfo->At(pos)->Tag() == 0))
96 // unauthenticated attributes not supported at this time
100 CleanupStack::PopAndDestroy(signerInfo);
103 void CPKCS7SignerInfo::DecodeEncryptedDigestL(const TDesC8& aRawData)
105 TASN1DecGeneric decGen(aRawData);
108 if(decGen.Tag() == EASN1OctetString)
110 TASN1DecOctetString decOct;
111 iEncryptedDigest = decOct.DecodeDERL(decGen);
115 User::Leave(KErrArgument);