mirror of
https://github.com/strongswan/strongswan.git
synced 2025-12-08 00:00:29 -05:00
implemented asn1_get_known_oid(), mapping OID index to ASN1 OID
This commit is contained in:
parent
9c4387edcd
commit
56807f35b9
@ -217,6 +217,35 @@ int asn1_known_oid(chunk_t object)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defined in header.
|
||||||
|
*/
|
||||||
|
chunk_t asn1_get_known_oid(int n)
|
||||||
|
{
|
||||||
|
chunk_t oid;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (n < 0 || n >= OID_MAX)
|
||||||
|
{
|
||||||
|
return chunk_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = oid_names[n].level + 1;
|
||||||
|
oid = chunk_alloc(i);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (oid_names[n].level >= i)
|
||||||
|
{
|
||||||
|
n--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
oid.ptr[--i] = oid_names[n--].octet;
|
||||||
|
}
|
||||||
|
while (i > 0);
|
||||||
|
|
||||||
|
return oid;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defined in header.
|
* Defined in header.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -106,6 +106,14 @@ chunk_t asn1_algorithmIdentifier(int oid);
|
|||||||
*/
|
*/
|
||||||
int asn1_known_oid(chunk_t object);
|
int asn1_known_oid(chunk_t object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an known OID index to ASN.1 OID
|
||||||
|
*
|
||||||
|
* @param n index into the oid_names[] table
|
||||||
|
* @return allocated OID chunk, chunk_empty if index out of range
|
||||||
|
*/
|
||||||
|
chunk_t asn1_get_known_oid(int n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length of an ASN.1 object
|
* Returns the length of an ASN.1 object
|
||||||
* The blob pointer is advanced past the tag length fields
|
* The blob pointer is advanced past the tag length fields
|
||||||
|
|||||||
@ -38,6 +38,7 @@ print OID_H "/* Object identifiers (OIDs) used by strongSwan\n",
|
|||||||
" u_char octet;\n",
|
" u_char octet;\n",
|
||||||
" u_int next;\n",
|
" u_int next;\n",
|
||||||
" u_int down;\n",
|
" u_int down;\n",
|
||||||
|
" u_int level;\n",
|
||||||
" const u_char *name;\n",
|
" const u_char *name;\n",
|
||||||
"} oid_t;\n",
|
"} oid_t;\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -77,6 +78,8 @@ while ($line = <SRC>)
|
|||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf OID_H "\n#define OID_MAX%s%d\n", "\t" x 8, $counter;
|
||||||
|
|
||||||
print OID_H "\n#endif /* OID_H_ */\n";
|
print OID_H "\n#endif /* OID_H_ */\n";
|
||||||
|
|
||||||
close SRC;
|
close SRC;
|
||||||
@ -113,12 +116,13 @@ for ($c = 0; $c < $counter; $c++)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf OID_C " {%s%s,%s%3d, %d, %s%s}%s /* %3d */\n"
|
printf OID_C " {%s%s,%s%3d, %d, %2d, %s%s}%s /* %3d */\n"
|
||||||
,' ' x @order[$c]
|
,' ' x @order[$c]
|
||||||
, @octet[$c]
|
, @octet[$c]
|
||||||
, ' ' x (1 + $max_order - @order[$c])
|
, ' ' x (1 + $max_order - @order[$c])
|
||||||
, @next[$c]
|
, @next[$c]
|
||||||
, @order[$c+1] > @order[$c]
|
, @order[$c+1] > @order[$c]
|
||||||
|
, @order[$c] / 2
|
||||||
, @name[$c]
|
, @name[$c]
|
||||||
, ' ' x ($max_name - length(@name[$c]))
|
, ' ' x ($max_name - length(@name[$c]))
|
||||||
, $c != $counter-1 ? "," : " "
|
, $c != $counter-1 ? "," : " "
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user