key_prot.x 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. * Key server protocol definition
  3. * Copyright (c) 2010, Oracle America, Inc.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are
  7. * met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above
  12. * copyright notice, this list of conditions and the following
  13. * disclaimer in the documentation and/or other materials
  14. * provided with the distribution.
  15. * * Neither the name of the "Oracle America, Inc." nor the names of its
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  24. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  26. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  29. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * The keyserver is a public key storage/encryption/decryption service
  33. * The encryption method used is based on the Diffie-Hellman exponential
  34. * key exchange technology.
  35. *
  36. * The key server is local to each machine, akin to the portmapper.
  37. * Under TI-RPC, communication with the keyserver is through the
  38. * loopback transport.
  39. *
  40. * NOTE: This .x file generates the USER level headers for the keyserver.
  41. * the KERNEL level headers are created by hand as they kernel has special
  42. * requirements.
  43. */
  44. %#if 0
  45. %#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI"
  46. %#endif
  47. %
  48. %/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
  49. %
  50. %/*
  51. % * Compiled from key_prot.x using rpcgen.
  52. % * DO NOT EDIT THIS FILE!
  53. % * This is NOT source code!
  54. % */
  55. /*
  56. * PROOT and MODULUS define the way the Diffie-Hellman key is generated.
  57. *
  58. * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1,
  59. * where p is also prime.
  60. *
  61. * PROOT satisfies the following two conditions:
  62. * (1) (PROOT ** 2) % MODULUS != 1
  63. * (2) (PROOT ** p) % MODULUS != 1
  64. *
  65. */
  66. const PROOT = 3;
  67. const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b";
  68. const HEXKEYBYTES = 48; /* HEXKEYBYTES == strlen(HEXMODULUS) */
  69. const KEYSIZE = 192; /* KEYSIZE == bit length of key */
  70. const KEYBYTES = 24; /* byte length of key */
  71. /*
  72. * The first 16 hex digits of the encrypted secret key are used as
  73. * a checksum in the database.
  74. */
  75. const KEYCHECKSUMSIZE = 16;
  76. /*
  77. * status of operation
  78. */
  79. enum keystatus {
  80. KEY_SUCCESS, /* no problems */
  81. KEY_NOSECRET, /* no secret key stored */
  82. KEY_UNKNOWN, /* unknown netname */
  83. KEY_SYSTEMERR /* system error (out of memory, encryption failure) */
  84. };
  85. typedef opaque keybuf[HEXKEYBYTES]; /* store key in hex */
  86. typedef string netnamestr<MAXNETNAMELEN>;
  87. /*
  88. * Argument to ENCRYPT or DECRYPT
  89. */
  90. struct cryptkeyarg {
  91. netnamestr remotename;
  92. des_block deskey;
  93. };
  94. /*
  95. * Argument to ENCRYPT_PK or DECRYPT_PK
  96. */
  97. struct cryptkeyarg2 {
  98. netnamestr remotename;
  99. netobj remotekey; /* Contains a length up to 1024 bytes */
  100. des_block deskey;
  101. };
  102. /*
  103. * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK
  104. */
  105. union cryptkeyres switch (keystatus status) {
  106. case KEY_SUCCESS:
  107. des_block deskey;
  108. default:
  109. void;
  110. };
  111. const MAXGIDS = 16; /* max number of gids in gid list */
  112. /*
  113. * Unix credential
  114. */
  115. struct unixcred {
  116. u_int uid;
  117. u_int gid;
  118. u_int gids<MAXGIDS>;
  119. };
  120. /*
  121. * Result returned from GETCRED
  122. */
  123. union getcredres switch (keystatus status) {
  124. case KEY_SUCCESS:
  125. unixcred cred;
  126. default:
  127. void;
  128. };
  129. /*
  130. * key_netstarg;
  131. */
  132. struct key_netstarg {
  133. keybuf st_priv_key;
  134. keybuf st_pub_key;
  135. netnamestr st_netname;
  136. };
  137. union key_netstres switch (keystatus status){
  138. case KEY_SUCCESS:
  139. key_netstarg knet;
  140. default:
  141. void;
  142. };
  143. #ifdef RPC_HDR
  144. %
  145. %#ifndef opaque
  146. %#define opaque char
  147. %#endif
  148. %
  149. #endif
  150. program KEY_PROG {
  151. version KEY_VERS {
  152. /*
  153. * This is my secret key.
  154. * Store it for me.
  155. */
  156. keystatus
  157. KEY_SET(keybuf) = 1;
  158. /*
  159. * I want to talk to X.
  160. * Encrypt a conversation key for me.
  161. */
  162. cryptkeyres
  163. KEY_ENCRYPT(cryptkeyarg) = 2;
  164. /*
  165. * X just sent me a message.
  166. * Decrypt the conversation key for me.
  167. */
  168. cryptkeyres
  169. KEY_DECRYPT(cryptkeyarg) = 3;
  170. /*
  171. * Generate a secure conversation key for me
  172. */
  173. des_block
  174. KEY_GEN(void) = 4;
  175. /*
  176. * Get me the uid, gid and group-access-list associated
  177. * with this netname (for kernel which cannot use NIS)
  178. */
  179. getcredres
  180. KEY_GETCRED(netnamestr) = 5;
  181. } = 1;
  182. version KEY_VERS2 {
  183. /*
  184. * #######
  185. * Procedures 1-5 are identical to version 1
  186. * #######
  187. */
  188. /*
  189. * This is my secret key.
  190. * Store it for me.
  191. */
  192. keystatus
  193. KEY_SET(keybuf) = 1;
  194. /*
  195. * I want to talk to X.
  196. * Encrypt a conversation key for me.
  197. */
  198. cryptkeyres
  199. KEY_ENCRYPT(cryptkeyarg) = 2;
  200. /*
  201. * X just sent me a message.
  202. * Decrypt the conversation key for me.
  203. */
  204. cryptkeyres
  205. KEY_DECRYPT(cryptkeyarg) = 3;
  206. /*
  207. * Generate a secure conversation key for me
  208. */
  209. des_block
  210. KEY_GEN(void) = 4;
  211. /*
  212. * Get me the uid, gid and group-access-list associated
  213. * with this netname (for kernel which cannot use NIS)
  214. */
  215. getcredres
  216. KEY_GETCRED(netnamestr) = 5;
  217. /*
  218. * I want to talk to X. and I know X's public key
  219. * Encrypt a conversation key for me.
  220. */
  221. cryptkeyres
  222. KEY_ENCRYPT_PK(cryptkeyarg2) = 6;
  223. /*
  224. * X just sent me a message. and I know X's public key
  225. * Decrypt the conversation key for me.
  226. */
  227. cryptkeyres
  228. KEY_DECRYPT_PK(cryptkeyarg2) = 7;
  229. /*
  230. * Store my public key, netname and private key.
  231. */
  232. keystatus
  233. KEY_NET_PUT(key_netstarg) = 8;
  234. /*
  235. * Retrieve my public key, netname and private key.
  236. */
  237. key_netstres
  238. KEY_NET_GET(void) = 9;
  239. /*
  240. * Return me the conversation key that is constructed
  241. * from my secret key and this publickey.
  242. */
  243. cryptkeyres
  244. KEY_GET_CONV(keybuf) = 10;
  245. } = 2;
  246. } = 100029;