News:

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

Main Menu

Inverse of xor ?

Started by guga, May 09, 2020, 04:24:55 AM

Previous topic - Next topic

guga

Hii Guys


I´m confused about the reverse operation involving and not and xor.

is correct to assume that the opposite of a and (with a not register) followed by a xor is like this ?

Operation:
mov eax 2213225 | and eax (not 159) | xor eax 4587817 | mov ecx eax

Reverse

and ecx (not 159) | xor ecx 4587817


And if it is, does it also works for MMX and SSe operations, such as:?

movq MM0 MM1 | pandn MM0 MM2| pxor MM0 MM3 | movq MM4 MM0

Is it equal to ?

movq MM0 MM4 | pandn MM0 MM2| pxor MM0 MM3



On the same question, how to determine the relation between 3 different numbers envolving the same operation ?


What is the relation between the resultant values and how to recover the values on their original operations ?

Ex: Say we have:

        movq MM0 A | pandn MM0 B | pxor MM0 Result1 | movq Result1 MM0
        movq MM0 B | pandn MM0 C | pxor MM0 Result2 | movq Result2 MM0
        movq MM0 C | pandn MM0 D | pxor MM0 Result3 | movq Result3 MM0
        movq MM0 D | pandn MM0 E | pxor MM0 Result4 | movq Result4 MM0
        movq MM0 E | pandn MM0 A | pxor MM0 Result5 | movq Result5 MM0

How to recover the values of A. B, C, D, E knowing the values of Result1 to Result5 ?


Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

FORTRANS

Hi,
Quote from: guga on May 09, 2020, 04:24:55 AM
I´m confused about the reverse operation involving and not and xor.

   For a general case, the AND operation is not reversible.  NOT and
XOR are reversible, but AND is not.


A | B | A.AND.B
T | T |    T
T | F |    F
F | T |    F
F | F |    F


   If the result is False, you cannot say what the individual inputs
were.  So you can not reproduce the input values.

Regards,

Steve N.

guga

#2
But they do relate to each other. "A" variable repeats on the 1st and 5th operation

Can the reverse be something like a polynomial multiplication as explained here ?

https://math.stackexchange.com/questions/523660/how-to-reverse-this-bitwise-and-xor-encoding-algorithm

Or also can it be reverted on similar way it does for shift xor ?
https://www.reddit.com/r/ReverseEngineering/comments/3pdf60/reversing_shiftxor_operation/
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

FORTRANS

Hi,

Quote from: guga on May 09, 2020, 06:19:40 AM
But they do relate to each other. "A" variable repeats on the 1st and 5th operation

   Okay, I wrote a program that wrote out results for the 1st and 5th
operations.  I used byte sized variables and wrote to Result1a and
Result5a to reuse the input values of Result1 and result5.  Four different
A (VarA) values produce the same output values.

   Here is the edited program output.


An example for MASM Forum member guga.
To answer a question about reversability.
VarA = C1
VarB = 2C
VarE = 9B
Result1 = 3E
Result5 = 85

Result1a = FF
Result5a = 9F

finis.

VarA = C1 Result1a = FF Result5a = 9F
VarA = C5 Result1a = FF Result5a = 9F
VarA = E5 Result1a = FF Result5a = 9F
VarA = E1 Result1a = FF Result5a = 9F


HTH,

Steve N.

Mikl__

not(0x5E)=0xFFFFFFA1
0x5E xor 0xFFFFFFFF=0xFFFFFFA1
0xFFFFFFFF - 0x5E= 0xFFFFFFA1

mineiro

I thought AND gate was reversible until mabdelouahab proposed a similar question. And I tried, first programming, then building a digital circuit and finally a truth table, but all in vain.
Imagine 100 sequential keys, one after another, and at the end a light bulb. Note that the lamp will light (1) only when the 100 keys are closed.
Now about your question: If only one key is open, the lamp will not light, I mean, the result will be 0. But which or how many keys are open? Brute force. I mean, the first key and the last one are closed, but what about the middle ones !?
In electronics, some factories only buy NAND (not and) because we can reconstruct all the other logic just using this (Integrated Circuit).

A Russian cryptographer created the XOR cipher, so far as I know it is unbreakable. XOR can logically encompass AND, OR, NOT.

xor ax, ax          ;mov ax,0               ;and ax,0
xor ax, 21h         ;add ax,21h (logical)   ;or ax,21
xor ax, 1           ;sub ax,1 (logical)     ;and ax,0feh
xor al, 0FFh        ;one complement         ;not al
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

daydreamer

XOR was good for underpowered computers XOR spritepixel,backgroundpixel to draw sprite and use it second time to erase sprite
or you need to alternate things,TRUE/FALSE flag
I used it when drawing a chessboard,every time in yloop
alternate=alternate xor squarewidth
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

mineiro

yes, xor is a three way.
A text1 XOR text2 == encripted result.
A text1 XOR encripted result == text2.
A text2 XOR encripted result == text1.
So, inserting a random number will do this job hard. The probability (frequency) of next char will be the probability of all other chars (possible combinations), hard to guess.

George Boole was thinking in create a math that was not arithmetic or geometry, so he create logic.
XOR have been created after AND,OR and NOT.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

daydreamer

Quote from: mineiro on May 16, 2020, 11:42:26 PM
yes, xor is a three way.
A text1 XOR text2 == encripted result.
A text1 XOR encripted result == text2.
A text2 XOR encripted result == text1.
So, inserting a random number will do this job hard. The probability (frequency) of next char will be the probability of all other chars (possible combinations), hard to guess.
thanks,so adding PXOR after 128bit random generator encrypts 16 chars at a time
more secure would be use Hutch randompad generator
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding