Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SHA256Transform(void* pstate, void* pinput, const void* pinit)
- {
- SHA256_CTX ctx;
- unsigned char data[64];
- SHA256_Init(&ctx);
- for (int i = 0; i < 16; i++)
- ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]);
- for (int i = 0; i < 8; i++)
- ctx.h[i] = ((uint32_t*)pinit)[i];
- SHA256_Update(&ctx, data, sizeof(data));
- for (int i = 0; i < 8; i++)
- ((uint32_t*)pstate)[i] = ctx.h[i];
- }
- 080b3770 <_Z15SHA256TransformPvS_PKv>:
- 80b3770: 55 push %ebp
- 80b3771: 57 push %edi
- 80b3772: 56 push %esi
- 80b3773: 53 push %ebx
- 80b3774: 81 ec ec 00 00 00 sub $0xec,%esp
- 80b377a: 8b 84 24 00 01 00 00 mov 0x100(%esp),%eax ;; pstate
- 80b3781: 8d 5c 24 2c lea 0x2c(%esp),%ebx ;; ctx
- 80b3785: 8b b4 24 04 01 00 00 mov 0x104(%esp),%esi ;; pinput
- 80b378c: 8d ac 24 9c 00 00 00 lea 0x9c(%esp),%ebp ;; data
- 80b3793: 8b bc 24 08 01 00 00 mov 0x108(%esp),%edi ;; pinit
- 80b379a: 89 1c 24 mov %ebx,(%esp) ;; ctx for SHA256_Init call
- 80b379d: 89 44 24 1c mov %eax,0x1c(%esp) ;; pstate
- ;; initialize "stack canary"
- 80b37a1: 65 a1 14 00 00 00 mov %gs:0x14,%eax
- 80b37a7: 89 84 24 dc 00 00 00 mov %eax,0xdc(%esp)
- 80b37ae: 31 c0 xor %eax,%eax
- SHA256_Init(&ctx);
- 80b37b0: e8 8b 3a fa ff call 8057240 <SHA256_Init@plt>
- for (int i = 0; i < 16; i++)
- 80b37b5: 31 d2 xor %edx,%edx ;; i = 0
- 80b37b7: 90 nop
- 0: ;; start of loop
- ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]);
- 80b37b8: 8b 0c 96 mov (%esi,%edx,4),%ecx ;; value from pinput array
- ;; begin ByteReverse
- ;; let's say the word is 0x11223344
- 80b37bb: 89 c8 mov %ecx,%eax
- 80b37bd: 81 e1 00 ff 00 ff and $0xff00ff00,%ecx ;; 0x11003300
- 80b37c3: 25 ff 00 ff 00 and $0xff00ff,%eax ;; 0x220044
- 80b37c8: c1 e0 08 shl $0x8,%eax ;; 0x22004400
- 80b37cb: c1 e9 08 shr $0x8,%ecx ;; 0x00110033
- 80b37ce: 09 c8 or %ecx,%eax ;; 0x22114433
- 80b37d0: c1 c8 10 ror $0x10,%eax ;; 0x44332211
- ;; end ByteReverse
- ;; FIXED: changed to bswap %edx
- 80b37d3: 89 44 95 00 mov %eax,0x0(%ebp,%edx,4) ;; store in data array
- 80b37d7: 83 c2 01 add $0x1,%edx
- 80b37da: 83 fa 10 cmp $0x10,%edx ;; i < 16 ?
- 80b37dd: 75 d9 jne 80b37b8 <_Z15SHA256TransformPvS_PKv+0x48> ;; jne 0b
- for (int i = 0; i < 8; i++)
- 80b37df: 31 c0 xor %eax,%eax ;; i = 0
- 80b37e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
- ctx.h[i] = ((uint32_t*)pinit)[i];
- 1: ;; start of loop
- 80b37e8: 8b 14 87 mov (%edi,%eax,4),%edx ;; from pinit array
- 80b37eb: 89 14 83 mov %edx,(%ebx,%eax,4) ;; to ctx array
- 80b37ee: 83 c0 01 add $0x1,%eax ;; i++
- 80b37f1: 83 f8 08 cmp $0x8,%eax ;; i < 8
- 80b37f4: 75 f2 jne 80b37e8 <_Z15SHA256TransformPvS_PKv+0x78> ;; jne 1b
- SHA256_Update(&ctx, data, sizeof(data));
- 80b37f6: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) ;; sizeof(data)
- 80b37fd: 00
- 80b37fe: 89 6c 24 04 mov %ebp,0x4(%esp) ;; data
- 80b3802: 89 1c 24 mov %ebx,(%esp) ;; ctx
- 80b3805: e8 f6 33 fa ff call 8056c00 <SHA256_Update@plt>
- for (int i = 0; i < 8; i++)
- ((uint32_t*)pstate)[i] = ctx.h[i];
- 80b380a: 8b 4c 24 1c mov 0x1c(%esp),%ecx ;; pstate
- 80b380e: 31 c0 xor %eax,%eax ;; i = 0
- 2: ;; start of loop
- 80b3810: 8b 14 83 mov (%ebx,%eax,4),%edx ;; from ctx
- 80b3813: 89 14 81 mov %edx,(%ecx,%eax,4) ;; to pstate
- 80b3816: 83 c0 01 add $0x1,%eax ;; i++
- 80b3819: 83 f8 08 cmp $0x8,%eax ;; i < 8
- 80b381c: 75 f2 jne 80b3810 <_Z15SHA256TransformPvS_PKv+0xa0> ;; jne 2b
- 80b381e: 8b 84 24 dc 00 00 00 mov 0xdc(%esp),%eax ;; stack canary
- 80b3825: 65 33 05 14 00 00 00 xor %gs:0x14,%eax ;; original canary value
- 80b382c: 75 0b jne 80b3839 <_Z15SHA256TransformPvS_PKv+0xc9> ;; fail if no match
- 80b382e: 81 c4 ec 00 00 00 add $0xec,%esp ;; clean up stack
- 80b3834: 5b pop %ebx ;; pop registers and return
- 80b3835: 5e pop %esi
- 80b3836: 5f pop %edi
- 80b3837: 5d pop %ebp
- 80b3838: c3 ret
- 80b3839: e8 c2 3c fa ff call 8057500 <__stack_chk_fail@plt>
- 80b383e: 66 90 xchg %ax,%ax
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement