diff options
-rw-r--r-- | modules/alg_ia32/serp_asm.S | 28 | ||||
-rw-r--r-- | modules/alg_ia32/serpent.cpp | 1 |
2 files changed, 17 insertions, 12 deletions
diff --git a/modules/alg_ia32/serp_asm.S b/modules/alg_ia32/serp_asm.S index e6c8c3cb3..30c154516 100644 --- a/modules/alg_ia32/serp_asm.S +++ b/modules/alg_ia32/serp_asm.S @@ -443,7 +443,6 @@ START_LISTING(serp_asm.S) *************************************************/ START_FUNCTION(serpent_encrypt) SPILL_REGS() - #define PUSHED 4 ASSIGN(EBP, ARG(1)) /* input block */ @@ -507,6 +506,7 @@ START_FUNCTION(serpent_encrypt) ASSIGN(ARRAY4(EBP, 3), EDX) RESTORE_REGS() +#undef PUSHED END_FUNCTION(serpent_encrypt) /************************************************* @@ -514,6 +514,7 @@ END_FUNCTION(serpent_encrypt) *************************************************/ START_FUNCTION(serpent_decrypt) SPILL_REGS() +#define PUSHED 4 ASSIGN(EBP, ARG(1)) /* input block */ ASSIGN(EDI, ARG(3)) /* round keys */ @@ -576,6 +577,7 @@ START_FUNCTION(serpent_decrypt) ASSIGN(ARRAY4(EBP, 3), EDX) RESTORE_REGS() +#undef PUSHED END_FUNCTION(serpent_decrypt) /************************************************* @@ -583,21 +585,25 @@ END_FUNCTION(serpent_decrypt) *************************************************/ START_FUNCTION(serpent_key_schedule) SPILL_REGS() +#define PUSHED 4 ASSIGN(EDI, ARG(1)) /* round keys */ ASSIGN(ESI, IMM(8)) ADD_IMM(EDI, 32) START_LOOP(.EXPANSION) - - ASSIGN(EAX, ESI) - SUB_IMM(EAX, 8) - - XOR(EAX, ARRAY4(EDI, -1)) - XOR(EAX, ARRAY4(EDI, -3)) - XOR(EAX, ARRAY4(EDI, -5)) - XOR(EAX, ARRAY4(EDI, -8)) - XOR(EAX, IMM(0x9E3779B9)) + ASSIGN(EAX, ARRAY4(EDI, -1)) + ASSIGN(EBX, ARRAY4(EDI, -3)) + ASSIGN(ECX, ARRAY4(EDI, -5)) + ASSIGN(EDX, ARRAY4(EDI, -8)) + + ASSIGN(EBP, ESI) + SUB_IMM(EBP, 8) + XOR(EBP, IMM(0x9E3779B9)) + XOR(EAX, EBX) + XOR(ECX, EDX) + XOR(EAX, EBP) + XOR(EAX, ECX) ROTL_IMM(EAX, 11) @@ -607,7 +613,6 @@ START_LOOP(.EXPANSION) ADD_IMM(ESI, 1) LOOP_UNTIL(ESI, IMM(140), .EXPANSION) - ASSIGN(EDI, ARG(1)) /* round keys */ #define LOAD_AND_SBOX(MSG, SBOX) \ @@ -660,5 +665,6 @@ LOOP_UNTIL(ESI, IMM(140), .EXPANSION) LOAD_AND_SBOX(32, SBOX_E4) RESTORE_REGS() +#undef PUSHED END_FUNCTION(serpent_key_schedule) diff --git a/modules/alg_ia32/serpent.cpp b/modules/alg_ia32/serpent.cpp index 964b677a1..fd489574b 100644 --- a/modules/alg_ia32/serpent.cpp +++ b/modules/alg_ia32/serpent.cpp @@ -43,7 +43,6 @@ void Serpent::key(const byte key[], u32bit length) W[length / 4] |= u32bit(1) << ((length%4)*8); serpent_key_schedule(W); - round_key.copy(W + 8, 132); } |