Hi,
lewurm wrote:
> Hi,
> to get familiar with MINI&Co I search for some simple thing to do on
> MINI, so I found out, there is no implementation for the SHA1-Engine
> in Hollywood, also it seems to be nicecly documented on
wiibrew.org
> (
http://wiibrew.org/wiki/Hardware/SHA-1_Engine). (Even if the PPC
> could it faster itself as I read 1-2 days ago on IRC)
>
> However, after some coding, the IPC-communication between PPC and MINI
> worked quite fine. As well the SHA1-Engine delivered some results, but
> the seems to be wrong. The result (input included in patch below) for
> the first part of the hash should be '0083dd51', but it is 'a37be777'.
> I think it mess up at writing the source for the data (SHA_SRC).
> Marcan (?) wrote something (in the wiki) about; the adress must be 64-
> byte aligned, but I don't know how to handle this correctly.
>
There are basically two problems with your patch that I can see:
At first, you do not perform the input padding which is required for a
normal SHA-1 operation.
You therefore need to apply the following three steps to the input data:
1) append the bit 1 to the message
2) append k zero bits so that k is the minimum number which satisfies
the following two conditions:
- k is greater or equal to zero
- k makes the length of your data in bits congruent to 448 mod 512
3) append the length of the original message in bits as a 64bit
big-endian integer
The second problem is that you shift the source address left by 5 bits.
This seems to be a misunderstanding:
The address has to be aligned to a 64 byte boundary which means that the
lowest 5 bit are always zero.
Thus they are marked as unused in the wiki.
Sven