LIBCRYPT:Bufixes and MD5 removal (duplicated in KERNEL)

ACOS:bugfixes in GET
KERNEL:fixes for //c loobing bug
This commit is contained in:
burniouf 2021-07-27 18:21:58 +02:00
parent f8b8e13285
commit 09923489fd
17 changed files with 411 additions and 423 deletions

Binary file not shown.

Binary file not shown.

View File

@ -265,16 +265,16 @@ EXP.ComputeY lda EXP.TYPE
clc
rts
.1 stz EXP.TYPE at the end ....TRUE/FALSE is int
cpy #3 +
.1 cpy #3 +
bne .2
ldx #SYS.StrCat
ldx #RT.StrAdd.ID
clc
jmp CODE.SYSCALL
jmp CODE.JSRRT
.2 cpy #11 <>
.2 stz EXP.TYPE at the end ....TRUE/FALSE is int
cpy #11 <>
bne .3
ldx #SYS.StrCmp

View File

@ -14,6 +14,14 @@ RT.NOT lda (pStack)
>PUSHA
rts
*--------------------------------------
RT.StrAdd >DEBUG
inc pStack
inc pStack
clc
rts
*--------------------------------------
RT.StrSet >PUSHB hStrings
txa
>PUSHA
@ -105,7 +113,7 @@ RT.TIMEd.1 >PUSHW ZPStrBuf
>PUSHW ZPStrBuf
rts
*--------------------------------------
RT.GET >SYSCALL GetChar
RT.GET jsr RT.GetChar
sta (ZPStrBuf)
ldy #1
@ -123,7 +131,7 @@ RT.INPUT lda #0
ldx #0 OUT.ELW
jsr RT.OUTX
.1 >SYSCALL GetChar
.1 jsr RT.GetChar
bcs RT.INPUT.9
ldy ZPPtr1
@ -300,6 +308,19 @@ RT.OUTX ldy #S.PS.hStdOut
>SYSCALL FPutS
rts
*--------------------------------------
* TODO: handle lost conn CS and remap VT100 ESC codes
*--------------------------------------
RT.GetChar >SYSCALL GetChar
cmp #C.CR
bne .8
>SYSCALL GetChar LF
lda #C.CR
.8 clc
rts
*--------------------------------------
MAN
SAVE usr/src/bin/acos.s.rt
LOAD usr/src/bin/acos.s

View File

@ -203,6 +203,8 @@ RT.VAL.ID .EQ *-J.RT
*--------------------------------------
RT.NOT.ID .EQ *-J.RT
.DA RT.NOT
RT.StrAdd.ID .EQ *-J.RT
.DA RT.StrAdd
RT.StrSet.ID .EQ *-J.RT
.DA RT.StrSet
RT.StrGet.ID .EQ *-J.RT
@ -393,11 +395,11 @@ CS.FClose >LDA.G hFile
.1 >LDA.G hInputBuf
beq .8
>SYSCALL FreeMem
>STZ.G hInputBuf
.8
.8
* clc
rts
*--------------------------------------

View File

@ -27,6 +27,11 @@ ArgIndex .BS 1
bWrite .BS 1
AttrAND .BS 1
AttrORA .BS 1
bContinue .BS 1
bRecurse .BS 1
bPause .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -121,13 +126,13 @@ CS.RUN.LOOP ldy #S.PS.hStdIn
cmp #$13 Ctrl-S
bne .1
>LDA.G bPause
lda bPause
eor #$ff
sta (pData),y
sta bPause
bne CS.RUN.LOOP
.1 >LDA.G bPause
bne CS.RUN.LOOP Pause...
.1 lda bPause
bmi CS.RUN.LOOP Pause...
*--------------------------------------
jsr GetEntry
bcs CS.RUN.LEAVE
@ -213,7 +218,7 @@ CS.RUN.DIR lda (ZPFileName)
>SYSCALL PrintF
bcs .9
.7 >LDA.G bRecurse
.7 bit bRecurse
bpl .8
>LDYA ZPFileName
@ -272,7 +277,8 @@ CS.RUN.SetAttr >PUSHW ZPFullPath
>PUSHA
>PUSHBI 1
>SYSCALL PrintF
>LDA.G bContinue
lda bContinue
eor #$80
asl
pla
@ -306,6 +312,7 @@ CS.RUN.CheckSwitch
.2 cmp OptionList,x
beq .3
dex
bpl .2
@ -314,7 +321,7 @@ CS.RUN.CheckSwitch
.3 ldy OptionVars,x
lda #$80
sta (pData),y
sta $0,y
clc
rts
@ -438,10 +445,6 @@ MSG.FILE .AZ "File:%s..."
.DUMMY
.OR 0
DS.START
bContinue .BS 1
bRecurse .BS 1
bPause .BS 1
hSrcFullPath .BS 1
ATTR .BS 17

View File

@ -156,7 +156,7 @@ CS.RUN.FILE >LDYAI FILEBUF.SIZE
tay
beq .3
.2 >LIBCALL hLIBCRYPT,LIBCRYPT.MD5Init
.2 >SYSCALL MD5Init
bcs .9
sta hHMACMD5Ctx
@ -168,10 +168,10 @@ CS.RUN.FILE >LDYAI FILEBUF.SIZE
>SYSCALL ArgV
>PUSHYA
>PUSHW ZPDataLen
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
>SYSCALL MD5Update
>PUSHB hHMACMD5Ctx
>PUSHEA.G HMACMD5Buf
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize
>SYSCALL MD5Finalize
jsr RevertASCII
@ -190,7 +190,7 @@ CS.RUN.FILE >LDYAI FILEBUF.SIZE
stz HMACMD5.OPAD+64
rebase
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Init
>SYSCALL MD5Init
bcc .6
rts
@ -200,7 +200,7 @@ rebase
>PUSHB hHMACMD5Ctx
>PUSHW L.HMACMD5.IPAD
>PUSHWI 64
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
>SYSCALL MD5Update
.7 >SLEEP
@ -222,16 +222,16 @@ rebase
>PUSHB hHMACMD5Ctx
>PUSHW ZPDataBufPtr
>PUSHW ZPDataLen
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
>SYSCALL MD5Update
bra .7
.10 >PUSHB hHMACMD5Ctx
>PUSHEA.G HMACMD5Buf
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize
>SYSCALL MD5Finalize
jsr RevertASCII
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Init
>SYSCALL MD5Init
bcs .99
sta hHMACMD5Ctx
@ -239,16 +239,16 @@ rebase
>PUSHB hHMACMD5Ctx
>PUSHW L.HMACMD5.OPAD
>PUSHWI 64
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
>SYSCALL MD5Update
>PUSHB hHMACMD5Ctx
>PUSHW L.HMACMD5.IPAD
>PUSHWI 16
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Update
>SYSCALL MD5Update
>PUSHB hHMACMD5Ctx
>PUSHEA.G HMACMD5Buf
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize
>SYSCALL MD5Finalize
CS.RUN.PRINT >LEA.G HMACMD5Buf
>SYSCALL PutS

View File

@ -84,6 +84,7 @@ CS.RUN >INC.G ArgIndex
jsr CS.RUN.CheckOpt
bcs .9
bne CS.RUN
>INC.G ArgIndex -X

View File

@ -1,253 +1,255 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/xargs
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/xargs
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.i
.INB inc/mli.e.i
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.i
.INB inc/mli.e.i
*--------------------------------------
.DUMMY
.OR ZPBIN
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgPattern .BS 1
ZPPtr1 .BS 2
ZPCommandPtr .BS 2
ZPBufPtr .BS 2
ZPCmdBuf .BS 2
hFile .BS 1
hBuf .BS 1
hCmdBuf .BS 1
DashArgs .BS 1
ArgIndex .BS 1
ArgPattern .BS 1
ZPPtr1 .BS 2
ZPCommandPtr .BS 2
ZPBufPtr .BS 2
ZPCmdBuf .BS 2
hFile .BS 1
hBuf .BS 1
hCmdBuf .BS 1
DashArgs .BS 1
ZS.END .ED
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
L.CMD.SPC .DA CMD.SPC
.DA 0
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.CRLF .DA MSG.CRLF
L.CMD.SPC .DA CMD.SPC
.DA 0
*--------------------------------------
CS.INIT clc
rts
CS.INIT clc
rts
*--------------------------------------
CS.RUN jsr CS.RUN.CheckArgs
bcs CS.RUN.LOOP.RTS
CS.RUN jsr CS.RUN.CheckArgs
bcs CS.RUN.LOOP.RTS
CS.RUN.LOOP >SLEEP
CS.RUN.LOOP >SLEEP
>PUSHB hFile
>PUSHW ZPBufPtr
>PUSHWI 256
>SYSCALL FGetS
bcs .9
>PUSHB hFile
>PUSHW ZPBufPtr
>PUSHWI 256
>SYSCALL FGetS
bcs .9
.2 jsr CS.RUN.PRINT
.2 jsr CS.RUN.PRINT
bcc CS.RUN.LOOP
rts
bcc CS.RUN.LOOP
rts
.9 cmp #MLI.E.EOF
bne .99
.9 cmp #MLI.E.EOF
bne .99
lda #0 Exit with no Error
lda #0 Exit with no Error
.99 sec
CS.RUN.LOOP.RTS rts
.99 sec
CS.RUN.LOOP.RTS rts
*--------------------------------------
CS.RUN.CheckArgs
jsr CS.RUN.NextArg
bcs .4
jsr CS.RUN.NextArg
bcs .4
lda (ZPPtr1)
cmp #'-'
beq .1
lda (ZPPtr1)
cmp #'-'
beq .1
lda ArgPattern
bne .11
lda ArgPattern
bne .11
lda ArgIndex
sta ArgPattern
>LDYA ZPPtr1
>STYA ZPCommandPtr
bra CS.RUN.CheckArgs
lda ArgIndex
sta ArgPattern
>LDYA ZPPtr1
>STYA ZPCommandPtr
bra CS.RUN.CheckArgs
.11 lda hFile
bne .97
.11 lda hFile
bne .97
>LDYA ZPPtr1
jsr CS.RUN.OPEN
bcs .9
>LDYA ZPPtr1
jsr CS.RUN.OPEN
bcs .9
sta hFile
bra CS.RUN.CheckArgs
sta hFile
bra CS.RUN.CheckArgs
.1 ldy #1
lda (ZPPtr1),y
.1 ldy #1
lda (ZPPtr1),y
ldx #OptionList.Cnt-1
ldx #OptionList.Cnt-1
.2 cmp OptionList,x
beq .3
.2 cmp OptionList,x
beq .3
dex
bpl .2
dex
bpl .2
bra .97
bra .97
.3 txa
lsr
beq .98
.3 txa
lsr
beq .98
tax
lda #$80
sta DashArgs-1,x
bra CS.RUN.CheckArgs
.4 lda hFile
bne .80
tax
lda #$80
sta DashArgs-1,x
bra CS.RUN.CheckArgs
.4 lda hFile
bne .80
ldy #S.PS.hStdIn
lda (pPS),y
tax
lda hFDs-1,x
>SYSCALL GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
cmp #S.FD.T.PIPE
bne .97
ldy #S.PS.hStdIn
lda (pPS),y
sta hFile
ldy #S.PS.hStdIn
lda (pPS),y
tax
lda hFDs-1,x
>SYSCALL GetMemPtr
>STYA ZPPtr1
lda (ZPPtr1)
cmp #S.FD.T.PIPE
bne .97
ldy #S.PS.hStdIn
lda (pPS),y
sta hFile
.80 >LDYAI 256
>SYSCALL GetMem
bcs .9
.80 >LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPBufPtr
stx hBuf
>STYA ZPBufPtr
stx hBuf
>LDYAI 256
>SYSCALL GetMem
bcs .9
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPCmdBuf
stx hCmdBuf
>STYA ZPCmdBuf
stx hCmdBuf
* clc
* clc
.9 rts
.9 rts
.97 lda #E.SYN
.97 lda #E.SYN
.98 pha
>PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
pla
sec
rts
.98 pha
>PUSHW L.MSG.USAGE
>PUSHBI 0
>SYSCALL PrintF
pla
sec
rts
*--------------------------------------
CS.RUN.NextArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
CS.RUN.NextArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
>STYA ZPPtr1
>STYA ZPPtr1
.9 rts
.9 rts
*--------------------------------------
CS.RUN.OPEN >PUSHYA
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
CS.RUN.OPEN >PUSHYA
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
sta hFile
sta hFile
.9 rts
.9 rts
*--------------------------------------
CS.RUN.PRINT >PUSHW ZPCmdBuf
>PUSHW ZPCommandPtr
>SYSCALL StrCpy
CS.RUN.PRINT >PUSHW ZPCmdBuf
>PUSHW ZPCommandPtr
>SYSCALL StrCpy
>PUSHW ZPCmdBuf
>PUSHW L.CMD.SPC
>SYSCALL StrCat
>PUSHW ZPCmdBuf
>PUSHW L.CMD.SPC
>SYSCALL StrCat
>PUSHW ZPCmdBuf
>LDYA ZPBufPtr
>PUSHYA
>SYSCALL StrCat
>PUSHW ZPCmdBuf
>LDYA ZPBufPtr
>PUSHYA
>SYSCALL StrCat
>LDYA ZPCmdBuf
>SYSCALL PutS
>LDYA ZPCmdBuf
>SYSCALL PutS
>PUSHW ZPCmdBuf
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
rts
>PUSHW ZPCmdBuf
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
rts
*--------------------------------------
CS.QUIT lda hFile
beq .1
CS.QUIT lda hFile
beq .1
>SYSCALL FClose
>SYSCALL FClose
.1 lda hBuf
beq .8
>SYSCALL FreeMem
.1 lda hBuf
beq .2
>SYSCALL FreeMem
lda hCmdBuf
beq .8
>SYSCALL FreeMem
.2 lda hCmdBuf
beq .8
.8 clc
rts
>SYSCALL FreeMem
.8 clc
rts
*--------------------------------------
CS.DOEVENT sec
rts
CS.DOEVENT sec
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "Hh"
OptionList.Cnt .EQ *-OptionList
OptionList .AS "Hh"
OptionList.Cnt .EQ *-OptionList
*--------------------------------------
MSG.USAGE .AS "Usage : XARGS command <file>\r\n"
.AS " or : CMD|XARGS command"
MSG.CRLF .AZ "\r\n"
CMD.SPC .AZ " "
MSG.USAGE .AS "Usage : XARGS command <file>\r\n"
.AS " or : CMD|XARGS command"
MSG.CRLF .AZ "\r\n"
CMD.SPC .AZ " "
*--------------------------------------
.DUMMY
.OR 0
.DUMMY
.OR 0
DS.START
DS.END .ED
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/xargs.s

View File

@ -7,12 +7,7 @@ LIBCRYPT.MD4Init .EQ 6
LIBCRYPT.MD4Update .EQ 8
LIBCRYPT.MD4Finalize .EQ 10
*--------------------------------------
LIBCRYPT.MD5 .EQ 12
LIBCRYPT.MD5Init .EQ 14
LIBCRYPT.MD5Update .EQ 16
LIBCRYPT.MD5Finalize .EQ LIBCRYPT.MD4Finalize
*--------------------------------------
LIBCRYPT.HMACMD5 .EQ 18
LIBCRYPT.HMACMD5 .EQ 12
*--------------------------------------
* S.MD4, S.MD5 STRUCT
*--------------------------------------

View File

@ -253,12 +253,13 @@ CIFS.Negotiate lda (pStack)
.97 jsr FreeRespData
.98 lda #MLI.E.IO
.98 lda #MLI.E.INVPARAM
.99 >RET 2
*--------------------------------------
* >PUSHB hSocket
* >PUSHB hSMBContext
* >PUSHW domain
* >PUSHW username
* >PUSHW password
* >PUSHBI 0
@ -272,7 +273,7 @@ CIFS.SessionSetup
dec
sta (pStack)
ldy #5 hSMBContext
ldy #7 hSMBContext
jsr GetSMBContext
ldx #S.SMB.H.CMD.SESSION.SETUP.ANDX
@ -309,7 +310,7 @@ CIFS.SessionSetup
jsr SetReqLen
ldy #6 hSocket
ldy #8 hSocket
lda (pStack),y
jsr WriteSocketA
bcs .99
@ -322,7 +323,7 @@ CIFS.SessionSetup
sta (pStack)
beq .98
ldy #6 hSocket
ldy #8 hSocket
lda (pStack),y
jsr ReadSocketA
bcc .6
@ -338,7 +339,7 @@ CIFS.SessionSetup
lda (ZPRespPtr),y
bne .97
ldy #5 hSMBContext
ldy #7 hSMBContext
jsr GetSMBContext
ldy #S.NETBIOS+S.SMB.H.UID
@ -355,7 +356,7 @@ CIFS.SessionSetup
.97 jsr FreeRespData
.98 lda #MLI.E.IO
.98 lda #MLI.E.LOCKED
sec
.99 >RET 7
*--------------------------------------
@ -1102,7 +1103,7 @@ SMB.SessionSetup.H
.DA 2 MAX MPX COUNT
.HS 0000 VC NUMBER
.HS 00000000 SESSION KEY
.DA 0 CI PASS LEN (ANSI)
.BS 2 CI PASS LEN (ANSI)
.DA 0 CS PASS LEN (UNICODE)
.HS 00000000
.HS 00000000 CAPABILITIES

View File

@ -15,11 +15,8 @@ ZS.START
ZPCtxPtr .BS 2
ZPDataPtr .BS 2
ZPHashPtr .BS 2
ZPChunkLen .BS 2
* MD.MODE .BS 1 32 BYTES MAX !!!!!
MD4.ABCD
MD5.ABCD
MD4.A
@ -127,9 +124,6 @@ CS.START cld
.DA MD4Init
.DA MD4Update
.DA MD4Finalize
.DA MD5
.DA MD5Init
.DA MD5Update
.DA HMACMD5
*--------------------------------------
J.MD4.XXXX .DA MD4.0015
@ -139,8 +133,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
L.HMACMD5.IPAD .DA HMACMD5.IPAD
L.HMACMD5.OPAD .DA HMACMD5.OPAD
.DA 0
*--------------------------------------
LIB.LOAD
@ -158,40 +152,21 @@ LIB.UNLOAD clc
* ## RETURN VALUE
* CC
*\--------------------------------------
MD4 lda #0
.HS 2C BIT ABS
*/--------------------------------------
* ## MD5
* Return MD5 Hash for input String
* # C
* `void MD5 (const char* str, char* digest);`
* # ASM
* `>PUSHW str`
* `>PUSHW digest`
* `>LIBCALL hLIBCRYPT,LIBCRYPT.MD5`
* ## RETURN VALUE
* CC
*\--------------------------------------
MD5 lda #1
sta MD.MODE
>PULLW ZPHashPtr
MD4 >PULLW ZPHashPtr
>PULLYA
>STYA ZPDataPtr
>SYSCALL2 strlen
>STYA ZPDataLen
.1 jsr MD4Init.I
.1 jsr MDxInit.I
bcs .9
pha save MD4/MD5 Context hMem
lda MD.MODE
bne .2
jsr MD4Update.I
bra .3
.2 jsr MD5Update.I
pha save MD4 Context hMem
jsr MD4Update.I
jsr MDxFinalize.I
.3 jsr MD4Finalize.I
pla
>SYSCALL2 FreeMem Free MD4/MD5 Context
>SYSCALL2 FreeMem Free MD4 Context
clc
.9 rts
*/--------------------------------------
@ -204,28 +179,14 @@ MD5 lda #1
* ## RETURN VALUE
* A = hMem To S.MD4
*\--------------------------------------
MD4Init lda #0
.HS 2C BIT ABS
*/--------------------------------------
* ## MD5Init
* Initialize a MD5 computation
* # C
* `hMD5 MD5init();`
* # ASM
* `>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Init`
* ## RETURN VALUE
* A = hMem To S.MD5
*\--------------------------------------
MD5Init lda #1
sta MD.MODE
MD4Init.I
MD5Init.I >LDYAI S.MD4
MD4Init
MDxInit.I >LDYAI S.MD4
>SYSCALL2 getmem
bcs .9
bcs MDxInit.9
>STYA ZPCtxPtr
ldy #0
MD5Reset.I ldy #0
.1 lda MD4.ABCDINIT,y
sta (ZPCtxPtr),y
@ -237,12 +198,12 @@ MD5Init.I >LDYAI S.MD4
.2 sta (ZPCtxPtr),y
iny
cpy #S.MD4 Includes S.MD4/5.FINALIZED Flag
cpy #S.MD4 Includes S.MD4/5.FINALIZED Flag
bne .2
txa
clc
.9 rts
MDxInit.9 rts
*/--------------------------------------
* ## MD4Update
* Add Data to MD4 computation
@ -255,28 +216,21 @@ MD5Init.I >LDYAI S.MD4
* `>hLIBCRYPT,LIBCRYPT.MD4Update`
* ## RETURN VALUE
*\--------------------------------------
*/--------------------------------------
* ## MD5Update
* Add Data to MD5 computation
* # C
* `void MD5update (hMD5 MD5, char* data, int len);`
* # ASM
* `>PUSHB MD5`
* `>PUSHW data`
* `>PUSHW len`
* `>hLIBCRYPT,LIBCRYPT.MD5Update`
* ## RETURN VALUE
*\--------------------------------------
MD4Update
MD5Update >PULLW ZPDataLen get LEN
MD4Update >PULLW ZPDataLen get LEN
>PULLW ZPDataPtr get DATA
>PULLA
>SYSCALL2 GetMemPtr get MD5 Context
>STYA ZPCtxPtr
MD4Update.I
MD5Update.I ldy #S.MD4.FINALIZED
MD4Update.I clc
.HS B0 BCS
MD5Update.I sec
ror MD.MODE
ldy #S.MD4.FINALIZED
lda (ZPCtxPtr),y
beq .1
@ -298,7 +252,7 @@ MD5Update.I ldy #S.MD4.FINALIZED
.3 lda #64
.50 sta ZPChunkLen Save Chunk Len
jsr MD4UpdateBitCount
jsr MDxUpdateBitCnt
ldy #0
@ -330,15 +284,11 @@ MD5Update.I ldy #S.MD4.FINALIZED
cmp #56 Enough room for BITCOUNT ?
bcs .58 no
jsr MD4AppendBitCount
jsr MDxAppendBitCnt
.58 lda MD.MODE
bne .59
jsr MD4Transform
bra .60
.59 jsr MD5Transform
.58 jsr MDxTransform
.60 jsr MD4UpdateABCD0
jsr MDxUpdateABCD0
.8 lda ZPDataLen Substract Bytes processed from LEN
sec
@ -366,38 +316,26 @@ MD5Update.I ldy #S.MD4.FINALIZED
* `>LIBCALL hLIBCRYPT,LIBCRYPT.MD4Finalize`
* ## RETURN VALUE
*\--------------------------------------
*/--------------------------------------
* ## MD5Finalize
* # C
* `void MD5finalize (hMD5 MD5, char* digest);`
* # ASM
* `>PUSHB MD5`
* `>PUSHW digest`
* `>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize`
* ## RETURN VALUE
*\--------------------------------------
MD4Finalize
MD5Finalize >PULLW ZPHashPtr
MD4Finalize >PULLW ZPHashPtr
>PULLA
pha
>SYSCALL2 GetMemPtr
>STYA ZPCtxPtr get MD5 Context
jsr MD4Finalize.I
jsr MDxFinalize.I
pla
>SYSCALL2 FreeMem
rts
MD4Finalize.I
MD5Finalize.I ldy #S.MD4.FINALIZED
MDxFinalize.I ldy #S.MD4.FINALIZED
lda (ZPCtxPtr),y
bne .11
jsr MD4ExtraChunk
jsr MDxExtraChunk
.11 ldy #S.MD4.ABCD0
.11 ldy #0
.1 lda (ZPCtxPtr),y
lsr
@ -406,30 +344,30 @@ MD5Finalize.I ldy #S.MD4.FINALIZED
lsr
tax
lda MD4.DIGITS,x
sta (ZPHashPtr)
inc ZPHashPtr
bne .2
jsr .7
inc ZPHashPtr+1
.2 lda (ZPCtxPtr),y
lda (ZPCtxPtr),y
and #$0F
tax
lda MD4.DIGITS,x
sta (ZPHashPtr)
inc ZPHashPtr
bne .3
jsr .7
inc ZPHashPtr+1
.3 iny
cpy #S.MD4.ABCD0+16
iny
cpy #16
bne .1
lda #0
sta (ZPHashPtr)
clc
.9 rts
rts
.7 sta (ZPHashPtr)
inc ZPHashPtr
bne MDxFinalize.RTS
inc ZPHashPtr+1
MDxFinalize.RTS rts
*/--------------------------------------
* ## HMACMD5
* Return HMACMD5 Hash for input String
@ -445,108 +383,111 @@ 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
HMACMD5 >PULLW ZPHashPtr
>PULLW ZPDataPtr
>PULLW HMAC.DTemp
.1 >LDYA ZPDataPtr
jsr MDxInit.I
bcs MDxFinalize.RTS
pha
>LDYA ZPDataPtr
>SYSCALL2 strlen
>STYA ZPDataLen
cpy #65
bcs .2
tay
beq .4
.2 jsr MD5Init
bcc .3
rts
.3 >PUSHW ZPHashPtr
.2 >PUSHW ZPHashPtr
jsr MD5Update.I
jsr MD5Finalize.I
jsr MDxFinalize.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
eor #$6A #$36 eor #$5C
sta HMACMD5.OPAD,y
iny
cpy #64
bne .5
stz HMACMD5.IPAD+64
stz HMACMD5.OPAD+64
jsr MD5Init
bcc .7
jsr MD5Reset.I
rts
.7 >LDYA L.HMACMD5.IPAD
>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
jsr MDxFinalize.I
>PULLW ZPHashPtr
ldy #S.MD5.ABCD0
ldy #0
.8 lda (ZPCtxPtr),y
sta HMACMD5.IPAD,y
iny
cpy #S.MD5.ABCD0+16
cpy #16
bne .8
jsr MD5Init.I
bcc .9
jsr MD5Reset.I
rts
.9 >LDYA L.HMACMD5.OPAD
>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
jsr MDxFinalize.I
pla
>SYSCALL2 FreeMem
rts
*--------------------------------------
* https://waterjuiceweb.wordpress.com/aes/
*--------------------------------------
* PRIVATE
*--------------------------------------
* MD4AppendBitCount
* MDxAppendBitCount
* In :
* ZPCtxPtr = MD4 Context
*--------------------------------------
* MD5AppendBitCount
* In :
* ZPCtxPtr = MD5 Context
*--------------------------------------
MD4AppendBitCount
MD5AppendBitCount
ldx #56
MDxAppendBitCnt ldx #56
ldy #S.MD4.BITCOUNT Append 8 Bytes of BITCOUNT
.1 lda (ZPCtxPtr),y
@ -561,20 +502,12 @@ MD5AppendBitCount
sta (ZPCtxPtr),y
rts
*--------------------------------------
* MD4UpdateBitCount
* MDxUpdateBitCnt
* In :
* CL = Size (in bytes) to add to MD4 context
* ZPCtxPtr = MD4 Context
* CL = Size (in bytes) to add to MDx context
* ZPCtxPtr = MDx Context
*--------------------------------------
*--------------------------------------
* MD5UpdateBitCount
* In :
* CL = Size (in bytes) to add to MD5 context
* ZPCtxPtr = MD5 Context
*--------------------------------------
MD4UpdateBitCount
MD5UpdateBitCount
stz ZPChunkLen+1
MDxUpdateBitCnt stz ZPChunkLen+1
lda ZPChunkLen
asl
rol ZPChunkLen+1
@ -603,17 +536,11 @@ MD5UpdateBitCount
.8 rts
*--------------------------------------
* MD4ExtraChunk
* MDxExtraChunk
* In :
* ZPCtxPtr = MD4 Context
* ZPCtxPtr = MDx Context
*--------------------------------------
*--------------------------------------
* MD5ExtraChunk
* In :
* ZPCtxPtr = MD5 Context
*--------------------------------------
MD4ExtraChunk
MD5ExtraChunk ldy #S.MD4.FINALIZED
MDxExtraChunk ldy #S.MD4.FINALIZED
lda #$80
sta (ZPCtxPtr),y Mark MD5 Context as "finalized"
ldx #0
@ -631,25 +558,14 @@ MD5ExtraChunk ldy #S.MD4.FINALIZED
cpx #56
bne .1 ...until room for bitcount
jsr MD4AppendBitCount
lda MD.MODE
bne .2
jsr MD4Transform
bra .3
.2 jsr MD5Transform
.3
jsr MDxAppendBitCnt
jsr MDxTransform
*--------------------------------------
* MD4UpdateABCD0
* MDxUpdateABCD0
* In:
* ZPCtxPtr = MD4 Context
* ZPCtxPtr = MDx Context
*--------------------------------------
*--------------------------------------
* MD5UpdateABCD0
* In:
* ZPCtxPtr = MD5 Context
*--------------------------------------
MD4UpdateABCD0
MD5UpdateABCD0 ldy #0
MDxUpdateABCD0 ldy #0
.1 clc ADC32 A+A0->A0, B, C, D....
@ -666,6 +582,11 @@ MD5UpdateABCD0 ldy #0
rts
*--------------------------------------
MDxTransform bit MD.MODE
bpl MD4Transform
jmp MD5Transform
*--------------------------------------
* MD4Transform
* In:
* ZPCtxPtr = MD4 Context
@ -730,6 +651,7 @@ MD4.XXXX.END >MOV32 MD4.D,MD4.DTemp
lsr
and #$0C
beq .3
tay
ldx #0

View File

@ -4,6 +4,8 @@ NEW
.OP 65C02 Target CPU, must match CPU level in header
.OR $2000 usualy $2000, but any value > $100 allowed
.TF sbin/cifsd
*--------------------------------------
AUTH .EQ 0
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
@ -12,6 +14,9 @@ NEW
.INB inc/libtcpip.i
.INB inc/net.smb.i
.INB inc/libcifs.i
.DO AUTH
.INB inc/libcrypt.i
.FIN
*--------------------------------------
TIMEOUT.MAX .EQ 250 25 sec.
*--------------------------------------
@ -49,6 +54,9 @@ CS.START cld
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.LIBCIFS .DA LIBCIFS
.DO AUTH
L.LIBCRYPT .DA LIBCRYPT
.FIN
L.MSG.USAGE .DA MSG.USAGE
L.MSG.TCPIPERR .DA MSG.TCPIPERR
L.MSG.UNKNOWN .DA MSG.UNKNOWN
@ -72,6 +80,13 @@ CS.INIT >LDYA L.LIBTCPIP
sta hLIBCIFS
.DO AUTH
>LDYA L.LIBCRYPT
>SYSCALL LoadLib
bcs .9
sta hLIBCRYPT
.FIN
* clc
.9
CS.INIT.RTS rts
@ -106,6 +121,7 @@ CS.RUN lda hSocket
>PUSHB hSMBContext
>PUSHWZ
>PUSHWZ
>PUSHWZ
>PUSHBI 0
>LIBCALL hLIBCIFS,LIBCIFS.SessionSetup
bcs CS.INIT.RTS
@ -226,10 +242,15 @@ CS.RUN.CheckArgs
sec
rts
.3 lda #2
.3 lda #4
>SYSCALL ArgV
bcc .4
.4
clc
.8 clc
CS.RUN.CheckArgs.RTS
rts
*--------------------------------------
@ -299,13 +320,16 @@ CS.QUIT lda hMount
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
.2 lda hLIBCIFS
beq .3
.2
.DO AUTH
lda hLIBCRYPT
jsr .7
.FIN
lda hLIBCIFS
jsr .7
>SYSCALL UnloadLib
.3 lda hLIBTCPIP
beq .8
lda hLIBTCPIP
.7 beq .8
>SYSCALL UnloadLib
@ -320,7 +344,12 @@ LIBTCPIP .AZ "libtcpip"
hLIBTCPIP .BS 1
LIBCIFS .AZ "libcifs"
hLIBCIFS .BS 1
MSG.USAGE .AZ "Usage : CIFSD <ip|host> sharename mountpoint"
.DO AUTH
LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1
.FIN
*--------------------------------------
MSG.USAGE .AZ "Usage : CIFSD <ip|host> sharename mountpoint [[domain\]user]"
MSG.TCPIPERR .AZ "CIFSD:TCP/IP Not initialized properly."
MSG.UNKNOWN .AZ "CIFSD:%s: Unknown host\r\n"
MSG.NOCONN .AZ "CIFSD:No Connection To %s\r\n"

View File

@ -5,7 +5,7 @@ NEW
.OR $2000
.TF sbin/initd
*--------------------------------------
INITDDBG .EQ 1
INITDDBG .EQ 0
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i

View File

@ -106,7 +106,7 @@ MD5X.Init >LDYAI S.MD5
.1 lda MD5.ABCDINIT,y
sta (ZPCtxPtr),y
iny
cpy #16
cpy #S.MD5.BITCOUNT
bne .1
lda #0

View File

@ -45,7 +45,7 @@ TERM.TOAUX lda A2osX.ASCREEN
clc
.1 ror bActive
sta SET80STORE
jsr .8
sta CLRREADAUX

View File

@ -267,6 +267,7 @@ TERMX.WRITE jsr TERMX.CUROFF
inc ZPBufPtr
bne .1
inc ZPBufPtr+1
bra .1
@ -632,20 +633,25 @@ Csi.Query ldx CsiPCnt
*--------------------------------------
Csi.Scroll ldy CsiPCnt
bne .1
lda #0
ldx #23
bra .8
.1 cpy #2
bne .9
lda CsiP
dec
ldx CsiP+1
dex
.8 ldy #S.DCB.TTY.SCROLLTOP
sta (ZPDCBPtr),y
iny S.DCB.TTY.SCROLLBOT
txa
sta (ZPDCBPtr),y
.9 clc
rts
*--------------------------------------
@ -1325,6 +1331,7 @@ TERMX.COPY.XtoL1
sta SETPAGE2
jsr .6
sta CLRPAGE2
.6 ldy #39
@ -1348,8 +1355,10 @@ SetCharAtCurPos pha
*--------------------------------------
SetCharAtYX cmp #$40
bcc .1
cmp #$60
bcs .1
and #$1F remap UPPERCASE
.1 phy
@ -1362,10 +1371,12 @@ SetCharAtYX cmp #$40
lda (ZPDCBPtr),y
clc
bpl .2
sec
.2 lda #$80
bcc .21
lsr
.21 iny #S.DCB.TTY.bG0G1ALT
@ -1395,12 +1406,13 @@ SetCharAtY.SCR pha
pla
bcs .2
sta SETPAGE2
sta (ZPScrBL1),y
sta CLRPAGE2
rts
.2 sta CLRPAGE2
sta (ZPScrBL1),y
.2 sta (ZPScrBL1),y
SetCharAtYX.8 rts
*--------------------------------------