k = strchr(a->alg_string, ':');
if (k) {
- unsigned i;
-
*k = 0;
a->key_string = k + 1;
if (strlen(a->key_string) & 1)
a->key = kmalloc(a->key_size, GFP_KERNEL);
if (!a->key)
goto nomem;
- for (i = 0; i < a->key_size; i++) {
- char digit[3];
- digit[0] = a->key_string[i * 2];
- digit[1] = a->key_string[i * 2 + 1];
- digit[2] = 0;
- if (strspn(digit, "0123456789abcdefABCDEF") != 2)
- goto inval;
- if (kstrtou8(digit, 16, &a->key[i]))
- goto inval;
- }
+ if (hex2bin(a->key, a->key_string, a->key_size))
+ goto inval;
}
return 0;