Update contrib.
2 * Copyright (c) 2005-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.
27 #include "randomimpl.h"
28 #include "pluginentry.h"
29 #include "pluginconfig.h"
30 #include "securityerr.h"
32 using namespace SoftwareCrypto;
35 CRandomImpl* CRandomImpl::NewL(TUid aImplementationUid)
37 CRandomImpl* self = new(ELeave)CRandomImpl(aImplementationUid);
41 CRandomImpl* CRandomImpl::NewLC(TUid aImplementationUid)
43 CRandomImpl* self = NewL(aImplementationUid);
44 CleanupStack::PushL(self);
48 void CRandomImpl::GenerateRandomBytesL(TDes8& aDestination)
50 // Call the Math library to populate the buffer with random data.
51 TRAPD(err, Math::RandomL(aDestination));
54 // As the end users are interested only in the security aspect of the output but not
55 // the internal states, accordingly translate the kernel side error code if required.
56 err = (err == KErrNotReady) ? KErrNotSecure : err;
62 CRandomImpl::CRandomImpl(TUid aImplementationUid) : iImplementationUid(aImplementationUid)
66 void CRandomImpl::GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics)
68 TInt randomNum = sizeof(KRandomCharacteristics)/sizeof(TRandomCharacteristics*);
69 for (TInt i = 0; i < randomNum; i++)
71 if (KRandomCharacteristics[i]->cmn.iImplementationUID == ImplementationUid().iUid)
73 aPluginCharacteristics = KRandomCharacteristics[i];
79 TAny* CRandomImpl::GetExtension(TUid /*aExtensionId*/)
84 CExtendedCharacteristics* CRandomImpl::CreateExtendedCharacteristicsL()
86 // All Symbian software plug-ins have unlimited concurrency, cannot be reserved
87 // for exclusive use and are not CERTIFIED to be standards compliant.
88 return CExtendedCharacteristics::NewL(KMaxTInt, EFalse);
91 const CExtendedCharacteristics* CRandomImpl::GetExtendedCharacteristicsL()
93 return CRandomImpl::CreateExtendedCharacteristicsL();
96 TUid CRandomImpl::ImplementationUid() const
98 return iImplementationUid;
101 CRandomImpl::~CRandomImpl()
105 void CRandomImpl::Close()
110 // All crypto plugins must implement this, to reset
111 // hardware if required. Do nothing in this version
112 void CRandomImpl::Reset()