75 HBufC8* result = HBufC8::NewL(20); |
75 HBufC8* result = HBufC8::NewL(20); |
76 TPtr8 ptrOutputBuff = result->Des(); |
76 TPtr8 ptrOutputBuff = result->Des(); |
77 |
77 |
78 CleanupStack::PushL(result); |
78 CleanupStack::PushL(result); |
79 |
79 |
80 CSHA1* sha1 = CSHA1::NewL(); |
80 if ( !iHmac || !iKey || (*iKey != aKey) ) |
81 CleanupStack::PushL(sha1); |
81 { |
|
82 CreateHmacL(aKey); |
|
83 } |
82 |
84 |
83 CHMAC *hmac = CHMAC::NewL(aKey, sha1); |
|
84 CleanupStack::Pop(sha1); |
|
85 CleanupStack::Pop(result); |
85 CleanupStack::Pop(result); |
86 |
86 |
87 SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Length is ", aAuthPortion.Length() ); |
87 SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Length is ", aAuthPortion.Length() ); |
88 SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Size is ", aAuthPortion.Size()); |
88 SRTP_DEBUG_TINT_VALUE( "HMAC INPUT and INPUT Size is ", aAuthPortion.Size()); |
89 SRTP_DEBUG_PACKET ( DES_AS_8_BIT(aAuthPortion) ); |
89 SRTP_DEBUG_PACKET ( DES_AS_8_BIT(aAuthPortion) ); |
90 |
90 |
91 if(aRoc.Length()) |
91 if(aRoc.Length()) |
92 { |
92 { |
93 hmac->Update(DES_AS_8_BIT(aAuthPortion)); |
93 iHmac->Update(DES_AS_8_BIT(aAuthPortion)); |
94 buf.Copy(hmac->Final(DES_AS_8_BIT(aRoc))); |
94 buf.Copy(iHmac->Final(DES_AS_8_BIT(aRoc))); |
95 } |
95 } |
96 else |
96 else |
97 { |
97 { |
98 buf.Copy(hmac->Final(DES_AS_8_BIT(aAuthPortion))); |
98 buf.Copy(iHmac->Final(DES_AS_8_BIT(aAuthPortion))); |
99 } |
99 } |
100 *result = buf; |
100 *result = buf; |
101 ptrOutputBuff.SetLength(aBitLength/8); |
101 ptrOutputBuff.SetLength(aBitLength/8); |
102 |
|
103 delete hmac; |
|
104 |
102 |
105 SRTP_DEBUG_DETAIL( "HMAC caculated Authentication tag"); |
103 SRTP_DEBUG_DETAIL( "HMAC caculated Authentication tag"); |
106 SRTP_DEBUG_PACKET( *result ); |
104 SRTP_DEBUG_PACKET( *result ); |
107 SRTP_DEBUG_DETAIL( "CSRTPAuthentication_HMAC_SHA1::AuthenticateL Exit" ); |
105 SRTP_DEBUG_DETAIL( "CSRTPAuthentication_HMAC_SHA1::AuthenticateL Exit" ); |
108 |
106 |
122 // --------------------------------------------------------------------------- |
120 // --------------------------------------------------------------------------- |
123 // CSRTPAuthentication_HMAC_SHA1::~CSRTPAuthentication_HMAC_SHA1 |
121 // CSRTPAuthentication_HMAC_SHA1::~CSRTPAuthentication_HMAC_SHA1 |
124 // --------------------------------------------------------------------------- |
122 // --------------------------------------------------------------------------- |
125 // |
123 // |
126 CSRTPAuthentication_HMAC_SHA1::~CSRTPAuthentication_HMAC_SHA1() |
124 CSRTPAuthentication_HMAC_SHA1::~CSRTPAuthentication_HMAC_SHA1() |
127 { |
125 { |
|
126 delete iHmac; |
|
127 delete iKey; |
128 } |
128 } |
129 |
129 |
130 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
131 // CSRTPAuthentication_HMAC_SHA1::CSRTPAuthentication_HMAC_SHA1 |
131 // CSRTPAuthentication_HMAC_SHA1::CSRTPAuthentication_HMAC_SHA1 |
132 // --------------------------------------------------------------------------- |
132 // --------------------------------------------------------------------------- |
134 CSRTPAuthentication_HMAC_SHA1::CSRTPAuthentication_HMAC_SHA1() |
134 CSRTPAuthentication_HMAC_SHA1::CSRTPAuthentication_HMAC_SHA1() |
135 { |
135 { |
136 |
136 |
137 } |
137 } |
138 |
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CSRTPAuthentication_HMAC_SHA1::CreateHmacL |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CSRTPAuthentication_HMAC_SHA1::CreateHmacL(const TDesC8& aKey) |
|
144 { |
|
145 delete iHmac; |
|
146 iHmac = 0; |
|
147 delete iKey; |
|
148 iKey = 0; |
|
149 iKey = aKey.AllocL(); |
|
150 CSHA1* sha1 = CSHA1::NewL(); |
|
151 CleanupStack::PushL(sha1); |
|
152 iHmac = CHMAC::NewL(*iKey, sha1); |
|
153 CleanupStack::Pop(sha1); |
|
154 } |