os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/destables.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/destables.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,184 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-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 +
    1.28 +#ifndef __DESTABLES_H__
    1.29 +#define __DESTABLES_H__
    1.30 +
    1.31 +#include <e32std.h>
    1.32 +
    1.33 +namespace DES_TABLE
    1.34 +{
    1.35 +/* initial permutation IP */
    1.36 +const TUint8 ip[] = {
    1.37 +	   58, 50, 42, 34, 26, 18, 10,  2,
    1.38 +	   60, 52, 44, 36, 28, 20, 12,  4,
    1.39 +	   62, 54, 46, 38, 30, 22, 14,  6,
    1.40 +	   64, 56, 48, 40, 32, 24, 16,  8,
    1.41 +	   57, 49, 41, 33, 25, 17,  9,  1,
    1.42 +	   59, 51, 43, 35, 27, 19, 11,  3,
    1.43 +	   61, 53, 45, 37, 29, 21, 13,  5,
    1.44 +	   63, 55, 47, 39, 31, 23, 15,  7
    1.45 +};
    1.46 +
    1.47 +/* final permutation IP^-1 */
    1.48 +const TUint8 fp[] = {
    1.49 +	   40,  8, 48, 16, 56, 24, 64, 32,
    1.50 +	   39,  7, 47, 15, 55, 23, 63, 31,
    1.51 +	   38,  6, 46, 14, 54, 22, 62, 30,
    1.52 +	   37,  5, 45, 13, 53, 21, 61, 29,
    1.53 +	   36,  4, 44, 12, 52, 20, 60, 28,
    1.54 +	   35,  3, 43, 11, 51, 19, 59, 27,
    1.55 +	   34,  2, 42, 10, 50, 18, 58, 26,
    1.56 +	   33,  1, 41,  9, 49, 17, 57, 25
    1.57 +};
    1.58 +
    1.59 +/* expansion operation matrix */
    1.60 +const TUint8 ei[] = {
    1.61 +	   32,  1,  2,  3,  4,  5,
    1.62 +		4,  5,  6,  7,  8,  9,
    1.63 +		8,  9, 10, 11, 12, 13,
    1.64 +	   12, 13, 14, 15, 16, 17,
    1.65 +	   16, 17, 18, 19, 20, 21,
    1.66 +	   20, 21, 22, 23, 24, 25,
    1.67 +	   24, 25, 26, 27, 28, 29,
    1.68 +	   28, 29, 30, 31, 32,  1
    1.69 +};
    1.70 +
    1.71 +const TUint32 sbox[8][64] = {
    1.72 +{
    1.73 +0x01010400,0x00000000,0x00010000,0x01010404, 0x01010004,0x00010404,0x00000004,0x00010000,
    1.74 +0x00000400,0x01010400,0x01010404,0x00000400, 0x01000404,0x01010004,0x01000000,0x00000004,
    1.75 +0x00000404,0x01000400,0x01000400,0x00010400, 0x00010400,0x01010000,0x01010000,0x01000404,
    1.76 +0x00010004,0x01000004,0x01000004,0x00010004, 0x00000000,0x00000404,0x00010404,0x01000000,
    1.77 +0x00010000,0x01010404,0x00000004,0x01010000, 0x01010400,0x01000000,0x01000000,0x00000400,
    1.78 +0x01010004,0x00010000,0x00010400,0x01000004, 0x00000400,0x00000004,0x01000404,0x00010404,
    1.79 +0x01010404,0x00010004,0x01010000,0x01000404, 0x01000004,0x00000404,0x00010404,0x01010400,
    1.80 +0x00000404,0x01000400,0x01000400,0x00000000, 0x00010004,0x00010400,0x00000000,0x01010004},
    1.81 +{
    1.82 +0x80108020,0x80008000,0x00008000,0x00108020, 0x00100000,0x00000020,0x80100020,0x80008020,
    1.83 +0x80000020,0x80108020,0x80108000,0x80000000, 0x80008000,0x00100000,0x00000020,0x80100020,
    1.84 +0x00108000,0x00100020,0x80008020,0x00000000, 0x80000000,0x00008000,0x00108020,0x80100000,
    1.85 +0x00100020,0x80000020,0x00000000,0x00108000, 0x00008020,0x80108000,0x80100000,0x00008020,
    1.86 +0x00000000,0x00108020,0x80100020,0x00100000, 0x80008020,0x80100000,0x80108000,0x00008000,
    1.87 +0x80100000,0x80008000,0x00000020,0x80108020, 0x00108020,0x00000020,0x00008000,0x80000000,
    1.88 +0x00008020,0x80108000,0x00100000,0x80000020, 0x00100020,0x80008020,0x80000020,0x00100020,
    1.89 +0x00108000,0x00000000,0x80008000,0x00008020, 0x80000000,0x80100020,0x80108020,0x00108000},
    1.90 +{
    1.91 +0x00000208,0x08020200,0x00000000,0x08020008, 0x08000200,0x00000000,0x00020208,0x08000200,
    1.92 +0x00020008,0x08000008,0x08000008,0x00020000, 0x08020208,0x00020008,0x08020000,0x00000208,
    1.93 +0x08000000,0x00000008,0x08020200,0x00000200, 0x00020200,0x08020000,0x08020008,0x00020208,
    1.94 +0x08000208,0x00020200,0x00020000,0x08000208, 0x00000008,0x08020208,0x00000200,0x08000000,
    1.95 +0x08020200,0x08000000,0x00020008,0x00000208, 0x00020000,0x08020200,0x08000200,0x00000000,
    1.96 +0x00000200,0x00020008,0x08020208,0x08000200, 0x08000008,0x00000200,0x00000000,0x08020008,
    1.97 +0x08000208,0x00020000,0x08000000,0x08020208, 0x00000008,0x00020208,0x00020200,0x08000008,
    1.98 +0x08020000,0x08000208,0x00000208,0x08020000, 0x00020208,0x00000008,0x08020008,0x00020200},
    1.99 +{
   1.100 +0x00802001,0x00002081,0x00002081,0x00000080, 0x00802080,0x00800081,0x00800001,0x00002001,
   1.101 +0x00000000,0x00802000,0x00802000,0x00802081, 0x00000081,0x00000000,0x00800080,0x00800001,
   1.102 +0x00000001,0x00002000,0x00800000,0x00802001, 0x00000080,0x00800000,0x00002001,0x00002080,
   1.103 +0x00800081,0x00000001,0x00002080,0x00800080, 0x00002000,0x00802080,0x00802081,0x00000081,
   1.104 +0x00800080,0x00800001,0x00802000,0x00802081, 0x00000081,0x00000000,0x00000000,0x00802000,
   1.105 +0x00002080,0x00800080,0x00800081,0x00000001, 0x00802001,0x00002081,0x00002081,0x00000080,
   1.106 +0x00802081,0x00000081,0x00000001,0x00002000, 0x00800001,0x00002001,0x00802080,0x00800081,
   1.107 +0x00002001,0x00002080,0x00800000,0x00802001, 0x00000080,0x00800000,0x00002000,0x00802080},
   1.108 +{
   1.109 +0x00000100,0x02080100,0x02080000,0x42000100, 0x00080000,0x00000100,0x40000000,0x02080000,
   1.110 +0x40080100,0x00080000,0x02000100,0x40080100, 0x42000100,0x42080000,0x00080100,0x40000000,
   1.111 +0x02000000,0x40080000,0x40080000,0x00000000, 0x40000100,0x42080100,0x42080100,0x02000100,
   1.112 +0x42080000,0x40000100,0x00000000,0x42000000, 0x02080100,0x02000000,0x42000000,0x00080100,
   1.113 +0x00080000,0x42000100,0x00000100,0x02000000, 0x40000000,0x02080000,0x42000100,0x40080100,
   1.114 +0x02000100,0x40000000,0x42080000,0x02080100, 0x40080100,0x00000100,0x02000000,0x42080000,
   1.115 +0x42080100,0x00080100,0x42000000,0x42080100, 0x02080000,0x00000000,0x40080000,0x42000000,
   1.116 +0x00080100,0x02000100,0x40000100,0x00080000, 0x00000000,0x40080000,0x02080100,0x40000100},
   1.117 +{
   1.118 +0x20000010,0x20400000,0x00004000,0x20404010, 0x20400000,0x00000010,0x20404010,0x00400000,
   1.119 +0x20004000,0x00404010,0x00400000,0x20000010, 0x00400010,0x20004000,0x20000000,0x00004010,
   1.120 +0x00000000,0x00400010,0x20004010,0x00004000, 0x00404000,0x20004010,0x00000010,0x20400010,
   1.121 +0x20400010,0x00000000,0x00404010,0x20404000, 0x00004010,0x00404000,0x20404000,0x20000000,
   1.122 +0x20004000,0x00000010,0x20400010,0x00404000, 0x20404010,0x00400000,0x00004010,0x20000010,
   1.123 +0x00400000,0x20004000,0x20000000,0x00004010, 0x20000010,0x20404010,0x00404000,0x20400000,
   1.124 +0x00404010,0x20404000,0x00000000,0x20400010, 0x00000010,0x00004000,0x20400000,0x00404010,
   1.125 +0x00004000,0x00400010,0x20004010,0x00000000, 0x20404000,0x20000000,0x00400010,0x20004010},
   1.126 +{
   1.127 +0x00200000,0x04200002,0x04000802,0x00000000, 0x00000800,0x04000802,0x00200802,0x04200800,
   1.128 +0x04200802,0x00200000,0x00000000,0x04000002, 0x00000002,0x04000000,0x04200002,0x00000802,
   1.129 +0x04000800,0x00200802,0x00200002,0x04000800, 0x04000002,0x04200000,0x04200800,0x00200002,
   1.130 +0x04200000,0x00000800,0x00000802,0x04200802, 0x00200800,0x00000002,0x04000000,0x00200800,
   1.131 +0x04000000,0x00200800,0x00200000,0x04000802, 0x04000802,0x04200002,0x04200002,0x00000002,
   1.132 +0x00200002,0x04000000,0x04000800,0x00200000, 0x04200800,0x00000802,0x00200802,0x04200800,
   1.133 +0x00000802,0x04000002,0x04200802,0x04200000, 0x00200800,0x00000000,0x00000002,0x04200802,
   1.134 +0x00000000,0x00200802,0x04200000,0x00000800, 0x04000002,0x04000800,0x00000800,0x00200002},
   1.135 +{
   1.136 +0x10001040,0x00001000,0x00040000,0x10041040, 0x10000000,0x10001040,0x00000040,0x10000000,
   1.137 +0x00040040,0x10040000,0x10041040,0x00041000, 0x10041000,0x00041040,0x00001000,0x00000040,
   1.138 +0x10040000,0x10000040,0x10001000,0x00001040, 0x00041000,0x00040040,0x10040040,0x10041000,
   1.139 +0x00001040,0x00000000,0x00000000,0x10040040, 0x10000040,0x10001000,0x00041040,0x00040000,
   1.140 +0x00041040,0x00040000,0x10041000,0x00001000, 0x00000040,0x10040040,0x00001000,0x00041040,
   1.141 +0x10001000,0x00000040,0x10000040,0x10040000, 0x10040040,0x10000000,0x00040000,0x10001040,
   1.142 +0x00000000,0x10041040,0x00040040,0x10000040, 0x10040000,0x10001000,0x10001040,0x00000000,
   1.143 +0x10041040,0x00041000,0x00041000,0x00001040, 0x00001040,0x00040040,0x10000000,0x10041000}
   1.144 +};
   1.145 +
   1.146 +
   1.147 +/* 32-bit permutation function P used on the output of the S-boxes */
   1.148 +const TUint8 p32i[] = {
   1.149 +	   16,  7, 20, 21,
   1.150 +	   29, 12, 28, 17,
   1.151 +		1, 15, 23, 26,
   1.152 +		5, 18, 31, 10,
   1.153 +		2,  8, 24, 14,
   1.154 +	   32, 27,  3,  9,
   1.155 +	   19, 13, 30,  6,
   1.156 +	   22, 11,  4, 25
   1.157 +};
   1.158 +
   1.159 +/* permuted choice table (key) */
   1.160 +const TUint8 pc1[] = {
   1.161 +	   57, 49, 41, 33, 25, 17,  9,
   1.162 +		1, 58, 50, 42, 34, 26, 18,
   1.163 +	   10,  2, 59, 51, 43, 35, 27,
   1.164 +	   19, 11,  3, 60, 52, 44, 36,
   1.165 +
   1.166 +	   63, 55, 47, 39, 31, 23, 15,
   1.167 +		7, 62, 54, 46, 38, 30, 22,
   1.168 +	   14,  6, 61, 53, 45, 37, 29,
   1.169 +	   21, 13,  5, 28, 20, 12,  4
   1.170 +};
   1.171 +
   1.172 +/* number left rotations of pc1 */
   1.173 +const TUint8 totrot[] = {1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28};
   1.174 +
   1.175 +/* permuted choice key (table) */
   1.176 +const TUint8 pc2[] = {
   1.177 +	   14, 17, 11, 24,  1,  5,
   1.178 +		3, 28, 15,  6, 21, 10,
   1.179 +	   23, 19, 12,  4, 26,  8,
   1.180 +	   16,  7, 27, 20, 13,  2,
   1.181 +	   41, 52, 31, 37, 47, 55,
   1.182 +	   30, 40, 51, 45, 33, 48,
   1.183 +	   44, 49, 39, 56, 34, 53,
   1.184 +	   46, 42, 50, 36, 29, 32
   1.185 +};
   1.186 +}	//	namespace DES_TABLE
   1.187 +#endif	//	__DESTABLES_H__