From 998455fb1a3920f19c101cc1c8149d7bdcdc25a2 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 30 Sep 1994 21:52:02 +0000 Subject: [PATCH] Add field for structure magic numbers git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4410 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/krb5/base-defs.h | 4 +++ src/include/krb5/ccache.h | 46 ++++++++++++++++--------------- src/include/krb5/copyright.h | 2 +- src/include/krb5/kdb.h | 5 ++++ src/include/krb5/keytab.h | 53 +++++++++++++++++++----------------- src/include/krb5/krb5.h | 25 +++++++++++++++++ src/include/krb5/preauth.h | 9 +++--- src/include/krb5/rcache.h | 3 ++ 8 files changed, 95 insertions(+), 52 deletions(-) diff --git a/src/include/krb5/base-defs.h b/src/include/krb5/base-defs.h index 37d7d0acb..f4bfa0189 100644 --- a/src/include/krb5/base-defs.h +++ b/src/include/krb5/base-defs.h @@ -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; diff --git a/src/include/krb5/ccache.h b/src/include/krb5/ccache.h index 41f155596..beeb740b6 100644 --- a/src/include/krb5/ccache.h +++ b/src/include/krb5/ccache.h @@ -31,31 +31,33 @@ 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 */ diff --git a/src/include/krb5/copyright.h b/src/include/krb5/copyright.h index 4720d048b..c0785988a 100644 --- a/src/include/krb5/copyright.h +++ b/src/include/krb5/copyright.h @@ -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 diff --git a/src/include/krb5/kdb.h b/src/include/krb5/kdb.h index 862ed95f5..f774bf974 100644 --- a/src/include/krb5/kdb.h +++ b/src/include/krb5/kdb.h @@ -33,11 +33,16 @@ 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; diff --git a/src/include/krb5/keytab.h b/src/include/krb5/keytab.h index 50c80a300..dd554628a 100644 --- a/src/include/krb5/keytab.h +++ b/src/include/krb5/keytab.h @@ -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 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 */ diff --git a/src/include/krb5/krb5.h b/src/include/krb5/krb5.h index d3db525c6..6fe990bb4 100644 --- a/src/include/krb5/krb5.h +++ b/src/include/krb5/krb5.h @@ -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; diff --git a/src/include/krb5/preauth.h b/src/include/krb5/preauth.h index a42d29c5a..649bf5e4b 100644 --- a/src/include/krb5/preauth.h +++ b/src/include/krb5/preauth.h @@ -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; /* diff --git a/src/include/krb5/rcache.h b/src/include/krb5/rcache.h index 8e0cee050..4bd531116 100644 --- a/src/include/krb5/rcache.h +++ b/src/include/krb5/rcache.h @@ -29,11 +29,13 @@ #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 */ -- 2.26.2