A Basic RSA Encrypter

This is a small post about implementing a basic RSA encrypter to encrypt sections in an exe. We can use this to exchange exes with people. We will encrypt the section using the public key and the user has to use his private key to decrypt the exe. This can be applied in evading anti-viruses too.
I will use multiplication instead of an exponent. Since it would be easy to implement in few lines in assembly. However, this will allow breaking the private key easily hence the complete scheme is broken.

[latexpage]Enc = (m*e) \text{ mod } N&bg=FFFFFF&s=1[/latexpage]

$latex Dec = (c*d) \text{ mod } N$

The correctness of this scheme depends on the fact that

$latex Dec(Enc(m)) = (m*e*d) \text{ mod } N = m \text{ mod } N&bg=FFFFFF&s=1$


For this example let’s take 3 as the public key and 171 as the private key.

$latex Enc = m * 3 \text{ mod } 256&bg=FFFFFF&s=1$

$latex Dec= c * 171 \text{ mod } 256&bg=FFFFFF&s=1$

Here’s a simple assembly implementation. Since we are using modulus 256 the first byte is removed out from the value. So we don’t need to again implement a modulus in the code.

I made a small video demonstration.

Leave a Reply