Changeset 11
 Timestamp:
 05/11/06 08:29:44 (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

camellia/trunk/camellia.py
r10 r11 315 315 idx1 = (idx + 1) & 0x03 316 316 idx2 = (idx1 + 1) & 0x03 317 return (317 return [ 318 318 ((x[idx ] << r)  (x[idx1] >> (32  r))) % 0x100000000, 319 ((x[idx1] << r)  (x[idx2] >> (32  r))) % 0x100000000 )319 ((x[idx1] << r)  (x[idx2] >> (32  r))) % 0x100000000] 320 320 321 321 keyLength = len(rawKey) … … 338 338 v = map(lambda a,b:a^b, v, t) 339 339 feistel1(v, SIGMA2) 340 return t + tuple(v) + \ 341 rot(t, 15) + rot(t, 79) + rot(v, 15) + rot(v, 79) + \ 342 rot(v, 30) + rot(v, 94) + rot(t, 45) + rot(t, 109) + \ 343 rot(v, 45) + rot(t, 124) + rot(v, 60) + rot(v, 124) + \ 344 rot(t, 77) + rot(t, 13) + rot(t, 94) + rot(t, 30) + \ 345 rot(v, 94) + rot(v, 30) + rot(t, 111) + rot(t, 47) + \ 346 rot(v, 111) + rot(v, 47) 340 t = list(t) 341 t += v 342 t += rot(t, 15) 343 t += rot(t, 79) 344 t += rot(v, 15) 345 t += rot(v, 79) 346 t += rot(v, 30) 347 t += rot(v, 94) 348 t += rot(t, 45) 349 t += rot(t, 109) 350 t += rot(v, 45) 351 t += rot(t, 124) 352 t += rot(v, 60) 353 t += rot(v, 124) 354 t += rot(t, 77) 355 t += rot(t, 13) 356 t += rot(t, 94) 357 t += rot(t, 30) 358 t += rot(v, 94) 359 t += rot(v, 30) 360 t += rot(t, 111) 361 t += rot(t, 47) 362 t += rot(v, 111) 363 t += rot(v, 47) 364 return tuple(t) 347 365 348 366 else: … … 353 371 w = map(lambda a,b:a^b, u, v) 354 372 feistel1(w, SIGMA3) 355 return t + tuple(w) + \ 356 rot(u, 15) + rot(u, 79) + rot(v, 15) + rot(v, 79) + \ 357 rot(u, 30) + rot(u, 94) + rot(w, 30) + rot(w, 94) + \ 358 rot(t, 45) + rot(t, 109) + rot(v, 45) + rot(v, 109) + \ 359 rot(t, 60) + rot(t, 124) + rot(u, 60) + rot(u, 124) + \ 360 rot(w, 60) + rot(w, 124) + rot(t, 77) + rot(t, 13) + \ 361 rot(v, 77) + rot(v, 13) + rot(u, 94) + rot(u, 30) + \ 362 rot(v, 94) + rot(v, 30) + rot(t, 111) + rot(t, 47) + \ 363 rot(w, 111) + rot(w, 47) 373 t = list(t) 374 t += w 375 t += rot(u, 15) 376 t += rot(u, 79) 377 t += rot(v, 15) 378 t += rot(v, 79) 379 t += rot(u, 30) 380 t += rot(u, 94) 381 t += rot(w, 30) 382 t += rot(w, 94) 383 t += rot(t, 45) 384 t += rot(t, 109) 385 t += rot(v, 45) 386 t += rot(v, 109) 387 t += rot(t, 60) 388 t += rot(t, 124) 389 t += rot(u, 60) 390 t += rot(u, 124) 391 t += rot(w, 60) 392 t += rot(w, 124) 393 t += rot(t, 77) 394 t += rot(t, 13) 395 t += rot(v, 77) 396 t += rot(v, 13) 397 t += rot(u, 94) 398 t += rot(u, 30) 399 t += rot(v, 94) 400 t += rot(v, 30) 401 t += rot(t, 111) 402 t += rot(t, 47) 403 t += rot(w, 111) 404 t += rot(w, 47) 405 return tuple(t) 364 406 365 407 return keyTable … … 369 411 '''EncryptBlock(plainText, keyTable) 370 412 371 plainText: string; 16 characters413 plainText: string; plain text 16 characters 372 414 keyTable: key generated by Ekeygen() 373 returns: chipher text'''415 returns: string; chipher text 16 characters''' 374 416 375 417 t = list(struct.unpack('!IIII', plainText)) … … 414 456 '''EncryptBlock(plainText, keyTable) 415 457 416 cipherText: 16 bytes string458 cipherText: string; cipher text 16 characters 417 459 keyTable: key generated by Ekeygen() 418 returns: plain text'''460 returns: string; plain text 16 characters''' 419 461 420 462 t = list(struct.unpack('!IIII', cipherText))
Note: See TracChangeset
for help on using the changeset viewer.