mirror of https://github.com/openssl/openssl.git
Add NumericString support
GOST requires improved NumericString support. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
parent
26d57a1a92
commit
68572c8af3
|
|
@ -72,6 +72,7 @@ static int cpy_asc(unsigned long value, void *arg);
|
||||||
static int cpy_bmp(unsigned long value, void *arg);
|
static int cpy_bmp(unsigned long value, void *arg);
|
||||||
static int cpy_univ(unsigned long value, void *arg);
|
static int cpy_univ(unsigned long value, void *arg);
|
||||||
static int cpy_utf8(unsigned long value, void *arg);
|
static int cpy_utf8(unsigned long value, void *arg);
|
||||||
|
static int is_numeric(unsigned long value);
|
||||||
static int is_printable(unsigned long value);
|
static int is_printable(unsigned long value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -169,7 +170,9 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
|
||||||
|
|
||||||
/* Now work out output format and string type */
|
/* Now work out output format and string type */
|
||||||
outform = MBSTRING_ASC;
|
outform = MBSTRING_ASC;
|
||||||
if (mask & B_ASN1_PRINTABLESTRING)
|
if (mask & B_ASN1_NUMERICSTRING)
|
||||||
|
str_type = V_ASN1_NUMERICSTRING;
|
||||||
|
else if (mask & B_ASN1_PRINTABLESTRING)
|
||||||
str_type = V_ASN1_PRINTABLESTRING;
|
str_type = V_ASN1_PRINTABLESTRING;
|
||||||
else if (mask & B_ASN1_IA5STRING)
|
else if (mask & B_ASN1_IA5STRING)
|
||||||
str_type = V_ASN1_IA5STRING;
|
str_type = V_ASN1_IA5STRING;
|
||||||
|
|
@ -320,6 +323,8 @@ static int type_str(unsigned long value, void *arg)
|
||||||
{
|
{
|
||||||
unsigned long types;
|
unsigned long types;
|
||||||
types = *((unsigned long *)arg);
|
types = *((unsigned long *)arg);
|
||||||
|
if ((types & B_ASN1_NUMERICSTRING) && !is_numeric(value))
|
||||||
|
types &= ~B_ASN1_NUMERICSTRING;
|
||||||
if ((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
|
if ((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
|
||||||
types &= ~B_ASN1_PRINTABLESTRING;
|
types &= ~B_ASN1_PRINTABLESTRING;
|
||||||
if ((types & B_ASN1_IA5STRING) && (value > 127))
|
if ((types & B_ASN1_IA5STRING) && (value > 127))
|
||||||
|
|
@ -419,3 +424,12 @@ static int is_printable(unsigned long value)
|
||||||
#endif /* CHARSET_EBCDIC */
|
#endif /* CHARSET_EBCDIC */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_numeric(unsigned long value)
|
||||||
|
{
|
||||||
|
if (value > '9')
|
||||||
|
return 0;
|
||||||
|
if (value < '0' && value != 32)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,10 @@ static const ASN1_STRING_TABLE tbl_standard[] = {
|
||||||
{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
|
{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||||
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||||
{NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
|
{NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
|
||||||
{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
|
{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
|
||||||
|
{NID_INN, 1, 12, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
|
||||||
|
{NID_OGRN, 1, 13, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
|
||||||
|
{NID_SNILS, 1, 11, B_ASN1_NUMERICSTRING, STABLE_NO_MASK}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sk_table_cmp(const ASN1_STRING_TABLE *const *a,
|
static int sk_table_cmp(const ASN1_STRING_TABLE *const *a,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue