flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Rijndael (and AES) macros for fasm |
Author |
|
revolution 23 Jul 2005, 02:33
Rijndael is the encryption scheme adopted by NIST for the AES. These macros support all the original Rijndael specification key and block sizes. ECB and CBC mode macros are included.
Encryption/decryption is not fast, about 350 bytes/second (using 128 bit key and block sizes) on my laptop. Possible uses might be if you have small pieces of code and/or data that you want to encode within your executable. For larger sections I would recommend using an external program to do the work unless you are patient and don't mind waiting for assembly to complete. The attachment contains 9 files: Rijndael-fasm.inc - the core macros Rijndael-fasm-verify.asm - verifying correct operation test-vectors.inc - test vectors for sanity check Rijndael-fasm-speed.asm - encrypts 100k, but be patient ecb_vk.asm - generates ecb_vk.txt for comparison to Rijndael specification ecb_vt.asm - generates ecb_vt.txt for comparison to Rijndael specification test_run.bat - WIN-2K and WIN-XP batch doing verification and comparison Reference\ecb_vk.txt - original Rijndael specification generated file Reference\ecb_vt.txt - original Rijndael specification generated file
Last edited by revolution on 14 Jun 2010, 04:12; edited 2 times in total |
|||||||||||
23 Jul 2005, 02:33 |
|
skingston 10 Feb 2006, 01:54
How easy would it be to convert the macros into a program? I would do this myself but I currently only have a limited knowledge of macros and I do not know how the algorithm works. Do you have info on the algorithm?
|
|||
10 Feb 2006, 01:54 |
|
revolution 10 Feb 2006, 02:54
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 authors site and download the original specifications. There is software available for many languages for free.
|
|||
10 Feb 2006, 02:54 |
|
Reverend 10 Feb 2006, 16:54
On Witeg's page there are many algo implementations but in MASM. Here is AES implementation. It's always easier/faster to rewrite it than to make it whole new. And MASM->FASM isn't so hard to do.
|
|||
10 Feb 2006, 16:54 |
|
vid 24 Aug 2006, 11:59
some links about rijndael from MHajduk:
http://www.iaik.tugraz.at/research/krypto/AES/old/~rijmen/rijndael http://csrc.nist.gov/CryptoToolkit/aes/rijndael/ |
|||
24 Aug 2006, 11:59 |
|
vid 30 Aug 2006, 08:14
just for case you want neat AES implementation in C (also contains asm implementation for x86, written in YASM):
http://fp.gladman.plus.com/cryptography_technology/rijndael/ |
|||
30 Aug 2006, 08:14 |
|
ziral2088 13 Jun 2010, 11:29
Hi guys. I want to place encrypted strings in resource section, so i download these macroses, but i cant use them in right way(
I use 128 bit key and 128 block size. Macroses say ok, but they write zeroes instead of crypted data. I try cbc and ecb - the result is the same. Code: .. UrlKey1 = 845AF1F7h UrlKey2 = 863428ABh UrlKey3 = 845AF1F7h UrlKey4 = 863428ABh UrlKey5 = 845AF1F7h UrlKey6 = 863428ABh UrlKey7 = 845AF1F7h UrlKey8 = 863428ABh macro simple_rijndael_fasm_encrypt key1 , key2 , key3 , key4 , key5 , key6 , key7 , key8 , pData , dwDataSize { rijndael_fasm_init 128 , 128 ;key size 128, block size 128 rijndael_fasm_key_schedule key1 , key2 , key3 , key4 , key5 , key6 , key7 , key8 rijndael_fasm_encrypt_blocks_ecb pData , dwDataSize;cbc give the same result. } macro PlaceInStringTableEncryptedString key1* , key2* , key3* , key4* , key5* , key6* , key7* , key8* , string* { local size,s virtual at 0 db string size = $ end virtual dw size s = $ du string simple_rijndael_fasm_encrypt key1 , key2 , key3 , key4 , key5 , key6 , key7 , key8 , s , size;(but here must be * 2, when i do so - error appear.) } PlaceInStringTableEncryptedString UrlKey1 , UrlKey2 , UrlKey3 , UrlKey4 , UrlKey5 , UrlKey6 , UrlKey7 , UrlKey8 ,\ "teststring" |
|||
13 Jun 2010, 11:29 |
|
revolution 14 Jun 2010, 04:15
ziral2088: I have updated the attachment in the first post.
The previous attachment was for older versions of fasm. The only change is that all double hashes ("##") have been changed to backslash-hash ("\#"). |
|||
14 Jun 2010, 04:15 |
|
ziral2088 14 Jun 2010, 19:48
thank you
Now all works. |
|||
14 Jun 2010, 19:48 |
|
Overflowz 29 Jun 2011, 09:05
Hi, I'm new with macros so, I don't understand it's algorithm.. Can someone tell me how to encrypt custom size of data ? for example "Hello World!" I've tried something like this but it fails..
Code: include 'Rijndael-fasm.inc' virtual at 0 ;************************************************************ ;CBC mode speed ;************************************************************ rijndael_test_data: db "Hello World!",0 rijndael_fasm_init 128,128 rijndael_fasm_key_schedule 0,0,0,0,0,0,0,0 rijndael_fasm_encrypt_blocks_cbc rijndael_test_data,12 end virtual |
|||
29 Jun 2011, 09:05 |
|
revolution 29 Jun 2011, 09:22
Pad your data to the next block size (128 bits in your case):
Code: db "Hello World!",4 dup 0 ;pad to 128 bits (16 bytes) |
|||
29 Jun 2011, 09:22 |
|
Overflowz 29 Jun 2011, 10:00
Thank you.. I though 128 was bytes not bits ^^
|
|||
29 Jun 2011, 10:00 |
|
Overflowz 04 Jul 2011, 08:26
Now what I'm doing wrong here ?......
Code: format PE CONSOLE 4.0 include 'WIN32AX.INC' include 'ENCRYPTION\Rijndael.inc' entry main section '.data' data readable writeable k1 = 845AF1F7h k2 = 863428ABh k3 = 845AF1F7h k4 = 863428ABh k5 = 845AF1F7h k6 = 863428ABh k7 = 845AF1F7h k8 = 863428ABh rijndael_data: db "Hello World!",4 dup 0 section '.text' code readable executable main: aes_128 rijndael_data,16,k1,k2,k3,k4,k5,k6,k7,k8 invoke Sleep,-1 ret aes_128 macro Code: macro aes_128 pData, size, key1, key2, key3, key4, key5, key6, key7, key8 { rijndael_fasm_init 128,128 rijndael_fasm_key_schedule key1, key2, key3, key4, key5, key6, key7, key8 rijndael_fasm_encrypt_blocks_ecb pData, size } error = "value out of range." Thanks. |
|||
04 Jul 2011, 08:26 |
|
revolution 06 Jul 2011, 05:18
You won't be able to access data outside the current section. Move your encryption into the data section:
Code: db "Hello World!",4 dup 0 aes_128 rijndael_data,16,k1,k2,k3,k4,k5,k6,k7,k8 section '.text' code readable executable |
|||
06 Jul 2011, 05:18 |
|
Overflowz 06 Jul 2011, 06:13
ahh..... I don't understood for what macroses were and now I know.. Thank you very much
|
|||
06 Jul 2011, 06:13 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.