Crypto Core

The main project of this chapter is a tiny, simple (not to say primitive) encryption/decryption module written entirely in Assembly. Since the topic of this chapter is interfacing Assembly modules and modules written in high-level languages, we will not delve into cryptography principles, but we will rather concentrate on the portability and interoperability of our code while using a slightly modified XOR algorithm. The idea behind the algorithm is to receive an array of bytes and do the following:

  1. Take a byte and rotate it a certain number of bits to the left (the counter is randomly generated at compile time).
  2. XOR the result with the 1-byte key (randomly generated at compile time as well).
  3. Write the byte back to the array.
  4. If there are more bytes to encrypt, go to step 1; otherwise break out of the loop.

The following screenshot is an example output of the algorithm we are about to implement:

Not the best encryption, but definitely enough for our needs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset