1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcryptospi/source/padding/paddingshim.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,190 @@
1.4 +/*
1.5 +* Copyright (c) 2006-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 +#include "paddingshim.h"
1.23 +#include <cryptospi/cryptospidef.h>
1.24 +
1.25 +// CPaddingNoneShim
1.26 +CPaddingNoneShim* CPaddingNoneShim::NewL(TInt aBlockBytes)
1.27 + {
1.28 + CPaddingNoneShim* self = CPaddingNoneShim::NewLC(aBlockBytes);
1.29 + CleanupStack::Pop(self);
1.30 + return self;
1.31 + }
1.32 +CPaddingNoneShim* CPaddingNoneShim::NewLC(TInt aBlockBytes)
1.33 + {
1.34 + CPaddingNoneShim* self = new(ELeave) CPaddingNoneShim(aBlockBytes);
1.35 + CleanupStack::PushL(self);
1.36 + return self;
1.37 + }
1.38 +
1.39 +TInt CPaddingNoneShim::Extension_(TUint aExtensionId, TAny*& a0, TAny* /*a1*/)
1.40 + {
1.41 + TInt err(KErrNone);
1.42 + if (aExtensionId == CryptoSpi::KPaddingInterface)
1.43 + {
1.44 + TUid* uid(static_cast<TUid*>(a0));
1.45 + *uid = CryptoSpi::KPaddingModeNoneUid;
1.46 + }
1.47 + else
1.48 + {
1.49 + err = KErrExtensionNotSupported;
1.50 + }
1.51 + return err;
1.52 + }
1.53 +
1.54 +CPaddingNoneShim::CPaddingNoneShim(TInt aBlockBytes) :
1.55 + CPaddingNone(aBlockBytes)
1.56 + {
1.57 + }
1.58 +
1.59 +// CPaddingPKCS1SignatureShim
1.60 +CPaddingPKCS1SignatureShim* CPaddingPKCS1SignatureShim::NewL(TInt aBlockBytes)
1.61 + {
1.62 + CPaddingPKCS1SignatureShim* self = CPaddingPKCS1SignatureShim::NewLC(aBlockBytes);
1.63 + CleanupStack::Pop(self);
1.64 + return self;
1.65 + }
1.66 +CPaddingPKCS1SignatureShim* CPaddingPKCS1SignatureShim::NewLC(TInt aBlockBytes)
1.67 + {
1.68 + CPaddingPKCS1SignatureShim* self = new(ELeave) CPaddingPKCS1SignatureShim(aBlockBytes);
1.69 + CleanupStack::PushL(self);
1.70 + return self;
1.71 + }
1.72 +
1.73 +TInt CPaddingPKCS1SignatureShim::Extension_(TUint aExtensionId, TAny*& a0, TAny* /*a1*/)
1.74 + {
1.75 + TInt err(KErrNone);
1.76 + if (aExtensionId == CryptoSpi::KPaddingInterface)
1.77 + {
1.78 + TUid* uid(static_cast<TUid*>(a0));
1.79 + *uid = CryptoSpi::KPaddingModePkcs1_v1_5_SignatureUid;
1.80 + }
1.81 + else
1.82 + {
1.83 + err = KErrExtensionNotSupported;
1.84 + }
1.85 + return err;
1.86 + }
1.87 +
1.88 +CPaddingPKCS1SignatureShim::CPaddingPKCS1SignatureShim(TInt aBlockBytes) :
1.89 + CPaddingPKCS1Signature(aBlockBytes)
1.90 + {
1.91 + }
1.92 +
1.93 +// CPaddingPKCS1EncryptionShim
1.94 +CPaddingPKCS1EncryptionShim* CPaddingPKCS1EncryptionShim::NewL(TInt aBlockBytes)
1.95 + {
1.96 + CPaddingPKCS1EncryptionShim* self = CPaddingPKCS1EncryptionShim::NewLC(aBlockBytes);
1.97 + CleanupStack::Pop(self);
1.98 + return self;
1.99 + }
1.100 +CPaddingPKCS1EncryptionShim* CPaddingPKCS1EncryptionShim::NewLC(TInt aBlockBytes)
1.101 + {
1.102 + CPaddingPKCS1EncryptionShim* self = new(ELeave) CPaddingPKCS1EncryptionShim(aBlockBytes);
1.103 + CleanupStack::PushL(self);
1.104 + return self;
1.105 + }
1.106 +
1.107 +TInt CPaddingPKCS1EncryptionShim::Extension_(TUint aExtensionId, TAny*& a0, TAny* /*a1*/)
1.108 + {
1.109 + TInt err(KErrNone);
1.110 + if (aExtensionId == CryptoSpi::KPaddingInterface)
1.111 + {
1.112 + TUid* uid(static_cast<TUid*>(a0));
1.113 + *uid = CryptoSpi::KPaddingModePkcs1_v1_5_EncryptionUid;
1.114 + }
1.115 + else
1.116 + {
1.117 + err = KErrExtensionNotSupported;
1.118 + }
1.119 + return err;
1.120 + }
1.121 +
1.122 +CPaddingPKCS1EncryptionShim::CPaddingPKCS1EncryptionShim(TInt aBlockBytes) :
1.123 + CPaddingPKCS1Encryption(aBlockBytes)
1.124 + {
1.125 + }
1.126 +
1.127 +// CPaddingSSLv3Shim
1.128 +CPaddingSSLv3Shim* CPaddingSSLv3Shim::NewL(TInt aBlockBytes)
1.129 + {
1.130 + CPaddingSSLv3Shim* self = CPaddingSSLv3Shim::NewLC(aBlockBytes);
1.131 + CleanupStack::Pop(self);
1.132 + return self;
1.133 + }
1.134 +CPaddingSSLv3Shim* CPaddingSSLv3Shim::NewLC(TInt aBlockBytes)
1.135 + {
1.136 + CPaddingSSLv3Shim* self = new(ELeave) CPaddingSSLv3Shim(aBlockBytes);
1.137 + CleanupStack::PushL(self);
1.138 + return self;
1.139 + }
1.140 +
1.141 +TInt CPaddingSSLv3Shim::Extension_(TUint aExtensionId, TAny*& a0, TAny* /*a1*/)
1.142 + {
1.143 + TInt err(KErrNone);
1.144 + if (aExtensionId == CryptoSpi::KPaddingInterface)
1.145 + {
1.146 + TUid* uid(static_cast<TUid*>(a0));
1.147 + *uid = CryptoSpi::KPaddingModeSSLv3Uid;
1.148 + }
1.149 + else
1.150 + {
1.151 + err = KErrExtensionNotSupported;
1.152 + }
1.153 + return err;
1.154 + }
1.155 +
1.156 +CPaddingSSLv3Shim::CPaddingSSLv3Shim(TInt aBlockBytes) :
1.157 + CPaddingSSLv3(aBlockBytes)
1.158 + {
1.159 + }
1.160 +
1.161 +// CPaddingPKCS7Shim
1.162 +CPaddingPKCS7Shim* CPaddingPKCS7Shim::NewL(TInt aBlockBytes)
1.163 + {
1.164 + CPaddingPKCS7Shim* self = CPaddingPKCS7Shim::NewLC(aBlockBytes);
1.165 + CleanupStack::Pop(self);
1.166 + return self;
1.167 + }
1.168 +CPaddingPKCS7Shim* CPaddingPKCS7Shim::NewLC(TInt aBlockBytes)
1.169 + {
1.170 + CPaddingPKCS7Shim* self = new(ELeave) CPaddingPKCS7Shim(aBlockBytes);
1.171 + CleanupStack::PushL(self);
1.172 + return self;
1.173 + }
1.174 +
1.175 +TInt CPaddingPKCS7Shim::Extension_(TUint aExtensionId, TAny*& a0, TAny* /*a1*/)
1.176 + {
1.177 + TInt err(KErrNone);
1.178 + if (aExtensionId == CryptoSpi::KPaddingInterface)
1.179 + {
1.180 + TUid* uid(static_cast<TUid*>(a0));
1.181 + *uid = CryptoSpi::KPaddingModePKCS7Uid;
1.182 + }
1.183 + else
1.184 + {
1.185 + err = KErrExtensionNotSupported;
1.186 + }
1.187 + return err;
1.188 + }
1.189 +
1.190 +CPaddingPKCS7Shim::CPaddingPKCS7Shim(TInt aBlockBytes) :
1.191 + CPaddingPKCS7(aBlockBytes)
1.192 + {
1.193 + }