xref: /titanic_41/usr/src/lib/krb5/plugins/kdb/ldap/libkdb_ldap/ldap_principal.h (revision 2dd2efa5a06a9befe46075cf41e16f57533c9f98)
1 /*
2  * lib/kdb/kdb_ldap/ldap_principal.h
3  *
4  * Copyright (c) 2004-2005, Novell, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  *   * Redistributions of source code must retain the above copyright notice,
11  *       this list of conditions and the following disclaimer.
12  *   * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in the
14  *       documentation and/or other materials provided with the distribution.
15  *   * The copyright holder's name is not used to endorse or promote products
16  *       derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef _LDAP_PRINCIPAL_H
32 #define _LDAP_PRINCIPAL_H 1
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include "ldap_tkt_policy.h"
37 
38 #define  KEYHEADER  12
39 
40 #define  NOOFKEYS(ptr) 		((ptr[10]<<8) | ptr[11])
41 
42 #define  PRINCIPALLEN(ptr) 	((ptr[0]<<8) | ptr[1])
43 #define  PRINCIPALNAME(ptr) 	(ptr + KEYHEADER + (NOOFKEYS(ptr) *8))
44 
45 #define  KEYBODY(ptr)		PRINCIPALNAME(ptr) + PRINCIPALLEN(ptr)
46 
47 #define  PKEYVER(ptr) 		((ptr[2]<<8) | ptr[3])
48 #define  MKEYVER(ptr) 		((ptr[4]<<8) | ptr[5])
49 
50 #define  KEYTYPE(ptr,j) 	((ptr[KEYHEADER+(j*8)]<<8) | ptr[KEYHEADER+1+(j*8)])
51 #define  KEYLENGTH(ptr,j) 	((ptr[KEYHEADER+2+(j*8)]<<8) | ptr[KEYHEADER+3+(j*8)])
52 #define  SALTTYPE(ptr,j) 	((ptr[KEYHEADER+4+(j*8)]<<8) | ptr[KEYHEADER+5+(j*8)])
53 #define  SALTLENGTH(ptr,j) 	((ptr[KEYHEADER+6+(j*8)]<<8) | ptr[KEYHEADER+7+(j*8)])
54 
55 #define MAX_KEY_LENGTH         1024
56 #define CONTAINERDN_ARG        "containerdn"
57 #define USERDN_ARG             "dn"
58 #define TKTPOLICY_ARG          "tktpolicy"
59 #define LINKDN_ARG             "linkdn"
60 
61 /* #define FILTER   "(&(objectclass=krbprincipalaux)(krbprincipalname=" */
62  #define FILTER   "(&(|(objectclass=krbprincipalaux)(objectclass=krbprincipal))(krbprincipalname="
63 
64 #define  KDB_USER_PRINCIPAL    0x01
65 #define  KDB_SERVICE_PRINCIPAL 0x02
66 #define KDB_STANDALONE_PRINCIPAL_OBJECT 0x01
67 
68 /* these will be consumed only by krb5_ldap_delete_principal*/
69 /* these will be set by krb5_ldap_get_principal and fed into the tl_data */
70 
71 /* See also attributes_set[] in ldap_principal.c.  */
72 #define KDB_MAX_LIFE_ATTR                    0x000001
73 #define KDB_MAX_RLIFE_ATTR                   0x000002
74 #define KDB_TKT_FLAGS_ATTR                   0x000004
75 #define KDB_PRINC_EXPIRE_TIME_ATTR           0x000008
76 #define KDB_POL_REF_ATTR                     0x000010
77 #define KDB_UP_FLAG_ATTR                     0x000020
78 #define KDB_PWD_POL_REF_ATTR                 0x000040
79 #define KDB_PWD_EXPIRE_TIME_ATTR             0x000080
80 #define KDB_SECRET_KEY_ATTR                  0x000100
81 #define KDB_LAST_PWD_CHANGE_ATTR             0x000200
82 #define KDB_EXTRA_DATA_ATTR                  0x000400
83 #define KDB_LAST_SUCCESS_ATTR                0x000800
84 #define KDB_LAST_FAILED_ATTR                 0x001000
85 #define KDB_FAIL_AUTH_COUNT_ATTR             0x002000
86 extern struct timeval timeout;
87 extern char *policyclass[];
88 
89 krb5_error_code
90 krb5_ldap_put_principal(krb5_context, krb5_db_entry *, int *, char **);
91 
92 krb5_error_code
93 krb5_ldap_get_principal(krb5_context , krb5_const_principal ,
94                         krb5_db_entry *,int *, krb5_boolean *);
95 
96 krb5_error_code
97 krb5_ldap_delete_principal(krb5_context, krb5_const_principal, int *);
98 
99 krb5_error_code
100 krb5_ldap_free_principal(krb5_context, krb5_db_entry *, int );
101 
102 /* Solaris Kerberos: adding support for db_args */
103 krb5_error_code
104 krb5_ldap_iterate(krb5_context, char *, krb5_error_code (*) (krb5_pointer, krb5_db_entry *),
105                   krb5_pointer/*, int */, char **);
106 
107 void
108 krb5_dbe_free_contents(krb5_context, krb5_db_entry *);
109 
110 krb5_error_code
111 krb5_ldap_unparse_principal_name(char *);
112 
113 krb5_error_code
114 krb5_ldap_parse_principal_name(char *, char **);
115 
116 krb5_error_code
117 krb5_decode_krbsecretkey(krb5_context, krb5_db_entry *, struct berval **);
118 
119 krb5_error_code
120 berval2tl_data(struct berval *in, krb5_tl_data **out);
121 
122 krb5_error_code
123 krb5_read_tkt_policy (krb5_context, krb5_ldap_context *, krb5_db_entry *, char *);
124 #endif
125