Update contrib.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "keyidentifierutil.h"
21 #include "asymmetrickeys.h"
23 EXPORT_C void KeyIdentifierUtil::RSAKeyIdentifierL(
24 const CRSAPublicKey& aKey, TKeyIdentifier& aIdentifier)
28 // Generate a hash of the appropriate data (for TKeyIdentifier)
29 const TInteger& keyModulus = aKey.N();
30 HBufC8* modulusData = keyModulus.BufferLC();
31 CSHA1* sha1 = CSHA1::NewL();
32 CleanupStack::PushL(sha1);
33 TPtrC8 hash = sha1->Final(*modulusData);
34 aIdentifier.Copy(hash);
35 CleanupStack::PopAndDestroy(2); // sha1, modulusData
38 EXPORT_C void KeyIdentifierUtil::DSAKeyIdentifierL(
39 const CDSAPublicKey& aKey, TKeyIdentifier& aIdentifier)
43 // Generate a hash of the appropriate data (for TKeyIdentifier)
44 const TInteger& Y = aKey.Y();
45 HBufC8* YData = Y.BufferLC();
46 CSHA1* sha1 = CSHA1::NewL();
47 CleanupStack::PushL(sha1);
48 TPtrC8 hash = sha1->Final(*YData);
49 aIdentifier.Copy(hash);
50 CleanupStack::PopAndDestroy(2); // sha1, YData
53 EXPORT_C void KeyIdentifierUtil::DHKeyIdentifierL(
54 const RInteger& aKey, TKeyIdentifier& aIdentifier)
57 User::Leave(KErrArgument);
61 // Generate a hash of the appropriate data (for TKeyIdentifier)
62 HBufC8* XData = aKey.BufferLC();
63 CSHA1* sha1 = CSHA1::NewL();
64 CleanupStack::PushL(sha1);
65 TPtrC8 hash = sha1->Final(*XData);
66 aIdentifier.Copy(hash);
67 CleanupStack::PopAndDestroy(2); // sha1, XData