News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Crude AES demo

Started by MichaelW, February 26, 2014, 06:16:24 PM

Previous topic - Next topic

MichaelW

I posted this here, in answer to a question in the Romper Room, to avoid having it get lost.

http://masm32.com/board/index.php?topic=2965.0

Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Michael,

nice example. Thank you.  :t

Gunther
You have to know the facts before you can distort them.

ragdog


jj2007

Works like a charm :t
... but with a few changes:
if 0   ; ML doesn't like redefinition of symbols...
CALG_AES_128           equ ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_AES_128
CALG_AES_192           equ ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_AES_192
CALG_AES_256           equ ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_AES_256
else
CALG_AES_256x           equ ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCK or ALG_SID_AES_256
endif
...
    invoke CryptGenKey, hProv, CALG_AES_256x, 0, ADDR hKey


The original ALG_SID_AES_256 chokes with error A2006: undefined symbol : ALG_TYPE_BLOCKorALG_SID_AES_256

I guess you corrected lines 16740ff in WinExtra.inc?

morgot

Michael, thank you  :t  :biggrin:
Sorry for the bad English

Siekmanski

Creative coders use backward thinking techniques as a strategy.

dedndave


MichaelW

Quote from: jj2007 on February 26, 2014, 08:56:37 PM
I guess you corrected lines 16740ff in WinExtra.inc?

I'm not on that system right now, but I recall noting the problem with multiple similar equates a few weeks back and adding it to my list of windows.inc errors, but I can't recall if I corrected the lines. In any case I assembled with ML 6.15, no warnings and no errors. Sorry about forgetting to mention this.

I also forgot to call CryptDestroyKey to release the key handle.
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

it seems that ML doesn't mind redefinition of EQU symbols, if the constant is the same   :biggrin:
at least, that's what i've observed with 6.15.8803

jj2007

I am now on my other system, and see the same oddities in WinExtra.inc, starting with line 16740 and ending with line 16764:

CALG_NO_SIGN                     equ (ALG_CLASS_SIGNATURE or ALG_TYPE_ANY or ALG_SID_ANY)
CALG_RSA_KEYX                    equ (ALG_CLASS_KEY_EXCHANGE or ALG_TYPE_RSAorALG_SID_RSA_ANY)
CALG_DES                         equ (ALG_CLASS_DATA_ENCRYPT or ALG_TYPE_BLOCKorALG_SID_DES)


Do more people have these strange lines, or is it limited to my machines? ;)

dedndave

oh oh - i see several such lines, Jochen   :redface:

MichaelW

#11
Searching the MASM32 winextra.inc on my second system I find 28 instances of "orALG".

Later:

I'm now on my first system, and I did make the changes to winextra.inc, and CALG_AES_256 is definitely being redefined in my source, so it looks like ML 6.15 tolerates this. I translated the definitions from WinCrypt.h because my first attempts to reference CALG_AES_256, and similar, failed.
Well Microsoft, here's another nice mess you've gotten us into.

morgot

MichaelW, can you tell me, how to set specific password? If I do not want to generate a random password, but take a specific string for the password.
Sorry for the bad English

dedndave

fill in the string with nulls so the user passwords are always the same length
use a fixed key to encrypt the password text
then use the encrypted password data to create the key

just an idea   :P