/* This is -*-c-*- */

/*
 * Interface to KAS
 */

const AUTHENTICATE_OLD		= 1;
const CHANGEPASSWORD		= 2;
const GETTICKET_OLD		= 3;
const SETPASSWORD		= 4;
const SETFIELDS			= 5;
const CREATEUSER		= 6;
const DELETEUSER		= 7;
const GETENTRY			= 8;
const LISTENTRY			= 9;
const GETSTATS			= 10;
const DEBUG			= 11;
const GETPASSWORD		= 12;
const GETRANDOMKEY		= 13;
const AUTHENTICATE		= 21;
const GETTICKET			= 23;

const MAXKAKVNO			= 127;

/* Flags (note 0 is illegal) */

const KAFNORMAL			= 0x1;
/* For the two following the KAFNORMAL MUST not be set */
const KAFREE			= 0x2;	/* on freelist */
const KAOLDKEYS			= 0x10;	/* used to store old keys */
/* misc flags */
const KASPECIAL			= 0x100; /* special authserver principal */
const KAFASSOCROOT		= 0x200; /* root of associate tree */
const KAFASSOC			= 0x300; /* associate entry */

/* The following flags are used on KAA_SetFields() */
const KAFADMIN			= 0x004; /* administrator */
const KAFNOTGS			= 0x008; /* can't get or use TGT */
const KAFNOSEAL			= 0x020; /* can't be used as server */
const KAFNOCPW			= 0x040; /* can't change password */
const KAFNEWASSOC		= 0x080; /* can create associates */

/* MISC stuff */

const KAMAJORVERSION		= 5;
const KAMINORVERSION		= 1;
const NEVERDATE			= 037777777777;
const KADEBUGKCINFOSIZE		= 25;

#define Date u_int32_t

/* Errors */

const  KADATABASEINCONSISTENT                   = 180480;
const  KAEXIST                                  = 180481;
const  KAIO                                     = 180482;
const  KACREATEFAIL                             = 180483;
const  KANOENT                                  = 180484;
const  KAEMPTY                                  = 180485;
const  KABADNAME                                = 180486;
const  KABADINDEX                               = 180487;
const  KANOAUTH                                 = 180488;
const  KAANSWERTOOLONG                          = 180489;
const  KABADREQUEST                             = 180490;
const  KAOLDINTERFACE                           = 180491;
const  KABADARGUMENT                            = 180492;
const  KABADCMD                                 = 180493;
const  KANOKEYS                                 = 180494;
const  KAREADPW                                 = 180495;
const  KABADKEY                                 = 180496;
const  KAUBIKINIT                               = 180497;
const  KAUBIKCALL                               = 180498;
const  KABADPROTOCOL                            = 180499;
const  KANOCELLS                                = 180500;
const  KANOCELL                                 = 180501;
const  KATOOMANYUBIKS                           = 180502;
const  KATOOMANYKEYS                            = 180503;
const  KABADTICKET                              = 180504;
const  KAUNKNOWNKEY                             = 180505;
const  KAKEYCACHEINVALID                        = 180506;
const  KABADSERVER                              = 180507;
const  KABADUSER                                = 180508;
const  KABADCPW                                 = 180509;
const  KABADCREATE                              = 180510;
const  KANOTICKET                               = 180511;
const  KAASSOCUSER                              = 180512;
const  KANOTSPECIAL                             = 180513;
const  KACLOCKSKEW                              = 180514;
const  KANORECURSE                              = 180515;
const  KARXFAIL                                 = 180516;
const  KANULLPASSWORD                           = 180517;
const  KAINTERNALERROR                          = 180518;
const  KAPWEXPIRED                              = 180519;
const  KAREUSED                                 = 180520;
const  KATOOSOON                                = 180521;
const  KALOCKED                                 = 180522;



struct ka_CBS {
    char Seq<>;
};

struct ka_BBS {
    int32_t MaxSeqLen;
    char Seq<>;
};

struct EncryptionKey {
    char key[8];
};

#define MAXKANAMELEN	64

typedef string kaname<MAXKANAMELEN>;

struct kaident {
    char name[MAXKANAMELEN];
    char instance[MAXKANAMELEN];
};

struct kaentryinfo {
    int32_t minor_version;
    int32_t flags;
    u_int32_t user_expiration;
    Date modification_time;
    kaident modification_user;
    Date change_password_time;
    long max_ticket_lifetime;
    long key_version;
    EncryptionKey key;
    u_int32_t keyCheckSym;
    int32_t reserved2;
    int32_t reserved3;
    int32_t reserved4;
};


package KAA_

Authenticate (IN kaname name,
	      IN kaname instance,
	      IN Date start_time,
	      IN Date end_time,
	      INOUT ka_BBS *answer) = 21;

ChangePassword (IN kaname name,
		IN kaname instance,
		IN ka_CBS arequest,
		INOUT ka_BBS *oanswer) = 2;

package KAM_

SetPassword (IN kaname name,
	     IN kaname instance,
	     IN int32_t kvno,
	     IN EncryptionKey password) = 4;

SetFields (IN kaname name,
	   IN kaname instance,
	   IN int32_t flags,
	   IN Date user_expiration,
	   IN int32_t max_ticket_lifetime,
	   IN int32_t maxAssociates,
	   IN int32_t spare1,
	   IN int32_t spare2) = 5;

CreateUser (IN kaname name,
	    IN kaname instance,
	    IN EncryptionKey password) = 6;

GetEntry (IN kaname name,
	  IN kaname instance,
	  IN long major_version,
	  OUT kaentryinfo *entry) = 8;


