2021-06-11 17:20:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF bin/hmacmd5
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
|
.INB inc/mli.e.i
|
|
|
|
|
.INB inc/libcrypt.i
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
FILEBUF.SIZE .EQ 4096
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPPtr1 .BS 2
|
|
|
|
|
ZPDataBufPtr .BS 2
|
|
|
|
|
ZPDataLen .BS 2
|
|
|
|
|
ArgIndex .BS 1
|
2021-06-16 03:36:26 +00:00
|
|
|
|
aOptD .BS 1
|
|
|
|
|
aOptK .BS 1
|
2021-06-11 17:20:35 +00:00
|
|
|
|
bText .BS 1
|
2021-06-16 03:36:26 +00:00
|
|
|
|
bGotKey .BS 1
|
2021-06-11 17:20:35 +00:00
|
|
|
|
hFile .BS 1
|
|
|
|
|
hDataBuf .BS 1
|
|
|
|
|
hHMACMD5Ctx .BS 1
|
|
|
|
|
|
|
|
|
|
ZS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #16 SS
|
|
|
|
|
.DA #ZS.END-ZS.START ZP
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.LIBCRYPT .DA LIBCRYPT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
2021-06-16 03:36:26 +00:00
|
|
|
|
L.HMACMD5.IPAD .DA HMACMD5.IPAD
|
|
|
|
|
L.HMACMD5.OPAD .DA HMACMD5.OPAD
|
2021-06-11 17:20:35 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT >LDYA L.LIBCRYPT
|
|
|
|
|
>SYSCALL LoadLib
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
sta hLIBCRYPT
|
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN ldy #S.PS.ARGC
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
beq .99
|
2023-07-14 10:24:49 +00:00
|
|
|
|
.10 lda #0
|
2021-06-16 03:36:26 +00:00
|
|
|
|
pha
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
|
|
|
|
.1 inc ArgIndex
|
|
|
|
|
lda ArgIndex
|
2021-06-19 17:46:36 +00:00
|
|
|
|
|
2021-06-11 17:20:35 +00:00
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
plx
|
|
|
|
|
bcs .8
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
ldy #OptionEnd-OptionList-1
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
|
|
|
|
.2 cmp OptionList,y
|
|
|
|
|
beq .3
|
|
|
|
|
dey
|
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
.99 >PUSHW L.MSG.USAGE
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL PrintF
|
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.3 tya
|
|
|
|
|
lsr
|
|
|
|
|
pha
|
|
|
|
|
tax
|
2021-06-11 17:20:35 +00:00
|
|
|
|
sec
|
2021-06-16 03:36:26 +00:00
|
|
|
|
ror bText,x
|
2021-06-11 17:20:35 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.4 lda ArgIndex
|
|
|
|
|
sta aOptD,x
|
2023-07-14 10:24:49 +00:00
|
|
|
|
bra .10
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.8 lda bGotKey
|
2021-06-11 17:20:35 +00:00
|
|
|
|
beq .99
|
|
|
|
|
|
|
|
|
|
lda bText
|
|
|
|
|
beq CS.RUN.FILE
|
|
|
|
|
*--------------------------------------
|
2021-06-16 03:36:26 +00:00
|
|
|
|
CS.RUN.TEXT lda aOptD
|
2021-06-11 17:20:35 +00:00
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>PUSHYA
|
2021-06-16 03:36:26 +00:00
|
|
|
|
lda aOptK
|
2021-06-11 17:20:35 +00:00
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHEA.G HMACMD5Buf
|
|
|
|
|
>LIBCALL hLIBCRYPT,LIBCRYPT.HMACMD5
|
|
|
|
|
jmp CS.RUN.PRINT
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.FILE >LDYAI FILEBUF.SIZE
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPDataBufPtr
|
|
|
|
|
stx hDataBuf
|
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
lda aOptD
|
2021-06-11 17:20:35 +00:00
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHBI O.RDONLY
|
|
|
|
|
>PUSHBI 0 ftype
|
|
|
|
|
>PUSHWZ Aux type
|
|
|
|
|
>SYSCALL FOpen
|
2021-06-16 03:36:26 +00:00
|
|
|
|
bcc .1
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.9 rts
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.1 sta hFile
|
|
|
|
|
|
|
|
|
|
lda aOptK
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>STYA ZPDataBufPtr
|
|
|
|
|
>SYSCALL2 strlen
|
|
|
|
|
>STYA ZPDataLen
|
|
|
|
|
cpy #65
|
|
|
|
|
bcs .2
|
|
|
|
|
tay
|
|
|
|
|
beq .3
|
|
|
|
|
|
2021-07-27 16:21:58 +00:00
|
|
|
|
.2 >SYSCALL MD5Init
|
2021-06-11 17:20:35 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
sta hHMACMD5Ctx
|
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
>SLEEP
|
|
|
|
|
|
|
|
|
|
>PUSHB hHMACMD5Ctx
|
|
|
|
|
lda aOptK
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW ZPDataLen
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Update
|
2021-06-16 03:36:26 +00:00
|
|
|
|
>PUSHB hHMACMD5Ctx
|
|
|
|
|
>PUSHEA.G HMACMD5Buf
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Finalize
|
2021-06-16 03:36:26 +00:00
|
|
|
|
|
|
|
|
|
jsr RevertASCII
|
|
|
|
|
|
|
|
|
|
.3 ldy #0
|
|
|
|
|
.4 lda #$36
|
|
|
|
|
cpy ZPDataLen
|
|
|
|
|
bcs .5
|
|
|
|
|
eor (ZPDataBufPtr),y
|
|
|
|
|
.5 sta HMACMD5.IPAD,y
|
|
|
|
|
eor #$6A #$36 eor #$5C
|
|
|
|
|
sta HMACMD5.OPAD,y
|
|
|
|
|
iny
|
|
|
|
|
cpy #64
|
|
|
|
|
bne .4
|
|
|
|
|
stz HMACMD5.IPAD+64
|
|
|
|
|
stz HMACMD5.OPAD+64
|
|
|
|
|
|
|
|
|
|
rebase
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Init
|
2021-06-16 03:36:26 +00:00
|
|
|
|
bcc .6
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.6 sta hHMACMD5Ctx
|
|
|
|
|
|
|
|
|
|
>PUSHB hHMACMD5Ctx
|
|
|
|
|
>PUSHW L.HMACMD5.IPAD
|
|
|
|
|
>PUSHWI 64
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Update
|
2021-06-16 03:36:26 +00:00
|
|
|
|
|
|
|
|
|
.7 >SLEEP
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
|
|
|
|
>PUSHB hFile
|
|
|
|
|
>PUSHW ZPDataBufPtr Dst Ptr
|
|
|
|
|
>PUSHWI FILEBUF.SIZE Bytes To Read
|
|
|
|
|
>SYSCALL FRead
|
2021-06-16 03:36:26 +00:00
|
|
|
|
bcc .8
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
|
|
|
|
cmp #MLI.E.EOF
|
2021-06-16 03:36:26 +00:00
|
|
|
|
beq .10
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.99 rts
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.8 >STYA ZPDataLen
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
|
|
|
|
>SLEEP
|
|
|
|
|
|
|
|
|
|
>PUSHB hHMACMD5Ctx
|
|
|
|
|
>PUSHW ZPDataBufPtr
|
|
|
|
|
>PUSHW ZPDataLen
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Update
|
2021-06-16 03:36:26 +00:00
|
|
|
|
bra .7
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
2021-06-16 03:36:26 +00:00
|
|
|
|
.10 >PUSHB hHMACMD5Ctx
|
|
|
|
|
>PUSHEA.G HMACMD5Buf
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Finalize
|
2021-06-16 03:36:26 +00:00
|
|
|
|
|
|
|
|
|
jsr RevertASCII
|
|
|
|
|
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Init
|
2021-06-16 03:36:26 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
sta hHMACMD5Ctx
|
|
|
|
|
|
|
|
|
|
>PUSHB hHMACMD5Ctx
|
|
|
|
|
>PUSHW L.HMACMD5.OPAD
|
|
|
|
|
>PUSHWI 64
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Update
|
2021-06-16 03:36:26 +00:00
|
|
|
|
|
|
|
|
|
>PUSHB hHMACMD5Ctx
|
|
|
|
|
>PUSHW L.HMACMD5.IPAD
|
|
|
|
|
>PUSHWI 16
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Update
|
2021-06-16 03:36:26 +00:00
|
|
|
|
|
|
|
|
|
>PUSHB hHMACMD5Ctx
|
2021-06-11 17:20:35 +00:00
|
|
|
|
>PUSHEA.G HMACMD5Buf
|
2021-07-27 16:21:58 +00:00
|
|
|
|
>SYSCALL MD5Finalize
|
2021-06-11 17:20:35 +00:00
|
|
|
|
|
|
|
|
|
CS.RUN.PRINT >LEA.G HMACMD5Buf
|
|
|
|
|
>SYSCALL PutS
|
|
|
|
|
lda #0
|
2021-06-16 03:36:26 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
*--------------------------------------
|
2021-07-29 16:41:57 +00:00
|
|
|
|
RevertASCII >LEA.G HMACMD5Buf
|
2021-06-16 03:36:26 +00:00
|
|
|
|
>STYA ZPDataBufPtr
|
|
|
|
|
ldx #16
|
|
|
|
|
stx ZPDataLen
|
|
|
|
|
ldy #31
|
|
|
|
|
.1 lda (ZPDataBufPtr),y
|
|
|
|
|
cmp #$3A
|
|
|
|
|
bcc .2
|
|
|
|
|
sbc #7
|
|
|
|
|
.2 and #$0f
|
|
|
|
|
sta bText
|
|
|
|
|
dey
|
|
|
|
|
lda (ZPDataBufPtr),y
|
|
|
|
|
cmp #$3A
|
|
|
|
|
bcc .3
|
|
|
|
|
sbc #7
|
|
|
|
|
.3 asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
ora bText
|
|
|
|
|
sta HMACMD5.IPAD-1,x
|
|
|
|
|
dex
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2021-06-11 17:20:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT lda hLIBCRYPT
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
>SYSCALL UnloadLib
|
|
|
|
|
|
|
|
|
|
.1 lda hDataBuf
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
.2 lda hFile
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
>SYSCALL FClose
|
|
|
|
|
|
|
|
|
|
.3 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
LIBCRYPT .AZ "libcrypt"
|
|
|
|
|
hLIBCRYPT .BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
OptionList .AS "DdKk"
|
2021-06-16 03:36:26 +00:00
|
|
|
|
OptionEnd
|
|
|
|
|
*--------------------------------------
|
2023-06-18 07:47:28 +00:00
|
|
|
|
MSG.USAGE .CZ "Usage : HMACMD5 [ -d input text | input file ] [ -k key ]\r\n"
|
2021-06-11 17:20:35 +00:00
|
|
|
|
*--------------------------------------
|
2021-06-16 03:36:26 +00:00
|
|
|
|
HMACMD5.IPAD .BS 65
|
|
|
|
|
HMACMD5.OPAD .BS 65
|
2021-06-11 17:20:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
|
|
|
|
HMACMD5Buf .BS 33
|
|
|
|
|
DS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE usr/src/bin/hmacmd5.s
|
|
|
|
|
ASM
|