First public contribution.
2 * Copyright (c) 2006-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.
30 #include <cmscertchoice.h>
32 class CCmsCertificateChoice;
33 class CX509AlgorithmIdentifier;
34 class CX509Certificate;
38 class TASN1DecGeneric;
39 class CASN1EncObjectIdentifier;
43 A utility class contains a set of static functions for encoding and decoding the
44 CMS signed data relevant CMS structures.
50 Decode the content type in CMS content info and encapsulated info.
51 @param aASN1DecGeneric the ASN decoded structure of the content info
52 @return the type of the content info.
54 static TInt DecodeContentTypeL(const TASN1DecGeneric* aASN1DecGeneric);
57 Encode the content type in CMS content info and encapsulated info.
58 @param aContentType the type of the content info
59 @return the ASN.1 oid instance of the content type.
61 static CASN1EncObjectIdentifier* EncodeContentTypeLC(TInt aContentType);
64 Add an encoded attribute certificate in the certificate set if it is not in the list already.
65 @param aCertList the certificate list to which the certificate is added
66 @param aCert the encoded certificate to be added.
67 @param aType the type of the encoded certificate.
69 static void AddCertificateL(RPointerArray<CCmsCertificateChoice>& aCertList, const TDesC8& aCert, CCmsCertificateChoice::TCertificateType aType);
72 Add an X509 certificate in the certificate set if it is not in the list already.
73 @param aCertList the certificate list to which the certificate is added
74 @param aCert the x509 certificate to be added.
76 static void AddCertificateL(RPointerArray<CCmsCertificateChoice>& aCertList, const CX509Certificate& aCert);
79 Add an algorithm in the algorithm set if it is not in the list already.
80 @param aAlgorithmIdList the algorithm list to which the algorithm is added
81 @param aDigestAlgorithm the digest algorithm identifier
83 static void AddAlgorithmIdentifierL(RPointerArray<CX509AlgorithmIdentifier>& aAlgorithmIdList, TAlgorithmId aDigestAlgorithm);
86 Decode the algorithm identifier set
87 @param aDigestAlgorithms the algorithm list to which the decoded algorithms is added
88 @param aRawData the encoded algorithm identifier set
90 static void DecodeDigestAlgorithmsL(RPointerArray<CX509AlgorithmIdentifier>& aDigestAlgorithms, const TDesC8& aRawData);
93 Decode the certificate set
94 @param aDigestAlgorithms the certficate list to which the decoded certificates is added
95 @param aRawData the encoded certficate set
97 static void DecodeCertificatesL(RPointerArray<CCmsCertificateChoice>& aCertificates, const TDesC8& aRawData);
100 Encode the certficate set and put the encoding on the cleanup stack
101 @param aCertList the certificates list to be encoded.
102 @return the ASN.1 DER encoding of certificate set
104 static CASN1EncBase* EncodeCertificatesLC(const RPointerArray<CCmsCertificateChoice>& aCertList);
107 Encode the digest algorithm set and put the encoding on the cleanup stack.
108 @param aCertList the certificates list to be encoded.
109 @return the ASN.1 DER encoding of certificate set
111 static CASN1EncBase* EncodeDigestAlgorithmsLC(const RPointerArray<CX509AlgorithmIdentifier>& aDigestAlgorithms);
114 Dncode the octet string
115 @param aRawData the certificates list to be encoded.
116 @param aBuf the buffer to hold the octet string.
118 static void DecodeOctetStringL(const TDesC8& aRawData, HBufC8*& aBuf);
121 Create a hash from the given algorithm identifier and put it on the cleanup stack.
122 @param aAlgorithm the hash identifier.
125 static CMessageDigest* CreateHashLC(TAlgorithmId aAlgorithm);
128 Create the DSA signature of the given hash.
129 @param aHash the hash used to create signature.
130 @param aKey the DSA private key used to create signature
131 @return the descriptor holds the signature.
133 static HBufC8* CreateSignatureL(const TDesC8& aHash, const CDSAPrivateKey& aKey);
136 Create the RSA signature of the given hash.
137 @param aHash the hash used to create signature.
138 @param aKey the RSA private key used to create signature
139 @return the descriptor holds the signature.
141 static HBufC8* CreateSignatureL(const TDesC8& aHash, const CRSAPrivateKey& aKey);
144 Create the RSA signature of the given data, algorithm and private key.
145 @param aDataToBeSigned the data content to be signed.
146 @param aIsHash if the first paramter is a hash
147 @param aAlgorithm the digest algorithm used to create hash
148 @param aKey the RSA private key.
149 @return the descriptor holds the signature.
151 static HBufC8* CreateSignatureL(const TDesC8& aDataToBeSigned, TBool aIsHash, TAlgorithmId aAlgorithm, const CRSAPrivateKey& aKey);
154 Create the DSA signature of the given data, algorithm and private key.
155 @param aDataToBeSigned the data content to be signed.
156 @param aIsHash if the first paramter is a hash
157 @param aAlgorithm the digest algorithm used to create hash
158 @param aKey the DSA private key.
159 @return the descriptor holds the signature.
161 static HBufC8* CreateSignatureL(const TDesC8& aDataToBeSigned, TBool aIsHash, TAlgorithmId aAlgorithm, const CDSAPrivateKey& aKey);
164 Create the raw data from the ASN.1 class.
165 @param aEncoding the reference of the ASN.1 class
166 @return the descritor holds the raw data.
168 static HBufC8* CreateDEREncodingLC(const CASN1EncBase& aEncoding);