1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright (C) 2014 by the Massachusetts Institute of Technology. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * This interface is not yet public and may change without honoring the 34 * pluggable interface version system. The header file is deliberately not 35 * installed by "make install". 36 * 37 * This interface references kdb.h, which is not stable. A module which 38 * references fields of krb5_db_entry, invokes libkdb5 functions, or uses the 39 * flags argument may not be future-proof even if this interface becomes 40 * public. 41 * 42 * Expecting modules to hand-modify enc_tkt_reply->authorization_data is 43 * cumbersome for the module, and doesn't work if the module uses a different 44 * allocator from the krb5 tree. A libkrb5 API to add an authdata value to a 45 * list would improve this situation. 46 */ 47 48 /* 49 * Declarations for kdcauthdata plugin module implementors. 50 * 51 * The kdcauthdata interface has a single supported major version, which is 1. 52 * Major version 1 has a current minor version of 1. kdcauthdata modules 53 * should define a function named kdcauthdata_<modulename>_initvt, matching the 54 * signature: 55 * 56 * krb5_error_code 57 * kdcauthdata_modname_initvt(krb5_context context, int maj_ver, int min_ver, 58 * krb5_plugin_vtable vtable); 59 * 60 * The initvt function should: 61 * 62 * - Check that the supplied maj_ver number is supported by the module, or 63 * return KRB5_PLUGIN_VER_NOTSUPP if it is not. 64 * 65 * - Cast the vtable pointer as appropriate for the interface and maj_ver: 66 * maj_ver == 1: Cast to krb5_kdcauthdata_vtable 67 * 68 * - Initialize the methods of the vtable, stopping as appropriate for the 69 * supplied min_ver. Optional methods may be left uninitialized. 70 * 71 * Memory for the vtable is allocated by the caller, not by the module. 72 */ 73 74 #ifndef KRB5_KDCAUTHDATA_PLUGIN_H 75 #define KRB5_KDCAUTHDATA_PLUGIN_H 76 77 #include <krb5/krb5.h> 78 #include <krb5/plugin.h> 79 #include <kdb.h> 80 81 /* Abstract type for module data. */ 82 typedef struct krb5_kdcauthdata_moddata_st *krb5_kdcauthdata_moddata; 83 84 /* Optional: module initialization function. If this function returns an 85 * error, the KDC will log the failure and ignore the module. */ 86 typedef krb5_error_code 87 (*krb5_kdcauthdata_init_fn)(krb5_context context, 88 krb5_kdcauthdata_moddata *moddata_out); 89 90 /* Optional: module cleanup function. */ 91 typedef void 92 (*krb5_kdcauthdata_fini_fn)(krb5_context context, 93 krb5_kdcauthdata_moddata moddata); 94 95 /* 96 * Mandatory: authorization data handling function. 97 * 98 * All values should be considered input-only, except that the method can 99 * modify enc_tkt_reply->authorization_data to add authdata values. This field 100 * is a null-terminated list of allocated pointers; the plugin method must 101 * reallocate it to make room for any added authdata values. 102 * 103 * If this function returns an error, the AS or TGS request will be rejected. 104 */ 105 typedef krb5_error_code 106 (*krb5_kdcauthdata_handle_fn)(krb5_context context, 107 krb5_kdcauthdata_moddata moddata, 108 unsigned int flags, 109 krb5_db_entry *client, krb5_db_entry *server, 110 krb5_db_entry *header_server, 111 krb5_keyblock *client_key, 112 krb5_keyblock *server_key, 113 krb5_keyblock *header_key, 114 krb5_data *req_pkt, krb5_kdc_req *req, 115 krb5_const_principal for_user_princ, 116 krb5_enc_tkt_part *enc_tkt_req, 117 krb5_enc_tkt_part *enc_tkt_reply); 118 119 typedef struct krb5_kdcauthdata_vtable_st { 120 /* Mandatory: name of module. */ 121 const char *name; 122 123 krb5_kdcauthdata_init_fn init; 124 krb5_kdcauthdata_fini_fn fini; 125 krb5_kdcauthdata_handle_fn handle; 126 /* Minor 1 ends here. */ 127 } *krb5_kdcauthdata_vtable; 128 129 #endif /* KRB5_KDCAUTHDATA_PLUGIN_H */ 130