Last active
December 30, 2019 05:36
-
-
Save enkomio/a24771cd915f0c468bb725b24aebb998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc main | |
push buffer /* push arguments */ | |
push buffer_length | |
push key | |
push key_length | |
push 4 /* number of arguments */ | |
push de_encrypt /* method to invoke */ | |
call | |
halt | |
endp | |
/* | |
This method accept: | |
1 - the length of the password | |
2 - a pointer to the password to use | |
3 - the lengh of the buffer | |
4 - a pointer to the buffer | |
*/ | |
proc de_encrypt | |
/* load arguments in local vars */ | |
pop key_length | |
pop key | |
pop buffer_length | |
pop buffer | |
/* init local var indexes */ | |
push 0 | |
pop buffer_index | |
push 0 | |
pop key_index | |
push 0 | |
pop buffer_char | |
push 0 | |
pop key_char | |
encryption_loop: | |
/* read the character from the buffer */ | |
push buffer_index | |
push buffer | |
add | |
nread | |
pop buffer_char | |
/* read the character from the key buffer */ | |
push key_index | |
push key | |
add | |
nread | |
pop key_char | |
/* do XOR and save the result on the stack */ | |
push key_char | |
push buffer_char | |
xor | |
/* write back the result */ | |
push buffer_index | |
push buffer | |
add | |
nwrite | |
/* increase counter */ | |
push 1 | |
push key_index | |
add | |
pop key_index | |
push 1 | |
push buffer_index | |
add | |
pop buffer_index | |
/* check if I have to round the password index (no modulo operation) */ | |
push key_length | |
push key_index | |
cmp | |
push check_for_completation | |
jumpifl | |
round_key: | |
push 0 | |
pop key_index | |
check_for_completation: | |
push buffer_length | |
push buffer_index | |
cmp | |
push encryption_loop | |
jumpifl | |
ret | |
endp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment