Advertisement
Guest User

Untitled

a guest
May 20th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. format ELF64
  2.  
  3. public CPUSupportsOptimizations
  4. public fast_aesb_pseudo_round_mut
  5. public fast_aesb_single_round
  6.  
  7. ; Returns nonzero if AES instruction set is supported
  8. ; void CPUSupportsOptimizations(void)
  9. CPUSupportsOptimizations:
  10.     mov eax, 1
  11.     cpuid
  12.     and ecx, 0xFFFFFFDF
  13.     mov eax, ecx
  14.     ret
  15.  
  16. ; void fast_aesb_single_round(in, out, expandedKey)
  17. fast_aesb_single_round:
  18.     movdqu xmm1, [rdi]          ; Move state into XMM1
  19.     aesenc xmm1, [rdx]
  20.     movdqu [rsi], xmm1
  21.     ret
  22.  
  23. ; void fast_aesb_pseudo_round_mut(val, expandedKey)
  24. fast_aesb_pseudo_round_mut:
  25.     xor r9, r9              ; Clear this so it can be used as a counter
  26.     mov r10, 10             ; Number of rounds
  27.  
  28.     movdqu xmm1, [rdi]          ; Move state into XMM1
  29.  
  30.     .AESRoundLoop:
  31.         aesenc xmm1, [rsi]
  32.         add rsi, 0x10           ; Advance expanded key pointer
  33.  
  34.         inc r9              ; Increment round counter
  35.         cmp r9, r10         ; Did we do all the rounds?
  36.         jl .AESRoundLoop        ; If not, loop some more
  37.  
  38.     movdqu [rdi], xmm1
  39.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement