sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@publishedPartner
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifndef __PKCS7_DIGEST_INFO_H__
|
sl@0
|
26 |
#define __PKCS7_DIGEST_INFO_H__
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <e32base.h>
|
sl@0
|
29 |
#include <x509cert.h>
|
sl@0
|
30 |
#include <signed.h>
|
sl@0
|
31 |
#include <asn1dec.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
Provides the means to decode PKCS#7 encoded DigestInfo Structure.
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
class CPKCS7DigestInfo : public CBase
|
sl@0
|
37 |
{
|
sl@0
|
38 |
public:
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
Creates a new PKCS#7 DigestInfo object.
|
sl@0
|
41 |
@param aRawData contains a PKCS#7 DigestInfo Structure
|
sl@0
|
42 |
@return A pointer to the newly allocated object.
|
sl@0
|
43 |
@leave KErrArgument if digestAlgorithm and digest is not present.
|
sl@0
|
44 |
@leave KErrNotSupported if algorithm is other than MD2, MD5 and SHA1.
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
IMPORT_C static CPKCS7DigestInfo* NewL(const TDesC8& aRawData);
|
sl@0
|
47 |
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
An Algorithm present DigestAlgorithmIdentifier.
|
sl@0
|
50 |
@return The enum which identifies the type of Algorithm
|
sl@0
|
51 |
used to obtain the hash.
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
IMPORT_C TAlgorithmId Algorithm() const;
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
Encoded Parameters present in the DigestAlgorithmIdentifier.
|
sl@0
|
57 |
The client has to check for data length. It is 0 in case there are no EncodedParams
|
sl@0
|
58 |
@return The Encoded Parameters which is in the DigestAlgorithmIdentifier.
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
IMPORT_C const TPtrC8& EncodedParams() const;
|
sl@0
|
61 |
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
The Digest which is in the DigestInfo.
|
sl@0
|
64 |
@return The Digest which is in the DigestInfo and is an Octet String.
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
IMPORT_C const TDesC8& Digest() const;
|
sl@0
|
67 |
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
Destructor.
|
sl@0
|
70 |
*/
|
sl@0
|
71 |
virtual ~CPKCS7DigestInfo();
|
sl@0
|
72 |
|
sl@0
|
73 |
private:
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
Constructor.
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
CPKCS7DigestInfo();
|
sl@0
|
78 |
|
sl@0
|
79 |
/**
|
sl@0
|
80 |
Copy Constructor.
|
sl@0
|
81 |
@param aDigestInfo A CPKCS7DigestInfo object.
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
CPKCS7DigestInfo(const CPKCS7DigestInfo& aDigestInfo);
|
sl@0
|
84 |
|
sl@0
|
85 |
/**
|
sl@0
|
86 |
Assignment operator.
|
sl@0
|
87 |
@param aDigestInfo A CPKCS7DigestInfo object.
|
sl@0
|
88 |
@return A reference to CPKCS7DigestInfo class.
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
CPKCS7DigestInfo& operator=(const CPKCS7DigestInfo& aDigestInfo);
|
sl@0
|
91 |
|
sl@0
|
92 |
/**
|
sl@0
|
93 |
Decodes the given ASN1 DigestInfo. Below is the ASN1 syntax
|
sl@0
|
94 |
|
sl@0
|
95 |
DigestInfo ::= SEQUENCE
|
sl@0
|
96 |
{
|
sl@0
|
97 |
digestAlgorithm DigestAlgorithmIdentifier,
|
sl@0
|
98 |
digest Digest
|
sl@0
|
99 |
}
|
sl@0
|
100 |
Digest ::= OCTET String
|
sl@0
|
101 |
DigestAlgorithmIdentifier ::= AlgorithmIdentifier
|
sl@0
|
102 |
AlgorithmIdentifier ::= SEQUENCE
|
sl@0
|
103 |
{
|
sl@0
|
104 |
algorithm ALGORITHM.&id({SupportedAlgorithms}),
|
sl@0
|
105 |
parameters ALGORITHM.&Type({SupportedAlgorithms}{@ algorithm}) OPTIONAL
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
@param aRawData A descriptor containing the PKCS7 DigestInfo Sequence.
|
sl@0
|
109 |
@leave KErrArgument if digestAlgorithm and digest is not present.
|
sl@0
|
110 |
@leave KErrNotSupported if algorithm is other than MD2, MD5 and SHA1.
|
sl@0
|
111 |
@see TASN1DecGeneric, CX509AlgorithmIdentifier.
|
sl@0
|
112 |
*/
|
sl@0
|
113 |
void ConstructL(const TDesC8& aRawData);
|
sl@0
|
114 |
|
sl@0
|
115 |
private:
|
sl@0
|
116 |
/**
|
sl@0
|
117 |
The object identifier which identifies the message-digest algorithm.
|
sl@0
|
118 |
A message-digest algorithm maps an octet string (the message) to
|
sl@0
|
119 |
another octet string (the message digest)
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
TAlgorithmId iAlgorithmId;
|
sl@0
|
122 |
|
sl@0
|
123 |
/** Encoded Parameters which is in the DigestAlgorithmIdentifier */
|
sl@0
|
124 |
TPtrC8 iEncodedParams;
|
sl@0
|
125 |
|
sl@0
|
126 |
/**
|
sl@0
|
127 |
The Digest is present in the DigestInfo.
|
sl@0
|
128 |
It is the result of the message-digesting process
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
TPtrC8 iDigest;
|
sl@0
|
131 |
};
|
sl@0
|
132 |
|
sl@0
|
133 |
#endif //__PKCS7_DIGEST_INFO_H__
|