Changeset 1193
 Timestamp:
 Feb 26, 2010, 1:27:59 AM (12 years ago)
 Location:
 trunk
 Files:

 7 edited
Legend:
 Unmodified
 Added
 Removed

trunk/CrypPlugins/AES/AES.cs
r1192 r1193 523 523 return null; 524 524 525 return NativeCryptography.Crypto.decryptAES(ciphertext, key, bits, size, ((AESSettings)plugin.Settings).Mode); 525 unsafe 526 { 527 fixed (byte* inp = ciphertext) 528 fixed (byte* akey = key) 529 { 530 return NativeCryptography.Crypto.decryptAES(inp, akey, bits, size, ((AESSettings)plugin.Settings).Mode); 531 } 532 } 526 533 } 527 534 
trunk/CrypPlugins/AES/AES.csproj
r1174 r1193 24 24 <ErrorReport>prompt</ErrorReport> 25 25 <WarningLevel>4</WarningLevel> 26 <AllowUnsafeBlocks>true</AllowUnsafeBlocks> 26 27 </PropertyGroup> 27 28 <PropertyGroup Condition=" '$(Configuration)$(Platform)' == 'ReleaseAnyCPU' "> … … 32 33 <ErrorReport>prompt</ErrorReport> 33 34 <WarningLevel>4</WarningLevel> 35 <AllowUnsafeBlocks>true</AllowUnsafeBlocks> 34 36 </PropertyGroup> 35 37 <ItemGroup> 
trunk/CrypPlugins/DES/DES.cs
r1192 r1193 556 556 int size = bytesToUse > ciphertext.Length ? ciphertext.Length : bytesToUse; 557 557 558 return NativeCryptography.Crypto.decryptDES(ciphertext, key, size, ((DESSettings)plugin.Settings).Mode); 558 unsafe 559 { 560 fixed (byte* inp = ciphertext) 561 fixed (byte* akey = key) 562 { 563 return NativeCryptography.Crypto.decryptDES(inp, akey, size, ((DESSettings)plugin.Settings).Mode); 564 } 565 } 559 566 } 560 567 
trunk/CrypPlugins/DES/DES.csproj
r1191 r1193 24 24 <ErrorReport>prompt</ErrorReport> 25 25 <WarningLevel>4</WarningLevel> 26 <AllowUnsafeBlocks>true</AllowUnsafeBlocks> 26 27 </PropertyGroup> 27 28 <PropertyGroup Condition=" '$(Configuration)$(Platform)' == 'ReleaseAnyCPU' "> … … 32 33 <ErrorReport>prompt</ErrorReport> 33 34 <WarningLevel>4</WarningLevel> 35 <AllowUnsafeBlocks>true</AllowUnsafeBlocks> 34 36 </PropertyGroup> 35 37 <ItemGroup> 
trunk/NativeCryptography/NativeCryptography.h
r1192 r1193 11 11 { 12 12 private: 13 static void arrayToCArray(array<unsigned char>^ a, unsigned char *ca, int length)14 {15 int counter;16 int l = (a>Length < length) ? a>Length : length;17 for (counter = 0; counter < l; counter++)18 ca[counter] = a[counter];19 for (; counter < length; counter++)20 ca[counter] = 0;21 }22 23 static void carrayToArray(array<unsigned char>^ a, unsigned char *ca, int length)24 {25 int counter;26 for (counter = 0; counter < length; counter++)27 a[counter] = ca[counter];28 }29 30 13 static void xorBlockAES(int *t1, int *t2) 31 14 { … … 43 26 44 27 public: 45 static array<unsigned char>^ decryptAES( array<unsigned char>^ input, array<unsigned char>^key, const int bits, const int length, const int mode)28 static array<unsigned char>^ decryptAES(unsigned char* input, unsigned char* key, const int bits, const int length, const int mode) 46 29 { 47 30 const int blockSize = 16; … … 50 33 numBlocks++; 51 34 52 unsigned char* inp = (unsigned char*)malloc(numBlocks*blockSize);53 35 unsigned char* outp = (unsigned char*)malloc(numBlocks*blockSize); 54 unsigned char ckey[32];55 36 56 arrayToCArray(input, inp, numBlocks*blockSize); 57 arrayToCArray(key, ckey, bits/8); 37 AES_KEY aeskey; 38 if (mode == 2) //CFB 39 { 40 AES_set_encrypt_key(key, bits, &aeskey); 41 unsigned char iv[blockSize]; 42 for (int i = 0; i < blockSize; i++) 43 { 44 iv[i] = 0; 45 } 58 46 59 AES_KEY aeskey; 60 AES_set_decrypt_key(ckey, bits, &aeskey); 61 AES_decrypt(inp, outp, &aeskey); 62 for (int c = 1; c < numBlocks; c++) 47 AES_encrypt(iv, outp, &aeskey); 48 xorBlockAES((int*)(outp), (int*)(input)); 49 50 for (int c = 0; c < numBlocks1; c++) 51 { 52 AES_encrypt((input+c*blockSize), outp+(c+1)*blockSize, &aeskey); 53 xorBlockAES((int*)(outp+(c+1)*blockSize), (int*)(input+(c+1)*blockSize)); 54 } 55 } 56 else 63 57 { 64 AES_decrypt((inp+c*blockSize), outp+c*blockSize, &aeskey); 65 if (mode == 1) //CBC 66 xorBlockAES((int*)(outp+c*blockSize), (int*)(inp+(c1)*blockSize)); 58 AES_set_decrypt_key(key, bits, &aeskey); 59 AES_decrypt(input, outp, &aeskey); 60 for (int c = 1; c < numBlocks; c++) 61 { 62 AES_decrypt((input+c*blockSize), outp+c*blockSize, &aeskey); 63 if (mode == 1) //CBC 64 xorBlockAES((int*)(outp+c*blockSize), (int*)(input+(c1)*blockSize)); 65 } 67 66 } 68 67 69 68 array<unsigned char>^ output = gcnew array<unsigned char>(length); 70 carrayToArray(output, outp, length);71 free(inp);72 free(outp); 69 for (int c = 0; c < length; c++) 70 output[c] = outp[c]; 71 73 72 return output; 74 73 } 75 74 76 static array<unsigned char>^ decryptDES( array<unsigned char>^ input, array<unsigned char>^key, const int length, const int mode)75 static array<unsigned char>^ decryptDES(unsigned char* input, unsigned char* key, const int length, const int mode) 77 76 { 78 77 const int blockSize = 8; … … 81 80 numBlocks++; 82 81 83 unsigned char* inp = (unsigned char*)malloc(numBlocks*blockSize);84 82 unsigned char* outp = (unsigned char*)malloc(numBlocks*blockSize); 85 unsigned char ckey[8];86 87 arrayToCArray(input, inp, numBlocks*blockSize);88 arrayToCArray(key, ckey, 8);89 83 90 84 DES_key_schedule deskey; 91 DES_set_key_unchecked(&ckey, &deskey); 92 DES_ecb_encrypt((const_DES_cblock*)inp, (const_DES_cblock*)outp, &deskey, DES_DECRYPT); 93 for (int c = 1; c < numBlocks; c++) 85 DES_set_key_unchecked((const_DES_cblock*)key, &deskey); 86 87 if (mode == 2) //CFB 88 { 89 unsigned char iv[blockSize]; 90 for (int i = 0; i < blockSize; i++) 91 { 92 iv[i] = 0; 93 } 94 95 DES_ecb_encrypt((const_DES_cblock*)iv, (const_DES_cblock*)outp, &deskey, DES_ENCRYPT); 96 xorBlockAES((int*)(outp), (int*)(input)); 97 98 for (int c = 0; c < numBlocks1; c++) 99 { 100 DES_ecb_encrypt((const_DES_cblock*)(input+c*blockSize), (const_DES_cblock*)(outp+(c+1)*blockSize), &deskey, DES_ENCRYPT); 101 xorBlockDES((int*)(outp+(c+1)*blockSize), (int*)(input+(c+1)*blockSize)); 102 } 103 } 104 else 94 105 { 95 DES_ecb_encrypt((const_DES_cblock*)(inp+c*blockSize), (const_DES_cblock*)(outp+c*blockSize), &deskey, DES_DECRYPT); 96 if (mode == 1) //CBC 97 xorBlockDES((int*)(outp+c*blockSize), (int*)(inp+(c1)*blockSize)); 106 DES_ecb_encrypt((const_DES_cblock*)input, (const_DES_cblock*)outp, &deskey, DES_DECRYPT); 107 for (int c = 1; c < numBlocks; c++) 108 { 109 DES_ecb_encrypt((const_DES_cblock*)(input+c*blockSize), (const_DES_cblock*)(outp+c*blockSize), &deskey, DES_DECRYPT); 110 if (mode == 1) //CBC 111 xorBlockDES((int*)(outp+c*blockSize), (int*)(input+(c1)*blockSize)); 112 } 98 113 } 99 114 100 115 array<unsigned char>^ output = gcnew array<unsigned char>(length); 101 carrayToArray(output, outp, length);102 free(inp);103 free(outp); 116 for (int c = 0; c < length; c++) 117 output[c] = outp[c]; 118 104 119 return output; 105 120 } 
trunk/NativeCryptography/aes_core.c
r1190 r1193 880 880 PUTU32(out + 12, s3); 881 881 } 882 883 /* 884 * Encrypt a single block 885 * in and out can overlap 886 */ 887 void AES_encrypt(const unsigned char *in, unsigned char *out, 888 const AES_KEY *key) { 889 890 const u32 *rk; 891 u32 s0, s1, s2, s3, t0, t1, t2, t3; 892 #ifndef FULL_UNROLL 893 int r; 894 #endif /* ?FULL_UNROLL */ 895 896 assert(in && out && key); 897 rk = key>rd_key; 898 899 /* 900 * map byte array block to cipher state 901 * and add initial round key: 902 */ 903 s0 = GETU32(in ) ^ rk[0]; 904 s1 = GETU32(in + 4) ^ rk[1]; 905 s2 = GETU32(in + 8) ^ rk[2]; 906 s3 = GETU32(in + 12) ^ rk[3]; 907 #ifdef FULL_UNROLL 908 /* round 1: */ 909 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; 910 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; 911 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; 912 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; 913 /* round 2: */ 914 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; 915 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; 916 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; 917 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; 918 /* round 3: */ 919 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; 920 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; 921 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; 922 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; 923 /* round 4: */ 924 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; 925 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; 926 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; 927 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; 928 /* round 5: */ 929 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; 930 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; 931 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; 932 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; 933 /* round 6: */ 934 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; 935 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; 936 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; 937 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; 938 /* round 7: */ 939 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; 940 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; 941 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; 942 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; 943 /* round 8: */ 944 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; 945 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; 946 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; 947 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; 948 /* round 9: */ 949 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; 950 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; 951 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; 952 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; 953 if (key>rounds > 10) { 954 /* round 10: */ 955 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; 956 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; 957 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; 958 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; 959 /* round 11: */ 960 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; 961 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; 962 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; 963 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; 964 if (key>rounds > 12) { 965 /* round 12: */ 966 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; 967 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; 968 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; 969 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; 970 /* round 13: */ 971 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; 972 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; 973 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; 974 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; 975 } 976 } 977 rk += key>rounds << 2; 978 #else /* !FULL_UNROLL */ 979 /* 980 * Nr  1 full rounds: 981 */ 982 r = key>rounds >> 1; 983 for (;;) { 984 t0 = 985 Te0[(s0 >> 24) ] ^ 986 Te1[(s1 >> 16) & 0xff] ^ 987 Te2[(s2 >> 8) & 0xff] ^ 988 Te3[(s3 ) & 0xff] ^ 989 rk[4]; 990 t1 = 991 Te0[(s1 >> 24) ] ^ 992 Te1[(s2 >> 16) & 0xff] ^ 993 Te2[(s3 >> 8) & 0xff] ^ 994 Te3[(s0 ) & 0xff] ^ 995 rk[5]; 996 t2 = 997 Te0[(s2 >> 24) ] ^ 998 Te1[(s3 >> 16) & 0xff] ^ 999 Te2[(s0 >> 8) & 0xff] ^ 1000 Te3[(s1 ) & 0xff] ^ 1001 rk[6]; 1002 t3 = 1003 Te0[(s3 >> 24) ] ^ 1004 Te1[(s0 >> 16) & 0xff] ^ 1005 Te2[(s1 >> 8) & 0xff] ^ 1006 Te3[(s2 ) & 0xff] ^ 1007 rk[7]; 1008 1009 rk += 8; 1010 if (r == 0) { 1011 break; 1012 } 1013 1014 s0 = 1015 Te0[(t0 >> 24) ] ^ 1016 Te1[(t1 >> 16) & 0xff] ^ 1017 Te2[(t2 >> 8) & 0xff] ^ 1018 Te3[(t3 ) & 0xff] ^ 1019 rk[0]; 1020 s1 = 1021 Te0[(t1 >> 24) ] ^ 1022 Te1[(t2 >> 16) & 0xff] ^ 1023 Te2[(t3 >> 8) & 0xff] ^ 1024 Te3[(t0 ) & 0xff] ^ 1025 rk[1]; 1026 s2 = 1027 Te0[(t2 >> 24) ] ^ 1028 Te1[(t3 >> 16) & 0xff] ^ 1029 Te2[(t0 >> 8) & 0xff] ^ 1030 Te3[(t1 ) & 0xff] ^ 1031 rk[2]; 1032 s3 = 1033 Te0[(t3 >> 24) ] ^ 1034 Te1[(t0 >> 16) & 0xff] ^ 1035 Te2[(t1 >> 8) & 0xff] ^ 1036 Te3[(t2 ) & 0xff] ^ 1037 rk[3]; 1038 } 1039 #endif /* ?FULL_UNROLL */ 1040 /* 1041 * apply last round and 1042 * map cipher state to byte array block: 1043 */ 1044 s0 = 1045 (Te2[(t0 >> 24) ] & 0xff000000) ^ 1046 (Te3[(t1 >> 16) & 0xff] & 0x00ff0000) ^ 1047 (Te0[(t2 >> 8) & 0xff] & 0x0000ff00) ^ 1048 (Te1[(t3 ) & 0xff] & 0x000000ff) ^ 1049 rk[0]; 1050 PUTU32(out , s0); 1051 s1 = 1052 (Te2[(t1 >> 24) ] & 0xff000000) ^ 1053 (Te3[(t2 >> 16) & 0xff] & 0x00ff0000) ^ 1054 (Te0[(t3 >> 8) & 0xff] & 0x0000ff00) ^ 1055 (Te1[(t0 ) & 0xff] & 0x000000ff) ^ 1056 rk[1]; 1057 PUTU32(out + 4, s1); 1058 s2 = 1059 (Te2[(t2 >> 24) ] & 0xff000000) ^ 1060 (Te3[(t3 >> 16) & 0xff] & 0x00ff0000) ^ 1061 (Te0[(t0 >> 8) & 0xff] & 0x0000ff00) ^ 1062 (Te1[(t1 ) & 0xff] & 0x000000ff) ^ 1063 rk[2]; 1064 PUTU32(out + 8, s2); 1065 s3 = 1066 (Te2[(t3 >> 24) ] & 0xff000000) ^ 1067 (Te3[(t0 >> 16) & 0xff] & 0x00ff0000) ^ 1068 (Te0[(t1 >> 8) & 0xff] & 0x0000ff00) ^ 1069 (Te1[(t2 ) & 0xff] & 0x000000ff) ^ 1070 rk[3]; 1071 PUTU32(out + 12, s3); 1072 } 
trunk/NativeCryptography/aes_core.h
r1190 r1193 65 65 int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); 66 66 67 void AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); 68 int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); 69 67 70 #ifdef __cplusplus 68 71 }
Note: See TracChangeset
for help on using the changeset viewer.