xref: /illumos-gate/usr/src/lib/krb5/plugins/kdb/ldap/libkdb_ldap/ldap_principal.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 #include "ldap_tkt_policy.h"
35 
36 #define  KEYHEADER  12
37 
38 #define  NOOFKEYS(ptr) 		((ptr[10]<<8) | ptr[11])
39 
40 #define  PRINCIPALLEN(ptr) 	((ptr[0]<<8) | ptr[1])
41 #define  PRINCIPALNAME(ptr) 	(ptr + KEYHEADER + (NOOFKEYS(ptr) *8))
42 
43 #define  KEYBODY(ptr)		PRINCIPALNAME(ptr) + PRINCIPALLEN(ptr)
44 
45 #define  PKEYVER(ptr) 		((ptr[2]<<8) | ptr[3])
46 #define  MKEYVER(ptr) 		((ptr[4]<<8) | ptr[5])
47 
48 #define  KEYTYPE(ptr,j) 	((ptr[KEYHEADER+(j*8)]<<8) | ptr[KEYHEADER+1+(j*8)])
49 #define  KEYLENGTH(ptr,j) 	((ptr[KEYHEADER+2+(j*8)]<<8) | ptr[KEYHEADER+3+(j*8)])
50 #define  SALTTYPE(ptr,j) 	((ptr[KEYHEADER+4+(j*8)]<<8) | ptr[KEYHEADER+5+(j*8)])
51 #define  SALTLENGTH(ptr,j) 	((ptr[KEYHEADER+6+(j*8)]<<8) | ptr[KEYHEADER+7+(j*8)])
52 
53 #define MAX_KEY_LENGTH         1024
54 #define CONTAINERDN_ARG        "containerdn"
55 #define USERDN_ARG             "dn"
56 #define TKTPOLICY_ARG          "tktpolicy"
57 #define LINKDN_ARG             "linkdn"
58 
59 /* #define FILTER   "(&(objectclass=krbprincipalaux)(krbprincipalname=" */
60  #define FILTER   "(&(|(objectclass=krbprincipalaux)(objectclass=krbprincipal))(krbprincipalname="
61 
62 #define  KDB_USER_PRINCIPAL    0x01
63 #define  KDB_SERVICE_PRINCIPAL 0x02
64 #define KDB_STANDALONE_PRINCIPAL_OBJECT 0x01
65 
66 /* these will be consumed only by krb5_ldap_delete_principal*/
67 /* these will be set by krb5_ldap_get_principal and fed into the tl_data */
68 
69 /* See also attributes_set[] in ldap_principal.c.  */
70 #define KDB_MAX_LIFE_ATTR                    0x000001
71 #define KDB_MAX_RLIFE_ATTR                   0x000002
72 #define KDB_TKT_FLAGS_ATTR                   0x000004
73 #define KDB_PRINC_EXPIRE_TIME_ATTR           0x000008
74 #define KDB_POL_REF_ATTR                     0x000010
75 #define KDB_UP_FLAG_ATTR                     0x000020
76 #define KDB_PWD_POL_REF_ATTR                 0x000040
77 #define KDB_PWD_EXPIRE_TIME_ATTR             0x000080
78 #define KDB_SECRET_KEY_ATTR                  0x000100
79 #define KDB_LAST_PWD_CHANGE_ATTR             0x000200
80 #define KDB_EXTRA_DATA_ATTR                  0x000400
81 #define KDB_LAST_SUCCESS_ATTR                0x000800
82 #define KDB_LAST_FAILED_ATTR                 0x001000
83 #define KDB_FAIL_AUTH_COUNT_ATTR             0x002000
84 extern struct timeval timeout;
85 extern char *policyclass[];
86 
87 krb5_error_code
88 krb5_ldap_put_principal(krb5_context, krb5_db_entry *, int *, char **);
89 
90 krb5_error_code
91 krb5_ldap_get_principal(krb5_context , krb5_const_principal ,
92                         krb5_db_entry *,int *, krb5_boolean *);
93 
94 krb5_error_code
95 krb5_ldap_delete_principal(krb5_context, krb5_const_principal, int *);
96 
97 krb5_error_code
98 krb5_ldap_free_principal(krb5_context, krb5_db_entry *, int );
99 
100 /* Solaris Kerberos: adding support for db_args */
101 krb5_error_code
102 krb5_ldap_iterate(krb5_context, char *, krb5_error_code (*) (krb5_pointer, krb5_db_entry *),
103                   krb5_pointer/*, int */, char **);
104 
105 void
106 krb5_dbe_free_contents(krb5_context, krb5_db_entry *);
107 
108 krb5_error_code
109 krb5_ldap_unparse_principal_name(char *);
110 
111 krb5_error_code
112 krb5_ldap_parse_principal_name(char *, char **);
113 
114 krb5_error_code
115 krb5_decode_krbsecretkey(krb5_context, krb5_db_entry *, struct berval **);
116 
117 krb5_error_code
118 berval2tl_data(struct berval *in, krb5_tl_data **out);
119 
120 krb5_error_code
121 krb5_read_tkt_policy (krb5_context, krb5_ldap_context *, krb5_db_entry *, char *);
122 #endif
123