author | Santosh Patil <santosh.v.patil@nokia.com> |
Wed, 08 Jul 2009 11:25:26 +0100 | |
changeset 0 | 2c201484c85f |
child 8 | 35751d3474b7 |
permissions | -rw-r--r-- |
0
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
1 |
/* |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
8 |
* |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
11 |
* |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
13 |
* |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
15 |
* This file contains the implementation of the ASN1 Sequence and Sequence-of |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
16 |
* object, as described in X208 Sections 20 and 21 and X209 Sections 14 and |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
17 |
* 15. The sequence object can contain an ordered series of zero, one or more |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
18 |
* other ASN1 objects. The sequence-of object contains zero, one or more of |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
19 |
* the objects described in its definition. The data encodings of both these |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
20 |
* objects is identical. The ordering of the objects contained within the |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
21 |
* sequence is defined outside the scope of this object, normally this would |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
22 |
* be handled by an object deriving from this object but it may be handled |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
23 |
* somewhere else. |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
24 |
* |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
25 |
*/ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
26 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
27 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
28 |
#include "asn1dec.h" |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
29 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
30 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
31 |
void TASN1DecSequence::CleanupSequence(TAny* aArray) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
32 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
33 |
CArrayPtrFlat<TASN1DecGeneric>* array = REINTERPRET_CAST(CArrayPtrFlat<TASN1DecGeneric>*, aArray); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
34 |
array->ResetAndDestroy(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
35 |
delete array; |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
36 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
37 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
38 |
EXPORT_C TASN1DecSequence::TASN1DecSequence() |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
39 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
40 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
41 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
42 |
EXPORT_C CArrayPtrFlat<TASN1DecGeneric>* TASN1DecSequence::DecodeDERLC(const TDesC8& aSource,TInt& aPos) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
43 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
44 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
45 |
CArrayPtrFlat<TASN1DecGeneric>* ret = new(ELeave) CArrayPtrFlat<TASN1DecGeneric> (1); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
46 |
TCleanupItem cleanupSeq(TASN1DecSequence::CleanupSequence, ret); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
47 |
CleanupStack::PushL(cleanupSeq); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
48 |
TASN1DecGeneric gen(aSource.Right(aSource.Length() - aPos)); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
49 |
gen.InitL(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
50 |
aPos += gen.LengthDER(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
51 |
DecodeContentsL(gen.GetContentDER(), *ret); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
52 |
return ret; |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
53 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
54 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
55 |
EXPORT_C CArrayPtrFlat<TASN1DecGeneric>* TASN1DecSequence::DecodeDERLC(const TASN1DecGeneric& aSource) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
56 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
57 |
CArrayPtrFlat<TASN1DecGeneric>* ret = new(ELeave) CArrayPtrFlat<TASN1DecGeneric> (1); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
58 |
TCleanupItem cleanupSeq(TASN1DecSequence::CleanupSequence, ret); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
59 |
CleanupStack::PushL(cleanupSeq); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
60 |
DecodeContentsL(aSource.GetContentDER(), *ret); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
61 |
return ret; |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
62 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
63 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
64 |
EXPORT_C CArrayPtrFlat<TASN1DecGeneric>* TASN1DecSequence::DecodeDERLC(const TDesC8& aSource,TInt& aPos, TInt aMin, TInt aMax) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
65 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
66 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
67 |
CArrayPtrFlat<TASN1DecGeneric>* ret = DecodeDERLC(aSource, aPos); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
68 |
TInt count = ret->Count(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
69 |
if ((count < aMin) || (count > aMax)) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
70 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
71 |
User::Leave(KErrArgument); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
72 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
73 |
return ret; |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
74 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
75 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
76 |
EXPORT_C CArrayPtrFlat<TASN1DecGeneric>* TASN1DecSequence::DecodeDERLC(const TASN1DecGeneric& aSource, TInt aMin, TInt aMax) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
77 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
78 |
CArrayPtrFlat<TASN1DecGeneric>* ret = DecodeDERLC(aSource); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
79 |
TInt count = ret->Count(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
80 |
if ((count < aMin) || (count > aMax)) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
81 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
82 |
User::Leave(KErrArgument); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
83 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
84 |
return ret; |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
85 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
86 |
|
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
87 |
void TASN1DecSequence::DecodeContentsL(const TDesC8& aSource, CArrayPtrFlat<TASN1DecGeneric>& aDest) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
88 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
89 |
TInt pos = 0; |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
90 |
while (pos < aSource.Length()) |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
91 |
{ |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
92 |
TPtrC8 p(aSource.Right(aSource.Length() - pos)); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
93 |
TASN1DecGeneric* Decoded = new(ELeave) TASN1DecGeneric(p); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
94 |
CleanupStack::PushL(Decoded); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
95 |
Decoded->InitL(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
96 |
aDest.AppendL(Decoded); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
97 |
pos+=Decoded->LengthDER(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
98 |
CleanupStack::Pop(); |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
99 |
} |
2c201484c85f
Move the Security package to EPL, and add the implementations of the cryptographic algorithms
Santosh Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
100 |
} |