FreeRDP
krb5glue.h
1 
20 #ifndef WINPR_SSPI_KERBEROS_GLUE_PRIVATE_H
21 #define WINPR_SSPI_KERBEROS_GLUE_PRIVATE_H
22 
23 #include <winpr/winpr.h>
24 #include <winpr/sspi.h>
25 
26 #include <krb5.h>
27 
28 #if defined(WITH_KRB5_MIT)
29 typedef krb5_key krb5glue_key;
30 typedef krb5_authenticator* krb5glue_authenticator;
31 
32 #define krb5glue_crypto_length(ctx, key, type, size) \
33  krb5_c_crypto_length(ctx, krb5_k_key_enctype(ctx, key), type, size)
34 #define krb5glue_crypto_length_iov(ctx, key, iov, size) \
35  krb5_c_crypto_length_iov(ctx, krb5_k_key_enctype(ctx, key), iov, size)
36 #define krb5glue_encrypt_iov(ctx, key, usage, iov, size) \
37  krb5_k_encrypt_iov(ctx, key, usage, NULL, iov, size)
38 #define krb5glue_decrypt_iov(ctx, key, usage, iov, size) \
39  krb5_k_decrypt_iov(ctx, key, usage, NULL, iov, size)
40 #define krb5glue_make_checksum_iov(ctx, key, usage, iov, size) \
41  krb5_k_make_checksum_iov(ctx, 0, key, usage, iov, size)
42 #define krb5glue_verify_checksum_iov(ctx, key, usage, iov, size, is_valid) \
43  krb5_k_verify_checksum_iov(ctx, 0, key, usage, iov, size, is_valid)
44 #define krb5glue_auth_con_set_cksumtype(ctx, auth_ctx, cksumtype) \
45  krb5_auth_con_set_req_cksumtype(ctx, auth_ctx, cksumtype)
46 #define krb5glue_set_principal_realm(ctx, principal, realm) \
47  krb5_set_principal_realm(ctx, principal, realm)
48 #define krb5glue_free_keytab_entry_contents(ctx, entry) krb5_free_keytab_entry_contents(ctx, entry)
49 #define krb5glue_auth_con_setuseruserkey(ctx, auth_ctx, keytab) \
50  krb5_auth_con_setuseruserkey(ctx, auth_ctx, keytab)
51 #define krb5glue_free_data_contents(ctx, data) krb5_free_data_contents(ctx, data)
52 krb5_prompt_type krb5glue_get_prompt_type(krb5_context ctx, krb5_prompt prompts[], int index);
53 
54 #define krb5glue_creds_getkey(creds) creds.keyblock
55 
56 #elif defined(WITH_KRB5_HEIMDAL)
57 typedef krb5_crypto krb5glue_key;
58 typedef krb5_authenticator krb5glue_authenticator;
59 
60 krb5_error_code krb5glue_crypto_length(krb5_context ctx, krb5glue_key key, int type,
61  unsigned int* size);
62 #define krb5glue_crypto_length_iov(ctx, key, iov, size) krb5_crypto_length_iov(ctx, key, iov, size)
63 #define krb5glue_encrypt_iov(ctx, key, usage, iov, size) \
64  krb5_encrypt_iov_ivec(ctx, key, usage, iov, size, NULL)
65 #define krb5glue_decrypt_iov(ctx, key, usage, iov, size) \
66  krb5_decrypt_iov_ivec(ctx, key, usage, iov, size, NULL)
67 #define krb5glue_make_checksum_iov(ctx, key, usage, iov, size) \
68  krb5_create_checksum_iov(ctx, key, usage, iov, size, NULL)
69 krb5_error_code krb5glue_verify_checksum_iov(krb5_context ctx, krb5glue_key key, unsigned usage,
70  krb5_crypto_iov* iov, unsigned int iov_size,
71  krb5_boolean* is_valid);
72 #define krb5glue_auth_con_set_cksumtype(ctx, auth_ctx, cksumtype) \
73  krb5_auth_con_setcksumtype(ctx, auth_ctx, cksumtype)
74 #define krb5glue_set_principal_realm(ctx, principal, realm) \
75  krb5_principal_set_realm(ctx, principal, realm)
76 #define krb5glue_free_keytab_entry_contents(ctx, entry) krb5_kt_free_entry(ctx, entry)
77 #define krb5glue_auth_con_setuseruserkey(ctx, auth_ctx, keytab) \
78  krb5_auth_con_setuserkey(ctx, auth_ctx, keytab)
79 #define krb5glue_free_data_contents(ctx, data) krb5_data_free(data)
80 #define krb5glue_get_prompt_type(ctx, prompts, index) prompts[index].type
81 
82 #define krb5glue_creds_getkey(creds) creds.session
83 #else
84 #error "Missing implementation for KRB5 provider"
85 #endif
86 
88 {
89  krb5glue_key session_key;
90  krb5glue_key initiator_key;
91  krb5glue_key acceptor_key;
92 };
93 
94 void krb5glue_keys_free(krb5_context ctx, struct krb5glue_keyset* keyset);
95 krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_ctx, BOOL acceptor,
96  struct krb5glue_keyset* keyset);
97 krb5_error_code krb5glue_log_error(krb5_context ctx, krb5_data* msg, const char* tag);
98 BOOL krb5glue_authenticator_validate_chksum(krb5glue_authenticator authenticator, int cksumtype,
99  uint32_t* flags);
100 krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ, krb5_ccache ccache,
101  krb5_prompter_fct prompter, char* password,
102  SEC_WINPR_KERBEROS_SETTINGS* krb_settings);
103 
104 #endif /* WINPR_SSPI_KERBEROS_GLUE_PRIVATE_H */