README.code
Info for hackers of pssh.


## Compilation ##

pssh is built using prc-tools and PilRC 3.0 on Mac OS X. 
pssh can probably be built on any platform supported by prc-tools. 
It probably cannot be built with CodeWarrior without significant porting 
work (multi-segment support, in particular).

prc-tools for Mac OS X: http://www.zenonez.com/prctoolsx/
PilRC 3.0 (newer than zenonez's version): http://www.ardiri.com/index.php?cat=pilrc
PilRC 3.0 is required. Earlier versions will not work.


To build, run `make` in the top-level source directory. This will build 
pssh's 68K code, ARM code, and resources, generating pssh.prc. 

WARNING: pssh's Makefile does NOT handle dependencies like changed .h files. 
Use `make clean` as necessary.


## Directories ##

arm: ARM-native code
arm/bn: bignum library from OpenSSL
arm/aes: AES cipher from OpenSSL

crypto: Basic cryptography algorithms
crypto/openssl: Cryptography algorithms from OpenSSL
crypto/rand: Fortuna random number generator
crypto/sha2: SHA256 algorithm by Aaron Gifford

data: Manipulation and display of data in Palm OS databases

forms: Event handlers and other form code

rsrc: Palm OS resource descriptions and font data
rsrc/pssh.rsrc: Palm OS Constructor mockups of some forms (not actually used)

ssh: SSH 2 protocol
ssh/openssh: SSH 2 code from OpenSSH

util: Miscellaneous utility code and headers
util/oem: Headers from various SDKs like palmOne and Sony

vt100: Terminal emulator from PuTTY


## SSH 2 protocol code ##

Palm OS programs are event-driven. OpenSSH's ssh client is not. 
To prevent blocking in socket I/O, much of OpenSSH's protocol code 
was rewritten as follows.

ssh.c
The highest-level wrapper around an SSH 2 session and its associated 
terminal emulator. All manipulation from outside goes through here.

packetizer.c
SSH 2 binary packet protocol. Handles socket I/O, version check, 
encryption, decryption, MAC check, padding. Sends unencrypted packet 
payloads to the transport layer. 

transport.c
SSH 2 transport protocol. Handles algorithm negotiation and key exchange. 
Sends other data to the connection layer.

connection.c
SSH 2 connection protocol. Handles authentication and stream data. 
Sends stream data to the terminal emulator.

The packetizer, transport, and connection layers are each a state machine 
whose states are generally defined by blocking network operations. This 
allows program control to return to the main event loop when waiting for 
packets to arrive. 
