diff --git a/basis/io/unix/files/bsd/bsd.factor b/basis/io/unix/files/bsd/bsd.factor index 18e713af2f..3c94baa39a 100644 --- a/basis/io/unix/files/bsd/bsd.factor +++ b/basis/io/unix/files/bsd/bsd.factor @@ -13,5 +13,8 @@ M: bsd stat>file-info ( stat -- file-info ) { [ stat-st_flags >>flags ] [ stat-st_gen >>gen ] - [ stat-st_birthtimespec timespec>unix-time >>birth-time ] + [ + stat-st_birthtimespec timespec>unix-time + >>birth-time + ] } cleave ; diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 67da640b71..2b85420ee9 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -142,7 +142,9 @@ os { [ opendir dup [ (io-error) ] unless ] dip dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline -: find-next-file ( DIR* -- byte-array ) +HOOK: find-next-file os ( DIR* -- byte-array ) + +M: unix find-next-file ( DIR* -- byte-array ) "dirent" f [ readdir_r 0 = [ (io-error) ] unless ] 2keep @@ -159,6 +161,8 @@ M: unix (directory-entries) ( path -- seq ) [ drop ] produce ] with-unix-directory ; +os openbsd = [ "io.unix.files.openbsd" require ] when + + dup 256 [ dup sbox nth rot set-nth ] with each ; + +: rcon ( -- array ) + { + HEX: 00 HEX: 01 HEX: 02 HEX: 04 HEX: 08 HEX: 10 + HEX: 20 HEX: 40 HEX: 80 HEX: 1b HEX: 36 + } ; + +: xtime ( x -- x' ) + [ 1 shift ] + [ HEX: 80 bitand 0 = 0 HEX: 1b ? ] bi bitxor 8 bits ; + +: ui32 ( a0 a1 a2 a3 -- a ) + [ 8 shift ] [ 16 shift ] [ 24 shift ] tri* + bitor bitor bitor 32 bits ; + +:: set-t ( T i -- ) + [let* | + a1 [ i sbox nth ] + a2 [ a1 xtime ] + a3 [ a1 a2 bitxor ] | + a2 a1 a1 a3 ui32 i T set-nth + a3 a2 a1 a1 ui32 i HEX: 100 + T set-nth + a1 a3 a2 a1 ui32 i HEX: 200 + T set-nth + a1 a1 a3 a2 ui32 i HEX: 300 + T set-nth + ] ; + + +MEMO:: t-table ( -- array ) + 1024 0 + dup 256 [ set-t ] with each ; + +:: set-d ( D i -- ) + [let* | + a1 [ i inv-sbox nth ] + a2 [ a1 xtime ] + a4 [ a2 xtime ] + a8 [ a4 xtime ] + a9 [ a8 a1 bitxor ] + ab [ a9 a2 bitxor ] + ad [ a9 a4 bitxor ] + ae [ a8 a4 a2 bitxor bitxor ] + | + ae a9 ad ab ui32 i D set-nth + ab ae a9 ad ui32 i HEX: 100 + D set-nth + ad ab ae a9 ui32 i HEX: 200 + D set-nth + a9 ad ab ae ui32 i HEX: 300 + D set-nth + ] ; + +MEMO:: d-table ( -- array ) + 1024 0 + dup 256 [ set-d ] with each ; + + +USE: multiline +/* +! : HT ( i x s -- + + +TUPLE: caes #rounds2 rkey ; +! rounds / 2, rkey is a byte-array 60 long +! key size is 16, 24, 32 bytes + +TUPLE: caescbc prev4 caes ; + + + +: aes-set-key-encode ( p key -- ) + + ; +*/ diff --git a/extra/crypto/aes/authors.txt b/extra/crypto/aes/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/extra/crypto/aes/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file