os/security/cryptoplugins/cryptospiplugins/test/h4drv/crypto_h4/cryptodriver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoplugins/cryptospiplugins/test/h4drv/crypto_h4/cryptodriver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,126 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalComponent
    1.25 + @released
    1.26 +*/
    1.27 +#include "cryptodriver.h"
    1.28 +
    1.29 +/*
    1.30 +  NOTE: The following member functions would normally be exported from a separate client DLL
    1.31 +  but are included inline in this header file for convenience.
    1.32 +*/
    1.33 +
    1.34 +
    1.35 +/**
    1.36 +  Opens a logical channel to the driver
    1.37 +
    1.38 +  @return One of the system wide error codes.
    1.39 +*/
    1.40 +EXPORT_C TInt RCryptoDriver::Open()
    1.41 +    {
    1.42 +    return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
    1.43 +    }
    1.44 +
    1.45 +
    1.46 +/**
    1.47 +  Gets the HW versions
    1.48 +
    1.49 +  @param aHwVersionsBuf A structure which will be filled with the versions
    1.50 +
    1.51 +  @return KErrNone
    1.52 +*/
    1.53 +EXPORT_C TInt RCryptoDriver::GetHwVersions(THwVersionsBuf& aHwVersionsBuf)
    1.54 +    {
    1.55 +    return DoControl(EGetHwVersions,(TAny*)&aHwVersionsBuf);
    1.56 +    }
    1.57 +
    1.58 +/**
    1.59 +  Gets the current configuration settings.
    1.60 +
    1.61 +  @param aConfig A structure which will be filled with the configuration settings.
    1.62 +
    1.63 +  @return KErrNone
    1.64 +*/
    1.65 +EXPORT_C TInt RCryptoDriver::GetConfig(TConfigBuf& aConfig)
    1.66 +    {
    1.67 +    return DoControl(EGetConfig,(TAny*)&aConfig);
    1.68 +    }
    1.69 +
    1.70 +
    1.71 +/**
    1.72 +  Sets the current configuration settings.
    1.73 +
    1.74 +  @param aConfig The new configuration settings to be used.
    1.75 +
    1.76 +  @return KErrInUse if there are outstanding data transfer requests.
    1.77 +          KErrArgument if any configuration values are invalid.
    1.78 +          KErrNone otherwise
    1.79 +*/
    1.80 +EXPORT_C TInt RCryptoDriver::SetConfig(const TConfigBuf& aConfig)
    1.81 +    {
    1.82 +    return DoControl(ESetConfig,(TAny*)&aConfig);
    1.83 +    }
    1.84 +
    1.85 +EXPORT_C void RCryptoDriver::Random(TRequestStatus& aStatus,TDes8& aBuffer)
    1.86 +    {
    1.87 +    DoRequest(ERandom,aStatus,(TAny*)&aBuffer);
    1.88 +    }
    1.89 +
    1.90 +
    1.91 +EXPORT_C void RCryptoDriver::RandomCancel()
    1.92 +    {
    1.93 +    DoCancel(1<<ERandom);
    1.94 +    }
    1.95 +
    1.96 +#include <e32debug.h>
    1.97 +EXPORT_C TInt RCryptoDriver::SetAesConfig(TBool aEncrypt, TChainingMode aMode, 
    1.98 +										  const TDesC8& aKey, const TDesC8& aIV)
    1.99 +    {
   1.100 +	TAesConfigBuf configBuf;
   1.101 +	TAesConfig &config = configBuf();
   1.102 +	config.iEncrypt = aEncrypt;
   1.103 +	config.iMode = aMode;
   1.104 +	config.iKey = &aKey;
   1.105 +	config.iIV = &aIV;
   1.106 +
   1.107 +    return DoControl(EAesSetConfig, (TAny*)&configBuf);
   1.108 +    }
   1.109 +
   1.110 +EXPORT_C void RCryptoDriver::AesWrite(TRequestStatus& aStatus, TDesC8& aBuffer)
   1.111 +    {
   1.112 +    DoRequest(EAesWrite, aStatus,(TAny*)&aBuffer);
   1.113 +    }
   1.114 +EXPORT_C void RCryptoDriver::AesCancelWrite()
   1.115 +    {
   1.116 +    DoCancel(1<<EAesWrite);
   1.117 +    }
   1.118 +
   1.119 +EXPORT_C void RCryptoDriver::AesRead(TRequestStatus& aStatus, TDes8& aBuffer, TUint32 aLength)
   1.120 +    {
   1.121 +    DoRequest(EAesRead, aStatus,(TAny*)&aBuffer, (TAny*)aLength);
   1.122 +    }
   1.123 +
   1.124 +EXPORT_C void RCryptoDriver::AesCancelRead()
   1.125 +    {
   1.126 +    DoCancel(1<<EAesRead);
   1.127 +    }
   1.128 +
   1.129 +// End of file