6 #include <windc_plugin.h>
8 static krb5_error_code KRB5_CALLCONV
9 windc_init(krb5_context context
, void **ctx
)
11 krb5_warnx(context
, "windc init");
16 static void KRB5_CALLCONV
21 static krb5_error_code KRB5_CALLCONV
22 pac_generate(void *ctx
, krb5_context context
,
23 struct hdb_entry_ex
*client
,
24 struct hdb_entry_ex
*server
,
25 const krb5_keyblock
*pk_replykey
,
26 uint64_t pac_attributes
,
32 if ((pac_attributes
& (KRB5_PAC_WAS_REQUESTED
|
33 KRB5_PAC_WAS_GIVEN_IMPLICITLY
)) == 0) {
38 krb5_warnx(context
, "pac generate");
40 data
.data
= "\x00\x01";
43 ret
= krb5_pac_init(context
, pac
);
47 ret
= krb5_pac_add_buffer(context
, *pac
, 1, &data
);
54 static krb5_error_code KRB5_CALLCONV
55 pac_verify(void *ctx
, krb5_context context
,
56 const krb5_principal new_ticket_client
,
57 const krb5_principal delegation_proxy
,
58 struct hdb_entry_ex
* client
,
59 struct hdb_entry_ex
* server
,
60 struct hdb_entry_ex
* krbtgt
,
65 krb5_cksumtype cstype
;
70 krb5_warnx(context
, "pac_verify");
72 ret
= krb5_pac_get_buffer(context
, *pac
, 1, &data
);
75 krb5_data_free(&data
);
77 ret
= krb5_pac_get_kdc_checksum_info(context
, *pac
, &cstype
, &rodc_id
);
81 if (rodc_id
== 0 || rodc_id
!= krbtgt
->entry
.kvno
>> 16) {
82 krb5_warnx(context
, "Wrong RODCIdentifier");
86 ret
= krb5_cksumtype_to_enctype(context
, cstype
, &etype
);
90 ret
= hdb_enctype2key(context
, &krbtgt
->entry
, NULL
, etype
, &key
);
94 return krb5_pac_verify(context
, *pac
, 0, NULL
, NULL
, &key
->key
);
97 static void logit(const char *what
, astgs_request_t r
)
99 krb5_warnx(r
->context
, "%s: client %s server %s",
101 r
->cname
? r
->cname
: "<unknown>",
102 r
->sname
? r
->sname
: "<unknown>");
105 static krb5_error_code KRB5_CALLCONV
106 client_access(void *ctx
, astgs_request_t r
)
108 logit("client_access", r
);
112 static krb5_error_code KRB5_CALLCONV
113 finalize_reply(void *ctx
, astgs_request_t r
)
115 logit("finalize_reply", r
);
119 static krb5plugin_windc_ftable windc
= {
120 KRB5_WINDC_PLUGING_MINOR
,
129 static const krb5plugin_windc_ftable
*const windc_plugins
[] = {
133 krb5_error_code KRB5_CALLCONV
134 windc_plugin_load(krb5_context context
,
135 krb5_get_instance_func_t
*get_instance
,
137 const krb5plugin_windc_ftable
*const **plugins
);
139 static uintptr_t KRB5_CALLCONV
140 windc_get_instance(const char *libname
)
142 if (strcmp(libname
, "hdb") == 0)
143 return hdb_get_instance(libname
);
144 else if (strcmp(libname
, "krb5") == 0)
145 return krb5_get_instance(libname
);
150 krb5_error_code KRB5_CALLCONV
151 windc_plugin_load(krb5_context context
,
152 krb5_get_instance_func_t
*get_instance
,
154 const krb5plugin_windc_ftable
*const **plugins
)
156 *get_instance
= windc_get_instance
;
157 *num_plugins
= sizeof(windc_plugins
) / sizeof(windc_plugins
[0]);
158 *plugins
= windc_plugins
;