Blame sunrpc/rpcsvc/key_prot.x

Packit 6c4009
/*
Packit 6c4009
 * Key server protocol definition
Packit 6c4009
 * Copyright (c) 2010, Oracle America, Inc.
Packit 6c4009
 *
Packit 6c4009
 * Redistribution and use in source and binary forms, with or without
Packit 6c4009
 * modification, are permitted provided that the following conditions are
Packit 6c4009
 * met:
Packit 6c4009
 *
Packit 6c4009
 *     * Redistributions of source code must retain the above copyright
Packit 6c4009
 *       notice, this list of conditions and the following disclaimer.
Packit 6c4009
 *     * Redistributions in binary form must reproduce the above
Packit 6c4009
 *       copyright notice, this list of conditions and the following
Packit 6c4009
 *       disclaimer in the documentation and/or other materials
Packit 6c4009
 *       provided with the distribution.
Packit 6c4009
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
Packit 6c4009
 *       contributors may be used to endorse or promote products derived
Packit 6c4009
 *       from this software without specific prior written permission.
Packit 6c4009
 *
Packit 6c4009
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 6c4009
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 6c4009
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Packit 6c4009
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
Packit 6c4009
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Packit 6c4009
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6c4009
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit 6c4009
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 6c4009
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit 6c4009
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 6c4009
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 6c4009
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 6c4009
 *
Packit 6c4009
 * The keyserver is a public key storage/encryption/decryption service
Packit 6c4009
 * The encryption method used is based on the Diffie-Hellman exponential
Packit 6c4009
 * key exchange technology.
Packit 6c4009
 *
Packit 6c4009
 * The key server is local to each machine, akin to the portmapper.
Packit 6c4009
 * Under TI-RPC, communication with the keyserver is through the
Packit 6c4009
 * loopback transport.
Packit 6c4009
 *
Packit 6c4009
 * NOTE: This .x file generates the USER level headers for the keyserver.
Packit 6c4009
 * the KERNEL level headers are created by hand as they kernel has special
Packit 6c4009
 * requirements.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
%#if 0
Packit 6c4009
%#pragma ident	"@(#)key_prot.x	1.7	94/04/29 SMI"
Packit 6c4009
%#endif
Packit 6c4009
%
Packit 6c4009
%/* Copyright (c)  1990, 1991 Sun Microsystems, Inc. */
Packit 6c4009
%
Packit 6c4009
%/*
Packit 6c4009
% * Compiled from key_prot.x using rpcgen.
Packit 6c4009
% * DO NOT EDIT THIS FILE!
Packit 6c4009
% * This is NOT source code!
Packit 6c4009
% */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * PROOT and MODULUS define the way the Diffie-Hellman key is generated.
Packit 6c4009
 *
Packit 6c4009
 * MODULUS should be chosen as a prime of the form: MODULUS == 2*p + 1,
Packit 6c4009
 * where p is also prime.
Packit 6c4009
 *
Packit 6c4009
 * PROOT satisfies the following two conditions:
Packit 6c4009
 * (1) (PROOT ** 2) % MODULUS != 1
Packit 6c4009
 * (2) (PROOT ** p) % MODULUS != 1
Packit 6c4009
 *
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
const PROOT = 3;
Packit 6c4009
const HEXMODULUS = "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b";
Packit 6c4009
Packit 6c4009
const HEXKEYBYTES = 48;		/* HEXKEYBYTES == strlen(HEXMODULUS) */
Packit 6c4009
const KEYSIZE = 192;		/* KEYSIZE == bit length of key */
Packit 6c4009
const KEYBYTES = 24;		/* byte length of key */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * The first 16 hex digits of the encrypted secret key are used as
Packit 6c4009
 * a checksum in the database.
Packit 6c4009
 */
Packit 6c4009
const KEYCHECKSUMSIZE = 16;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * status of operation
Packit 6c4009
 */
Packit 6c4009
enum keystatus {
Packit 6c4009
	KEY_SUCCESS,	/* no problems */
Packit 6c4009
	KEY_NOSECRET,	/* no secret key stored */
Packit 6c4009
	KEY_UNKNOWN,	/* unknown netname */
Packit 6c4009
	KEY_SYSTEMERR 	/* system error (out of memory, encryption failure) */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
typedef opaque keybuf[HEXKEYBYTES];	/* store key in hex */
Packit 6c4009
Packit 6c4009
typedef string netnamestr<MAXNETNAMELEN>;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Argument to ENCRYPT or DECRYPT
Packit 6c4009
 */
Packit 6c4009
struct cryptkeyarg {
Packit 6c4009
	netnamestr remotename;
Packit 6c4009
	des_block deskey;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Argument to ENCRYPT_PK or DECRYPT_PK
Packit 6c4009
 */
Packit 6c4009
struct cryptkeyarg2 {
Packit 6c4009
	netnamestr remotename;
Packit 6c4009
	netobj	remotekey;	/* Contains a length up to 1024 bytes */
Packit 6c4009
	des_block deskey;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Result of ENCRYPT, DECRYPT, ENCRYPT_PK, and DECRYPT_PK
Packit 6c4009
 */
Packit 6c4009
union cryptkeyres switch (keystatus status) {
Packit 6c4009
case KEY_SUCCESS:
Packit 6c4009
	des_block deskey;
Packit 6c4009
default:
Packit 6c4009
	void;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
const MAXGIDS  = 16;	/* max number of gids in gid list */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Unix credential
Packit 6c4009
 */
Packit 6c4009
struct unixcred {
Packit 6c4009
	u_int uid;
Packit 6c4009
	u_int gid;
Packit 6c4009
	u_int gids<MAXGIDS>;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Result returned from GETCRED
Packit 6c4009
 */
Packit 6c4009
union getcredres switch (keystatus status) {
Packit 6c4009
case KEY_SUCCESS:
Packit 6c4009
	unixcred cred;
Packit 6c4009
default:
Packit 6c4009
	void;
Packit 6c4009
};
Packit 6c4009
/*
Packit 6c4009
 * key_netstarg;
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
struct key_netstarg {
Packit 6c4009
	keybuf st_priv_key;
Packit 6c4009
	keybuf st_pub_key;
Packit 6c4009
	netnamestr st_netname;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
union key_netstres switch (keystatus status){
Packit 6c4009
case KEY_SUCCESS:
Packit 6c4009
	key_netstarg knet;
Packit 6c4009
default:
Packit 6c4009
	void;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
#ifdef RPC_HDR
Packit 6c4009
%
Packit 6c4009
%#ifndef opaque
Packit 6c4009
%#define opaque char
Packit 6c4009
%#endif
Packit 6c4009
%
Packit 6c4009
#endif
Packit 6c4009
program KEY_PROG {
Packit 6c4009
	version KEY_VERS {
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * This is my secret key.
Packit 6c4009
	 	 * Store it for me.
Packit 6c4009
		 */
Packit 6c4009
		keystatus
Packit 6c4009
		KEY_SET(keybuf) = 1;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * I want to talk to X.
Packit 6c4009
		 * Encrypt a conversation key for me.
Packit 6c4009
	 	 */
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_ENCRYPT(cryptkeyarg) = 2;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * X just sent me a message.
Packit 6c4009
		 * Decrypt the conversation key for me.
Packit 6c4009
		 */
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_DECRYPT(cryptkeyarg) = 3;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Generate a secure conversation key for me
Packit 6c4009
		 */
Packit 6c4009
		des_block
Packit 6c4009
		KEY_GEN(void) = 4;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Get me the uid, gid and group-access-list associated
Packit 6c4009
		 * with this netname (for kernel which cannot use NIS)
Packit 6c4009
		 */
Packit 6c4009
		getcredres
Packit 6c4009
		KEY_GETCRED(netnamestr) = 5;
Packit 6c4009
	} = 1;
Packit 6c4009
	version KEY_VERS2 {
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * #######
Packit 6c4009
		 * Procedures 1-5 are identical to version 1
Packit 6c4009
		 * #######
Packit 6c4009
		 */
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * This is my secret key.
Packit 6c4009
	 	 * Store it for me.
Packit 6c4009
		 */
Packit 6c4009
		keystatus
Packit 6c4009
		KEY_SET(keybuf) = 1;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * I want to talk to X.
Packit 6c4009
		 * Encrypt a conversation key for me.
Packit 6c4009
	 	 */
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_ENCRYPT(cryptkeyarg) = 2;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * X just sent me a message.
Packit 6c4009
		 * Decrypt the conversation key for me.
Packit 6c4009
		 */
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_DECRYPT(cryptkeyarg) = 3;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Generate a secure conversation key for me
Packit 6c4009
		 */
Packit 6c4009
		des_block
Packit 6c4009
		KEY_GEN(void) = 4;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Get me the uid, gid and group-access-list associated
Packit 6c4009
		 * with this netname (for kernel which cannot use NIS)
Packit 6c4009
		 */
Packit 6c4009
		getcredres
Packit 6c4009
		KEY_GETCRED(netnamestr) = 5;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * I want to talk to X. and I know X's public key
Packit 6c4009
		 * Encrypt a conversation key for me.
Packit 6c4009
	 	 */
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_ENCRYPT_PK(cryptkeyarg2) = 6;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * X just sent me a message. and I know X's public key
Packit 6c4009
		 * Decrypt the conversation key for me.
Packit 6c4009
		 */
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_DECRYPT_PK(cryptkeyarg2) = 7;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Store my public key, netname and private key.
Packit 6c4009
		 */
Packit 6c4009
		keystatus
Packit 6c4009
		KEY_NET_PUT(key_netstarg) = 8;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Retrieve my public key, netname and private key.
Packit 6c4009
		 */
Packit 6c4009
 		key_netstres
Packit 6c4009
		KEY_NET_GET(void) = 9;
Packit 6c4009
Packit 6c4009
		/*
Packit 6c4009
		 * Return me the conversation key that is constructed
Packit 6c4009
		 * from my secret key and this publickey.
Packit 6c4009
		 */
Packit 6c4009
Packit 6c4009
		cryptkeyres
Packit 6c4009
		KEY_GET_CONV(keybuf) = 10;
Packit 6c4009
Packit 6c4009
Packit 6c4009
	} = 2;
Packit 6c4009
} = 100029;