|
1 /* |
|
2 * Copyright (c) 2004 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 // INCLUDES |
|
22 #include <e32std.h> |
|
23 #include "srtpmasterkey.h" |
|
24 #include "srtpmastersalt.h" |
|
25 #include "srtpcryptocontext.h" |
|
26 #include "srtpdef.h" |
|
27 #include "srtputils.h" |
|
28 |
|
29 |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // Two-phased constructor. Used when stream uses its own cryptographic context |
|
33 // |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C CSRTPMasterSalt* CSRTPMasterSalt::NewL( const TDesC8& aKey, TUint aN_S ) |
|
37 { |
|
38 CSRTPMasterSalt* self = CSRTPMasterSalt::NewLC( aKey, aN_S ); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Two-phased constructor. Used when stream uses its own cryptographic context |
|
45 // |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C CSRTPMasterSalt* CSRTPMasterSalt::NewLC( const TDesC8& aKey, TUint aN_S ) |
|
49 { |
|
50 |
|
51 CSRTPMasterSalt* self = new( ELeave )CSRTPMasterSalt ( aN_S ); |
|
52 |
|
53 |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( aKey ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CSRTPMasterSalt::CSRTPMasterSalt |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CSRTPMasterSalt::CSRTPMasterSalt( TUint aN_S ) : |
|
64 iN_S( aN_S ) |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSRTPMasterSalt::ConstructL |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CSRTPMasterSalt::ConstructL( const TDesC8& aKey ) |
|
73 { |
|
74 iKey = aKey.AllocL(); |
|
75 if(aKey.Length()>14) |
|
76 { |
|
77 TSRTPUtils::HexString( *iKey ); |
|
78 } |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CSRTPMasterSalt::~CSRTPMasterSalt |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CSRTPMasterSalt::~CSRTPMasterSalt( ) |
|
86 |
|
87 { |
|
88 delete iKey; |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CSRTPMasterSalt::MasterSalt |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C const TDesC8& CSRTPMasterSalt::MasterSalt() const |
|
97 { |
|
98 return *iKey; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CSRTPMasterSalt::SaltLength |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C TUint CSRTPMasterSalt::SaltLength() const |
|
106 { |
|
107 return iN_S; |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CSRTPMasterSalt::operator= |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 const CSRTPMasterSalt& CSRTPMasterSalt::operator=(const CSRTPMasterSalt& aSalt) |
|
116 { |
|
117 return aSalt; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CSRTPMasterSalt::Valid() |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C TBool CSRTPMasterSalt::Valid() const |
|
125 { |
|
126 if (iKey->Length() != KSRTPDefaultMasterSaltLength/8) |
|
127 { |
|
128 return EFalse; |
|
129 } |
|
130 |
|
131 if (iN_S != KSRTPDefSessionSaltingKeyLength) |
|
132 { |
|
133 return EFalse; |
|
134 } |
|
135 |
|
136 return ETrue; |
|
137 } |
|
138 |