From 9e85ae9b75acdbe245243784d8d5b1b4de1b24f9 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Mon, 30 Mar 2009 08:58:09 +0000 Subject: x20090330-0957 --- appl/cmd/ssh/sshio.m | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 appl/cmd/ssh/sshio.m (limited to 'appl/cmd/ssh/sshio.m') diff --git a/appl/cmd/ssh/sshio.m b/appl/cmd/ssh/sshio.m new file mode 100644 index 00000000..3532dce0 --- /dev/null +++ b/appl/cmd/ssh/sshio.m @@ -0,0 +1,194 @@ + + # internal debugging flags + DBG, DBG_CRYPTO, DBG_PACKET, DBG_AUTH, DBG_PROC, DBG_PROTO, DBG_IO, DBG_SCP: con 1<Conn, nil: ref Sshio->Msg): ref AuthInfo; + auth: fn(nil: ref Sshio->Conn): int; +}; + +Sshio: module +{ + PATH: con "sshio.dis"; + + Conn: adt{ + in: chan of (ref Msg, string); + out: chan of ref Msg; + + sessid: array of byte; + sesskey: array of byte; + hostkey: ref Keyring->PK.RSA; + flags: int; + cipher: Cipher; # chosen cipher + user: string; + host: string; + interactive: int; + unget: ref Msg; + + mk: fn(host: string, fd: ref Sys->FD): ref Conn; + setkey: fn(c: self ref Conn, key: ref Keyring->PK.RSA); + }; + + Msg: adt{ + mtype: int; + data: array of byte; + rp: int; # read pointer + wp: int; # write pointer + ep: int; # byte just beyond message data + + mk: fn(mtype: int, length: int): ref Msg; + text: fn(m: self ref Msg): string; + fulltext: fn(m: self ref Msg): string; + + get1: fn(m: self ref Msg): int; + get2: fn(m: self ref Msg): int; + get4: fn(m: self ref Msg): int; + getstring: fn(m: self ref Msg): string; + getbytes: fn(m: self ref Msg, n: int): array of byte; + getarray: fn(m: self ref Msg): array of byte; + getipint: fn(m: self ref Msg): ref Keyring->IPint; + getpk: fn(m: self ref Msg): ref Keyring->PK.RSA; + + put1: fn(m: self ref Msg, nil: int); + put2: fn(m: self ref Msg, nil: int); + put4: fn(m: self ref Msg, nil: int); + putstring: fn(m: self ref Msg, s: string); + putbytes: fn(m: self ref Msg, a: array of byte, n: int); + putipint: fn(m: self ref Msg, mp: ref Keyring->IPint); + putpk: fn(m: self ref Msg, pk: ref Keyring->PK.RSA); + }; + + init: fn(); + + badmsg: fn(nil: ref Msg, nil: int, err: string); + recvmsg: fn(nil: ref Conn, nil: int): ref Msg; + unrecvmsg: fn(nil: ref Conn, nil: ref Msg); + rsapad: fn(nil: ref Keyring->IPint, nil: int): ref Keyring->IPint; + rsaunpad: fn(nil: ref Keyring->IPint): ref Keyring->IPint; + iptorjustbe: fn(nil: ref Keyring->IPint, nil: array of byte, nil: int); + rsaencryptbuf: fn(nil: ref Keyring->PK.RSA, nil: array of byte, nil: int): ref Keyring->IPint; + rsagen: fn(nbits: int): ref Keyring->SK.RSA; + rsaencrypt: fn(key: ref Keyring->PK.RSA, b: ref Keyring->IPint): ref Keyring->IPint; + rsadecrypt: fn(key: ref Keyring->SK.RSA, b: ref Keyring->IPint): ref Keyring->IPint; + + debug: fn(nil: int, nil: string); + error: fn(nil: string); + readstrnl: fn(fd: ref Sys->FD, buf: array of byte, nbytes: int): int; + calcsessid: fn(hostmod: ref Keyring->IPint, servermod: ref Keyring->IPint, cookie: array of byte): array of byte; +# sshlog: fn(nil: array of byte); # TBA was ... + + fastrand: fn(): int; + eqbytes: fn(a: array of byte, b: array of byte, n: int): int; + readversion: fn(fd: ref Sys->FD): (int, int, string); + hex: fn(a: array of byte): string; +}; -- cgit v1.2.3