PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/crypto/heimdal/tests/plugin/windc.c

https://bitbucket.org/freebsd/freebsd-head/
C | 77 lines | 62 code | 15 blank | 0 comment | 3 complexity | be71c2ff9dfcd06027d16654d0fe95f3 MD5 | raw file
 1#include <krb5.h>
 2#include <hdb.h>
 3#include <windc_plugin.h>
 4
 5static krb5_error_code
 6windc_init(krb5_context context, void **ctx)
 7{
 8    krb5_warnx(context, "windc init");
 9    *ctx = NULL;
10    return 0;
11}
12
13static void
14windc_fini(void *ctx)
15{
16}
17
18static krb5_error_code 
19pac_generate(void *ctx, krb5_context context,
20	     struct hdb_entry_ex *client, krb5_pac *pac)
21{
22    krb5_error_code ret;
23    krb5_data data;
24
25    krb5_warnx(context, "pac generate");
26
27    data.data = "\x00\x01";
28    data.length = 2;
29
30    ret = krb5_pac_init(context, pac);
31    if (ret)
32	return ret;
33
34    ret = krb5_pac_add_buffer(context, *pac, 1, &data);
35    if (ret)
36	return ret;
37
38    return 0;
39}
40
41static krb5_error_code 
42pac_verify(void *ctx, krb5_context context,
43	   const krb5_principal client_principal,
44	   struct hdb_entry_ex *client, 
45	   struct hdb_entry_ex *server,
46	   krb5_pac *pac)
47{
48    krb5_error_code ret;
49    krb5_data data;
50
51    krb5_warnx(context, "pac_verify");
52
53    ret = krb5_pac_get_buffer(context, *pac, 1, &data);
54    if (ret)
55	return ret;
56
57    krb5_data_free(&data);
58
59    return 0;
60}
61
62static krb5_error_code 
63client_access(void *ctx, krb5_context context, 
64	      struct hdb_entry_ex *client, KDC_REQ *req)
65{
66    krb5_warnx(context, "client_access");
67    return 0;
68}
69
70krb5plugin_windc_ftable windc = {
71    KRB5_WINDC_PLUGING_MINOR,
72    windc_init,
73    windc_fini,
74    pac_generate,
75    pac_verify,
76    client_access
77};