i use again the HW MD5 in the actuell SDK 1.5.4 NONOS but can't figure out again like in past.
know - there is no document in the past online -
but i know about MD5 and the steps - so i read in the eagle.rom.addr.v6.ld
this:
Code: Select all
..
PROVIDE ( MD5Final = 0x40009900 );
PROVIDE ( MD5Init = 0x40009818 );
PROVIDE ( MD5Update = 0x40009834 );
..
so i do simple this in a definitation:
i create simple types and function pointer to this
Code: Select all
typedef unsigned char xmd5_byte_t; /* 8-bit byte */
typedef unsigned int xmd5_word_t; /* 32-bit word */
typedef struct xmd5_state_s {
xmd5_word_t count[2]; /* message length in bits, lsw first */
xmd5_word_t abcd[4]; /* digest buffer */
xmd5_byte_t buf[64]; /* accumulate block */
} xmd5_state_t;
typedef void (*xmd5_init) (xmd5_state_t *pms);
typedef void (*xmd5_append) (xmd5_state_t *pms, const xmd5_byte_t *data, int nbytes);
typedef void (*xmd5_finish) (xmd5_state_t *pms, xmd5_byte_t digest[16]);
// example for better understand how i work with this..
// PROVIDE ( uart_tx_one_char = 0x40003b30 );
typedef void (*funcptr)(uint8);
and now i work with this
// first the simple example..
Code: Select all
// we print out
((funcptr)0x40003b30)('h');
((funcptr)0x40003b30)('e');
((funcptr)0x40003b30)('l');
((funcptr)0x40003b30)('l');
((funcptr)0x40003b30)('o');
((funcptr)0x40003b30)(' ');
((funcptr)0x40003b30)('w');
((funcptr)0x40003b30)('o');
((funcptr)0x40003b30)('r');
((funcptr)0x40003b30)('l');
((funcptr)0x40003b30)('d');
((funcptr)0x40003b30)('\n');
pricipal understand?
ok ,,
same principal for the chip id
Code: Select all
uint32 id = ((*(volatile uint32*)(0x3ff00050) & 0xff000000) >> 24) |
((*(volatile uint32*)(0x3ff00054) & 0x00ffffff) << 8);
os_printf("Chip Id: %lu\n", id );
ok .. like i said,
in past the HW MD5 was go -
now i try to resample it like this
Code: Select all
char text[] = "MasterBlasterFC";
int i2;
xmd5_state_t state2;
xmd5_byte_t digest2[16];
os_printf("\nNow HW MD5 :\n");
// typedef void (*xmd5_init) (xmd5_state_t *pms);
((xmd5_init)0x40009818) (&state2);
// typedef void (*xmd5_append) (xmd5_state_t *pms, const xmd5_byte_t *data, int nbytes);
((xmd5_append)0x40009834) (&state2, (const xmd5_byte_t *)text, strlen(text));
// typedef void (*xmd5_finish) (xmd5_state_t *pms, xmd5_byte_t digest[16]);
((xmd5_finish)0x40009900) (&state2, digest2);
os_printf("HW md5 hash of string %s = ", text);
for(i2=0; i2 < 16; i2++)
{
os_printf("%02x", digest2[i2]);
}
os_printf("\n");
the output is:
sometimes this:
Code: Select all
Chip Id: 10273663<\r><\n>
<\r><\n>
Now HW MD5 :<\r><\n>
Fatal exception 9(LoadStoreAlignmentCause):<\r><\n>
epc1=0x40009913, epc2=0x00000000, epc3=0x00000000, excvaddr=0x3ffffab9, depc=0x00000000<\r><\n>
"@*rjrA(!?SKu????<27>X?Q?~<7>?????UI????I*E,??1<6>?<21>)DP?Y?Y?~?h???n?*Mm )i?~?9?N?~?<1>&zA,!??A? ??*El-?,1?!e|?<25>????A,!??n?*e??hI?A,PZ<\r>?r<7>,R?*5<6>??vA/9<5>?y*Eh n?*E"????A,X[M??A,X[?rf[112] : 03<\r><\n>
rf[113] : 00<\r><\n>
rf[114] : 01<\r><\n>
<\r><\n>
SDK ver: 1.5.4(baaeaebb) compiled @ May 17 2016 19:23:54<\r><\n>
phy ver: 972, pp ver: 10.1<\r><\n>
<\r><\n>
..
i spend a little time in this to go on again..
i have use a software md5
and use the hw md5 for compare..
// my function
Code: Select all
// the software MD5
char text[] = "MasterBlasterFC";
int i;
md5_state_t state;
md5_byte_t digest[16];
md5_init(&state);
md5_append(&state, (const md5_byte_t *)text, strlen(text));
md5_finish(&state, digest);
os_printf("md5 hash of string %s = ", text);
for(i=0; i < 16; i++)
{
os_printf("%02x", digest[i]);
}
os_printf("\n");
// return 0;
// now the HW MD5
char text2[] = "MasterBlasterFC";
int i2;
xmd5_state_t state2;
xmd5_byte_t digest2[16];
// ((funcptr)0x40003b30)('r');
os_printf("\nNow HW MD5 :\n");
// typedef void (*xmd5_init) (xmd5_state_t *pms);
((xmd5_init)0x40009818) (&state2);
// typedef void (*xmd5_append) (xmd5_state_t *pms, const xmd5_byte_t *data, int nbytes);
((xmd5_append)0x40009834) (&state2, (const xmd5_byte_t *)text2, strlen(text2));
// typedef void (*xmd5_finish) (xmd5_state_t *pms, xmd5_byte_t digest[16]);
((xmd5_finish)0x40009900) (&state2, digest2);
os_printf("HW md5 hash of string %s = ", text);
for(i2=0; i2 < 16; i2++)
{
os_printf("%02x", digest2[i2]);
}
os_printf("\n");
Code: Select all
// my call ( string, strlen)
FCM_md5_hash_me(void);
the output
Code: Select all
..
hello world!<\n>
Chip Id: 10273663<\r><\n>
md5 hash of string MasterBlasterFC = 834b0a82fbe5d7aee196cac93a8d76c5<\r><\n>
<\r><\n>
Now HW MD5 :<\r><\n>
HW md5 hash of string MasterBlasterFC = 00000000b7cf90813ad79905b580e4af<\r><\n>
..
no problem if HW5 no more support in SDK 1.5.4 and higher -
can work with MD5 soft -
but would be fine - if we can use it -
have you a right teaching in this
how we can use the Hardware MD5 now?
thank you
best wishes
rudi

header of the SoftWare MD5
Code: Select all
#ifndef _MD5_H_
#define _MD5_H_
typedef unsigned char md5_byte_t; /* 8-bit byte */
typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
md5_word_t count[2]; /* message length in bits, lsw first */
md5_word_t abcd[4]; /* digest buffer */
md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;
#ifdef __cplusplus
extern "C"
{
#endif
/* Initialize the algorithm. */
void md5_init(md5_state_t *pms);
/* Append a string to the message. */
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
/* Finish the message and return the digest. */
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif