Update contrib.
2 * Copyright (c) 2007-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.
15 * Tests deleting a key from the hardware store.
24 #include "kmslddtest.h"
27 TInt DeleteSingleKeySync(TKeyHandle aHandle)
29 Delete a single key using the global channel object. This function
30 is provided for convenience, so the caller does not have to set up
31 their own TRequestStatus object.
33 @param aHandle Key to delete.
34 @return Symbian OS error code with which the driver completed
39 KmsChannel.DeleteKey(CurrentProcess, aHandle, rs);
40 User::WaitForRequest(rs);
44 void TestDeleteSingleKey(TKeyHandle aHandle, TInt aExpectedResult)
46 Attempt to delete a single key and test the request was completed
47 with the expected error code.
49 @param aHandle Key to delete.
50 @param aExpectedResult Expected Symbian OS error code with which the
51 driver is expected to complete the request.
54 TInt r = DeleteSingleKeySync(aHandle);
55 test(r == aExpectedResult);
58 static TInt TestDeleteKeyNotCreator(RProcess aProcess)
60 Attempt to delete a key with the supplied process as the claimed
61 owner. This function is defined to test the driver the correctly
62 polices key deletion according to the claimed owner.
64 @param aProcess Process which claims to own, and can therefore
66 @return Error code with which the driver completed the
71 KmsChannel.DeleteKey(aProcess, GenKeyHandle0, rs);
77 Test deleting keys from the hardware store. See in-function
78 comments for specific test cases.
81 test.Start(_L(" @SYMTestCaseID:SEC-CRYPTOSPI-DELETE-0001 TestDeleteKey "));
83 TestGenerateSingleKey(1, CurrentProcess, GenKeyHandle0, KErrNone);
84 TestGenerateSingleKey(1, CurrentProcess, GenKeyHandle1, KErrNone);
85 TestGenerateSingleKey(1, CurrentProcess, StoreKeyHandle0, KErrNone);
86 TestGenerateSingleKey(1, CurrentProcess, StoreKeyHandle1, KErrNone);
88 TestDeleteSingleKey(GenKeyHandle0, KErrNone);
89 TestDeleteSingleKey(GenKeyHandle1, KErrNone);
90 TestDeleteSingleKey(StoreKeyHandle0, KErrNone);
91 TestDeleteSingleKey(StoreKeyHandle1, KErrNone);
93 // error case - non-existent handle
94 TestDeleteSingleKey(GenKeyHandle0, KErrNotFound);
95 TestDeleteSingleKey(GenKeyHandle1, KErrNotFound);
96 TestDeleteSingleKey(StoreKeyHandle0, KErrNotFound);
97 TestDeleteSingleKey(StoreKeyHandle1, KErrNotFound);
99 // error case - not deleted by creator
100 TestGenerateSingleKey(3, GenKeyHandle0, KErrNone);
101 TestSecondProcess(/* aCapabilityMask */ 0, /* aSecureId */ 0, TestDeleteKeyNotCreator, KErrPermissionDenied);
102 TestDeleteSingleKey(GenKeyHandle0, KErrNone);