private byte[] handleHandshake(NfcMessage inputMessage) {
		// no sequence number in handshake
		if (inputMessage.isSelectAidApdu()) {
			/*
			 * The size of the returned message is specified in NfcTransceiver
			 * and is currently set to 2.
			 */
			if (Config.DEBUG)
				Log.d(TAG, "AID selected");
			
			return new NfcMessage(Type.AID).response().bytes();
		} else if (inputMessage.type() == Type.USER_ID) {
			if (inputMessage.version() > NfcMessage.getSupportedVersion()) {
				if (Config.DEBUG)
					Log.d(TAG, "excepted NfcMessage version "+NfcMessage.getSupportedVersion()+" but was "+inputMessage.version());
				
				eventHandler.handleMessage(NfcEvent.FATAL_ERROR, NfcInitiator.INCOMPATIBLE_VERSIONS);
				return new NfcMessage(Type.ERROR).payload(NfcInitiator.INCOMPATIBLE_VERSIONS.getBytes()).bytes();
			}
			
			// now we have the user id, get it
			long newUserId = Utils.byteArrayToLong(inputMessage.payload(), 0);
			int maxFragLen = Utils.byteArrayToInt(inputMessage.payload(), 8);
			
			messageSplitter.maxTransceiveLength(maxFragLen);
			if (inputMessage.isResume() && newUserId == userIdReceived) {
				if (Config.DEBUG)
					Log.d(TAG, "resume");
				
				return new NfcMessage(Type.DEFAULT).resume().bytes();
			} else {
				if (Config.DEBUG)
					Log.d(TAG, "new session (no resume)");
				
				userIdReceived = newUserId;
				lastMessageSent = null;
				lastMessageReceived = null;
				eventHandler.handleMessage(NfcEvent.INITIALIZED, Long.valueOf(userIdReceived));
				resetStates();
				return new NfcMessage(Type.USER_ID).bytes();
			}
		}
		return null;
	}