kerberosgss.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright (c) 2006-2009 Apple Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. **/
  16. #ifndef KERBEROS_GSS_H
  17. #define KERBEROS_GSS_H
  18. #include <stdbool.h>
  19. #include <gssapi/gssapi.h>
  20. #include <gssapi/gssapi_generic.h>
  21. #include <gssapi/gssapi_krb5.h>
  22. #define krb5_get_err_text(context,code) error_message(code)
  23. #define AUTH_GSS_ERROR -1
  24. #define AUTH_GSS_COMPLETE 1
  25. #define AUTH_GSS_CONTINUE 0
  26. #define GSS_AUTH_P_NONE 1
  27. #define GSS_AUTH_P_INTEGRITY 2
  28. #define GSS_AUTH_P_PRIVACY 4
  29. typedef struct {
  30. int return_code;
  31. char *message;
  32. } gss_client_response;
  33. typedef struct {
  34. gss_ctx_id_t context;
  35. gss_name_t server_name;
  36. long int gss_flags;
  37. char* username;
  38. char* response;
  39. char* credentials_cache;
  40. } gss_client_state;
  41. typedef struct {
  42. gss_ctx_id_t context;
  43. gss_name_t server_name;
  44. gss_name_t client_name;
  45. gss_cred_id_t server_creds;
  46. gss_cred_id_t client_creds;
  47. char* username;
  48. char* targetname;
  49. char* response;
  50. bool constrained_delegation;
  51. char* delegated_credentials_cache;
  52. } gss_server_state;
  53. // char* server_principal_details(const char* service, const char* hostname);
  54. gss_client_response *authenticate_gss_client_init(const char* service, long int gss_flags, const char* credentials_cache, gss_client_state* state);
  55. gss_client_response *authenticate_gss_client_clean(gss_client_state *state);
  56. gss_client_response *authenticate_gss_client_step(gss_client_state *state, const char *challenge);
  57. gss_client_response *authenticate_gss_client_unwrap(gss_client_state* state, const char* challenge);
  58. gss_client_response *authenticate_gss_client_wrap(gss_client_state* state, const char* challenge, const char* user);
  59. gss_client_response *authenticate_gss_server_init(const char* service, bool constrained_delegation, const char *username, gss_server_state* state);
  60. gss_client_response *authenticate_gss_server_clean(gss_server_state *state);
  61. gss_client_response *authenticate_gss_server_step(gss_server_state *state, const char *challenge);
  62. gss_client_response *authenticate_user_krb5_password(const char *username,
  63. const char *password,
  64. const char *service);
  65. OM_uint32 gss_krb5_import_cred(OM_uint32 *minor_status,
  66. krb5_ccache id, krb5_principal keytab_principal,
  67. krb5_keytab keytab, gss_cred_id_t *cred);
  68. #endif