mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 20:33:13 +00:00
LIBCRYPT: add HMAC-MD5
This commit is contained in:
parent
03603b431c
commit
a414e9d080
@ -138,6 +138,8 @@ J.MD5.XXXX .DA MD5.0015
|
||||
.DA MD5.1631
|
||||
.DA MD5.3247
|
||||
.DA MD5.4863
|
||||
L.HMACMD5.IPAD .DA HMACMD5.IPAD
|
||||
L.HMACMD5.OPAD .DA HMACMD5.OPAD
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
LIB.LOAD
|
||||
@ -176,7 +178,7 @@ MD5 lda #1
|
||||
>STYA ZPDataPtr
|
||||
>SYSCALL2 strlen
|
||||
>STYA ZPDataLen
|
||||
.1 jsr MD4Init
|
||||
.1 jsr MD4Init.I
|
||||
bcs .9
|
||||
|
||||
pha save MD4/MD5 Context hMem
|
||||
@ -201,6 +203,8 @@ MD5 lda #1
|
||||
* ## RETURN VALUE
|
||||
* A = hMem To S.MD4
|
||||
*\--------------------------------------
|
||||
MD4Init lda #0
|
||||
.HS 2C BIT ABS
|
||||
*/--------------------------------------
|
||||
* ## MD5Init
|
||||
* Initialize a MD5 computation
|
||||
@ -211,8 +215,11 @@ MD5 lda #1
|
||||
* ## RETURN VALUE
|
||||
* A = hMem To S.MD5
|
||||
*\--------------------------------------
|
||||
MD4Init
|
||||
MD5Init >LDYAI S.MD4
|
||||
MD5Init lda #1
|
||||
sta MD.MODE
|
||||
|
||||
MD4Init.I
|
||||
MD5Init.I >LDYAI S.MD4
|
||||
>SYSCALL2 getmem
|
||||
bcs .9
|
||||
|
||||
@ -247,8 +254,6 @@ MD5Init >LDYAI S.MD4
|
||||
* `>hLIBCRYPT,LIBCRYPT.MD4Update`
|
||||
* ## RETURN VALUE
|
||||
*\--------------------------------------
|
||||
MD4Update lda #0
|
||||
.HS 2C BIT ABS
|
||||
*/--------------------------------------
|
||||
* ## MD5Update
|
||||
* Add Data to MD5 computation
|
||||
@ -261,10 +266,8 @@ MD4Update lda #0
|
||||
* `>hLIBCRYPT,LIBCRYPT.MD5Update`
|
||||
* ## RETURN VALUE
|
||||
*\--------------------------------------
|
||||
MD5Update lda #1
|
||||
sta MD.MODE
|
||||
|
||||
>PULLW ZPDataLen get LEN
|
||||
MD4Update
|
||||
MD5Update >PULLW ZPDataLen get LEN
|
||||
>PULLW ZPDataPtr get DATA
|
||||
|
||||
>PULLA
|
||||
@ -442,6 +445,91 @@ MD5Finalize.I ldy #S.MD4.FINALIZED
|
||||
* https://github.com/fab13n/org.eclipse.mihini/blob/master/libs/hmac-md5/hmac_rfc2104/hmac-md5.c
|
||||
*--------------------------------------
|
||||
HMACMD5
|
||||
>PULLW ZPHashPtr
|
||||
>PULLW ZPDataPtr
|
||||
>PULLW HMAC.DTemp
|
||||
.1 jsr MD5Init
|
||||
bcc .2
|
||||
|
||||
rts
|
||||
|
||||
.2 >LDYA ZPDataPtr
|
||||
>SYSCALL2 strlen
|
||||
>STYA ZPDataLen
|
||||
cpy #65
|
||||
bcs .3
|
||||
tay
|
||||
beq .4
|
||||
|
||||
.3 >PUSHW ZPHashPtr
|
||||
jsr MD5Update.I
|
||||
jsr MD5Finalize.I
|
||||
>PULLW ZPHashPtr
|
||||
>LDYA ZPCtxPtr
|
||||
>STYA ZPDataPtr
|
||||
lda #16
|
||||
sta ZPDataLen
|
||||
|
||||
.4 ldy #0
|
||||
.5 lda #$36
|
||||
cpy ZPDataLen
|
||||
bcs .6
|
||||
eor (ZPDataPtr),y
|
||||
.6 sta HMACMD5.IPAD,y
|
||||
eor #$6A #$36 eor #$5C
|
||||
sta HMACMD5.OPAD,y
|
||||
iny
|
||||
cpy #64
|
||||
bne .5
|
||||
stz HMACMD5.IPAD+64
|
||||
stz HMACMD5.OPAD+64
|
||||
|
||||
jsr MD5Init.I
|
||||
bcc .7
|
||||
|
||||
rts
|
||||
|
||||
.7 >LDYA L.HMACMD5.IPAD
|
||||
>STYA ZPDataPtr
|
||||
>LDYAI 64
|
||||
>STYA ZPDataLen
|
||||
>PUSHW ZPHashPtr
|
||||
jsr MD5Update.I
|
||||
>LDYA HMAC.DTemp
|
||||
>STYA ZPDataPtr
|
||||
>SYSCALL2 strlen
|
||||
>STYA ZPDataLen
|
||||
jsr MD5Update.I
|
||||
jsr MD5Finalize.I
|
||||
>PULLW ZPHashPtr
|
||||
|
||||
ldy #S.MD5.ABCD0
|
||||
|
||||
.8 lda (ZPCtxPtr),y
|
||||
sta HMACMD5.IPAD,y
|
||||
iny
|
||||
cpy #S.MD5.ABCD0+16
|
||||
bne .8
|
||||
|
||||
jsr MD5Init.I
|
||||
bcc .9
|
||||
|
||||
rts
|
||||
|
||||
.9 >LDYA L.HMACMD5.OPAD
|
||||
>STYA ZPDataPtr
|
||||
>LDYAI 64
|
||||
>STYA ZPDataLen
|
||||
jsr MD5Update.I
|
||||
>LDYA L.HMACMD5.IPAD
|
||||
>STYA ZPDataPtr
|
||||
ldy #16
|
||||
sty ZPDataLen
|
||||
jsr MD5Update.I
|
||||
jsr MD5Finalize.I
|
||||
|
||||
rts
|
||||
|
||||
*--------------------------------------
|
||||
* https://waterjuiceweb.wordpress.com/aes/
|
||||
*--------------------------------------
|
||||
@ -836,6 +924,9 @@ MD4.i
|
||||
MD5.i .BS 1
|
||||
MD4.BUFFER64
|
||||
MD5.BUFFER64 .BS 64
|
||||
HMAC.DTemp .BS 4
|
||||
HMACMD5.IPAD .BS 65
|
||||
HMACMD5.OPAD .BS 65
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE usr/src/lib/libcrypt.s
|
||||
|
Loading…
Reference in New Issue
Block a user