1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define HASH_GLOBALS
#include "type.h"
#include "vdef.h"
#include "vhace.h"
#include "vfun.h"
void HashAst3000(ULONG ulLength, ULONG *output, ULONG ulHashMode)
{
ULONG i, ulTemp, ulCommand, ulDigestLength;
ULONG ulValue;
/* Get Info */
switch (ulHashMode)
{
case VHASHMODE_MD5:
ulCommand = VHASH_ALG_SELECT_MD5;
ulDigestLength = 16;
break;
case VHASHMODE_SHA1:
ulCommand = VHASH_ALG_SELECT_SHA1;
ulDigestLength = 20;
break;
case VHASHMODE_SHA256:
ulCommand = VHASH_ALG_SELECT_SHA256;
ulDigestLength = 32;
break;
case VHASHMODE_SHA224:
ulCommand = VHASH_ALG_SELECT_SHA224;
ulDigestLength = 28;
break;
}
/* Init. HW */
WriteMemoryLongHost(VHAC_REG_BASE, VREG_HASH_SRC_BASE_OFFSET, g_HashSrcBuffer);
WriteMemoryLongHost(VHAC_REG_BASE, VREG_HASH_DST_BASE_OFFSET, g_HashDstBuffer);
WriteMemoryLongHost(VHAC_REG_BASE, VREG_HASH_LEN_OFFSET, ulLength);
/* write src */
//already fill in g_VIDEO1_COMPRESS_BUF_ADDR
/* fire cmd */
WriteMemoryLongHost(VHAC_REG_BASE, VREG_HASH_CMD_OFFSET, ulCommand);
/* get digest */
do {
ulTemp = ReadMemoryLongHost(VHAC_REG_BASE, VREG_HASH_STATUS_OFFSET);
} while (ulTemp & VHASH_BUSY);
for (i=0; i<ulDigestLength/4; i++)
{
ulValue = *(((ULONG *)g_HashDstBuffer) + i);
//output is ULONG pointer
*(output + i) = ulValue;
}
}
|