]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/crypto/common/common.factor
Fixing basis -> extra dependencies
[factor.git] / extra / crypto / common / common.factor
index 651bd51774164a7316a16239119557c7fcc7176a..61cc11f95986fa5671114075077b068016fd1fc0 100644 (file)
@@ -1,55 +1,17 @@
 USING: arrays kernel io io.binary sbufs splitting grouping
 strings sequences namespaces math math.parser parser
-hints math.bitfields.lib assocs ;
+hints math.bitwise assocs ;
 IN: crypto.common
 
-: w+ ( int int -- int ) + 32 bits ; inline
-
 : (nth-int) ( string n -- int )
     2 shift dup 4 + rot <slice> ; inline
     
 : nth-int ( string n -- int ) (nth-int) le> ; inline
     
-: nth-int-be ( string n -- int ) (nth-int) be> ; inline
-
 : update ( num var -- ) [ w+ ] change ; inline
-    
-: calculate-pad-length ( length -- pad-length )
-    dup 56 < 55 119 ? swap - ;
 
-: preprocess-plaintext ( string big-endian? -- padded-string )
-    #! pad 0x80 then 00 til 8 bytes left, then 64bit length in bits
-    >r >sbuf r> over [
-        HEX: 80 ,
-        dup length HEX: 3f bitand
-        calculate-pad-length 0 <string> %
-        length 3 shift 8 rot [ >be ] [ >le ] if %
-    ] "" make over push-all ;
-
-SYMBOL: bytes-read
 SYMBOL: big-endian?
 
-: pad-last-block ( str big-endian? length -- str )
-    [
-        rot %
-        HEX: 80 ,
-        dup HEX: 3f bitand calculate-pad-length 0 <string> %
-        3 shift 8 rot [ >be ] [ >le ] if %
-    ] "" make 64 group ;
-
-: update-old-new ( old new -- )
-    [ get >r get r> ] 2keep >r >r w+ dup r> set r> set ; inline
-
-: slice3 ( n seq -- a b c ) >r dup 3 + r> <slice> first3 ;
-
-: seq>2seq ( seq -- seq1 seq2 )
-    #! { abcdefgh } -> { aceg } { bdfh }
-    2 group flip dup empty? [ drop { } { } ] [ first2 ] if ;
-
-: 2seq>seq ( seq1 seq2 -- seq )
-    #! { aceg } { bdfh } -> { abcdefgh }
-    [ zip concat ] keep like ;
-
 : mod-nth ( n seq -- elt )
     #! 5 "abcd" -> b
     [ length mod ] [ nth ] bi ;