public int handlePeerData (Blob data) throws IOException {
		
		switch (wrState) {
			//---------------------------------------------------------
			// initial state:
			//---------------------------------------------------------
			case STATE_INITIAL:
				if (isServer) {
					if (skVersion == 1)
						// server: extract peer challenge
						peerChallenge = data.asByteArray (true);
				}
				else {
					// client: parse ticket request @@@
				}
				wrState = STATE_TICKET;
				break;
			//---------------------------------------------------------
			// handle ticket (request/response)
			//---------------------------------------------------------
			case STATE_TICKET:
				if (isServer) {
					// extract ticket data and handle ticket.
					byte[] authTsData = data.getArray (LEN_TS);
					int rc = handleTicket (authTsData, id.password);

					// check for correct record type
					// and successful operation
					if (rc != AuthTs) {
						info = "unknown server key";
						rc = -1;
					}
					if (rc < 0)
						return AUTH_FAILED;

					// extract and handle authenticator.
					byte[] authAcData = data.getArray (LEN_TS, LEN_AC);
					rc = handleAuthenticator (authAcData);

					// check for correct record type
					if (rc != AuthAc) {
						info = "invalid authenticator";
						rc = -1;
					}
					if (rc < 0)
						return AUTH_FAILED;

					// everything is fine.
					wrState = STATE_DONE;
				}
				break;
		}

		return AUTH_CONTINUE;
	}