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)"
🍋‹added constants (hexadecimal)›
definition K::"nat => word32" where "K j =
(if ( 0 <= j & j <= 15) then 0x00000000
else if (16 <= j & j <= 31) then 0x5A827999
else if (32 <= j & j <= 47) then 0x6ED9EBA1
else if (48 <= j & j <= 63) then 0x8F1BBCDC
else if (64 <= j & j <= 79) then 0xA953FD4E
else 0)"
definition K'::"nat => word32" where "K' j =
(if ( 0 <= j & j <= 15) then 0x50A28BE6
else if (16 <= j & j <= 31) then 0x5C4DD124
else if (32 <= j & j <= 47) then 0x6D703EF3
else if (48 <= j & j <= 63) then 0x7A6D76E9
else if (64 <= j & j <= 79) then 0x00000000
else 0)"
definition step_l :: "[ block,
chain,
nat
] => chain" where "step_l X c j =
(let (A, B, C, D, E) = c in
(🍋‹‹A:›› E, 🍋‹‹B:›› word_rotl (s j) (A + f j B C D + X (r j) + K j) + E, 🍋‹‹C:›› B, 🍋‹‹D:›› word_rotl 10 C, 🍋‹‹E:›› D))"
definition step_r :: "[ block,
chain,
nat
] ==> chain" where "step_r X c' j =
(let (A', B', C', D', E') = c'in
(🍋‹‹A':\\ E', 🍋‹‹B':\\ word_rotl (s' j) (A' + f (79 - j) B' C' D' + X (r' j) + K' j) + E', 🍋‹‹C':\\ B', 🍋‹‹D':\\ word_rotl 10 C', 🍋‹‹E':\\ 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
(🍋‹‹h0:›› h1 + C + D', 🍋‹‹h1:›› h2 + D + E', 🍋‹‹h2:›› h3 + E + A', 🍋‹‹h3:›› h4 + A + B', 🍋‹‹h4:›› 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"
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 und die Messung sind noch experimentell.