[SHA1-Engine] Problem with SHA_SRC

31 views
Skip to first unread message

lewurm

unread,
Jun 21, 2009, 8:01:09 PM6/21/09
to bootmii-devel
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.

Anyway, I stuck at this problem for some hours, I hope somebody can
help me :)

patches for
- ppcskel: patch generated with git diff, since there is no official
git repository (ppcskel.zip can found here on the list)
- mini (commit 4d854edb54cf): patch generated with git format-patch
can found here:
http://stud4.tuwien.ac.at/~e0725771/sha1-engine_ppcskel.diff
http://stud4.tuwien.ac.at/~e0725771/0001-tried-to-get-working-the-sha1-engine-through-mini.patch


thanks in advance,
lewurm

Sven Peter

unread,
Jun 22, 2009, 5:23:47 AM6/22/09
to bootmi...@googlegroups.com
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.
> Anyway, I stuck at this problem for some hours, I hope somebody can
> help me :)
>
> patches for
> - ppcskel: patch generated with git diff, since there is no official
> git repository (ppcskel.zip can found here on the list)
> - mini (commit 4d854edb54cf): patch generated with git format-patch
> can found here:
> http://stud4.tuwien.ac.at/~e0725771/sha1-engine_ppcskel.diff
> http://stud4.tuwien.ac.at/~e0725771/0001-tried-to-get-working-the-sha1-engine-through-mini.patch
>
>
> thanks in advance,
> lewurm
> >
>


Sven
Reply all
Reply to author
Forward
0 new messages