mirror of
https://github.com/A2osX/A2osX.git
synced 2024-12-29 01:33:40 +00:00
forgot to commit this one after ZP reorg
This commit is contained in:
parent
1fc656e102
commit
9ec40dba75
@ -6,12 +6,17 @@ AUTO 6
|
||||
.LIST OFF
|
||||
.OP 65C02
|
||||
.OR $2000
|
||||
.TF LIB/LIBCRYPT.O
|
||||
.TF /A2OSX.BOOT/LIB/LIBCRYPT.O
|
||||
*--------------------------------------
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/A2OSX.I
|
||||
.INB INC/LIBCRYPT.I
|
||||
*--------------------------------------
|
||||
ZPTmpPtr1 .EQ ZPLIB
|
||||
ZPTmpPtr2 .EQ ZPLIB+2
|
||||
ZPTmpPtr3 .EQ ZPLIB+4
|
||||
ZPTmpPtr4 .EQ ZPLIB+6
|
||||
*--------------------------------------
|
||||
* DWORD Macros : Do NOT disturb carry with cpx, cpy...
|
||||
*--------------------------------------
|
||||
.MA ADC32
|
||||
@ -81,28 +86,26 @@ AUTO 6
|
||||
bne :2
|
||||
.EM
|
||||
*--------------------------------------
|
||||
* Main entry point
|
||||
* input :
|
||||
* X = Function
|
||||
*--------------------------------------
|
||||
* Code signature and relocation table
|
||||
*--------------------------------------
|
||||
* CLD $D8
|
||||
* JMP (*,x) $7C
|
||||
* #JMPTABLE
|
||||
* /JMPTABLE
|
||||
* 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
|
||||
.DA 0
|
||||
.DA 0
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
* Relocation Table
|
||||
*--------------------------------------
|
||||
.1 .DA LIB.LOAD
|
||||
.DA LIB.UNLOAD
|
||||
.DA MD5PStrA
|
||||
.DA MD5Init
|
||||
.DA MD5Update
|
||||
.DA MD5FinalizeA
|
||||
*--------------------------------------
|
||||
.DA 0
|
||||
.DA CS.END-CS.START
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
LIB.LOAD
|
||||
@ -116,19 +119,19 @@ LIB.UNLOAD clc
|
||||
* A = hMem To MessageDigest
|
||||
*--------------------------------------
|
||||
MD5PStrA >SYSCALL SYS.GetMemPtrA
|
||||
>STYA ZPQuickPtr3 1 and 2 used by other MD5 functions
|
||||
>STYA ZPTmpPtr3 1 and 2 used by other MD5 functions
|
||||
ldy #0
|
||||
lda (ZPQuickPtr3),y get PStr len
|
||||
sta ZPQuickPtr4 ZPQuickPtr4 = str len
|
||||
stz ZPQuickPtr4+1 0,PSTR len <= 255
|
||||
inc ZPQuickPtr3
|
||||
lda (ZPTmpPtr3),y get PStr len
|
||||
sta ZPTmpPtr4 ZPTmpPtr4 = str len
|
||||
stz ZPTmpPtr4+1 0,PSTR len <= 255
|
||||
inc ZPTmpPtr3
|
||||
bne .1
|
||||
inc ZPQuickPtr3+1 Make DATA skip PSTR Len Byte
|
||||
inc ZPTmpPtr3+1 Make DATA skip PSTR Len Byte
|
||||
.1 jsr MD5Init
|
||||
bcs .9
|
||||
pha save MD5 Context hMem
|
||||
>PUSHW ZPQuickPtr4 Push LEN
|
||||
>PUSHW ZPQuickPtr3 Push DATA
|
||||
>PUSHW ZPTmpPtr4 Push LEN
|
||||
>PUSHW ZPTmpPtr3 Push DATA
|
||||
pla
|
||||
pha
|
||||
>PUSHA Push MD5 Context
|
||||
@ -153,15 +156,15 @@ MD5Init >PUSHWI S.MD5.SIZE
|
||||
>PUSHBI 0
|
||||
>SYSCALL SYS.GetMem
|
||||
bcs .9
|
||||
>STYA ZPQuickPtr1
|
||||
>STYA ZPTmpPtr1
|
||||
ldy #0
|
||||
.1 lda MD5.ABCDINIT,y
|
||||
sta (ZPQuickPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
iny
|
||||
cpy #16
|
||||
bne .1
|
||||
lda #0
|
||||
.2 sta (ZPQuickPtr1),y
|
||||
.2 sta (ZPTmpPtr1),y
|
||||
iny
|
||||
cpy #S.MD5.SIZE Includes S.MD5.FINALIZED Flag
|
||||
bne .2
|
||||
@ -177,11 +180,11 @@ MD5Init >PUSHWI S.MD5.SIZE
|
||||
*--------------------------------------
|
||||
MD5Update >PULLA get MD5 Context
|
||||
>SYSCALL SYS.GetMemPtrA
|
||||
>STYA ZPQuickPtr1 get MD5 Context
|
||||
>STYA ZPTmpPtr1 get MD5 Context
|
||||
>PULLW R.AX get DATA
|
||||
>PULLW R.BX get LEN
|
||||
ldy #S.MD5.FINALIZED
|
||||
lda (ZPQuickPtr1),y
|
||||
lda (ZPTmpPtr1),y
|
||||
beq .1
|
||||
sec
|
||||
rts
|
||||
@ -214,7 +217,7 @@ MD5Update >PULLA get MD5 Context
|
||||
bra .52
|
||||
.53 ldy #S.MD5.EXTRABIT Mark MD5 Context as Appended
|
||||
lda #$80
|
||||
sta (ZPQuickPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
lda R.CL
|
||||
cmp #56 Enough room for BITCOUNT ?
|
||||
bcs .58 no
|
||||
@ -242,42 +245,42 @@ MD5Update >PULLA get MD5 Context
|
||||
* A = MessageDigest (PSTR, 16 Bytes, 32 Chars)
|
||||
*--------------------------------------
|
||||
MD5FinalizeA >SYSCALL SYS.GetMemPtrA
|
||||
>STYA ZPQuickPtr1 get MD5 Context
|
||||
>STYA ZPTmpPtr1 get MD5 Context
|
||||
ldy #S.MD5.FINALIZED
|
||||
lda (ZPQuickPtr1),y
|
||||
lda (ZPTmpPtr1),y
|
||||
bne .11
|
||||
jsr MD5ExtraChunk
|
||||
.11 >PUSHWI 33 Len + 32 Digits
|
||||
>PUSHBI 0
|
||||
>SYSCALL SYS.GetMem
|
||||
bcs .9
|
||||
>STYA ZPQuickPtr2
|
||||
>STYA ZPTmpPtr2
|
||||
phx save hMem for return
|
||||
lda #32
|
||||
sta (ZPQuickPtr2)
|
||||
inc ZPQuickPtr2
|
||||
sta (ZPTmpPtr2)
|
||||
inc ZPTmpPtr2
|
||||
bne .10
|
||||
inc ZPQuickPtr2+1
|
||||
inc ZPTmpPtr2+1
|
||||
.10 ldy #S.MD5.ABCD0
|
||||
.1 lda (ZPQuickPtr1),y
|
||||
.1 lda (ZPTmpPtr1),y
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tax
|
||||
lda MD5.DIGITS,x
|
||||
sta (ZPQuickPtr2)
|
||||
inc ZPQuickPtr2
|
||||
sta (ZPTmpPtr2)
|
||||
inc ZPTmpPtr2
|
||||
bne .2
|
||||
inc ZPQuickPtr2+1
|
||||
.2 lda (ZPQuickPtr1),y
|
||||
inc ZPTmpPtr2+1
|
||||
.2 lda (ZPTmpPtr1),y
|
||||
and #$0F
|
||||
tax
|
||||
lda MD5.DIGITS,x
|
||||
sta (ZPQuickPtr2)
|
||||
inc ZPQuickPtr2
|
||||
sta (ZPTmpPtr2)
|
||||
inc ZPTmpPtr2
|
||||
bne .3
|
||||
inc ZPQuickPtr2+1
|
||||
inc ZPTmpPtr2+1
|
||||
.3 iny
|
||||
cpy #S.MD5.ABCD0+16
|
||||
bne .1
|
||||
@ -289,12 +292,12 @@ MD5FinalizeA >SYSCALL SYS.GetMemPtrA
|
||||
*--------------------------------------
|
||||
* MD5AppendBitCount
|
||||
* In :
|
||||
* ZPQuickPtr1 = MD5 Context
|
||||
* ZPTmpPtr1 = MD5 Context
|
||||
*--------------------------------------
|
||||
MD5AppendBitCount
|
||||
ldx #56
|
||||
ldy #S.MD5.BITCOUNT Append 8 Bytes of BITCOUNT
|
||||
.1 lda (ZPQuickPtr1),y
|
||||
.1 lda (ZPTmpPtr1),y
|
||||
sta MD5.BUFFER64,x
|
||||
inx
|
||||
iny
|
||||
@ -302,13 +305,13 @@ MD5AppendBitCount
|
||||
bne .1
|
||||
ldy #S.MD5.FINALIZED Mark MD5 Context as Finalized
|
||||
lda #$80
|
||||
sta (ZPQuickPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
rts
|
||||
*--------------------------------------
|
||||
* MD5UpdateBitCount
|
||||
* In :
|
||||
* CL = Size (in bytes) to add to MD5 context
|
||||
* ZPQuickPtr1 = MD5 Context
|
||||
* ZPTmpPtr1 = MD5 Context
|
||||
*--------------------------------------
|
||||
MD5UpdateBitCount
|
||||
stz R.CH
|
||||
@ -321,17 +324,17 @@ MD5UpdateBitCount
|
||||
rol R.CH
|
||||
clc
|
||||
ldy #S.MD5.BITCOUNT
|
||||
adc (ZPQuickPtr1),y
|
||||
sta (ZPQuickPtr1),y
|
||||
adc (ZPTmpPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
iny
|
||||
lda R.CH
|
||||
adc (ZPQuickPtr1),y
|
||||
sta (ZPQuickPtr1),y
|
||||
adc (ZPTmpPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
bcc .8
|
||||
.1 iny
|
||||
lda (ZPQuickPtr1),y
|
||||
lda (ZPTmpPtr1),y
|
||||
inc
|
||||
sta (ZPQuickPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
bne .8
|
||||
cpy #7
|
||||
bne .1
|
||||
@ -339,18 +342,18 @@ MD5UpdateBitCount
|
||||
*--------------------------------------
|
||||
* MD5ExtraChunk
|
||||
* In :
|
||||
* ZPQuickPtr1 = MD5 Context
|
||||
* ZPTmpPtr1 = MD5 Context
|
||||
*--------------------------------------
|
||||
MD5ExtraChunk ldy #S.MD5.FINALIZED
|
||||
lda #$80
|
||||
sta (ZPQuickPtr1),y Mark MD5 Context as "finalized"
|
||||
sta (ZPTmpPtr1),y Mark MD5 Context as "finalized"
|
||||
ldx #0
|
||||
ldy #S.MD5.EXTRABIT Extra Bit already appended ?
|
||||
lda (ZPQuickPtr1),y
|
||||
lda (ZPTmpPtr1),y
|
||||
bne .1
|
||||
lda #$80
|
||||
sta MD5.BUFFER64 Add extra bit to buffer
|
||||
sta (ZPQuickPtr1),y Mark Extrabit added
|
||||
sta (ZPTmpPtr1),y Mark Extrabit added
|
||||
inx
|
||||
.1 stz MD5.BUFFER64,x pad with "0"...
|
||||
inx
|
||||
@ -361,13 +364,13 @@ MD5ExtraChunk ldy #S.MD5.FINALIZED
|
||||
*--------------------------------------
|
||||
* MD5UpdateABCD0
|
||||
* In:
|
||||
* ZPQuickPtr1 = MD5 Context
|
||||
* ZPTmpPtr1 = MD5 Context
|
||||
*--------------------------------------
|
||||
MD5UpdateABCD0 ldy #0
|
||||
.1 clc ADC32 A+A0->A0, B, C, D....
|
||||
.2 lda MD5.ABCD,y
|
||||
adc (ZPQuickPtr1),y
|
||||
sta (ZPQuickPtr1),y
|
||||
adc (ZPTmpPtr1),y
|
||||
sta (ZPTmpPtr1),y
|
||||
iny
|
||||
tya
|
||||
and #3
|
||||
@ -378,13 +381,13 @@ MD5UpdateABCD0 ldy #0
|
||||
*--------------------------------------
|
||||
* MD5Transform
|
||||
* In:
|
||||
* ZPQuickPtr1 = MD5 Context
|
||||
* ZPTmpPtr1 = MD5 Context
|
||||
* 512 Bits Padded chunk in MD5.BUFFER64
|
||||
* Out:
|
||||
* Updated MD5.ABCD
|
||||
*--------------------------------------
|
||||
MD5Transform ldy #15 init ABCD Chunk with Context ABCD0
|
||||
.1 lda (ZPQuickPtr1),y
|
||||
.1 lda (ZPTmpPtr1),y
|
||||
sta MD5.ABCD,y
|
||||
dey
|
||||
bpl .1
|
||||
|
Loading…
Reference in New Issue
Block a user