/usr/src/uts/common/io/comstar/port/iscsit/iscsit_authclient.h

https://github.com/buffygb/illumos-gate · C Header · 160 lines · 102 code · 30 blank · 28 comment · 0 complexity · 8bf8a4a74f88d928ef4b28423e8ba7cc MD5 · raw file

  1. /*
  2. * CDDL HEADER START
  3. *
  4. * The contents of this file are subject to the terms of the
  5. * Common Development and Distribution License (the "License").
  6. * You may not use this file except in compliance with the License.
  7. *
  8. * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  9. * or http://www.opensolaris.org/os/licensing.
  10. * See the License for the specific language governing permissions
  11. * and limitations under the License.
  12. *
  13. * When distributing Covered Code, include this CDDL HEADER in each
  14. * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15. * If applicable, add the following below this CDDL HEADER, with the
  16. * fields enclosed by brackets "[]" replaced with your own identifying
  17. * information: Portions Copyright [yyyy] [name of copyright owner]
  18. *
  19. * CDDL HEADER END
  20. */
  21. /*
  22. * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  23. * Use is subject to license terms.
  24. */
  25. #ifndef _ISCSIT_AUTHCLIENT_H_
  26. #define _ISCSIT_AUTHCLIENT_H_
  27. #define ISCSI_AUTH_PASSED 0
  28. #define ISCSI_AUTH_FAILED 1
  29. enum { iscsitAuthStringMaxLength = 256 };
  30. enum { AuthStringMaxLength = 256 };
  31. enum { AuthStringBlockMaxLength = 1024 };
  32. enum { AuthLargeBinaryMaxLength = 1024 };
  33. enum { iscsitAuthChapResponseLength = 16 };
  34. enum { iscsitAuthMethodMaxCount = 2 };
  35. enum { iscsitAuthChapAlgorithmMd5 = 5 };
  36. enum {
  37. AKT_CHAP_A = 0,
  38. AKT_CHAP_I,
  39. AKT_CHAP_C,
  40. AKT_CHAP_N,
  41. AKT_CHAP_R,
  42. AUTH_KEY_TYPE_MAX
  43. };
  44. typedef union auth_value {
  45. uint32_t numeric;
  46. char *string;
  47. unsigned char *binary;
  48. } auth_value_t;
  49. typedef struct auth_key {
  50. unsigned char present;
  51. unsigned int len;
  52. auth_value_t value;
  53. } auth_key_t;
  54. typedef struct iscsit_auth_key_block {
  55. auth_key_t key[AUTH_KEY_TYPE_MAX];
  56. } auth_key_block_t;
  57. typedef struct auth_large_binary {
  58. unsigned char largeBinary[AuthLargeBinaryMaxLength];
  59. } auth_large_binary_t;
  60. typedef enum {
  61. AM_CHAP = 1, /* keep 0 as invalid */
  62. AM_KRB5,
  63. AM_SPKM1,
  64. AM_SPKM2,
  65. AM_SRP,
  66. AM_NONE
  67. } iscsit_auth_method_t;
  68. typedef enum {
  69. /* authentication phase start status */
  70. AP_AM_UNDECIDED = 0,
  71. AP_AM_PROPOSED,
  72. AP_AM_DECIDED,
  73. /* authentication phase for chap */
  74. AP_CHAP_A_WAITING,
  75. AP_CHAP_A_RCVD,
  76. AP_CHAP_R_WAITING,
  77. AP_CHAP_R_RCVD,
  78. /* authentication phase for kerberos */
  79. AP_KRB_REQ_WAITING,
  80. AP_KRB_REQ_RCVD,
  81. /* authentication phase done */
  82. AP_DONE
  83. } iscsit_auth_phase_t;
  84. typedef struct iscsit_auth_client {
  85. iscsit_auth_phase_t phase;
  86. iscsit_auth_method_t negotiatedMethod;
  87. auth_large_binary_t auth_send_binary_block;
  88. auth_key_block_t recvKeyBlock;
  89. auth_key_block_t sendKeyBlock;
  90. } iscsit_auth_client_t;
  91. void
  92. client_set_numeric_data(auth_key_block_t *keyBlock,
  93. int key_type,
  94. uint32_t numeric);
  95. void
  96. client_set_string_data(auth_key_block_t *keyBlock,
  97. int key_type,
  98. char *string);
  99. void
  100. client_set_binary_data(auth_key_block_t *keyBlock,
  101. int key_type,
  102. unsigned char *binary, unsigned int len);
  103. void
  104. client_get_numeric_data(auth_key_block_t *keyBlock,
  105. int key_type,
  106. uint32_t *numeric);
  107. void
  108. client_get_string_data(auth_key_block_t *keyBlock,
  109. int key_type,
  110. char **string);
  111. void
  112. client_get_binary_data(auth_key_block_t *keyBlock,
  113. int key_type,
  114. unsigned char **binary, unsigned int *len);
  115. int
  116. client_auth_key_present(auth_key_block_t *keyBlock,
  117. int key_type);
  118. void
  119. client_compute_chap_resp(uchar_t *resp,
  120. unsigned int chap_i,
  121. uint8_t *password, int password_len,
  122. uchar_t *chap_c, unsigned int challenge_len);
  123. int
  124. client_verify_chap_resp(char *target_chap_name, char *initiator_chap_name,
  125. uint8_t *password, int password_len,
  126. unsigned int chap_i, uchar_t *chap_c, unsigned int challenge_len,
  127. uchar_t *chap_r, unsigned int resp_len);
  128. void
  129. auth_random_set_data(uchar_t *data, unsigned int length);
  130. #endif /* _ISCSIT_AUTHCLIENT_H_ */