17c478bd9Sstevel@tonic-gate /* 2ab9b2e15Sgtb * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate * 57c478bd9Sstevel@tonic-gate * lib/krb5/keytab/file/ktfile.h 67c478bd9Sstevel@tonic-gate * 77c478bd9Sstevel@tonic-gate * Copyright 1990 by the Massachusetts Institute of Technology. 87c478bd9Sstevel@tonic-gate * All Rights Reserved. 97c478bd9Sstevel@tonic-gate * 107c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may 117c478bd9Sstevel@tonic-gate * require a specific license from the United States Government. 127c478bd9Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating 137c478bd9Sstevel@tonic-gate * export to obtain such a license before exporting. 14*1da57d55SToomas Soome * 157c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 167c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and 177c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright 187c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and 197c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that 207c478bd9Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining 217c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior 227c478bd9Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label 237c478bd9Sstevel@tonic-gate * your software as modified software and not distribute it in such a 247c478bd9Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software. 257c478bd9Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of 267c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express 277c478bd9Sstevel@tonic-gate * or implied warranty. 28*1da57d55SToomas Soome * 297c478bd9Sstevel@tonic-gate * 307c478bd9Sstevel@tonic-gate * This header file contains information needed by internal routines 317c478bd9Sstevel@tonic-gate * of the file-based ticket cache implementation. 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifndef _KRB5_KTFILE 357c478bd9Sstevel@tonic-gate #define _KRB5_KTFILE 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <stdio.h> 387c478bd9Sstevel@tonic-gate #include <sys/mman.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * Constants 427c478bd9Sstevel@tonic-gate */ 437c478bd9Sstevel@tonic-gate #define IGNORE_VNO 0 447c478bd9Sstevel@tonic-gate #define IGNORE_ENCTYPE 0 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #define KRB5_KT_VNO_1 0x0501 /* krb v5, keytab version 1 (DCE compat) */ 477c478bd9Sstevel@tonic-gate #define KRB5_KT_VNO 0x0502 /* krb v5, keytab version 2 (standard) */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define KRB5_KT_DEFAULT_VNO KRB5_KT_VNO 507c478bd9Sstevel@tonic-gate 51*1da57d55SToomas Soome /* 527c478bd9Sstevel@tonic-gate * Types 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate typedef struct _krb5_ktfile_data { 557c478bd9Sstevel@tonic-gate char *name; /* Name of the file */ 567c478bd9Sstevel@tonic-gate char *datap; /* ptr to the file data */ 577c478bd9Sstevel@tonic-gate int version; /* Version number of keytab */ 587c478bd9Sstevel@tonic-gate offset_t offset; /* current offset into the data buffer */ 597c478bd9Sstevel@tonic-gate size_t filesize; /* size of original file */ 607c478bd9Sstevel@tonic-gate size_t bufsize; /* total size of data buffer */ 617c478bd9Sstevel@tonic-gate uchar_t writable:1; /* Was the file opened for writing? */ 627c478bd9Sstevel@tonic-gate } krb5_ktfile_data; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Macros 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define KTPRIVATE(id) ((krb5_ktfile_data *)(id)->data) 687c478bd9Sstevel@tonic-gate #define KTFILENAME(id) (((krb5_ktfile_data *)(id)->data)->name) 697c478bd9Sstevel@tonic-gate /* 707c478bd9Sstevel@tonic-gate #define KTFILEP(id) (((krb5_ktfile_data *)(id)->data)->openf) 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define KTDATAP(id) (((krb5_ktfile_data *)(id)->data)->datap) 737c478bd9Sstevel@tonic-gate #define KTVERSION(id) (((krb5_ktfile_data *)(id)->data)->version) 747c478bd9Sstevel@tonic-gate #define KTOFFSET(id) (((krb5_ktfile_data *)(id)->data)->offset) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate extern struct _krb5_kt_ops krb5_ktf_ops; 777c478bd9Sstevel@tonic-gate extern struct _krb5_kt_ops krb5_ktf_writable_ops; 787c478bd9Sstevel@tonic-gate 79*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_resolve 80ab9b2e15Sgtb (krb5_context, 817c478bd9Sstevel@tonic-gate const char *, 82ab9b2e15Sgtb krb5_keytab *); 837c478bd9Sstevel@tonic-gate 84*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_wresolve 85ab9b2e15Sgtb (krb5_context, 867c478bd9Sstevel@tonic-gate const char *, 87ab9b2e15Sgtb krb5_keytab *); 887c478bd9Sstevel@tonic-gate 89*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_get_name 90ab9b2e15Sgtb (krb5_context, 917c478bd9Sstevel@tonic-gate krb5_keytab, 927c478bd9Sstevel@tonic-gate char *, 93ab9b2e15Sgtb int); 947c478bd9Sstevel@tonic-gate 95*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_close 96ab9b2e15Sgtb (krb5_context, 97ab9b2e15Sgtb krb5_keytab); 987c478bd9Sstevel@tonic-gate 99*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_get_entry 100ab9b2e15Sgtb (krb5_context, 1017c478bd9Sstevel@tonic-gate krb5_keytab, 1027c478bd9Sstevel@tonic-gate krb5_const_principal, 1037c478bd9Sstevel@tonic-gate krb5_kvno, 1047c478bd9Sstevel@tonic-gate krb5_enctype, 105ab9b2e15Sgtb krb5_keytab_entry *); 1067c478bd9Sstevel@tonic-gate 107*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_start_seq_get 108ab9b2e15Sgtb (krb5_context, 1097c478bd9Sstevel@tonic-gate krb5_keytab, 110ab9b2e15Sgtb krb5_kt_cursor *); 1117c478bd9Sstevel@tonic-gate 112*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_get_next 113ab9b2e15Sgtb (krb5_context, 1147c478bd9Sstevel@tonic-gate krb5_keytab, 1157c478bd9Sstevel@tonic-gate krb5_keytab_entry *, 116ab9b2e15Sgtb krb5_kt_cursor *); 1177c478bd9Sstevel@tonic-gate 118*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_end_get 119ab9b2e15Sgtb (krb5_context, 1207c478bd9Sstevel@tonic-gate krb5_keytab, 121ab9b2e15Sgtb krb5_kt_cursor *); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* routines to be included on extended version (write routines) */ 124*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_add 125ab9b2e15Sgtb (krb5_context, 1267c478bd9Sstevel@tonic-gate krb5_keytab, 127ab9b2e15Sgtb krb5_keytab_entry *); 1287c478bd9Sstevel@tonic-gate 129*1da57d55SToomas Soome krb5_error_code KRB5_CALLCONV krb5_ktfile_remove 130ab9b2e15Sgtb (krb5_context, 1317c478bd9Sstevel@tonic-gate krb5_keytab, 132ab9b2e15Sgtb krb5_keytab_entry *); 1337c478bd9Sstevel@tonic-gate 134*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_openr 135ab9b2e15Sgtb (krb5_context, 136ab9b2e15Sgtb krb5_keytab); 1377c478bd9Sstevel@tonic-gate 138*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_openw 139ab9b2e15Sgtb (krb5_context, 140ab9b2e15Sgtb krb5_keytab); 1417c478bd9Sstevel@tonic-gate 142*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_close 143ab9b2e15Sgtb (krb5_context, 144ab9b2e15Sgtb krb5_keytab); 1457c478bd9Sstevel@tonic-gate 146*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_read_entry 147ab9b2e15Sgtb (krb5_context, 1487c478bd9Sstevel@tonic-gate krb5_keytab, 149ab9b2e15Sgtb krb5_keytab_entry *); 1507c478bd9Sstevel@tonic-gate 151*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_write_entry 152ab9b2e15Sgtb (krb5_context, 1537c478bd9Sstevel@tonic-gate krb5_keytab, 154ab9b2e15Sgtb krb5_keytab_entry *); 1557c478bd9Sstevel@tonic-gate 156*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_delete_entry 157ab9b2e15Sgtb (krb5_context, 1587c478bd9Sstevel@tonic-gate krb5_keytab, 159ab9b2e15Sgtb krb5_int32); 1607c478bd9Sstevel@tonic-gate 161*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_internal_read_entry 162ab9b2e15Sgtb (krb5_context, 1637c478bd9Sstevel@tonic-gate krb5_keytab, 1647c478bd9Sstevel@tonic-gate krb5_keytab_entry *, 165ab9b2e15Sgtb krb5_int32 *); 1667c478bd9Sstevel@tonic-gate 167*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_size_entry 168ab9b2e15Sgtb (krb5_context, 1697c478bd9Sstevel@tonic-gate krb5_keytab_entry *, 170ab9b2e15Sgtb krb5_int32 *); 1717c478bd9Sstevel@tonic-gate 172*1da57d55SToomas Soome krb5_error_code krb5_ktfileint_find_slot 173ab9b2e15Sgtb (krb5_context, 1747c478bd9Sstevel@tonic-gate krb5_keytab, 1757c478bd9Sstevel@tonic-gate krb5_int32 *, 176ab9b2e15Sgtb krb5_int32 *); 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #endif /* _KRB5_KTFILE */ 180