|
1 /* |
|
2 * Copyright (c) 2002-2005 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 "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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include "sencertutils.h" |
|
26 #include <ssl.h> |
|
27 |
|
28 EXPORT_C HBufC8* SenCertUtils::CertInfoToStringLC(const TCertInfo& aCertInfo) |
|
29 { |
|
30 // |
|
31 // Convert TCertInfo to TDesC8 |
|
32 // |
|
33 TInt certLength = aCertInfo.iIssuerDNInfo.iCountry.Length(); |
|
34 certLength += aCertInfo.iIssuerDNInfo.iOrganizationUnit.Length(); |
|
35 certLength += aCertInfo.iIssuerDNInfo.iOrganization.Length(); |
|
36 certLength += aCertInfo.iIssuerDNInfo.iCommonName.Length(); |
|
37 certLength += aCertInfo.iSerialNo.Length() * 2; |
|
38 certLength += aCertInfo.iFingerprint.Length() * 2; |
|
39 |
|
40 HBufC8* casn = HBufC8::NewLC( certLength + 4); |
|
41 TPtr8 ptr = casn->Des(); |
|
42 |
|
43 |
|
44 if ( aCertInfo.iIssuerDNInfo.iCommonName.Length()) |
|
45 { |
|
46 ptr.Append( aCertInfo.iIssuerDNInfo.iCommonName); |
|
47 ptr.Append( KSenCASNDelimiter ); |
|
48 } |
|
49 |
|
50 if ( aCertInfo.iIssuerDNInfo.iOrganization.Length()) |
|
51 { |
|
52 ptr.Append( aCertInfo.iIssuerDNInfo.iOrganization); |
|
53 ptr.Append( KSenCASNDelimiter ); |
|
54 } |
|
55 |
|
56 if ( aCertInfo.iIssuerDNInfo.iOrganizationUnit.Length()) |
|
57 { |
|
58 ptr.Append( aCertInfo.iIssuerDNInfo.iOrganizationUnit); |
|
59 ptr.Append( KSenCASNDelimiter ); |
|
60 } |
|
61 |
|
62 if ( aCertInfo.iIssuerDNInfo.iCountry.Length()) |
|
63 { |
|
64 ptr.Append( aCertInfo.iIssuerDNInfo.iCountry); |
|
65 ptr.Append( KSenCASNDelimiter ); |
|
66 } |
|
67 |
|
68 if ( aCertInfo.iSerialNo.Length()) |
|
69 { |
|
70 //convert serialnumber to plain text |
|
71 for ( TInt i(0); i < aCertInfo.iSerialNo.Length(); i++) |
|
72 { |
|
73 ptr.AppendNum( aCertInfo.iSerialNo[i], EHex); |
|
74 } |
|
75 ptr.Append( KSenCASNDelimiter ); |
|
76 } |
|
77 |
|
78 if ( aCertInfo.iFingerprint.Length()) |
|
79 { |
|
80 //convert fingerprint to plain text |
|
81 for ( TInt i(0); i < aCertInfo.iFingerprint.Length(); i++) |
|
82 { |
|
83 ptr.AppendNum( aCertInfo.iFingerprint[i], EHex); |
|
84 } |
|
85 } |
|
86 return casn; |
|
87 } |
|
88 |
|
89 // End of file |
|
90 |
|
91 |