Add field for structure magic numbers
authorTheodore Tso <tytso@mit.edu>
Fri, 30 Sep 1994 21:52:02 +0000 (21:52 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 30 Sep 1994 21:52:02 +0000 (21:52 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4410 dc483132-0cff-0310-8789-dd5450dbe970

src/include/krb5/base-defs.h
src/include/krb5/ccache.h
src/include/krb5/copyright.h
src/include/krb5/kdb.h
src/include/krb5/keytab.h
src/include/krb5/krb5.h
src/include/krb5/preauth.h
src/include/krb5/rcache.h

index 37d7d0acb370aeb4ff84157c95bf2da6ca9438f7..f4bfa018927958447ffecb1ec44ce108302e1b43 100644 (file)
@@ -53,7 +53,10 @@ typedef krb5_int32   krb5_timestamp;
 typedef        krb5_int32      krb5_error_code;
 typedef krb5_int32     krb5_deltat;
 
+typedef krb5_error_code        krb5_magic;
+
 typedef struct _krb5_data {
+    krb5_magic magic;
     int length;
     char *data;
 } krb5_data;
@@ -103,6 +106,7 @@ typedef char const * krb5_const_pointer;
 #endif
 
 typedef struct krb5_principal_data {
+    krb5_magic magic;
     krb5_data realm;
     krb5_data *data;           /* An array of strings */
     krb5_int32 length;
index 41f1555961c19c0f5dcaa777349b8c8701bdd886..beeb740b66ff8fd0cf49bf5480866500621f8c42 100644 (file)
 typedef        krb5_pointer    krb5_cc_cursor; /* cursor for sequential lookup */
 
 typedef struct _krb5_ccache {
-       struct _krb5_cc_ops *ops;
-       krb5_pointer data;
+    krb5_magic magic;
+    struct _krb5_cc_ops *ops;
+    krb5_pointer data;
 } *krb5_ccache;
 
 typedef struct _krb5_cc_ops {
-       char *prefix;
-       char *(*get_name) NPROTOTYPE((krb5_ccache));
-       krb5_error_code (*resolve) NPROTOTYPE((krb5_ccache *, char *));
-       krb5_error_code (*gen_new) NPROTOTYPE((krb5_ccache *));
-       krb5_error_code (*init) NPROTOTYPE((krb5_ccache, krb5_principal));
-       krb5_error_code (*destroy) NPROTOTYPE((krb5_ccache));
-       krb5_error_code (*close) NPROTOTYPE((krb5_ccache));
-       krb5_error_code (*store) NPROTOTYPE((krb5_ccache, krb5_creds *));
-       krb5_error_code (*retrieve) NPROTOTYPE((krb5_ccache, krb5_flags,
-                                  krb5_creds *, krb5_creds *));
-       krb5_error_code (*get_princ) NPROTOTYPE((krb5_ccache,
-                                               krb5_principal *));
-       krb5_error_code (*get_first) NPROTOTYPE((krb5_ccache,
-                                               krb5_cc_cursor *));
-       krb5_error_code (*get_next) NPROTOTYPE((krb5_ccache, krb5_cc_cursor *,
-                                  krb5_creds *));
-       krb5_error_code (*end_get) NPROTOTYPE((krb5_ccache, krb5_cc_cursor *));
-       krb5_error_code (*remove_cred) NPROTOTYPE((krb5_ccache, krb5_flags,
-                                     krb5_creds *));
-       krb5_error_code (*set_flags) NPROTOTYPE((krb5_ccache, krb5_flags));
+    krb5_magic magic;
+    char *prefix;
+    char *(*get_name) NPROTOTYPE((krb5_ccache));
+    krb5_error_code (*resolve) NPROTOTYPE((krb5_ccache *, char *));
+    krb5_error_code (*gen_new) NPROTOTYPE((krb5_ccache *));
+    krb5_error_code (*init) NPROTOTYPE((krb5_ccache, krb5_principal));
+    krb5_error_code (*destroy) NPROTOTYPE((krb5_ccache));
+    krb5_error_code (*close) NPROTOTYPE((krb5_ccache));
+    krb5_error_code (*store) NPROTOTYPE((krb5_ccache, krb5_creds *));
+    krb5_error_code (*retrieve) NPROTOTYPE((krb5_ccache, krb5_flags,
+                                           krb5_creds *, krb5_creds *));
+    krb5_error_code (*get_princ) NPROTOTYPE((krb5_ccache,
+                                            krb5_principal *));
+    krb5_error_code (*get_first) NPROTOTYPE((krb5_ccache,
+                                            krb5_cc_cursor *));
+    krb5_error_code (*get_next) NPROTOTYPE((krb5_ccache, krb5_cc_cursor *,
+                                           krb5_creds *));
+    krb5_error_code (*end_get) NPROTOTYPE((krb5_ccache, krb5_cc_cursor *));
+    krb5_error_code (*remove_cred) NPROTOTYPE((krb5_ccache, krb5_flags,
+                                              krb5_creds *));
+    krb5_error_code (*set_flags) NPROTOTYPE((krb5_ccache, krb5_flags));
 } krb5_cc_ops;
 
 /* for retrieve_cred */
index 4720d048b47f3d1294eae23cf9b5573a10560421..c0785988ab65eac1370650259764a2d62d18a85b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1989-1992 by the Massachusetts Institute of Technology,
+ * Copyright (C) 1989-1994 by the Massachusetts Institute of Technology,
  * Cambridge, MA, USA.  All Rights Reserved.
  * 
  * This software is being provided to you, the LICENSEE, by the 
index 862ed95f5cfb36070d68d3a6728af504b12b33ea..f774bf974727069fabe804eabf743d8c5138d5f1 100644 (file)
    decrypted keys in the database */
 
 typedef struct _krb5_encrypted_keyblock {
+    krb5_magic magic;
     krb5_keytype keytype;
     int length;
     krb5_octet *contents;
 } krb5_encrypted_keyblock;
 
+/*
+ * Note --- this structure cannot be modified without changing the
+ * database version number in libkdb.a
+ */
 typedef struct _krb5_db_entry {
     krb5_principal principal;
     krb5_encrypted_keyblock key;
index 50c80a3006c4d94255ffd93add5af70a434774ee..dd554628a404fe7efd6588da55076be1f2081c20 100644 (file)
@@ -35,6 +35,7 @@
 typedef krb5_pointer krb5_kt_cursor;   /* XXX */
 
 typedef struct krb5_keytab_entry_st {
+    krb5_magic magic;
     krb5_principal principal;  /* principal of this key */
     krb5_timestamp timestamp;   /* time entry written to keytable */
     krb5_kvno vno;             /* key version number */
@@ -43,8 +44,9 @@ typedef struct krb5_keytab_entry_st {
 
 
 typedef struct _krb5_kt {
-       struct _krb5_kt_ops *ops;
-       krb5_pointer data;
+    krb5_magic magic;
+    struct _krb5_kt_ops *ops;
+    krb5_pointer data;
 } *krb5_keytab;
 
 
@@ -52,30 +54,31 @@ typedef struct _krb5_kt {
 #include <krb5/widen.h>
 
 typedef struct _krb5_kt_ops {
-       char *prefix;
-        /* routines always present */
-       krb5_error_code (*resolve) NPROTOTYPE((char *,
-                                             krb5_keytab *));
-       krb5_error_code (*get_name) NPROTOTYPE((krb5_keytab,
-                                              char *,
-                                              int));
-       krb5_error_code (*close) NPROTOTYPE((krb5_keytab));
-       krb5_error_code (*get) NPROTOTYPE((krb5_keytab,
-                                         krb5_principal,
-                                         krb5_kvno,
+    krb5_magic magic;
+    char *prefix;
+    /* routines always present */
+    krb5_error_code (*resolve) NPROTOTYPE((char *,
+                                          krb5_keytab *));
+    krb5_error_code (*get_name) NPROTOTYPE((krb5_keytab,
+                                           char *,
+                                           int));
+    krb5_error_code (*close) NPROTOTYPE((krb5_keytab));
+    krb5_error_code (*get) NPROTOTYPE((krb5_keytab,
+                                      krb5_principal,
+                                      krb5_kvno,
+                                      krb5_keytab_entry *));
+    krb5_error_code (*start_seq_get) NPROTOTYPE((krb5_keytab,
+                                                krb5_kt_cursor *));    
+    krb5_error_code (*get_next) NPROTOTYPE((krb5_keytab,
+                                           krb5_keytab_entry *,
+                                           krb5_kt_cursor *));
+    krb5_error_code (*end_get) NPROTOTYPE((krb5_keytab,
+                                          krb5_kt_cursor *));
+    /* routines to be included on extended version (write routines) */
+    krb5_error_code (*add) NPROTOTYPE((krb5_keytab,
+                                      krb5_keytab_entry *));
+    krb5_error_code (*remove) NPROTOTYPE((krb5_keytab,
                                          krb5_keytab_entry *));
-       krb5_error_code (*start_seq_get) NPROTOTYPE((krb5_keytab,
-                                                   krb5_kt_cursor *)); 
-       krb5_error_code (*get_next) NPROTOTYPE((krb5_keytab,
-                                              krb5_keytab_entry *,
-                                              krb5_kt_cursor *));
-       krb5_error_code (*end_get) NPROTOTYPE((krb5_keytab,
-                                             krb5_kt_cursor *));
-       /* routines to be included on extended version (write routines) */
-       krb5_error_code (*add) NPROTOTYPE((krb5_keytab,
-                                         krb5_keytab_entry *));
-       krb5_error_code (*remove) NPROTOTYPE((krb5_keytab,
-                                            krb5_keytab_entry *));
 } krb5_kt_ops;
 
 /* and back to narrow */
index d3db525c6e2fdb4d1b5f2c66920e5fb57e1ce3b1..6fe990bb4eb533668e92d7d6b22247948814fcba 100644 (file)
@@ -55,6 +55,7 @@ typedef struct _krb5_ticket_times {
 
 /* structure for auth data */
 typedef struct _krb5_authdata {
+    krb5_magic magic;
     krb5_authdatatype ad_type;
     int length;
     krb5_octet *contents;
@@ -62,11 +63,13 @@ typedef struct _krb5_authdata {
 
 /* structure for transited encoding */
 typedef struct _krb5_transited {
+    krb5_magic magic;
     krb5_octet tr_type;
     krb5_data tr_contents;
 } krb5_transited;
 
 typedef struct _krb5_enc_tkt_part {
+    krb5_magic magic;
     /* to-be-encrypted portion */
     krb5_flags flags;                  /* flags */
     krb5_keyblock *session;            /* session key: includes keytype */
@@ -78,6 +81,7 @@ typedef struct _krb5_enc_tkt_part {
 } krb5_enc_tkt_part;
 
 typedef struct _krb5_ticket {
+    krb5_magic magic;
     /* cleartext portion */
     krb5_principal server;             /* server name/realm */
     krb5_enc_data enc_part;            /* encryption type, kvno, encrypted
@@ -88,6 +92,7 @@ typedef struct _krb5_ticket {
 
 /* the unencrypted version */
 typedef struct _krb5_authenticator {
+    krb5_magic magic;
     krb5_principal client;             /* client name/realm */
     krb5_checksum *checksum;           /* checksum, includes type, optional */
     krb5_int32 cusec;                  /* client usec portion */
@@ -98,6 +103,7 @@ typedef struct _krb5_authenticator {
 } krb5_authenticator;
 
 typedef struct _krb5_tkt_authent {
+    krb5_magic magic;
     krb5_ticket *ticket;
     krb5_authenticator *authenticator;
     krb5_flags ap_options;
@@ -105,6 +111,7 @@ typedef struct _krb5_tkt_authent {
 
 /* credentials:  Ticket, session key, etc. */
 typedef struct _krb5_creds {
+    krb5_magic magic;
     krb5_principal client;             /* client's principal identifier */
     krb5_principal server;             /* server's principal identifier */
     krb5_keyblock keyblock;            /* session encryption key info */
@@ -122,18 +129,21 @@ typedef struct _krb5_creds {
 
 /* Last request fields */
 typedef struct _krb5_last_req_entry {
+    krb5_magic magic;
     krb5_octet lr_type;
     krb5_timestamp value;
 } krb5_last_req_entry;
 
 /* pre-authentication data */
 typedef struct _krb5_pa_data {
+    krb5_magic magic;
     krb5_ui_2  pa_type;
     int length;
     krb5_octet *contents;
 } krb5_pa_data;
 
 typedef struct _krb5_kdc_req {
+    krb5_magic magic;
     krb5_msgtype msg_type;             /* AS_REQ or TGS_REQ? */
     krb5_pa_data **padata;             /* e.g. encoded AP_REQ */
     /* real body */
@@ -155,6 +165,7 @@ typedef struct _krb5_kdc_req {
 } krb5_kdc_req;
 
 typedef struct _krb5_enc_kdc_rep_part {
+    krb5_magic magic;
     /* encrypted part: */
     krb5_msgtype msg_type;             /* krb5 message type */
     krb5_keyblock *session;            /* session key */
@@ -169,6 +180,7 @@ typedef struct _krb5_enc_kdc_rep_part {
 } krb5_enc_kdc_rep_part;
 
 typedef struct _krb5_kdc_rep {
+    krb5_magic magic;
     /* cleartext part: */
     krb5_msgtype msg_type;             /* AS_REP or KDC_REP? */
     krb5_pa_data **padata;             /* preauthentication data from KDC */
@@ -181,6 +193,7 @@ typedef struct _krb5_kdc_rep {
 
 /* error message structure */
 typedef struct _krb5_error {
+    krb5_magic magic;
     /* some of these may be meaningless in certain contexts */
     krb5_timestamp ctime;              /* client sec portion; optional */
     krb5_int32 cusec;                  /* client usec portion; optional */
@@ -195,16 +208,19 @@ typedef struct _krb5_error {
 } krb5_error;
 
 typedef struct _krb5_ap_req {
+    krb5_magic magic;
     krb5_flags ap_options;             /* requested options */
     krb5_ticket *ticket;               /* ticket */
     krb5_enc_data authenticator;       /* authenticator (already encrypted) */
 } krb5_ap_req;
 
 typedef struct _krb5_ap_rep {
+    krb5_magic magic;
     krb5_enc_data enc_part;
 } krb5_ap_rep;
 
 typedef struct _krb5_ap_rep_enc_part {
+    krb5_magic magic;
     krb5_timestamp ctime;              /* client time, seconds portion */
     krb5_int32 cusec;                  /* client time, microseconds portion */
     krb5_keyblock *subkey;             /* true session key, optional */
@@ -212,11 +228,13 @@ typedef struct _krb5_ap_rep_enc_part {
 } krb5_ap_rep_enc_part;
 
 typedef struct _krb5_response {
+    krb5_magic magic;
     krb5_octet message_type;
     krb5_data response;
 } krb5_response;
 
 typedef struct _krb5_safe {
+    krb5_magic magic;
     krb5_data user_data;               /* user data */
     krb5_timestamp timestamp;          /* client time, optional */
     krb5_int32 usec;                   /* microsecond portion of time,
@@ -228,10 +246,12 @@ typedef struct _krb5_safe {
 } krb5_safe;
 
 typedef struct _krb5_priv {
+    krb5_magic magic;
     krb5_enc_data enc_part;            /* encrypted part */
 } krb5_priv;
 
 typedef struct _krb5_priv_enc_part {
+    krb5_magic magic;
     krb5_data user_data;               /* user data */
     krb5_timestamp timestamp;          /* client time, optional */
     krb5_int32 usec;                   /* microsecond portion of time, opt. */
@@ -241,11 +261,13 @@ typedef struct _krb5_priv_enc_part {
 } krb5_priv_enc_part;
 
 typedef struct _krb5_cred {
+    krb5_magic magic;
     krb5_ticket **tickets;             /* tickets */
     krb5_enc_data enc_part;            /* encrypted part */
 } krb5_cred;
 
 typedef struct _krb5_cred_info {
+    krb5_magic magic;
     krb5_keyblock* session;             /* session key used to encrypt */
                                        /* ticket */
     krb5_principal client;              /* client name/realm, optional */
@@ -257,6 +279,7 @@ typedef struct _krb5_cred_info {
 } krb5_cred_info;
 
 typedef struct _krb5_cred_enc_part {
+    krb5_magic magic;
     krb5_int32 nonce;                   /* nonce, optional */
     krb5_timestamp timestamp;           /* client time */
     krb5_int32 usec;                    /* microsecond portion of time */
@@ -275,11 +298,13 @@ typedef struct _krb5_cred_enc_part {
 
 /* Sandia password generation structures */
 typedef struct _passwd_phrase_element {
+    krb5_magic magic;
     krb5_data *passwd;
     krb5_data *phrase;
 } passwd_phrase_element;
 
 typedef struct _krb5_pwd_data {
+    krb5_magic magic;
     int sequence_count;
     passwd_phrase_element **element;
 } krb5_pwd_data;
index a42d29c5a17a6591ea2c67adb36f694c3258aecb..649bf5e4b88ee1dbdb947ac4392c524629a86714 100644 (file)
@@ -42,10 +42,11 @@ typedef krb5_error_code (krb5_preauth_verify_proc)
               krb5_data *data));
 
 typedef struct _krb5_preauth_ops {
-        int     type;
-       int     flags;
-       krb5_preauth_obtain_proc        *obtain;
-       krb5_preauth_verify_proc        *verify;
+    krb5_magic magic;
+    int     type;
+    int        flags;
+    krb5_preauth_obtain_proc   *obtain;
+    krb5_preauth_verify_proc   *verify;
 } krb5_preauth_ops;
 
 /*
index 8e0cee050c6fb1e9eef595d83e4d36ac77da1746..4bd531116ddc467d6f38a32394bccc6f06656d7b 100644 (file)
 #define KRB5_RCACHE__
 
 typedef struct krb5_rc_st {
+    krb5_magic magic;
     struct _krb5_rc_ops *ops;
     krb5_pointer data;
 } *krb5_rcache;
 
 typedef struct _krb5_donot_replay {
+    krb5_magic magic;
     char *server;                      /* null-terminated */
     char *client;                      /* null-terminated */
     krb5_int32 cusec;
@@ -41,6 +43,7 @@ typedef struct _krb5_donot_replay {
 } krb5_donot_replay;
 
 typedef struct _krb5_rc_ops {
+    krb5_magic magic;
     char *type;
     krb5_error_code (*init)NPROTOTYPE((krb5_rcache,krb5_deltat)); /* create */
     krb5_error_code (*recover)NPROTOTYPE((krb5_rcache)); /* open */