\<comment> \<open>nonlinear functions at bit level\<close>
definition f::"[nat, word32, word32, word32] => word32" where "f j x y z =
(if ( 0 <= j & j <= 15) then x XOR y XOR z
else if (16 <= j & j <= 31) then (x AND y) OR (NOT x AND z)
else if (32 <= j & j <= 47) then (x OR NOT y) XOR z
else if (48 <= j & j <= 63) then (x AND z) OR (y AND NOT z)
else if (64 <= j & j <= 79) then x XOR (y OR NOT z)
else 0)"
definition step_l :: "[ block,
chain,
nat
] => chain" where "step_l X c j =
(let (A, B, C, D, E) = c in
(\<comment> \<open>\<open>A:\<close>\<close> E, \<comment> \<open>\<open>B:\<close>\<close> word_rotl (s j) (A + f j B C D + X (r j) + K j) + E, \<comment> \<open>\<open>C:\<close>\<close> B, \<comment> \<open>\<open>D:\<close>\<close> word_rotl 10 C, \<comment> \<open>\<open>E:\<close>\<close> D))"
definition step_r :: "[ block,
chain,
nat
] \<Rightarrow> chain" where "step_r X c' j =
(let (A', B', C', D', E') = c'in
(\<comment> \<open>\<open>A':\<close>\<close> E', \<comment> \<open>\<open>B':\<close>\<close> word_rotl (s' j) (A' + f (79 - j) B' C' D' + X (r' j) + K' j) + E', \<comment> \<open>\<open>C':\<close>\<close> B', \<comment> \<open>\<open>D':\<close>\<close> word_rotl 10 C', \<comment> \<open>\<open>E':\<close>\<close> D'))"
definition step_both :: "[ block, chain * chain, nat ] \ chain * chain" where "step_both X cc j = (case cc of (c, c') \
(step_l X c j, step_r X c' j))"
definition steps::"[ block, chain * chain, nat] \ chain * chain" where"steps X cc i = foldl (step_both X) cc [0..
definition round::"[ block, chain ] \ chain" where"round X h =
(let (h0, h1, h2, h3, h4) = h in let ((A, B, C, D, E), (A', B', C', D', E')) = steps X (h, h) 80 in
(\<comment> \<open>\<open>h0:\<close>\<close> h1 + C + D', \<comment> \<open>\<open>h1:\<close>\<close> h2 + D + E', \<comment> \<open>\<open>h2:\<close>\<close> h3 + E + A', \<comment> \<open>\<open>h3:\<close>\<close> h4 + A + B', \<comment> \<open>\<open>h4:\<close>\<close> h0 + B + C'))"
definition rmd_body::"[ message, chain, nat ] => chain" where "rmd_body X h i = round (X i) h"
definition rounds::"message \ chain \ nat \ chain" where "rounds X h i = foldl (rmd_body X) h_0 [0..
definition rmd :: "message \ nat \ chain" where "rmd X len = rounds X h_0 len"
end
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.