Rev 14 | Rev 16 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 14 | Rev 15 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | * limitations under the License. |
18 | * limitations under the License. |
19 | */ |
19 | */ |
20 | 20 | ||
21 | // All functions in this library are compatible with leading zeroes (not recommended) and leading dots |
21 | // All functions in this library are compatible with leading zeroes (not recommended) and leading dots |
22 | 22 | ||
23 | // TODO: change some function names, so that they have a uniform naming schema, and rename "oid identifier" into "asn.1 alphanumeric identifier" |
23 | // TODO: change some function names, so that they have a uniform naming schema, and rename "oid identifier" into "ASN.1 alphanumeric identifier" |
24 | // oid_id_is_valid() => asn1_alpha_id_valid() |
24 | // oid_id_is_valid() => asn1_alpha_id_valid() |
25 | 25 | ||
26 | define('OID_DOT_FORBIDDEN', 0); |
26 | define('OID_DOT_FORBIDDEN', 0); |
27 | define('OID_DOT_OPTIONAL', 1); |
27 | define('OID_DOT_OPTIONAL', 1); |
28 | define('OID_DOT_REQUIRED', 2); |
28 | define('OID_DOT_REQUIRED', 2); |
Line 339... | Line 339... | ||
339 | **/ |
339 | **/ |
340 | $oid_sanitize_cache = array(); |
340 | $oid_sanitize_cache = array(); |
341 | function sanitizeOID($oid, $leading_dot=false) { |
341 | function sanitizeOID($oid, $leading_dot=false) { |
342 | if ($leading_dot) $leading_dot = substr($oid,0,1) == '.'; |
342 | if ($leading_dot) $leading_dot = substr($oid,0,1) == '.'; |
343 | 343 | ||
344 | // We are using a cache, since this function is used very often by OID+ |
344 | // We are using a cache, since this function is used very often by OIDplus |
345 | global $oid_sanitize_cache; |
345 | global $oid_sanitize_cache; |
346 | $v = ($leading_dot ? 'T' : 'F').$oid; |
346 | $v = ($leading_dot ? 'T' : 'F').$oid; |
347 | if (isset($oid_sanitize_cache[$v])) return $oid_sanitize_cache[$v]; |
347 | if (isset($oid_sanitize_cache[$v])) return $oid_sanitize_cache[$v]; |
348 | 348 | ||
349 | if ($leading_dot) { |
349 | if ($leading_dot) { |
Line 811... | Line 811... | ||
811 | $standardized = asn1_get_standardized_array(); |
811 | $standardized = asn1_get_standardized_array(); |
812 | 812 | ||
813 | // Clean up |
813 | // Clean up |
814 | $count = -1; |
814 | $count = -1; |
815 | $asn = preg_replace('@^\\{(.+)\\}$@', '\\1', $asn, -1, $count); |
815 | $asn = preg_replace('@^\\{(.+)\\}$@', '\\1', $asn, -1, $count); |
816 | if ($count == 0) return false; // { and } are required. The asn.1 path will NOT be trimmed by this function |
816 | if ($count == 0) return false; // { and } are required. The ASN.1 path will NOT be trimmed by this function |
817 | 817 | ||
818 | // If identifier is set, apply it (no check if it overrides a standardized identifier) |
818 | // If identifier is set, apply it (no check if it overrides a standardized identifier) |
819 | $asn = preg_replace('|\s*([a-z][a-zA-Z0-9-]*)\s*\((\d+)\)|', ' \\2', $asn); |
819 | $asn = preg_replace('|\s*([a-z][a-zA-Z0-9-]*)\s*\((\d+)\)|', ' \\2', $asn); |
820 | $asn = trim($asn); |
820 | $asn = trim($asn); |
821 | 821 |