sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __DES_INL__ sl@0: #define __DES_INL__ sl@0: sl@0: inline void IPerm(TUint32& left, TUint32& right) sl@0: { sl@0: TUint32 work; sl@0: sl@0: right = rotlFixed(right, 4U); sl@0: work = (left ^ right) & 0xf0f0f0f0; sl@0: left ^= work; sl@0: right = rotrFixed(right^work, 20U); sl@0: work = (left ^ right) & 0xffff0000; sl@0: left ^= work; sl@0: right = rotrFixed(right^work, 18U); sl@0: work = (left ^ right) & 0x33333333; sl@0: left ^= work; sl@0: right = rotrFixed(right^work, 6U); sl@0: work = (left ^ right) & 0x00ff00ff; sl@0: left ^= work; sl@0: right = rotlFixed(right^work, 9U); sl@0: work = (left ^ right) & 0xaaaaaaaa; sl@0: left = rotlFixed(left^work, 1U); sl@0: right ^= work; sl@0: } sl@0: sl@0: inline void FPerm(TUint32& left, TUint32& right) sl@0: { sl@0: TUint32 work; sl@0: sl@0: right = rotrFixed(right, 1U); sl@0: work = (left ^ right) & 0xaaaaaaaa; sl@0: right ^= work; sl@0: left = rotrFixed(left^work, 9U); sl@0: work = (left ^ right) & 0x00ff00ff; sl@0: right ^= work; sl@0: left = rotlFixed(left^work, 6U); sl@0: work = (left ^ right) & 0x33333333; sl@0: right ^= work; sl@0: left = rotlFixed(left^work, 18U); sl@0: work = (left ^ right) & 0xffff0000; sl@0: right ^= work; sl@0: left = rotlFixed(left^work, 20U); sl@0: work = (left ^ right) & 0xf0f0f0f0; sl@0: right ^= work; sl@0: left = rotrFixed(left^work, 4U); sl@0: } sl@0: sl@0: inline void ReverseKeySchedule(TUint32* aKey) sl@0: { sl@0: TInt i = 0; sl@0: for (; i<16; i+=2) sl@0: { sl@0: TClassSwap((*(aKey+i)), (*(aKey+(32-2-i)))); sl@0: TClassSwap((*(aKey+i+1)), (*(aKey+(32-1-i)))); sl@0: } sl@0: } sl@0: sl@0: #endif //__DES_INL__