|
|
As previously stated, 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 as there is for program number assignment.
Calls are often made where the caller does not authenticate itself and the server does not care who the caller is. In these cases, the flavor value (the ``discriminant'' of the opaque_auth ``union'') of the RPC message's credentials, verifier, and response verifier is AUTH_NONE. The bytes of the ``body'' field in the opaque_auth structure are undefined. It is recommended that the ``body'' length be zero when AUTH_NONE authentication is used.
The caller of a remote procedure may want to identify itself using traditional System V 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 int gid; gid_t int gids<10>; };
When using AUTH_SYS authentication, the flavor of the response verifier received in the reply message from the server may 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 may now be passed to the server instead of the original AUTH_SYS credentials.
The server keeps a cache that maps shorthand opaque structures (passed back by way of an AUTH_SHORT style response verifier) to the original credentials of the caller. The caller can save network bandwidth and server CPU cycles by using the new credentials.
The server may flush the shorthand opaque structure at any time. If this happens, the remote procedure call message will be rejected owing to an authentication error. The reason for the failure will be AUTH_REJECTEDCRED. At this point, the caller may want to try the original AUTH_SYS style of credentials.
AUTH_SYS authentication suffers from the following problems:
The first problem 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 ``netname'' or network name of the caller. The server should not interpret the caller's name in any way other than as the identify of the caller. Thus, netnames should be unique for every caller in the naming domain.
It is up to each operating system's implementation of AUTH_DES authentication to generate netnames for its users that insure this uniqueness when they call remote servers. Operating systems already know how to distinguish users local to their systems. It is usually a simple matter to extend this mechanism to the network. For example, a user with a user ID of 515 might be assigned the following netname: ``UNIX.515@sun.com.'' This netname contains three items that serve to insure it is unique. Going backwards, there is only one naming domain called sun.com in the internet. Within this domain, there is only one UNIX user with user ID 515. However, there may be another user on another operating system, for example VMS®, within the same naming domain that, by coincidence, happens to have the same user ID. To insure that these two users can be distinguished we add the operating system name. So one user is ``"UNIX.515@sun.com"'' and the other is ``"VMS.515@sun.com"''.
Unlike AUTH_SYS authentication, AUTH_DES authentication does have a verifier so the server can validate the client's credential (and vice-versa). The contents of this verifier is primarily an encrypted timestamp. The server can decrypt this timestamp, and if it is close to what the real time is, then the client must have encrypted it correctly. The only way the client could encrypt it correctly is to know the conversation key of the RPC session. If the client knows the conversation key, then it must be the real client.
The conversation key is a DES 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 with 192-bit keys. The details of this encryption method are described later.
The client and the server need the same notion of the current time for this to work. If network time synchronization cannot be guaranteed, then client can synchronize with the server before beginning the conversation, perhaps by consulting the Internet Time Server.
A server can determine if a client timestamp is valid. For any transaction after the first, the server checks for two things:
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'' which must be equal to the window minus 1, or the server will reject 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 anything other than this, it will reject it.
After the first transaction, the server's AUTH_DES authentication subsystem returns in its verifier to the client an integer ``nickname'' that the client may use in its further transactions instead of passing its netname, 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 netname, decrypted DES key and window.
Though originally synchronized, client and server clocks can get out of sync. If this happens, the client RPC subsystem most likely will get back RPC_AUTHERROR at which point it should resynchronize.
A client may still get the RPC_AUTHERROR error even though it is synchronized with the server. The reason is that the server's nickname table is a limited size, and it may flush entries whenever it wants. The client should resend its original credential and the server will give it a new nickname. If a server crashes, the entire nickname table may get flushed, and all clients will have to resend their original credentials.
/* * 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 fullname in its first transaction with the * server, in which the server will return 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 */ union authdes_cred switch (authdes_namekind adc_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 client */ };
In this scheme, there are two constants, PROOT and HEXMODULUS. The particular values chosen for these for the DES authentication protocol are:
const PROOT = 3; const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; /* hex */
The way this scheme works is best explained by an example. Suppose there are two people ``A'' and ``B'' who want to send encrypted messages to each other. So, A and B each generate a random secret key that they do not disclose to anyone. Let these keys be represented as ``SK(A)'' and ``SK(B).'' They also publish in a public directory their public keys. These keys are computed as follows:
PK(A) = ( PROOT ** SK(A) ) mod HEXMODULUS PK(B) = ( PROOT ** SK(B) ) mod HEXMODULUSThe ``**'' notation is used here to represent exponentiation.
Now, both A and B can arrive at the common key between them, represented here as ``CK(A,B)'', without disclosing their secret keys.
A computes:
CK(A, B) = ( PK(B) ** SK(A)) mod HEXMODULUSwhile B computes:
CK(A, B) = ( PK(A) ** SK(B)) mod HEXMODULUSThese two can be shown to be equivalent:
(PK(B)**SK(A)) mod HEXMODULUS = (PK(A)**SK(B)) mod HEXMODULUSWe drop the mod HEXMODULUS parts and assume modulo arithmetic to simplify things:
PK(B) ** SK(A) = PK(A) ** SK(B)Then, replace PK(B) by what B computed earlier and likewise for PK(A).
((PROOT ** SK(B)) ** SK(A) = (PROOT ** SK(A)) ** SK(B)which leads to:
PROOT ** (SK(A) * SK(B)) = PROOT ** (SK(A) * SK(B))This common key CK(A,B) is not used to encrypt the timestamps used in the protocol. It is used only to encrypt a conversation key that is then used to encrypt the timestamps. The reason for doing this is to use the common key as little as possible, for fear that it could be broken. Breaking the conversation key is a far less serious offense, because conversations are comparatively short-lived.
The conversation key is encrypted using 56-bit DES keys, yet the common key is 192 bits. To reduce the number of bits, 56 bits are selected from the common key as follows. The middle-most 8-bytes are selected from the common key, and then parity is added to the lower order bit of each byte, producing a 56-bit key with 8 bits of parity.