diff options
Diffstat (limited to 'drivers/target/iscsi/iscsi_target_auth.c')
| -rw-r--r-- | drivers/target/iscsi/iscsi_target_auth.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index 11fd74307811..beb39469e7f1 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
| 19 | ******************************************************************************/ | 19 | ******************************************************************************/ |
| 20 | 20 | ||
| 21 | #include <linux/kernel.h> | ||
| 21 | #include <linux/string.h> | 22 | #include <linux/string.h> |
| 22 | #include <linux/crypto.h> | 23 | #include <linux/crypto.h> |
| 23 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| @@ -27,40 +28,11 @@ | |||
| 27 | #include "iscsi_target_nego.h" | 28 | #include "iscsi_target_nego.h" |
| 28 | #include "iscsi_target_auth.h" | 29 | #include "iscsi_target_auth.h" |
| 29 | 30 | ||
| 30 | static unsigned char chap_asciihex_to_binaryhex(unsigned char val[2]) | ||
| 31 | { | ||
| 32 | unsigned char result = 0; | ||
| 33 | /* | ||
| 34 | * MSB | ||
| 35 | */ | ||
| 36 | if ((val[0] >= 'a') && (val[0] <= 'f')) | ||
| 37 | result = ((val[0] - 'a' + 10) & 0xf) << 4; | ||
| 38 | else | ||
| 39 | if ((val[0] >= 'A') && (val[0] <= 'F')) | ||
| 40 | result = ((val[0] - 'A' + 10) & 0xf) << 4; | ||
| 41 | else /* digit */ | ||
| 42 | result = ((val[0] - '0') & 0xf) << 4; | ||
| 43 | /* | ||
| 44 | * LSB | ||
| 45 | */ | ||
| 46 | if ((val[1] >= 'a') && (val[1] <= 'f')) | ||
| 47 | result |= ((val[1] - 'a' + 10) & 0xf); | ||
| 48 | else | ||
| 49 | if ((val[1] >= 'A') && (val[1] <= 'F')) | ||
| 50 | result |= ((val[1] - 'A' + 10) & 0xf); | ||
| 51 | else /* digit */ | ||
| 52 | result |= ((val[1] - '0') & 0xf); | ||
| 53 | |||
| 54 | return result; | ||
| 55 | } | ||
| 56 | |||
| 57 | static int chap_string_to_hex(unsigned char *dst, unsigned char *src, int len) | 31 | static int chap_string_to_hex(unsigned char *dst, unsigned char *src, int len) |
| 58 | { | 32 | { |
| 59 | int i, j = 0; | 33 | int j = DIV_ROUND_UP(len, 2); |
| 60 | 34 | ||
| 61 | for (i = 0; i < len; i += 2) { | 35 | hex2bin(dst, src, j); |
| 62 | dst[j++] = (unsigned char) chap_asciihex_to_binaryhex(&src[i]); | ||
| 63 | } | ||
| 64 | 36 | ||
| 65 | dst[j] = '\0'; | 37 | dst[j] = '\0'; |
| 66 | return j; | 38 | return j; |
