flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > RSA Public Key Encryption (PKE) macros for fasm |
Author |
|
revolution 23 Jul 2005, 17:16
RSA Public Key Encryption (PKE) macros for fasm
RSA is the encryption method used with PGP. We publicise a modulus and key so that others can encrypt messages and send to us (or can decrypt messages we send to them). Once encrypted with one key a message cannot be decrypted with the same key. We can use either key to encrypt and after that we have to use the other key to decrypt. I have attached macros to perform PKE. Once again, not fast but convenient. There is no restriction on key size except that is must be a multiple of 32 bits. You can set the length of the modulus to any multiple of 32 but the limiting factor will probably be your patience waiting for it to complete for the larger key sizes. Obviously since I have published both private and public keys in the attachment you won't be able to use these for any serious encryption. You will have to generate your own key pairs and moduli to make proper use of these macros. While testing these macros I discovered a small problem with the assembler, occasionally the run time will be double the usual if the source file is if the "wrong" length. This is because the generated code in memory within fasm is not aligned to any fixed boundary. I also submit a small change to the file 'PARSER.INC': Code: ;between lines 40 and 41 I align the code to 16 jne invalid_value ;<-- line 40 add edi,15 ;<-- insert this line and edi,not 15 ;<-- and insert this line also mov [code_start],edi ;<-- line 41 The attachment contains 3 files: RSA-fasm.inc - The core macros RSA-fasm-test.asm - Some basic tests to check functionality RSA-fasm-example.asm - An example of possible use This is the last of the three sets of macros I will post (SHA, Rijndael and RSA). I had originally intended to do a fourth with ECC encryption but since most of the interesting functions are similar to RSA I have decided not to do this. Feel free to add ECC to the set yourself, use the RSA macros as a starting point. Why did I do this? I wanted to learn more about how to use the preprocessor and assembler and also how they interact. Making these macros has taught me many things that I will be able to apply to other projects. I hope you all can find good uses for these macros, and perhaps also learn how to do some tasks that you may have thought not possible. If you discover any new tricks and/or methods don't forget to post here.
Last edited by revolution on 23 Sep 2008, 08:43; edited 2 times in total |
|||||||||||
23 Jul 2005, 17:16 |
|
revolution 31 Jul 2005, 01:34
I have updated the attachment above to fix the problem of multiply overflow with the new fasm version 1.63.3
|
|||
31 Jul 2005, 01:34 |
|
shism2 15 Sep 2005, 19:14
I tried using it and after it fnishes it.. The executable outputed is blank
|
|||
15 Sep 2005, 19:14 |
|
revolution 16 Sep 2005, 00:58
The code is not an executable, it is just an example of how it might be used. But you should get a small file with the encrypted signature and the public key and modulus included. Try using a hex editor to view the output.
|
|||
16 Sep 2005, 00:58 |
|
shism2 16 Sep 2005, 02:36
ya I figured that out after lol ... What a noob I am
|
|||
16 Sep 2005, 02:36 |
|
skingston 10 Feb 2006, 01:24
How secure are these marcros? ie. how easy is it for someone to decrypt with the key?
I'm looking for some simple assembly routines that i can use to encrypt data between my program and a server, without having to use something like SSL, but still with as much security as possible. |
|||
10 Feb 2006, 01:24 |
|
skingston 10 Feb 2006, 01:31
How easy would it be to convert these macros to a program?
I only have limited knowledge on macros and do not know how RSA works. Is there a source (ie. info on RSA) you used to write the code? I'm looking for some simple assembly routines that i can use to encrypt data between my program and a server, without having to use something like SSL, but still with as much security as possible. |
|||
10 Feb 2006, 01:31 |
|
revolution 10 Feb 2006, 02:55
I don't have any direct links handy to post but there is plenty of information about this stuff on the WWW. Do a search for it in your favourite search engine. Visit the RSA site and download the original specifications. There is software available for many languages for free.
|
|||
10 Feb 2006, 02:55 |
|
Reverend 10 Feb 2006, 17:00
To implement RSA download BigLib by fleur or other bignum library. In fact RSA is just a powmod function. So first read about RSA, understand how it works, then read BigLib's documentation on biglib_powmod() (or sth like this)
|
|||
10 Feb 2006, 17:00 |
|
Madis731 10 Jan 2007, 17:50
It doesn't work with the latest release of FASM and I saw that parser already included these lines you included (though they are somewhere between lines 163..166). I got the same effect that its blank. It includes all the keys, but the encrypted message is blanked out (all zeroes).
The tests are even worse they don't even compile - they only say that "halt-something went wrong" and I don't know how to debug it. I want to get it working so I can convert it to PHP that doesn't have this function yet. The only problem then remains the 32-bit-ONLY PHP whereas FASM is 64-bit internally. |
|||
10 Jan 2007, 17:50 |
|
revolution 10 Jan 2007, 23:14
Madis731 wrote: It doesn't work with the latest release of FASM I have replaced the attachment in the first post with the edited version that is compatible with fasm 1.67.18. I ran a quick verification test and it says "Okay" now. BTW: the only change is that all double hashes (##) have become backslash-hash (\#). |
|||
10 Jan 2007, 23:14 |
|
Madis731 11 Jan 2007, 08:00
Wow, really thanks, now everything works as expected. I'll post the PHP somewhere if I ever get it finished.
|
|||
11 Jan 2007, 08:00 |
|
loki 11 Feb 2011, 16:34
Thank you very match, good job mmm!
|
|||
11 Feb 2011, 16:34 |
|
loki 07 Sep 2011, 07:16
Good day, none of you did an example implementation of the client to the server FASM in PHP or similar to the key above 512, ideally 4096? sorry, my english is bad:(
|
|||
07 Sep 2011, 07:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.