Changeset 3137
- Timestamp:
- Aug 9, 2012 1:30:02 AM (10 months ago)
- Files:
-
- 1 added
- 6 edited
-
cpu/arm/mmp2/hash.fth (modified) (2 diffs)
-
cpu/arm/mmp2/random.fth (added)
-
cpu/arm/olpc/1.75/crypto-version.fth (modified) (1 diff)
-
cpu/arm/olpc/3.0/crypto-version.fth (modified) (1 diff)
-
cpu/arm/olpc/cl4/crypto-version.fth (modified) (1 diff)
-
cpu/arm/olpc/prefw.fth (modified) (1 diff)
-
ofw/wifi/hmacsha1.fth (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cpu/arm/mmp2/hash.fth
r3071 r3137 2 2 purpose: Hashes (MD5, SHA1, SHA-256) using Marvell hardware acceleration 3 3 4 [ifdef] use-mmp2-hashes 4 5 h# 8101 constant dval 5 6 : dma>hash ( adr len -- ) … … 120 121 : sha1-update hash-update ; 121 122 : sha1-final hash-final drop to sha1-digest ; 122 123 : ebg-set ( n -- ) h# 292c00 io@ or h# 292c00 io! ;124 : ebg-clr ( n -- ) invert h# 292c00 io@ and h# 292c00 io! ;125 126 0 [if]127 \ This is the procedure recommended by the datasheet, but it doesn't work128 : init-entropy-digital ( -- )129 \ h# ffffffff ebg-clr \ All off130 h# 00008000 ebg-set \ Digital entropy mode131 h# 00000400 ebg-clr \ RNG reset132 h# 00000200 ebg-set \ Bias power up133 d# 400 us134 h# 00000100 ebg-set \ Fast OSC enable135 h# 00000080 ebg-set \ Slow OSC enable136 h# 02000000 ebg-set \ Downsampling ratio137 h# 00110000 ebg-set \ Slow OSC divider138 h# 00000400 ebg-set \ RNG unreset139 h# 00000040 ebg-set \ Post processor enable140 h# 00001000 ebg-set141 ;142 [else]143 \ This procedure works144 : init-entropy ( -- ) \ Using digital method145 h# 21117c0 h# 292c00 io!146 ;147 123 [then] 148 149 : random-short ( -- w )150 begin h# 292c04 io@ dup 0>= while drop repeat151 h# ffff and152 ;153 : random-byte ( -- b ) random-short 2/ h# ff and ;154 : random-long ( -- l )155 random-short random-short wljoin156 ;157 alias random random-long158 159 stand-init: Random number generator160 h# 1b h# 68 pmua! \ Ensure WTM clock is enabled161 init-entropy162 ;163 124 164 125 \ LICENSE_BEGIN -
cpu/arm/olpc/1.75/crypto-version.fth
r2008 r3137 4 4 5 5 \ The bios_verify image 6 macro: CRYPTO_VERSION 0. 5-ARM6 macro: CRYPTO_VERSION 0.6-ARM -
cpu/arm/olpc/3.0/crypto-version.fth
r2727 r3137 4 4 5 5 \ The bios_verify image 6 macro: CRYPTO_VERSION 0. 5-ARM6 macro: CRYPTO_VERSION 0.6-ARM -
cpu/arm/olpc/cl4/crypto-version.fth
r3055 r3137 4 4 5 5 \ The bios_verify image 6 macro: CRYPTO_VERSION 0. 5-ARM6 macro: CRYPTO_VERSION 0.6-ARM -
cpu/arm/olpc/prefw.fth
r3049 r3137 151 151 fload ${BP}/cpu/arm/mmp2/socregs.fth \ MMP2 registers used by many functional units 152 152 153 fload ${BP}/cpu/arm/mmp2/ hash.fth \ Hashes - SHA1, SHA-256, MD5153 fload ${BP}/cpu/arm/mmp2/random.fth \ Random numbers 154 154 fload ${BP}/cpu/x86/pc/olpc/crypto.fth \ Cryptographic image validation 155 fload ${BP}/cpu/arm/olpc/swhash.fth \ Hashes - SHA1, SHA-256, MD5 155 156 fload ${BP}/cpu/x86/pc/olpc/lzip.fth \ Access zip images from memory 156 157 -
ofw/wifi/hmacsha1.fth
r2004 r3137 37 37 then 38 38 ; 39 [ifndef] sha1-n 40 : sha1-n ( datan$..data1$ n -- digest$ ) 41 sha1-init 42 0 ?do sha1-update loop 43 sha1-final 44 sha1-digest /sha1-digest ( digest$ ) 45 ; 46 [then] 39 47 : hmac-sha1 ( datan$..data1$ n key$ -- digest$ ) 40 ?sha1-reset-key ( datan$..data1$ n key$' ) 41 2dup key>keypad >r >r ( datan$..data1$ n ) ( R: key$ ) 48 ?sha1-reset-key 2>r ( datan$..data1$ n ) ( R: key$' ) 42 49 43 50 \ sha1-idigest = SHA1(K XOR ipad, text) 44 keypad h# 36 xor-keypad ( datan$..data1$ n ) ( R: key$ ) 45 sha1-init ( datan$..data1$ n ) ( R: key$ ) 46 keypad /keypad sha1-update ( datan$..data1$ n ) ( R: key$ ) 47 0 ?do sha1-update loop ( ) ( R: key$ ) 48 sha1-final ( ) ( R: key$ ) 49 sha1-digest sha1-idigest /sha1-digest move ( ) ( R: key$ ) 51 2r@ key>keypad ( datan$..data1$ n ) ( R: key$ ) 52 keypad h# 36 xor-keypad ( datan$..data1$ n ) 50 53 51 \ sha1-digest = SHA1(K XOR opad, sha1-idigest) 52 r> r> key>keypad ( ) 54 keypad /keypad rot 1+ sha1-n ( digest$ ) ( R: key$ ) 55 sha1-idigest swap move ( ) ( R: key$ ) 56 57 2r> key>keypad ( ) 53 58 keypad h# 5c xor-keypad 54 sha1-init55 keypad /keypad sha1-update56 sha1-idigest /sha1-digest sha1-update57 sha1-final58 59 59 sha1- digest /sha1-digest( digest$ )60 sha1-idigest /sha1-digest keypad /keypad 2 sha1-n ( digest$ ) 60 61 ; 61 62 … … 75 76 /sha1-digest buffer: temp2 \ Current digest 76 77 : (pbkdf2-sha1) ( passphrase$ ssid$ -- ) 77 2over >r>r ( passphrase$ ssid$ ) ( R: passphrase$ )78 pbkdf2-cnt-buf 4 2swap 2 r>r> hmac-sha1 ( passphrase$ digest$ )78 2over 2>r ( passphrase$ ssid$ ) ( R: passphrase$ ) 79 pbkdf2-cnt-buf 4 2swap 2 2r> hmac-sha1 ( passphrase$ digest$ ) 79 80 temp2 swap move ( passphrase$ ) 80 81 d# 4096 1 do … … 90 91 begin dup 0> while ( passphrase$ ssid$ psk$ ) 91 92 pbkdf2-cnt++ ( passphrase$ ssid$ psk$ ) 92 >r>r 2over 2over (pbkdf2-sha1) ( passphrase$ ssid$ ) ( R: psk$ )93 r>r> 2dup /sha1-digest min sha1-digest -rot move ( passphrase$ ssid$ psk$ )93 2>r 2over 2over (pbkdf2-sha1) ( passphrase$ ssid$ ) ( R: psk$ ) 94 2r> 2dup /sha1-digest min sha1-digest -rot move ( passphrase$ ssid$ psk$ ) 94 95 /sha1-digest /string ( passphrase$ ssid$ psk$' ) 95 96 repeat 2drop 2drop 2drop ( ) … … 102 103 0 prf-cnt c! 103 104 begin dup 0> while ( key$ label$ data$ result$ ) 104 >r>r ( key$ label$ data$ ) ( R: result$ )105 2>r ( key$ label$ data$ ) ( R: result$ ) 105 106 prf-cnt 1 2over zero$ ( key$ label$ data$ cnt$ data$ zero$ ) ( R: result$ ) 106 107 9 pick 9 pick 4 ( key$ label$ data$ cnt$ data$ zero$ label$ n ) ( R: result$ ) 107 108 d# 14 pick d# 14 pick hmac-sha1 ( key$ label$ data$ digest$ ) ( R: result$ ) 108 r>r> 2swap 2over rot min move ( key$ label$ data$ result$ )109 2r> 2swap 2over rot min move ( key$ label$ data$ result$ ) 109 110 /sha1-digest /string ( key$ label$ data$ result$' ) 110 111 prf-cnt c@ 1+ prf-cnt c! ( key$ label$ data$ result$ ) 111 112 repeat 2drop 2drop 2drop 2drop ( ) 112 113 113 ; 114 114
Note: See TracChangeset
for help on using the changeset viewer.
