1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcrypto/source/symmetric/des.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,76 @@
1.4 +/*
1.5 +* Copyright (c) 2003-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 +#ifndef __DES_INL__
1.23 +#define __DES_INL__
1.24 +
1.25 +inline void IPerm(TUint32& left, TUint32& right)
1.26 + {
1.27 + TUint32 work;
1.28 +
1.29 + right = rotlFixed(right, 4U);
1.30 + work = (left ^ right) & 0xf0f0f0f0;
1.31 + left ^= work;
1.32 + right = rotrFixed(right^work, 20U);
1.33 + work = (left ^ right) & 0xffff0000;
1.34 + left ^= work;
1.35 + right = rotrFixed(right^work, 18U);
1.36 + work = (left ^ right) & 0x33333333;
1.37 + left ^= work;
1.38 + right = rotrFixed(right^work, 6U);
1.39 + work = (left ^ right) & 0x00ff00ff;
1.40 + left ^= work;
1.41 + right = rotlFixed(right^work, 9U);
1.42 + work = (left ^ right) & 0xaaaaaaaa;
1.43 + left = rotlFixed(left^work, 1U);
1.44 + right ^= work;
1.45 + }
1.46 +
1.47 +inline void FPerm(TUint32& left, TUint32& right)
1.48 + {
1.49 + TUint32 work;
1.50 +
1.51 + right = rotrFixed(right, 1U);
1.52 + work = (left ^ right) & 0xaaaaaaaa;
1.53 + right ^= work;
1.54 + left = rotrFixed(left^work, 9U);
1.55 + work = (left ^ right) & 0x00ff00ff;
1.56 + right ^= work;
1.57 + left = rotlFixed(left^work, 6U);
1.58 + work = (left ^ right) & 0x33333333;
1.59 + right ^= work;
1.60 + left = rotlFixed(left^work, 18U);
1.61 + work = (left ^ right) & 0xffff0000;
1.62 + right ^= work;
1.63 + left = rotlFixed(left^work, 20U);
1.64 + work = (left ^ right) & 0xf0f0f0f0;
1.65 + right ^= work;
1.66 + left = rotrFixed(left^work, 4U);
1.67 + }
1.68 +
1.69 +inline void ReverseKeySchedule(TUint32* aKey)
1.70 + {
1.71 + TInt i = 0;
1.72 + for (; i<16; i+=2)
1.73 + {
1.74 + TClassSwap((*(aKey+i)), (*(aKey+(32-2-i))));
1.75 + TClassSwap((*(aKey+i+1)), (*(aKey+(32-1-i))));
1.76 + }
1.77 + }
1.78 +
1.79 +#endif //__DES_INL__