Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
B.  RPC Protocol and Language Specification Program and Procedure Numbers RPC Message Protocol  Previous   Contents   Next 
   
 

Record-Marking Standard

When RPC messages are passed on top of a byte-stream transport like TCP, you should try to delimit one message from another to detect and possibly recover from user protocol errors. This is called record marking (RM). One RPC message fits into one RM record.

A record is composed of one or more record fragments. A record fragment is a 4-byte header followed by 0 to (2**31) - 1 bytes of fragment data. The bytes encode an unsigned binary number. As with XDR integers, the byte order is the network byte order.

The header encodes two values:

  • A Boolean that specifies whether the fragment is the last fragment of the record. Bit value 1 implies the fragment is the last fragment.

  • A 31-bit unsigned binary value that is the length in bytes of the fragment's data. The Boolean value is the highest-order bit of the header. The length is the 31 low-order bits. This record specification is not in XDR standard form.

Authentication Protocols

Authentication parameters are opaque but open-ended to the rest of the RPC protocol. This section defines some flavors of authentication that have already been implemented. Other sites are free to invent new authentication types, with the same rules of flavor number assignment for program number assignment. Sun Microsystems maintains and administers a range of authentication flavors. To have authentication numbers like RPC program numbers allocated or registered to them, contact the Sun RPC Administrator.

AUTH_NONE

Calls are often made in which the caller does not authenticate itself and the server disregards who the caller is. In these cases, the flavor value of the RPC message's credentials, verifier, and response verifier is AUTH_NONE. The flavor value is the "discriminant" of the opaque_auth "union." The body length is zero when AUTH_NONE authentication flavor is used.

AUTH_SYS

AUTH_SYS This is the same as the authentication flavor previously known as AUTH_UNIX. The caller of a remote procedure might wish to identify itself using traditional UNIX process permissions authentication. The flavor of the opaque_auth of such an RPC call message is AUTH_SYS. The bytes of the body encode the following structure:

struct auth_sysparms {
  	unsigned int stamp;
  	string machinename<255>;
  	uid_t uid;
  	gid_t gid;
  	gid_t gids<10>;
 };
stamp

is an arbitrary ID that the caller machine can generate.

machinename

is the name of the caller's machine.

uid

is the caller's effective user ID.

gid

is the caller's effective group ID.

gids

is a counted array of groups in which the caller is a member.

The flavor of the verifier accompanying the credentials should be AUTH_NONE.

AUTH_SHORT Verifier

When using AUTH_SYS authentication, the flavor of the response verifier received in the reply message from the server might be AUTH_NONE or AUTH_SHORT.

If AUTH_SHORT, the bytes of the response verifier's string encode a short_hand_verf structure. This opaque structure can now be passed to the server instead of the original AUTH_SYS credentials.

The server keeps a cache that maps the shorthand opaque structures to the original credentials of the caller. These structures are passed back by way of an AUTH_SHORT style response verifier. The caller can save network bandwidth and server CPU cycles by using the new credentials.

The server can flush the shorthand opaque structure at any time. If a flush occurs, the remote procedure call message is rejected because of an authentication error. The reason for the failure is AUTH_REJECTEDCRED. At this point, the caller might try the original AUTH_SYS style of credentials, as shown in the following figure.

Figure B-1 Authentication Process Map

AUTH_DES Authentication

You might encounter the following situations with AUTH_SYS authentication:

  • Caller identification cannot be guaranteed to be unique if machines with differing operating systems are on the same network.

  • No verifier exists, so credentials can easily be faked.

AUTH_DES authentication attempts to fix these two problems.

The first issue is handled by addressing the caller by a simple string of characters instead of by an operating system-specific integer. This string of characters is known as the net name or network name of the caller. The server should not interpret the caller's name in any way other than as the identity of the caller. Thus, net names should be unique for every caller in the naming domain.

Each operating system's implementation of AUTH_DES authentication generates net names for its users that ensure this uniqueness when they call remote servers. Operating systems already distinguish users local to their systems. Extending this mechanism to the network is usually a simple matter.

For example, a user with a user ID of 515 might be assigned the following net name: UNIX.515@sun.com. This net name contains three items that serve to ensure it is unique. Backtracking, only one naming domain is called sun.com in the Internet. Within this domain, only one UNIX user has the user ID 515. However, there might be another user on another operating system, for example VMS, within the same naming domain who, by coincidence, happens to have the same user ID. To ensure that these two users can be distinguished, you add the operating system name. So one user is UNIX.515@sun.com and the other is VMS.515@sun.com.

The first field is actually a naming method rather than an operating system name. It just happens that almost a one-to-one correspondence exists between naming methods and operating systems. If there was a common worldwide naming standard, the first field could be a name from that standard, instead of an operating system name.

AUTH_DES Authentication Verifiers

Unlike AUTH_SYS authentication, AUTH_DES authentication does have a verifier so the server can validate the client's credential, and the reverse. The contents of this verifier are primarily an encrypted timestamp. The server can decrypt this timestamp, and if it is close to its current real time, then the client must have encrypted it correctly. The only way the client could encrypt the timestamp correctly is to know the conversation key of the RPC session. If the client knows the conversation key, it must be the real client.

The conversation key is a DES [5] key that the client generates and notifies the server of in its first RPC call. The conversation key is encrypted using a public-key scheme in this first transaction. The particular public-key scheme used in AUTH_DES authentication is Diffie-Hellman [3] with 192-bit keys. The details of this encryption method are described in "Diffie-Hellman Encryption".

The client and the server need the same notion of the current time for the verification to work. If network time synchronization cannot be guaranteed, then the client can synchronize with the server before beginning the conversation. rpcbind provides a procedure, RPCBPROC_GETTIME, which can be used to obtain the current time.

A server can determine if a client timestamp is valid. For any transaction after the first, the server checks for two things:

  • The timestamp is greater than the one previously seen from the same client.

  • The timestamp has not expired. A timestamp is expired if the server's time is later than the sum of the client's timestamp plus what is known as the client's window. The window is an encrypted number the client passes to the server in its first transaction. The window can be thought of as a lifetime for the credential.

For the first transaction, the server checks that the timestamp has not expired. As an added check, the client sends an encrypted item in the first transaction known as the window verifier. This verifier must be equal to the window minus 1, or the server rejects the credential.

The client must check the verifier returned from the server to be sure it is legitimate. The server sends back to the client the encrypted timestamp it received from the client, minus one second. If the client gets any result other than this one, the verifier is rejected.

Nicknames and Clock Synchronization

After the first transaction, the server's AUTH_DES authentication subsystem returns in its verifier to the client an integer nickname. The client can use this nickname in its further transactions instead of passing its net name, encrypted DES key, and window every time. The nickname is most likely an index into a table on the server that stores for each client its net name, decrypted DES key, and window. It should however be treated as opaque data by the client.

Though originally synchronized, client and server clocks can get out of sync. If this situation occurs, the client RPC subsystem most likely receives an RPC_AUTHERROR at which point it should resynchronize.

A client can still get the RPC_AUTHERROR error even though it is synchronized with the server. The server's nickname table is a limited size, and it can flush entries as needed. The client should resend its original credential and the server gives the client a new nickname. If a server crashes, the entire nickname table is flushed, and all clients have to resend their original credentials.

DES Authentication Protocol (in XDR language)

Credentials are explained in the following example:


Example B-2 AUTH_DES Authentication Protocol

/*
 * There are two kinds of credentials: one in which the client
 * uses its full network name, and one in which it uses its
 * "nickname" (just an unsigned integer) given to it by the
 * server. The client must use its full name in its first
 * transaction with the server, in which the server returns
 * to the client its nickname. The client may use its nickname
 * in all further transactions with the server. There is no
 * requirement to use the nickname, but it is wise to use it for
 * performance reasons.
 */
enum authdes_namekind {
 	ADN_FULLNAME = 0,
 	ADN_NICKNAME = 1
 };
 
/*
 * A 64-bit block of encrypted DES data
 */
 typedef opaque des_block[8];
 
/*
 * Maximum length of a network user's name
 */
const MAXNETNAMELEN = 255;
 
/*
 * A fullname contains the network name of the client, an
 * encrypted conversation key and the window. The window
 * is actually a lifetime for the credential. If the time
 * indicated in the verifier timestamp plus the window has
 * passed, then the server should expire the request and 
 * not grant it. To insure that requests are not replayed,
 * the server should insist that timestamps be greater
 * than the previous one seen, unless it is the first transaction.
 * In the first transaction, the server checks instead that the
 * window verifier is one less than the window.
 */
struct authdes_fullname {
 	string name<MAXNETNAMELEN>; /* name of client */
 	des_block key;              /* PK encrypted conversation key */
 	unsigned int window;        /* encrypted window */
};                             /* NOTE: PK means "public key" */
 
/*
 * A credential is either a fullname or a nickname
 */
unionauthdes_credswitch(authdes_namekindadc_namekind){
 	case ADN_FULLNAME:
 		authdes_fullname adc_fullname;
 	case ADN_NICKNAME:
 		unsigned int adc_nickname;
};
 
/*
 * A timestamp encodes the time since midnight, January 1, 1970.
 */
struct timestamp {
 	unsigned int seconds;      /* seconds */
 	unsigned int useconds;     /* and microseconds */
};
 
/*
 * Verifier: client variety
  */
struct authdes_verf_clnt {
 	timestamp adv_timestamp;   /* encrypted timestamp */
 	unsigned int adv_winverf;  /* encrypted window verifier */
};
 
/*
 * Verifier: server variety
 * The server returns (encrypted) the same timestamp the client gave
 * it minus one second. It also tells the client its nickname to be
 * used in future transactions (unencrypted).
 */
struct authdes_verf_svr {
 	timestamp adv_timeverf;    /* encrypted verifier */
 	unsigned int adv_nickname; /* new nickname for clnt */};

 
 
 
  Previous   Contents   Next