key_prot.x
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:6k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. %/*
  2. % * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  3. % * unrestricted use provided that this legend is included on all tape
  4. % * media and as a part of the software program in whole or part.  Users
  5. % * may copy or modify Sun RPC without charge, but are not authorized
  6. % * to license or distribute it to anyone else except as part of a product or
  7. % * program developed by the user.
  8. % *
  9. % * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  10. % * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  11. % * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  12. % *
  13. % * Sun RPC is provided with no support and without any obligation on the
  14. % * part of Sun Microsystems, Inc. to assist in its use, correction,
  15. % * modification or enhancement.
  16. % *
  17. % * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  18. % * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  19. % * OR ANY PART THEREOF.
  20. % *
  21. % * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  22. % * or profits or other special, indirect and consequential damages, even if
  23. % * Sun has been advised of the possibility of such damages.
  24. % *
  25. % * Sun Microsystems, Inc.
  26. % * 2550 Garcia Avenue
  27. % * Mountain View, California  94043
  28. % */
  29. /*
  30.  * Key server protocol definition
  31.  * Copyright (C) 1990, 1991 Sun Microsystems, Inc.
  32.  *
  33.  * The keyserver is a public key storage/encryption/decryption service
  34.  * The encryption method used is based on the Diffie-Hellman exponential
  35.  * key exchange technology.
  36.  *
  37.  * The key server is local to each machine, akin to the portmapper.
  38.  * Under TI-RPC, communication with the keyserver is through the
  39.  * loopback transport.
  40.  *
  41.  * NOTE: This .x file generates the USER level headers for the keyserver.
  42.  * the KERNEL level headers are created by hand as they kernel has special
  43.  * requirements.
  44.  */
  45. %#if 0
  46. %#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
  47. %#endif
  48. %
  49. %/* Copyright (c)  1990, 1991 Sun Microsystems, Inc. */
  50. %
  51. %/* 
  52. % * Compiled from key_prot.x using rpcgen.
  53. % * DO NOT EDIT THIS FILE!
  54. % * This is NOT source code!
  55. % */
  56. /*
  57.  * PROOT and MODULUS define the way the Diffie-Hellman key is generated.
  58.  *
  59.  * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1,
  60.  * where p is also prime.
  61.  *
  62.  * PROOT satisfies the following two conditions:
  63.  * (1) (PROOT ** 2) % MODULUS != 1
  64.  * (2) (PROOT ** p) % MODULUS != 1
  65.  *
  66.  */
  67. const PROOT = 3;
  68. const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b";
  69. const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */
  70. const KEYSIZE = 192; /* KEYSIZE == bit length of key */
  71. const KEYBYTES = 24; /* byte length of key */
  72. /*
  73.  * The first 16 hex digits of the encrypted secret key are used as
  74.  * a checksum in the database.
  75.  */
  76. const KEYCHECKSUMSIZE = 16;
  77. /*
  78.  * status of operation
  79.  */
  80. enum keystatus {
  81. KEY_SUCCESS, /* no problems */
  82. KEY_NOSECRET, /* no secret key stored */
  83. KEY_UNKNOWN, /* unknown netname */
  84. KEY_SYSTEMERR  /* system error (out of memory, encryption failure) */
  85. };
  86. typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */
  87. typedef string netnamestr<MAXNETNAMELEN>;
  88. /*
  89.  * Argument to ENCRYPT or DECRYPT 
  90.  */
  91. struct cryptkeyarg {
  92. netnamestr remotename;
  93. des_block deskey;
  94. };
  95. /*
  96.  * Argument to ENCRYPT_PK or DECRYPT_PK
  97.  */
  98. struct cryptkeyarg2 {
  99. netnamestr remotename;
  100. netobj remotekey; /* Contains a length up to 1024 bytes */
  101. des_block deskey;
  102. };
  103. /*
  104.  * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK
  105.  */
  106. union cryptkeyres switch (keystatus status) {
  107. case KEY_SUCCESS:
  108. des_block deskey;
  109. default:
  110. void;
  111. };
  112. const MAXGIDS  = 16; /* max number of gids in gid list */
  113. /*
  114.  * Unix credential 
  115.  */
  116. struct unixcred {
  117. u_int uid;
  118. u_int gid;
  119. u_int gids<MAXGIDS>;
  120. };
  121. /*
  122.  * Result returned from GETCRED
  123.  */
  124. union getcredres switch (keystatus status) {
  125. case KEY_SUCCESS:
  126. unixcred cred;
  127. default:
  128. void;
  129. };
  130. /*
  131.  * key_netstarg;
  132.  */
  133. struct key_netstarg {
  134. keybuf st_priv_key;
  135. keybuf st_pub_key;
  136. netnamestr st_netname;
  137. };
  138. union key_netstres switch (keystatus status){
  139. case KEY_SUCCESS:
  140. key_netstarg knet;
  141. default:
  142. void;
  143. };
  144. #ifdef RPC_HDR
  145. %
  146. %#ifndef opaque
  147. %#define opaque char
  148. %#endif
  149. %
  150. #endif
  151. program KEY_PROG {
  152. version KEY_VERS {
  153. /*
  154.  * This is my secret key.
  155.    * Store it for me.
  156.  */
  157. keystatus 
  158. KEY_SET(keybuf) = 1;
  159. /*
  160.  * I want to talk to X.
  161.  * Encrypt a conversation key for me.
  162.    */
  163. cryptkeyres
  164. KEY_ENCRYPT(cryptkeyarg) = 2;
  165. /*
  166.  * X just sent me a message.
  167.  * Decrypt the conversation key for me.
  168.  */
  169. cryptkeyres
  170. KEY_DECRYPT(cryptkeyarg) = 3;
  171. /*
  172.  * Generate a secure conversation key for me
  173.  */
  174. des_block 
  175. KEY_GEN(void) = 4;
  176. /*
  177.  * Get me the uid, gid and group-access-list associated
  178.  * with this netname (for kernel which cannot use NIS)
  179.  */
  180. getcredres
  181. KEY_GETCRED(netnamestr) = 5;
  182. } = 1;
  183. version KEY_VERS2 {
  184. /*
  185.  * #######
  186.  * Procedures 1-5 are identical to version 1
  187.  * #######
  188.  */
  189. /*
  190.  * This is my secret key.
  191.    * Store it for me.
  192.  */
  193. keystatus 
  194. KEY_SET(keybuf) = 1;
  195. /*
  196.  * I want to talk to X.
  197.  * Encrypt a conversation key for me.
  198.    */
  199. cryptkeyres
  200. KEY_ENCRYPT(cryptkeyarg) = 2;
  201. /*
  202.  * X just sent me a message.
  203.  * Decrypt the conversation key for me.
  204.  */
  205. cryptkeyres
  206. KEY_DECRYPT(cryptkeyarg) = 3;
  207. /*
  208.  * Generate a secure conversation key for me
  209.  */
  210. des_block 
  211. KEY_GEN(void) = 4;
  212. /*
  213.  * Get me the uid, gid and group-access-list associated
  214.  * with this netname (for kernel which cannot use NIS)
  215.  */
  216. getcredres
  217. KEY_GETCRED(netnamestr) = 5;
  218. /*
  219.  * I want to talk to X. and I know X's public key
  220.  * Encrypt a conversation key for me.
  221.    */
  222. cryptkeyres
  223. KEY_ENCRYPT_PK(cryptkeyarg2) = 6;
  224. /*
  225.  * X just sent me a message. and I know X's public key
  226.  * Decrypt the conversation key for me.
  227.  */
  228. cryptkeyres
  229. KEY_DECRYPT_PK(cryptkeyarg2) = 7;
  230. /* 
  231.  * Store my public key, netname and private key. 
  232.  */
  233. keystatus
  234. KEY_NET_PUT(key_netstarg) = 8;
  235. /*
  236.  * Retrieve my public key, netname and private key. 
  237.  */
  238.   key_netstres
  239. KEY_NET_GET(void) = 9;
  240. /*
  241.  * Return me the conversation key that is constructed 
  242.  * from my secret key and this publickey. 
  243.  */
  244. cryptkeyres 
  245. KEY_GET_CONV(keybuf) = 10; 
  246. } = 2;
  247. } = 100029;