equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation for DER encoding of Booleans |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <asn1enc.h> |
|
21 |
|
22 const TUint8 KTrueEncodingDER = 0xFF; |
|
23 const TUint8 KFalseEncodingDER = 0x00; |
|
24 |
|
25 EXPORT_C CASN1EncBoolean* CASN1EncBoolean::NewLC(const TBool aBool) |
|
26 { |
|
27 CASN1EncBoolean* self = new (ELeave) CASN1EncBoolean(aBool); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 return self; |
|
31 } |
|
32 |
|
33 EXPORT_C CASN1EncBoolean* CASN1EncBoolean::NewL(const TBool aBool) |
|
34 { |
|
35 CASN1EncBoolean* self = NewLC(aBool); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CASN1EncBoolean::CASN1EncBoolean(const TBool aBool) |
|
41 : CASN1EncPrimitive(EASN1Boolean), iBool(aBool) |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 void CASN1EncBoolean::CalculateContentsLengthDER() |
|
47 { |
|
48 iContentsLengthDER = 1; |
|
49 } |
|
50 |
|
51 |
|
52 void CASN1EncBoolean::WriteContentsDERL(TDes8& aBuf) const |
|
53 { |
|
54 if (iBool) |
|
55 { |
|
56 aBuf[0] = KTrueEncodingDER; |
|
57 } |
|
58 else |
|
59 { |
|
60 aBuf[0] = KFalseEncodingDER; |
|
61 } |
|
62 } |