The MASM Forum

General => The Campus => Topic started by: paneselchino on June 07, 2013, 02:47:24 PM

Title: XorData, RorData, and RolData
Post by: paneselchino on June 07, 2013, 02:47:24 PM
Can someone give examples of this functions I google them for a while, but I can't find something useful. Thanks in advanced
Title: Re: XorData, RorData, and RolData
Post by: Adamanteus on June 07, 2013, 03:30:43 PM
 That's need exacting what's it doing, so first function bit filed operation, two last could supply copy bits algo.
Title: Re: XorData, RorData, and RolData
Post by: paneselchino on June 07, 2013, 03:36:34 PM
Quote from: Adamanteus on June 07, 2013, 03:30:43 PM
That's need exacting what's it doing, so first function bit filed operation, two last could supply copy bits algo.
I need code man
like this:
.386
.model flat, stdcall
option casemap :none ; case sensitive
.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
.list
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
message DW 27
key DW 30
.code
inicio:
invoke XorData,addr message,sizeof message,addr key,sizeof key
end inicio

By the way this code isn't working
Title: Re: XorData, RorData, and RolData
Post by: hutch-- on June 07, 2013, 04:05:44 PM
It does not appear that you have read the help file on those algos. They all need another file to combine the data with, usually  a high quality random pad. XOR the second time to unencrypt the data using the identical pad, with the rotate algos, the first one used is decrypted with the second against the identical pad.
Title: Re: XorData, RorData, and RolData
Post by: paneselchino on June 07, 2013, 04:17:34 PM
I just only need a example, a basic example, teach me with code :) , I read the help...
Title: Re: XorData, RorData, and RolData
Post by: hutch-- on June 07, 2013, 07:03:03 PM
We don't do requests here, show us what you have written.
Title: Re: XorData, RorData, and RolData
Post by: dedndave on June 07, 2013, 10:43:56 PM
\masm32\help\masmlib.chm, under Encryption Components

your code might work, you just aren't looking at the results properly

but - try something a bit larger than words
Title: Re: XorData, RorData, and RolData
Post by: hutch-- on June 08, 2013, 12:18:03 AM
This should get you going.



IF 0  ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                      Build this template with "CONSOLE ASSEMBLE AND LINK"
ENDIF ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include\masm32rt.inc

    .data
      srctxt db "I wanna encrypt this data",0   ; the data to encrypt
      thekey db "this is the key I will use",0  ; the KEY to encrypt it against
      lsrc dd sizeof srctxt                     ; the length of the source to encrypt
      lkey dd sizeof thekey                     ; the length of the key to encrypt against

    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    print ADDR srctxt,13,10                     ; display the original string

    invoke XorData,OFFSET srctxt,lsrc,OFFSET thekey,lkey

    print ADDR srctxt,13,10                     ; display what you can of the encrypted string

    invoke XorData,OFFSET srctxt,lsrc,OFFSET thekey,lkey

    print ADDR srctxt,13,10                     ; display the string again after decrypting it

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start
Title: Re: XorData, RorData, and RolData
Post by: hutch-- on June 08, 2013, 12:32:34 AM
Something you should note when using these very simple algorithms, it is not the algorithm that gives you the encryption strength, it is the quality of the key or properly the PAD that you use to encrypt against. If it is a highly randomised pad it will be much harder to break and also note that in critical tasks the reusing the same pad makes it weaker each time. An amateur will not breqak it as the pad weakens but a pro will work it out if they need to.
Title: Re: XorData, RorData, and RolData
Post by: dedndave on June 08, 2013, 12:38:00 AM
yah - a longer key is better
and, XorData on the data, then RolData on the key   :P
Title: Re: XorData, RorData, and RolData
Post by: paneselchino on June 08, 2013, 05:48:25 AM

Thank you, you wasn't helpful, here is my code it read a string from keyboard and a key and that message get encrypt and decrypted.I'll leave it here since it was difficult to find information

Here is the code --hutch...
with XorData:

.386
.model flat, stdcall
option casemap :none ; case sensitive
.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc


.list
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
mensaje1 DB "Digite un mensaje a encriptar ",0
mensaje2 DB "Digite llave de encriptacion ",0
mensaje3 DB "Mensaje Encriptado ",0
mensaje4 DB "Mensaje despues de desencriptar ",0
msj DB 127 DUP (0),0
key DB 127 DUP (0),0

.code
inicio:
invoke ClearScreen
invoke StdOut,ADDR mensaje1
invoke StdIn,ADDR msj,LENGTHOF msj
invoke StdOut,ADDR mensaje2
invoke StdIn,ADDR key,LENGTHOF key
invoke XorData,ADDR msj,LENGTHOF msj,ADDR key,LENGTHOF key
invoke StdOut,ADDR mensaje3
invoke StdOut,ADDR msj
invoke XorData,ADDR msj,LENGTHOF msj,addr key,LENGTHOF key
invoke StdOut,ADDR mensaje4
invoke StdOut,ADDR msj
invoke ExitProcess,0
end inicio

RorData and RolData

.386
.model flat, stdcall
option casemap :none ; case sensitive
.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc


.list
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
mensaje1 DB "Digite un mensaje a encriptar ",0
mensaje2 DB "Digite llave de encriptacion ",0
mensaje3 DB "Mensaje Encriptado ",0
mensaje4 DB "Mensaje despues de desencriptar ",0
msj DB 127 DUP (0),0
key DB 127 DUP (0),0

.code
inicio:
invoke ClearScreen
invoke StdOut,ADDR mensaje1
invoke StdIn,ADDR msj,LENGTHOF msj
invoke StdOut,ADDR mensaje2
invoke StdIn,ADDR key,LENGTHOF key
invoke RolData,ADDR msj,LENGTHOF msj,ADDR key,LENGTHOF key
invoke StdOut,ADDR mensaje3
invoke StdOut,ADDR msj
invoke RorData,ADDR msj,LENGTHOF msj,addr key,LENGTHOF key
invoke StdOut,ADDR mensaje4
invoke StdOut,ADDR msj
invoke ExitProcess,0
end inicio

Greetings from El Salvador.