2 .\" Must use -- tbl -- with this one
4 .\" @(#)rpc.rfc.ms 2.2 88/08/05 4.0 RPCSRC
8 .if \\n%=1 .tl ''- % -''
11 .\" prevent excess underlining in nroff
13 .OH 'Remote Procedure Calls: Protocol Specification''Page %'
14 .EH 'Page %''Remote Procedure Calls: Protocol Specification'
17 \&Remote Procedure Calls: Protocol Specification
22 Note: This chapter specifies a protocol that Sun Microsystems, Inc.,
24 It has been designated RFC1050 by the ARPA Network
30 This chapter specifies a message protocol used in implementing
31 Sun's Remote Procedure Call (RPC) package. (The message protocol is
32 specified with the External Data Representation (XDR) language.
34 .I "External Data Representation Standard: Protocol Specification"
35 for the details. Here, we assume that the reader is familiar
36 with XDR and do not attempt to justify it or its uses). The paper
37 by Birrell and Nelson [1] is recommended as an excellent background
38 to and justification of RPC.
42 This chapter discusses servers, services, programs, procedures,
43 clients, and versions. A server is a piece of software where network
44 services are implemented. A network service is a collection of one
45 or more remote programs. A remote program implements one or more
46 remote procedures; the procedures, their parameters, and results are
47 documented in the specific program's protocol specification (see the
48 \fIPort Mapper Program Protocol\fP\, below, for an example). Network
49 clients are pieces of software that initiate remote procedure calls
50 to services. A server may support more than one version of a remote
51 program in order to be forward compatible with changing protocols.
53 For example, a network file service may be composed of two programs.
54 One program may deal with high-level applications such as file system
55 access control and locking. The other may deal with low-level file
56 IO and have procedures like "read" and "write". A client machine of
57 the network file service would call the procedures associated with
58 the two programs of the service on behalf of some user on the client
63 The remote procedure call model is similar to the local procedure
64 call model. In the local case, the caller places arguments to a
65 procedure in some well-specified location (such as a result
66 register). It then transfers control to the procedure, and
67 eventually gains back control. At that point, the results of the
68 procedure are extracted from the well-specified location, and the
69 caller continues execution.
71 The remote procedure call is similar, in that one thread of control
72 logically winds through two processes\(emone is the caller's process,
73 the other is a server's process. That is, the caller process sends a
74 call message to the server process and waits (blocks) for a reply
75 message. The call message contains the procedure's parameters, among
76 other things. The reply message contains the procedure's results,
77 among other things. Once the reply message is received, the results
78 of the procedure are extracted, and caller's execution is resumed.
80 On the server side, a process is dormant awaiting the arrival of a
81 call message. When one arrives, the server process extracts the
82 procedure's parameters, computes the results, sends a reply message,
83 and then awaits the next call message.
85 Note that in this model, only one of the two processes is active at
86 any given time. However, this model is only given as an example.
87 The RPC protocol makes no restrictions on the concurrency model
88 implemented, and others are possible. For example, an implementation
89 may choose to have RPC calls be asynchronous, so that the client may
90 do useful work while waiting for the reply from the server. Another
91 possibility is to have the server create a task to process an
92 incoming request, so that the server can be free to receive other
95 \&Transports and Semantics
97 The RPC protocol is independent of transport protocols. That is, RPC
98 does not care how a message is passed from one process to another.
99 The protocol deals only with specification and interpretation of
102 It is important to point out that RPC does not try to implement any
103 kind of reliability and that the application must be aware of the
104 type of transport protocol underneath RPC. If it knows it is running
105 on top of a reliable transport such as TCP/IP[6], then most of the
106 work is already done for it. On the other hand, if it is running on
107 top of an unreliable transport such as UDP/IP[7], it must implement
108 is own retransmission and time-out policy as the RPC layer does not
109 provide this service.
111 Because of transport independence, the RPC protocol does not attach
112 specific semantics to the remote procedures or their execution.
113 Semantics can be inferred from (but should be explicitly specified
114 by) the underlying transport protocol. For example, consider RPC
115 running on top of an unreliable transport such as UDP/IP. If an
116 application retransmits RPC messages after short time-outs, the only
117 thing it can infer if it receives no reply is that the procedure was
118 executed zero or more times. If it does receive a reply, then it can
119 infer that the procedure was executed at least once.
121 A server may wish to remember previously granted requests from a
122 client and not regrant them in order to insure some degree of
123 execute-at-most-once semantics. A server can do this by taking
124 advantage of the transaction ID that is packaged with every RPC
125 request. The main use of this transaction is by the client RPC layer
126 in matching replies to requests. However, a client application may
127 choose to reuse its previous transaction ID when retransmitting a
128 request. The server application, knowing this fact, may choose to
129 remember this ID after granting a request and not regrant requests
130 with the same ID in order to achieve some degree of
131 execute-at-most-once semantics. The server is not allowed to examine
132 this ID in any other way except as a test for equality.
134 On the other hand, if using a reliable transport such as TCP/IP, the
135 application can infer from a reply message that the procedure was
136 executed exactly once, but if it receives no reply message, it cannot
137 assume the remote procedure was not executed. Note that even if a
138 connection-oriented protocol like TCP is used, an application still
139 needs time-outs and reconnection to handle server crashes.
141 There are other possibilities for transports besides datagram- or
142 connection-oriented protocols. For example, a request-reply protocol
143 such as VMTP[2] is perhaps the most natural transport for RPC.
146 NOTE: At Sun, RPC is currently implemented on top of both TCP/IP
147 and UDP/IP transports.
150 \&Binding and Rendezvous Independence
152 The act of binding a client to a service is NOT part of the remote
153 procedure call specification. This important and necessary function
154 is left up to some higher-level software. (The software may use RPC
155 itself\(emsee the \fIPort Mapper Program Protocol\fP\, below).
157 Implementors should think of the RPC protocol as the jump-subroutine
158 instruction ("JSR") of a network; the loader (binder) makes JSR
159 useful, and the loader itself uses JSR to accomplish its task.
160 Likewise, the network makes RPC useful, using RPC to accomplish this
165 The RPC protocol provides the fields necessary for a client to
166 identify itself to a service and vice-versa. Security and access
167 control mechanisms can be built on top of the message authentication.
168 Several different authentication protocols can be supported. A field
169 in the RPC header indicates which protocol is being used. More
170 information on specific authentication protocols can be found in the
171 \fIAuthentication Protocols\fP\,
175 \&RPC Protocol Requirements
177 The RPC protocol must provide for the following:
179 Unique specification of a procedure to be called.
181 Provisions for matching response messages to request messages.
184 Provisions for authenticating the caller to service and vice-versa.
186 Besides these requirements, features that detect the following are
187 worth supporting because of protocol roll-over errors, implementation
188 bugs, user error, and network administration:
190 RPC protocol mismatches.
192 Remote program protocol version mismatches.
194 Protocol errors (such as misspecification of a procedure's parameters).
196 Reasons why remote authentication failed.
198 Any other reasons why the desired procedure was not called.
200 \&Programs and Procedures
202 The RPC call message has three unsigned fields: remote program
203 number, remote program version number, and remote procedure number.
204 The three fields uniquely identify the procedure to be called.
205 Program numbers are administered by some central authority (like
206 Sun). Once an implementor has a program number, he can implement his
207 remote program; the first implementation would most likely have the
208 version number of 1. Because most new protocols evolve into better,
209 stable, and mature protocols, a version field of the call message
210 identifies which version of the protocol the caller is using.
211 Version numbers make speaking old and new protocols through the same
212 server process possible.
214 The procedure number identifies the procedure to be called. These
215 numbers are documented in the specific program's protocol
216 specification. For example, a file service's protocol specification
217 may state that its procedure number 5 is "read" and procedure number
220 Just as remote program protocols may change over several versions,
221 the actual RPC message protocol could also change. Therefore, the
222 call message also has in it the RPC version number, which is always
223 equal to two for the version of RPC described here.
225 The reply message to a request message has enough information to
226 distinguish the following error conditions:
228 The remote implementation of RPC does speak protocol version 2.
229 The lowest and highest supported RPC version numbers are returned.
231 The remote program is not available on the remote system.
233 The remote program does not support the requested version number.
234 The lowest and highest supported remote program version numbers are
237 The requested procedure number does not exist. (This is usually a
238 caller side protocol or programming error.)
240 The parameters to the remote procedure appear to be garbage from the
241 server's point of view. (Again, this is usually caused by a
242 disagreement about the protocol between client and service.)
246 Provisions for authentication of caller to service and vice-versa are
247 provided as a part of the RPC protocol. The call message has two
248 authentication fields, the credentials and verifier. The reply
249 message has one authentication field, the response verifier. The RPC
250 protocol specification defines all three fields to be the following
260 /* \fIand more to be defined\fP */
269 In simple English, any
273 enumeration followed by bytes which are opaque to the RPC protocol
276 The interpretation and semantics of the data contained within the
277 authentication fields is specified by individual, independent
278 authentication protocol specifications. (See
279 \fIAuthentication Protocols\fP\,
280 below, for definitions of the various authentication protocols.)
282 If authentication parameters were rejected, the response message
283 contains information stating why they were rejected.
285 \&Program Number Assignment
287 Program numbers are given out in groups of
289 (decimal 536870912) according to the following chart:
294 Program Numbers&Description
297 0 - 1fffffff&Defined by Sun
298 20000000 - 3fffffff&Defined by user
299 40000000 - 5fffffff&Transient
300 60000000 - 7fffffff&Reserved
301 80000000 - 9fffffff&Reserved
302 a0000000 - bfffffff&Reserved
303 c0000000 - dfffffff&Reserved
304 e0000000 - ffffffff&Reserved
307 The first group is a range of numbers administered by Sun
308 Microsystems and should be identical for all sites. The second range
309 is for applications peculiar to a particular site. This range is
310 intended primarily for debugging new programs. When a site develops
311 an application that might be of general interest, that application
312 should be given an assigned number in the first range. The third
313 group is for applications that generate program numbers dynamically.
314 The final groups are reserved for future use, and should not be used.
316 \&Other Uses of the RPC Protocol
318 The intended use of this protocol is for calling remote procedures.
319 That is, each call message is matched with a response message.
320 However, the protocol itself is a message-passing protocol with which
321 other (non-RPC) protocols can be implemented. Sun currently uses, or
322 perhaps abuses, the RPC message protocol for the following two
323 (non-RPC) protocols: batching (or pipelining) and broadcast RPC.
324 These two protocols are discussed but not defined below.
328 Batching allows a client to send an arbitrarily large sequence of
329 call messages to a server; batching typically uses reliable byte
330 stream protocols (like TCP/IP) for its transport. In the case of
331 batching, the client never waits for a reply from the server, and the
332 server does not send replies to batch requests. A sequence of batch
333 calls is usually terminated by a legitimate RPC in order to flush the
334 pipeline (with positive acknowledgement).
338 In broadcast RPC-based protocols, the client sends a broadcast packet
339 to the network and waits for numerous replies. Broadcast RPC uses
340 unreliable, packet-based protocols (like UDP/IP) as its transports.
341 Servers that support broadcast protocols only respond when the
342 request is successfully processed, and are silent in the face of
343 errors. Broadcast RPC uses the Port Mapper RPC service to achieve
344 its semantics. See the \fIPort Mapper Program Protocol\fP\, below,
345 for more information.
348 \&The RPC Message Protocol
350 This section defines the RPC message protocol in the XDR data
351 description language. The message is defined in a top-down style.
362 * A reply to a call message can take on two forms:
363 * The message was either accepted or rejected.
373 * Given that a call message was accepted, the following is the
374 * status of an attempt to call a remote procedure.
378 SUCCESS = 0, /* \fIRPC executed successfully \fP*/
379 PROG_UNAVAIL = 1, /* \fIremote hasn't exported program \fP*/
380 PROG_MISMATCH = 2, /* \fIremote can't support version # \fP*/
381 PROC_UNAVAIL = 3, /* \fIprogram can't support procedure \fP*/
382 GARBAGE_ARGS = 4 /* \fIprocedure can't decode params \fP*/
389 * Reasons why a call message was rejected:
393 RPC_MISMATCH = 0, /* \fIRPC version number != 2 \fP*/
394 AUTH_ERROR = 1 /* \fIremote can't authenticate caller \fP*/
399 * Why authentication failed:
403 AUTH_BADCRED = 1, /* \fIbad credentials \fP*/
404 AUTH_REJECTEDCRED = 2, /* \fIclient must begin new session \fP*/
405 AUTH_BADVERF = 3, /* \fIbad verifier \fP*/
406 AUTH_REJECTEDVERF = 4, /* \fIverifier expired or replayed \fP*/
407 AUTH_TOOWEAK = 5 /* \fIrejected for security reasons \fP*/
416 * All messages start with a transaction identifier, xid,
417 * followed by a two-armed discriminated union. The union's
418 * discriminant is a msg_type which switches to one of the two
419 * types of the message. The xid of a \fIREPLY\fP message always
420 * matches that of the initiating \fICALL\fP message. NB: The xid
421 * field is only used for clients matching reply messages with
422 * call messages or for servers detecting retransmissions; the
423 * service side cannot treat this id as any type of sequence
429 union switch (msg_type mtype) {
441 * Body of an RPC request call:
442 * In version 2 of the RPC protocol specification, rpcvers must
443 * be equal to 2. The fields prog, vers, and proc specify the
444 * remote program, its version number, and the procedure within
445 * the remote program to be called. After these fields are two
446 * authentication parameters: cred (authentication credentials)
447 * and verf (authentication verifier). The two authentication
448 * parameters are followed by the parameters to the remote
449 * procedure, which are specified by the specific program
454 unsigned int rpcvers; /* \fImust be equal to two (2) \fP*/
460 /* \fIprocedure specific parameters start here \fP*/
467 * Body of a reply to an RPC request:
468 * The call message was either accepted or rejected.
471 union reply_body switch (reply_stat stat) {
473 accepted_reply areply;
475 rejected_reply rreply;
482 * Reply to an RPC request that was accepted by the server:
483 * there could be an error even though the request was accepted.
484 * The first field is an authentication verifier that the server
485 * generates in order to validate itself to the caller. It is
486 * followed by a union whose discriminant is an enum
487 * accept_stat. The \fISUCCESS\fP arm of the union is protocol
488 * specific. The \fIPROG_UNAVAIL\fP, \fIPROC_UNAVAIL\fP, and \fIGARBAGE_ARGP\fP
489 * arms of the union are void. The \fIPROG_MISMATCH\fP arm specifies
490 * the lowest and highest version numbers of the remote program
491 * supported by the server.
494 struct accepted_reply {
496 union switch (accept_stat stat) {
499 /* \fIprocedure-specific results start here\fP */
508 * Void. Cases include \fIPROG_UNAVAIL, PROC_UNAVAIL\fP,
509 * and \fIGARBAGE_ARGS\fP.
520 * Reply to an RPC request that was rejected by the server:
521 * The request can be rejected for two reasons: either the
522 * server is not running a compatible version of the RPC
523 * protocol (\fIRPC_MISMATCH\fP), or the server refuses to
524 * authenticate the caller (\fIAUTH_ERROR\fP). In case of an RPC
525 * version mismatch, the server returns the lowest and highest
526 * supported RPC version numbers. In case of refused
527 * authentication, failure status is returned.
530 union rejected_reply switch (reject_stat stat) {
541 \&Authentication Protocols
543 As previously stated, authentication parameters are opaque, but
544 open-ended to the rest of the RPC protocol. This section defines
545 some "flavors" of authentication implemented at (and supported by)
546 Sun. Other sites are free to invent new authentication types, with
547 the same rules of flavor number assignment as there is for program
550 \&Null Authentication
552 Often calls must be made where the caller does not know who he is or
553 the server does not care who the caller is. In this case, the flavor
554 value (the discriminant of the \fIopaque_auth\fP's union) of the RPC
555 message's credentials, verifier, and response verifier is
557 The bytes of the opaque_auth's body are undefined.
558 It is recommended that the opaque length be zero.
560 \&UNIX Authentication
562 The caller of a remote procedure may wish to identify himself as he
563 is identified on a UNIX system. The value of the credential's
564 discriminant of an RPC call message is
567 the credential's opaque body encode the following structure:
572 string machinename<255>;
575 unsigned int gids<10>;
580 is an arbitrary ID which the caller machine may
583 is the name of the caller's machine (like "krypton"). The
585 is the caller's effective user ID. The
587 is the caller's effective group ID. The
590 counted array of groups which contain the caller as a member. The
591 verifier accompanying the credentials should be of
595 The value of the discriminant of the response verifier received in
596 the reply message from the server may be
602 the bytes of the response verifier's string encode an opaque
603 structure. This new opaque structure may now be passed to the server
604 instead of the original
606 flavor credentials. The server keeps a cache which maps shorthand
607 opaque structures (passed back by way of an
609 style response verifier) to the original credentials of the caller.
610 The caller can save network bandwidth and server cpu cycles by using
613 The server may flush the shorthand opaque structure at any time. If
614 this happens, the remote procedure call message will be rejected due
615 to an authentication error. The reason for the failure will be
616 .I AUTH_REJECTEDCRED .
617 At this point, the caller may wish to try the original
619 style of credentials.
624 UNIX authentication suffers from two major problems:
626 The naming is too UNIX-system oriented.
628 There is no verifier, so credentials can easily be faked.
630 DES authentication attempts to fix these two problems.
635 The first problem is handled by addressing the caller by a simple
636 string of characters instead of by an operating system specific
637 integer. This string of characters is known as the "netname" or
638 network name of the caller. The server is not allowed to interpret
639 the contents of the caller's name in any other way except to
640 identify the caller. Thus, netnames should be unique for every
641 caller in the internet.
643 It is up to each operating system's implementation of DES
644 authentication to generate netnames for its users that insure this
645 uniqueness when they call upon remote servers. Operating systems
646 already know how to distinguish users local to their systems. It is
647 usually a simple matter to extend this mechanism to the network.
648 For example, a UNIX user at Sun with a user ID of 515 might be
649 assigned the following netname: "unix.515@sun.com". This netname
650 contains three items that serve to insure it is unique. Going
651 backwards, there is only one naming domain called "sun.com" in the
652 internet. Within this domain, there is only one UNIX user with
653 user ID 515. However, there may be another user on another
654 operating system, for example VMS, within the same naming domain
655 that, by coincidence, happens to have the same user ID. To insure
656 that these two users can be distinguished we add the operating
657 system name. So one user is "unix.515@sun.com" and the other is
660 The first field is actually a naming method rather than an
661 operating system name. It just happens that today there is almost
662 a one-to-one correspondence between naming methods and operating
663 systems. If the world could agree on a naming standard, the first
664 field could be the name of that standard, instead of an operating
668 \&DES Authentication Verifiers
670 Unlike UNIX authentication, DES authentication does have a verifier
671 so the server can validate the client's credential (and
672 vice-versa). The contents of this verifier is primarily an
673 encrypted timestamp. The server can decrypt this timestamp, and if
674 it is close to what the real time is, then the client must have
675 encrypted it correctly. The only way the client could encrypt it
676 correctly is to know the "conversation key" of the RPC session. And
677 if the client knows the conversation key, then it must be the real
680 The conversation key is a DES [5] key which the client generates
681 and notifies the server of in its first RPC call. The conversation
682 key is encrypted using a public key scheme in this first
683 transaction. The particular public key scheme used in DES
684 authentication is Diffie-Hellman [3] with 192-bit keys. The
685 details of this encryption method are described later.
687 The client and the server need the same notion of the current time
688 in order for all of this to work. If network time synchronization
689 cannot be guaranteed, then client can synchronize with the server
690 before beginning the conversation, perhaps by consulting the
691 Internet Time Server (TIME[4]).
693 The way a server determines if a client timestamp is valid is
694 somewhat complicated. For any other transaction but the first, the
695 server just checks for two things:
697 the timestamp is greater than the one previously seen from the
700 the timestamp has not expired.
702 A timestamp is expired if the server's time is later than the sum
703 of the client's timestamp plus what is known as the client's
704 "window". The "window" is a number the client passes (encrypted)
705 to the server in its first transaction. You can think of it as a
706 lifetime for the credential.
708 This explains everything but the first transaction. In the first
709 transaction, the server checks only that the timestamp has not
710 expired. If this was all that was done though, then it would be
711 quite easy for the client to send random data in place of the
712 timestamp with a fairly good chance of succeeding. As an added
713 check, the client sends an encrypted item in the first transaction
714 known as the "window verifier" which must be equal to the window
715 minus 1, or the server will reject the credential.
717 The client too must check the verifier returned from the server to
718 be sure it is legitimate. The server sends back to the client the
719 encrypted timestamp it received from the client, minus one second.
720 If the client gets anything different than this, it will reject it.
723 \&Nicknames and Clock Synchronization
725 After the first transaction, the server's DES authentication
726 subsystem returns in its verifier to the client an integer
727 "nickname" which the client may use in its further transactions
728 instead of passing its netname, encrypted DES key and window every
729 time. The nickname is most likely an index into a table on the
730 server which stores for each client its netname, decrypted DES key
733 Though they originally were synchronized, the client's and server's
734 clocks can get out of sync again. When this happens the client RPC
735 subsystem most likely will get back
737 at which point it should resynchronize.
739 A client may still get the
741 error even though it is
742 synchronized with the server. The reason is that the server's
743 nickname table is a limited size, and it may flush entries whenever
744 it wants. A client should resend its original credential in this
745 case and the server will give it a new nickname. If a server
746 crashes, the entire nickname table gets flushed, and all clients
747 will have to resend their original credentials.
750 \&DES Authentication Protocol (in XDR language)
755 * There are two kinds of credentials: one in which the client uses
756 * its full network name, and one in which it uses its "nickname"
757 * (just an unsigned integer) given to it by the server. The
758 * client must use its fullname in its first transaction with the
759 * server, in which the server will return to the client its
760 * nickname. The client may use its nickname in all further
761 * transactions with the server. There is no requirement to use the
762 * nickname, but it is wise to use it for performance reasons.
765 enum authdes_namekind {
772 * A 64-bit block of encrypted DES data
775 typedef opaque des_block[8];
779 * Maximum length of a network user's name
782 const MAXNETNAMELEN = 255;
786 * A fullname contains the network name of the client, an encrypted
787 * conversation key and the window. The window is actually a
788 * lifetime for the credential. If the time indicated in the
789 * verifier timestamp plus the window has past, then the server
790 * should expire the request and not grant it. To insure that
791 * requests are not replayed, the server should insist that
792 * timestamps are greater than the previous one seen, unless it is
793 * the first transaction. In the first transaction, the server
794 * checks instead that the window verifier is one less than the
798 struct authdes_fullname {
799 string name<MAXNETNAMELEN>; /* \fIname of client \f(CW*/
800 des_block key; /* \fIPK encrypted conversation key \f(CW*/
801 unsigned int window; /* \fIencrypted window \f(CW*/
806 * A credential is either a fullname or a nickname
809 union authdes_cred switch (authdes_namekind adc_namekind) {
811 authdes_fullname adc_fullname;
813 unsigned int adc_nickname;
818 * A timestamp encodes the time since midnight, January 1, 1970.
822 unsigned int seconds; /* \fIseconds \fP*/
823 unsigned int useconds; /* \fIand microseconds \fP*/
828 * Verifier: client variety
829 * The window verifier is only used in the first transaction. In
830 * conjunction with a fullname credential, these items are packed
831 * into the following structure before being encrypted:
834 * \f(CWadv_timestamp; \fP-- one DES block
835 * \f(CWadc_fullname.window; \fP-- one half DES block
836 * \f(CWadv_winverf; \fP-- one half DES block
838 * This structure is encrypted using CBC mode encryption with an
839 * input vector of zero. All other encryptions of timestamps use
840 * ECB mode encryption.
843 struct authdes_verf_clnt {
844 timestamp adv_timestamp; /* \fIencrypted timestamp \fP*/
845 unsigned int adv_winverf; /* \fIencrypted window verifier \fP*/
850 * Verifier: server variety
851 * The server returns (encrypted) the same timestamp the client
852 * gave it minus one second. It also tells the client its nickname
853 * to be used in future transactions (unencrypted).
856 struct authdes_verf_svr {
857 timestamp adv_timeverf; /* \fIencrypted verifier \fP*/
858 unsigned int adv_nickname; /* \fInew nickname for client \fP*/
863 \&Diffie-Hellman Encryption
865 In this scheme, there are two constants,
870 particular values Sun has chosen for these for the DES
871 authentication protocol are:
877 "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"; /* \fIhex \fP*/
880 The way this scheme works is best explained by an example. Suppose
881 there are two people "A" and "B" who want to send encrypted
882 messages to each other. So, A and B both generate "secret" keys at
883 random which they do not reveal to anyone. Let these keys be
884 represented as SK(A) and SK(B). They also publish in a public
885 directory their "public" keys. These keys are computed as follows:
889 PK(A) = ( BASE ** SK(A) ) mod MODULUS
890 PK(B) = ( BASE ** SK(B) ) mod MODULUS
893 The "**" notation is used here to represent exponentiation. Now,
894 both A and B can arrive at the "common" key between them,
895 represented here as CK(A, B), without revealing their secret keys.
901 CK(A, B) = ( PK(B) ** SK(A)) mod MODULUS
908 CK(A, B) = ( PK(A) ** SK(B)) mod MODULUS
911 These two can be shown to be equivalent:
915 (PK(B) ** SK(A)) mod MODULUS = (PK(A) ** SK(B)) mod MODULUS
918 We drop the "mod MODULUS" parts and assume modulo arithmetic to
923 PK(B) ** SK(A) = PK(A) ** SK(B)
926 Then, replace PK(B) by what B computed earlier and likewise for
931 ((BASE ** SK(B)) ** SK(A) = (BASE ** SK(A)) ** SK(B)
938 BASE ** (SK(A) * SK(B)) = BASE ** (SK(A) * SK(B))
941 This common key CK(A, B) is not used to encrypt the timestamps used
942 in the protocol. Rather, it is used only to encrypt a conversation
943 key which is then used to encrypt the timestamps. The reason for
944 doing this is to use the common key as little as possible, for fear
945 that it could be broken. Breaking the conversation key is a far
946 less serious offense, since conversations are relatively
949 The conversation key is encrypted using 56-bit DES keys, yet the
950 common key is 192 bits. To reduce the number of bits, 56 bits are
951 selected from the common key as follows. The middle-most 8-bytes
952 are selected from the common key, and then parity is added to the
953 lower order bit of each byte, producing a 56-bit key with 8 bits of
957 \&Record Marking Standard
959 When RPC messages are passed on top of a byte stream protocol (like
960 TCP/IP), it is necessary, or at least desirable, to delimit one
961 message from another in order to detect and possibly recover from
962 user protocol errors. This is called record marking (RM). Sun uses
963 this RM/TCP/IP transport for passing RPC messages on TCP streams.
964 One RPC message fits into one RM record.
966 A record is composed of one or more record fragments. A record
967 fragment is a four-byte header followed by 0 to (2**31) - 1 bytes of
968 fragment data. The bytes encode an unsigned binary number; as with
969 XDR integers, the byte order is from highest to lowest. The number
970 encodes two values\(ema boolean which indicates whether the fragment
971 is the last fragment of the record (bit value 1 implies the fragment
972 is the last fragment) and a 31-bit unsigned binary value which is the
973 length in bytes of the fragment's data. The boolean value is the
974 highest-order bit of the header; the length is the 31 low-order bits.
975 (Note that this record specification is NOT in XDR standard form!)
981 Just as there was a need to describe the XDR data-types in a formal
982 language, there is also need to describe the procedures that operate
983 on these XDR data-types in a formal language as well. We use the RPC
984 Language for this purpose. It is an extension to the XDR language.
985 The following example is used to describe the essence of the
988 \&An Example Service Described in the RPC Language
990 Here is an example of the specification of a simple ping program.
996 * Simple ping program
1000 /* \fILatest and greatest version\fP */
1001 version PING_VERS_PINGBACK {
1003 PINGPROC_NULL(void) = 0;
1007 * Ping the caller, return the round-trip time
1008 * (in microseconds). Returns -1 if the operation
1013 PINGPROC_PINGBACK(void) = 1;
1021 version PING_VERS_ORIG {
1023 PINGPROC_NULL(void) = 0;
1027 const PING_VERS = 2; /* \fIlatest version \fP*/
1032 The first version described is
1033 .I PING_VERS_PINGBACK
1034 with two procedures,
1037 .I PINGPROC_PINGBACK .
1039 takes no arguments and returns no results, but it is useful for
1040 computing round-trip times from the client to the server and back
1041 again. By convention, procedure 0 of any RPC protocol should have
1042 the same semantics, and never require any kind of authentication.
1043 The second procedure is used for the client to have the server do a
1044 reverse ping operation back to the client, and it returns the amount
1045 of time (in microseconds) that the operation used. The next version,
1047 is the original version of the protocol
1048 and it does not contain
1049 .I PINGPROC_PINGBACK
1050 procedure. It is useful
1051 for compatibility with old client programs, and as this program
1052 matures it may be dropped from the protocol entirely.
1055 \&The RPC Language Specification
1057 The RPC language is identical to the XDR language, except for the
1058 added definition of a
1064 "program" identifier "{"
1067 "}" "=" constant ";"
1070 "version" identifier "{"
1073 "}" "=" constant ";"
1076 type-specifier identifier "(" type-specifier ")"
1083 The following keywords are added and cannot be used as
1084 identifiers: "program" and "version";
1086 A version name cannot occur more than once within the scope of
1087 a program definition. Nor can a version number occur more than once
1088 within the scope of a program definition.
1090 A procedure name cannot occur more than once within the scope
1091 of a version definition. Nor can a procedure number occur more than
1092 once within the scope of version definition.
1094 Program identifiers are in the same name space as constant and
1097 Only unsigned constants can be assigned to programs, versions
1100 \&Port Mapper Program Protocol
1102 The port mapper program maps RPC program and version numbers to
1103 transport-specific port numbers. This program makes dynamic binding
1104 of remote programs possible.
1106 This is desirable because the range of reserved port numbers is very
1107 small and the number of potential remote programs is very large. By
1108 running only the port mapper on a reserved port, the port numbers of
1109 other remote programs can be ascertained by querying the port mapper.
1111 The port mapper also aids in broadcast RPC. A given RPC program will
1112 usually have different port number bindings on different machines, so
1113 there is no way to directly broadcast to all of these programs. The
1114 port mapper, however, does have a fixed port number. So, to
1115 broadcast to a given program, the client actually sends its message
1116 to the port mapper located at the broadcast address. Each port
1117 mapper that picks up the broadcast then calls the local service
1118 specified by the client. When the port mapper gets the reply from
1119 the local service, it sends the reply on back to the client.
1122 \&Port Mapper Protocol Specification (in RPC Language)
1127 const PMAP_PORT = 111; /* \fIportmapper port number \fP*/
1131 * A mapping of (program, version, protocol) to port number
1143 * Supported values for the "prot" field
1146 const IPPROTO_TCP = 6; /* \fIprotocol number for TCP/IP \fP*/
1147 const IPPROTO_UDP = 17; /* \fIprotocol number for UDP/IP \fP*/
1151 * A list of mappings
1165 * Arguments to callit
1180 struct call_result {
1192 * Port mapper procedures
1198 PMAPPROC_NULL(void) = 0;
1201 PMAPPROC_SET(mapping) = 1;
1204 PMAPPROC_UNSET(mapping) = 2;
1207 PMAPPROC_GETPORT(mapping) = 3;
1210 PMAPPROC_DUMP(void) = 4;
1213 PMAPPROC_CALLIT(call_args) = 5;
1219 \&Port Mapper Operation
1221 The portmapper program currently supports two protocols (UDP/IP and
1222 TCP/IP). The portmapper is contacted by talking to it on assigned
1223 port number 111 (SUNRPC [8]) on either of these protocols. The
1224 following is a description of each of the portmapper procedures:
1225 .IP \fBPMAPPROC_NULL:\fP
1226 This procedure does no work. By convention, procedure zero of any
1227 protocol takes no parameters and returns no results.
1228 .IP \fBPMAPPROC_SET:\fP
1229 When a program first becomes available on a machine, it registers
1230 itself with the port mapper program on the same machine. The program
1231 passes its program number "prog", version number "vers", transport
1232 protocol number "prot", and the port "port" on which it awaits
1233 service request. The procedure returns a boolean response whose
1236 if the procedure successfully established the mapping and
1238 otherwise. The procedure refuses to establish
1239 a mapping if one already exists for the tuple "(prog, vers, prot)".
1240 .IP \fBPMAPPROC_UNSET:\fP
1241 When a program becomes unavailable, it should unregister itself with
1242 the port mapper program on the same machine. The parameters and
1243 results have meanings identical to those of
1245 The protocol and port number fields of the argument are ignored.
1246 .IP \fBPMAPPROC_GETPORT:\fP
1247 Given a program number "prog", version number "vers", and transport
1248 protocol number "prot", this procedure returns the port number on
1249 which the program is awaiting call requests. A port value of zeros
1250 means the program has not been registered. The "port" field of the
1251 argument is ignored.
1252 .IP \fBPMAPPROC_DUMP:\fP
1253 This procedure enumerates all entries in the port mapper's database.
1254 The procedure takes no parameters and returns a list of program,
1255 version, protocol, and port values.
1256 .IP \fBPMAPPROC_CALLIT:\fP
1257 This procedure allows a caller to call another remote procedure on
1258 the same machine without knowing the remote procedure's port number.
1259 It is intended for supporting broadcasts to arbitrary remote programs
1260 via the well-known port mapper's port. The parameters "prog",
1261 "vers", "proc", and the bytes of "args" are the program number,
1262 version number, procedure number, and parameters of the remote
1268 This procedure only sends a response if the procedure was
1269 successfully executed and is silent (no response) otherwise.
1271 The port mapper communicates with the remote program using UDP/IP
1275 The procedure returns the remote program's port number, and the bytes
1276 of results are the results of the remote procedure.
1281 [1] Birrell, Andrew D. & Nelson, Bruce Jay; "Implementing Remote
1282 Procedure Calls"; XEROX CSL-83-7, October 1983.
1284 [2] Cheriton, D.; "VMTP: Versatile Message Transaction Protocol",
1285 Preliminary Version 0.3; Stanford University, January 1987.
1287 [3] Diffie & Hellman; "New Directions in Cryptography"; IEEE
1288 Transactions on Information Theory IT-22, November 1976.
1290 [4] Harrenstien, K.; "Time Server", RFC 738; Information Sciences
1291 Institute, October 1977.
1293 [5] National Bureau of Standards; "Data Encryption Standard"; Federal
1294 Information Processing Standards Publication 46, January 1977.
1296 [6] Postel, J.; "Transmission Control Protocol - DARPA Internet
1297 Program Protocol Specification", RFC 793; Information Sciences
1298 Institute, September 1981.
1300 [7] Postel, J.; "User Datagram Protocol", RFC 768; Information Sciences
1301 Institute, August 1980.
1303 [8] Reynolds, J. & Postel, J.; "Assigned Numbers", RFC 923; Information
1304 Sciences Institute, October 1984.