180{
181
182
183
184 int KC, BC, ROUNDS;
185 int i,
j,
t, rconpointer = 0;
187
188 switch (keyBits) {
189 case 128: KC = 4; break;
190 case 192: KC = 6; break;
191 case 256: KC = 8; break;
192 default : return (-1);
193 }
194
195 switch (blockBits) {
196 case 128: BC = 4; break;
197 case 192: BC = 6; break;
198 case 256: BC = 8; break;
199 default : return (-2);
200 }
201
202 switch (keyBits >= blockBits ? keyBits : blockBits) {
203 case 128: ROUNDS = 10; break;
204 case 192: ROUNDS = 12; break;
205 case 256: ROUNDS = 14; break;
206 default : return (-3);
207 }
208
209
210 for(
j = 0;
j < KC;
j++)
211 for(
i = 0;
i < 4;
i++)
214
215 for(
j = 0; (
j < KC) && (
t < (ROUNDS+1)*BC);
j++,
t++)
216 for(
i = 0;
i < 4;
i++)
W[
t / BC][
i][
t % BC] = tk[
i][
j];
217
218 while (
t < (ROUNDS+1)*BC) {
219
220 for(
i = 0;
i < 4;
i++)
221 tk[
i][0] ^=
S[tk[(
i+1)%4][KC-1]];
222 tk[0][0] ^=
rcon[rconpointer++];
223
224 if (KC != 8)
225 for(
j = 1;
j < KC;
j++)
226 for(
i = 0;
i < 4;
i++) tk[
i][
j] ^= tk[
i][
j-1];
227 else {
228 for(
j = 1;
j < KC/2;
j++)
229 for(
i = 0;
i < 4;
i++) tk[
i][
j] ^= tk[
i][
j-1];
230 for(
i = 0;
i < 4;
i++) tk[
i][KC/2] ^=
S[tk[
i][KC/2 - 1]];
231 for(
j = KC/2 + 1;
j < KC;
j++)
232 for(
i = 0;
i < 4;
i++) tk[
i][
j] ^= tk[
i][
j-1];
233 }
234
235 for(
j = 0; (
j < KC) && (
t < (ROUNDS+1)*BC);
j++,
t++)
236 for(
i = 0;
i < 4;
i++)
W[
t / BC][
i][
t % BC] = tk[
i][
j];
237 }
238
239 return 0;
240}
static const ulong32 rcon[]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j