sha1_pad :: HInt -> HArr (HExp Word8) -> Hardware (HArr (HExp Word8))
sha1_pad blocks message =
  do let len = length message :: HInt
     bits :: HWord64           <- shareM (i2n len * 8)
     size :: HInt              <- shareM (64 * blocks)
     imsg :: HIrr (HExp Word8) <- unsafeFreezeArr message
     pad  :: HArr (HExp Word8) <- newArr (64 * blocks)
     -- copy original message.
     for (0) (len-1) $ \i ->
       setArr pad i (imsg !! i)
     -- add the single one.
     setArr pad len 1
     -- fill with zeroes.
     for (len+1) (size-9) $ \i ->
       setArr pad i 0
     -- add length in last 8 8-bits.
     for (size-8) (size-1) $ \i ->
       setArr pad i (i2n (bits `shiftR` (8 * ((size-1) - i))))
     return pad
sha1_pad :: HInt -> HArr (HExp Word8) -> Hardware (HArr (HExp Word8))
sha1_pad blocks message =
  do let len = length message :: HInt
     bits :: HWord64           <- shareM (i2n len * 8)
     size :: HInt              <- shareM (64 * blocks)
     imsg :: HIrr (HExp Word8) <- unsafeFreezeArr message
     pad  :: HArr (HExp Word8) <- newArr (64 * blocks)
     -- copy original message.
     for (0) (len-1) $ \i ->
       setArr pad i (imsg !! i)
     -- add the single one.
     setArr pad len 1
     -- fill with zeroes.
     for (len+1) (size-9) $ \i ->
       setArr pad i 0
     -- add length in last 8 8-bits.
     for (size-8) (size-1) $ \i ->
       setArr pad i (i2n (bits `shiftR` (8 * ((size-1) - i))))
     return pad
sha1_pad blocks message =
  do let len = length message :: HInt
     bits :: HWord64           <- shareM (i2n len * 8)
     size :: HInt              <- shareM (64 * blocks)
     imsg :: HIrr (HExp Word8) <- unsafeFreezeArr message
     pad  :: HArr (HExp Word8) <- newArr (64 * blocks)
     -- copy original message.
     for (0) (len-1) $ \i ->
       setArr pad i (imsg !! i)
     -- add the single one.
     setArr pad len 1
     -- fill with zeroes.
     for (len+1) (size-9) $ \i ->
       setArr pad i 0
     -- add length in last 8 8-bits.
     for (size-8) (size-1) $ \i ->
       setArr pad i (i2n (bits `shiftR` (8 * ((size-1) - i))))
     return pad