All pastes #415682 Raw Edit

Mine

public text v1 · immutable
#415682 ·published 2007-03-29 20:02 UTC
rendered paste body
: ROL ( X1 Count -- X2 )
	2dup lshift -rot negate 32 + rshift or ;

: F1 ( Data Mask Rotation -- Output )
	>r + r> rol								( I    				)
	dup  22 rshift $3FC and sbox1 + @		( I Sx0				)
	over 14 rshift $3FC and sbox2 + @ xor	( I Sx0^Sx1			)
	over  6 rshift $3FC and sbox3 + @ -    	( I Sx0^Sx1-Sx2		)
	swap  2 lshift $3FC and sbox4 + @ xor	( I Sx0^Sx1-Sx2^Sx3 )
;

: 4swap ( x1 x2 x3 x4 -- x4 x3 x2 x1 )
	swap 2swap swap ;

: FEISTEL ( Xt1 Xt2 Xt3 Xt4 "Name" -- )
	CREATE 4swap , , , ,
DOES> ( data mask rotation xt-ptr -- ) >r
	-rot r> dup cell+ >r @ execute swap rol
	dup  22 rshift $3FC and sbox1 + @
	over 14 rshift $3FC and sbox2 + @ r> dup cell+ >r @ execute
	over  6 rshift $3FC and sbox3 + @ r> dup cell+ >r @ execute
	swap  2 lshift $3FC and sbox4 + @ r> @ execute
;