/* RPCInternal.h*/
/* Last modified by D. Swinehart, August 25, 1982  3:53 PM */

/* Unambiguous name of a host      */
struct HostNet {
	byte net;
	byte host; };

union Machine {	/* a "word" */
	word w; /* whole thing */
	struct HostNet b; };
	
struct HostConversationID {
	/* Host-relative ID of a conversation; unique for all time --*/
	word LS;
	word fields; /* Here's what would be in them:
		bLank bit
		ms	bit 15 */
	};
	#define lenHostConversationID (sizeof (HostConversationID)/2)
	
struct ConversationID {
	/* Absolute ID of a conversation; unique for all hosts and a long time --*/
	union Machine originator;
	struct HostConversationID count; };
    #define lenConversationID (sizeof (struct ConversationID)/2)

struct DispatcherID {
	word LS;
	word ms; };
    #define lenDispatcherID (sizeof (struct DispatcherID)/2)

struct DispatcherDetails {
  word mds;	/* top half of dispatcher's MDS base address --*/
  struct DispatcherID dispatcherID;	/* exporter-relative UID of interface instance --*/
  num dispatcherHint; };	/* hint to exporter host's export table --*/
     #define lenDispatcherDetails (sizeof (struct DispatcherDetails)/2)

union RPCCall {
	struct DispatcherDetails dispatcherDet;
	int outcome;
	word words[1]; };

union RPCData {
	byte bytes[2];
	word words[1]; };

/* ******** Authentication/Security: exported by RPCSecurity ******** --*/

/* for A talking to B using key CK, contains { CK, time, A }CB */
/* Authenticator must be constructed in "marshalled" form. */
struct Authenticator {
      num length;						/* Unmarshalled automatically */
      struct EncryptionKey ky;		/* Byte order OK */
      struct EncryptionKey kySpare;/* unused */
      struct EncryptionKey ck;		/* Byte order OK */
      struct EncryptionKey ckSpare;/* unused */
      word time[2];					/* Byte order OK until time used for something */
      struct ShortSTRING a; };		/* Must be unmarshalled to examine, but is stored marshalled! */
   #define lenAuthenticator (1+(4*lenEncryptionKey)+2)
   	/* does not include length(a) */

/* for A talking to B using key CK, contains:
  {KX}KA, spare, { {CK}KA, spare, nonce, B }KX .
  The keys are single cipher blocks.
  The rest is encrypted with CBC-check using a zero IV
  Intended to be returned along with an authenticator, also encrypted under KX (!) */
struct Authentication {
      num length;						/* Unmarshalled automatically */
      struct EncryptionKey kx;		/* Byte order OK */
      struct EncryptionKey kxSpare;/* Unused */
      struct EncryptionKey ck;		/* Byte order OK */
      struct EncryptionKey ckSpare;/* Unused */
      word nonceId[2];				/* Must unmarshall to compare */
      struct ShortSTRING b; };		/* Must unmarshall to compare */

struct ConversationObject {
	struct ConversationObject *next;
	struct ConversationID id;
	int level; /* security level */
	struct EncryptionKey key;	/* Conversation Key */
	struct IV iv; /* Initial vector */
	struct ShortSTRING *originator;	/* RPC.Principal */
	struct ShortSTRING *responder;	/* RPC.Principal */
	struct Authenticator *authenticator;	/* pointer to authenticator */
	};
    #define lenConversationObject   	(sizeof (struct ConversationObject)/2)
	#define Conversation ConversationObject