ported parts of two-sim branch
eap_identity parameter to exchange in eap_identity some auth_info/peer_cfg refactorings fixed some bugs, introduced new ones
This commit is contained in:
@@ -298,16 +298,28 @@ static char hex2bin(char hex)
|
||||
chunk_t chunk_from_hex(chunk_t hex, char *buf)
|
||||
{
|
||||
int i, len;
|
||||
bool odd = FALSE;
|
||||
|
||||
len = hex.len / 2;
|
||||
len = (hex.len / 2);
|
||||
if (hex.len % 2)
|
||||
{
|
||||
odd = TRUE;
|
||||
len++;
|
||||
}
|
||||
if (!buf)
|
||||
{
|
||||
buf = malloc(len);
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
/* buffer is filled from the right */
|
||||
memset(buf, 0, len);
|
||||
hex.ptr += hex.len;
|
||||
for (i = len - 1; i >= 0; i--)
|
||||
{
|
||||
buf[i] = hex2bin(*hex.ptr++) << 4;
|
||||
buf[i] |= hex2bin(*hex.ptr++);
|
||||
buf[i] = hex2bin(*(--hex.ptr));
|
||||
if (i > 0 || !odd)
|
||||
{
|
||||
buf[i] |= hex2bin(*(--hex.ptr)) << 4;
|
||||
}
|
||||
}
|
||||
return chunk_create(buf, len);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,8 @@ chunk_t chunk_to_hex(chunk_t chunk, char *buf, bool uppercase);
|
||||
/**
|
||||
* Convert a hex encoded in a binary chunk.
|
||||
*
|
||||
* If buf is supplied, it must hold at least (hex.len / 2).
|
||||
* If buf is supplied, it must hold at least (hex.len / 2) + (hex.len % 2)
|
||||
* bytes. It is filled by the right to give correct values for short inputs.
|
||||
*
|
||||
* @param hex hex encoded input data
|
||||
* @param buf buffer to write decoded data, NULL to malloc
|
||||
@@ -164,7 +165,7 @@ void chunk_clear(chunk_t *chunk);
|
||||
/**
|
||||
* Clone a chunk on heap
|
||||
*/
|
||||
#define chunk_clone(chunk) chunk_create_clone(malloc(chunk.len), chunk)
|
||||
#define chunk_clone(chunk) chunk_create_clone((chunk).len ? malloc(chunk.len) : NULL, chunk)
|
||||
|
||||
/**
|
||||
* Clone a chunk on stack
|
||||
|
||||
@@ -915,6 +915,7 @@ static int print(FILE *stream, const struct printf_info *info,
|
||||
case ID_FQDN:
|
||||
case ID_RFC822_ADDR:
|
||||
case ID_DER_ASN1_GN_URI:
|
||||
case ID_EAP:
|
||||
proper = sanitize_chunk(this->encoded);
|
||||
snprintf(buf, sizeof(buf), "%.*s", proper.len, proper.ptr);
|
||||
chunk_free(&proper);
|
||||
@@ -1169,6 +1170,7 @@ identification_t *identification_create_from_encoding(id_type_t type, chunk_t en
|
||||
case ID_PUBKEY_INFO_SHA1:
|
||||
case ID_PUBKEY_SHA1:
|
||||
case ID_CERT_DER_SHA1:
|
||||
case ID_EAP:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -142,6 +142,11 @@ enum id_type_t {
|
||||
* SHA1 hash of the binary DER encoding of a certificate
|
||||
*/
|
||||
ID_CERT_DER_SHA1,
|
||||
|
||||
/**
|
||||
* Generic EAP identity
|
||||
*/
|
||||
ID_EAP,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user