OpenSSL 1.1.1-pre2
This commit is contained in:
+10
-10
@@ -24,7 +24,7 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
unsigned char *p, *d;
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
len = a->length;
|
||||
|
||||
@@ -61,7 +61,7 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
|
||||
ret = 1 + len;
|
||||
if (pp == NULL)
|
||||
return (ret);
|
||||
return ret;
|
||||
|
||||
p = *pp;
|
||||
|
||||
@@ -73,7 +73,7 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
p[-1] &= (0xff << bits);
|
||||
}
|
||||
*pp = p;
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
@@ -96,7 +96,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL)) {
|
||||
if ((ret = ASN1_BIT_STRING_new()) == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
} else
|
||||
ret = (*a);
|
||||
|
||||
@@ -132,16 +132,16 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
if (a != NULL)
|
||||
(*a) = ret;
|
||||
*pp = p;
|
||||
return (ret);
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_C2I_ASN1_BIT_STRING, i);
|
||||
if ((a == NULL) || (*a != ret))
|
||||
ASN1_BIT_STRING_free(ret);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* These next 2 functions from Goetz Babin-Ebell <babinebell@trustcenter.de>
|
||||
* These next 2 functions from Goetz Babin-Ebell.
|
||||
*/
|
||||
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
|
||||
|
||||
if ((a->length < (w + 1)) || (a->data == NULL)) {
|
||||
if (!value)
|
||||
return (1); /* Don't need to set */
|
||||
return 1; /* Don't need to set */
|
||||
c = OPENSSL_clear_realloc(a->data, a->length, w + 1);
|
||||
if (c == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_BIT_STRING_SET_BIT, ERR_R_MALLOC_FAILURE);
|
||||
@@ -175,7 +175,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
|
||||
a->data[w] = ((a->data[w]) & iv) | v;
|
||||
while ((a->length > 0) && (a->data[a->length - 1] == 0))
|
||||
a->length--;
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n)
|
||||
@@ -185,7 +185,7 @@ int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n)
|
||||
w = n / 8;
|
||||
v = 1 << (7 - (n & 0x07));
|
||||
if ((a == NULL) || (a->length < (w + 1)) || (a->data == NULL))
|
||||
return (0);
|
||||
return 0;
|
||||
return ((a->data[w] & v) != 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#include "internal/numbers.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);
|
||||
#include "internal/asn1_int.h"
|
||||
|
||||
#ifndef NO_OLD_ASN1
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
@@ -26,12 +25,12 @@ void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x)
|
||||
|
||||
if ((b = BIO_new(BIO_s_file())) == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_D2I_FP, ERR_R_BUF_LIB);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
BIO_set_fp(b, in, BIO_NOCLOSE);
|
||||
ret = ASN1_d2i_bio(xnew, d2i, b, x);
|
||||
BIO_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -50,7 +49,7 @@ void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x)
|
||||
ret = d2i(x, &p, len);
|
||||
err:
|
||||
BUF_MEM_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -70,7 +69,7 @@ void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
|
||||
ret = ASN1_item_d2i(x, &p, len, it);
|
||||
err:
|
||||
BUF_MEM_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
@@ -81,18 +80,18 @@ void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
|
||||
|
||||
if ((b = BIO_new(BIO_s_file())) == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_D2I_FP, ERR_R_BUF_LIB);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
BIO_set_fp(b, in, BIO_NOCLOSE);
|
||||
ret = ASN1_item_d2i_bio(it, b, x);
|
||||
BIO_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define HEADER_SIZE 8
|
||||
#define ASN1_CHUNK_INITIAL_SIZE (16 * 1024)
|
||||
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
BUF_MEM *b;
|
||||
unsigned char *p;
|
||||
|
||||
@@ -29,7 +29,7 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
|
||||
i = i2d(data, NULL);
|
||||
if ((str = OPENSSL_malloc(i)) == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_MALLOC_FAILURE);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
p = str;
|
||||
i2d(data, &p);
|
||||
@@ -39,7 +39,7 @@ int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
|
||||
return 0;
|
||||
}
|
||||
OPENSSL_free(str);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -52,12 +52,12 @@ int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
|
||||
|
||||
i = ASN1_item_i2d(asn, &str, it);
|
||||
if (!str)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
if (!EVP_Digest(str, i, md, len, type, NULL)) {
|
||||
OPENSSL_free(str);
|
||||
return 0;
|
||||
}
|
||||
OPENSSL_free(str);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
+6
-6
@@ -21,20 +21,20 @@ void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
|
||||
char *ret;
|
||||
|
||||
if (x == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
i = i2d(x, NULL);
|
||||
b = OPENSSL_malloc(i + 10);
|
||||
if (b == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_DUP, ERR_R_MALLOC_FAILURE);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
p = b;
|
||||
i = i2d(x, &p);
|
||||
p2 = b;
|
||||
ret = d2i(NULL, &p2, i);
|
||||
OPENSSL_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -54,15 +54,15 @@ void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
|
||||
void *ret;
|
||||
|
||||
if (x == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
i = ASN1_item_i2d(x, &b, it);
|
||||
if (b == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_DUP, ERR_R_MALLOC_FAILURE);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
p = b;
|
||||
ret = ASN1_item_d2i(NULL, &p, i, it);
|
||||
OPENSSL_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
+20
-211
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -17,121 +17,13 @@
|
||||
#include <openssl/asn1.h>
|
||||
#include "asn1_locl.h"
|
||||
|
||||
/* This is the primary function used to parse ASN1_GENERALIZEDTIME */
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
|
||||
{
|
||||
static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||
char *a;
|
||||
int n, i, l, o;
|
||||
|
||||
/* wrapper around asn1_time_to_tm */
|
||||
if (d->type != V_ASN1_GENERALIZEDTIME)
|
||||
return (0);
|
||||
l = d->length;
|
||||
a = (char *)d->data;
|
||||
o = 0;
|
||||
/*
|
||||
* GENERALIZEDTIME is similar to UTCTIME except the year is represented
|
||||
* as YYYY. This stuff treats everything as a two digit field so make
|
||||
* first two fields 00 to 99
|
||||
*/
|
||||
if (l < 13)
|
||||
goto err;
|
||||
for (i = 0; i < 7; i++) {
|
||||
if ((i == 6) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||
i++;
|
||||
if (tm)
|
||||
tm->tm_sec = 0;
|
||||
break;
|
||||
}
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
if (++o > l)
|
||||
goto err;
|
||||
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
if (++o > l)
|
||||
goto err;
|
||||
|
||||
if ((n < min[i]) || (n > max[i]))
|
||||
goto err;
|
||||
if (tm) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
tm->tm_year = n * 100 - 1900;
|
||||
break;
|
||||
case 1:
|
||||
tm->tm_year += n;
|
||||
break;
|
||||
case 2:
|
||||
tm->tm_mon = n - 1;
|
||||
break;
|
||||
case 3:
|
||||
tm->tm_mday = n;
|
||||
break;
|
||||
case 4:
|
||||
tm->tm_hour = n;
|
||||
break;
|
||||
case 5:
|
||||
tm->tm_min = n;
|
||||
break;
|
||||
case 6:
|
||||
tm->tm_sec = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Optional fractional seconds: decimal point followed by one or more
|
||||
* digits.
|
||||
*/
|
||||
if (a[o] == '.') {
|
||||
if (++o > l)
|
||||
goto err;
|
||||
i = o;
|
||||
while ((a[o] >= '0') && (a[o] <= '9') && (o <= l))
|
||||
o++;
|
||||
/* Must have at least one digit after decimal point */
|
||||
if (i == o)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (a[o] == 'Z')
|
||||
o++;
|
||||
else if ((a[o] == '+') || (a[o] == '-')) {
|
||||
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
|
||||
o++;
|
||||
if (o + 4 > l)
|
||||
goto err;
|
||||
for (i = 7; i < 9; i++) {
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
o++;
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
if ((n < min[i]) || (n > max[i]))
|
||||
goto err;
|
||||
if (tm) {
|
||||
if (i == 7)
|
||||
offset = n * 3600;
|
||||
else if (i == 8)
|
||||
offset += n * 60;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||
return 0;
|
||||
} else if (a[o]) {
|
||||
/* Missing time zone information. */
|
||||
goto err;
|
||||
}
|
||||
return (o == l);
|
||||
err:
|
||||
return (0);
|
||||
return 0;
|
||||
return asn1_time_to_tm(tm, d);
|
||||
}
|
||||
|
||||
int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
|
||||
@@ -146,15 +38,15 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
|
||||
t.type = V_ASN1_GENERALIZEDTIME;
|
||||
t.length = strlen(str);
|
||||
t.data = (unsigned char *)str;
|
||||
if (ASN1_GENERALIZEDTIME_check(&t)) {
|
||||
if (s != NULL) {
|
||||
if (!ASN1_STRING_set((ASN1_STRING *)s, str, t.length))
|
||||
return 0;
|
||||
s->type = V_ASN1_GENERALIZEDTIME;
|
||||
}
|
||||
return (1);
|
||||
} else
|
||||
return (0);
|
||||
t.flags = 0;
|
||||
|
||||
if (!ASN1_GENERALIZEDTIME_check(&t))
|
||||
return 0;
|
||||
|
||||
if (s != NULL && !ASN1_STRING_copy(s, &t))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
|
||||
@@ -167,107 +59,24 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
|
||||
time_t t, int offset_day,
|
||||
long offset_sec)
|
||||
{
|
||||
char *p;
|
||||
struct tm *ts;
|
||||
struct tm data;
|
||||
size_t len = 20;
|
||||
ASN1_GENERALIZEDTIME *tmps = NULL;
|
||||
|
||||
if (s == NULL)
|
||||
tmps = ASN1_GENERALIZEDTIME_new();
|
||||
else
|
||||
tmps = s;
|
||||
if (tmps == NULL)
|
||||
return NULL;
|
||||
|
||||
ts = OPENSSL_gmtime(&t, &data);
|
||||
if (ts == NULL)
|
||||
goto err;
|
||||
return NULL;
|
||||
|
||||
if (offset_day || offset_sec) {
|
||||
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||
goto err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = (char *)tmps->data;
|
||||
if ((p == NULL) || ((size_t)tmps->length < len)) {
|
||||
p = OPENSSL_malloc(len);
|
||||
if (p == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
OPENSSL_free(tmps->data);
|
||||
tmps->data = (unsigned char *)p;
|
||||
}
|
||||
|
||||
BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900,
|
||||
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||
ts->tm_sec);
|
||||
tmps->length = strlen(p);
|
||||
tmps->type = V_ASN1_GENERALIZEDTIME;
|
||||
#ifdef CHARSET_EBCDIC_not
|
||||
ebcdic2ascii(tmps->data, tmps->data, tmps->length);
|
||||
#endif
|
||||
return tmps;
|
||||
err:
|
||||
if (s == NULL)
|
||||
ASN1_GENERALIZEDTIME_free(tmps);
|
||||
return NULL;
|
||||
return asn1_time_from_tm(s, ts, V_ASN1_GENERALIZEDTIME);
|
||||
}
|
||||
|
||||
const char *_asn1_mon[12] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
|
||||
{
|
||||
char *v;
|
||||
int gmt = 0;
|
||||
int i;
|
||||
int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
|
||||
char *f = NULL;
|
||||
int f_len = 0;
|
||||
|
||||
i = tm->length;
|
||||
v = (char *)tm->data;
|
||||
|
||||
if (i < 12)
|
||||
goto err;
|
||||
if (v[i - 1] == 'Z')
|
||||
gmt = 1;
|
||||
for (i = 0; i < 12; i++)
|
||||
if ((v[i] > '9') || (v[i] < '0'))
|
||||
goto err;
|
||||
y = (v[0] - '0') * 1000 + (v[1] - '0') * 100
|
||||
+ (v[2] - '0') * 10 + (v[3] - '0');
|
||||
M = (v[4] - '0') * 10 + (v[5] - '0');
|
||||
if ((M > 12) || (M < 1))
|
||||
goto err;
|
||||
d = (v[6] - '0') * 10 + (v[7] - '0');
|
||||
h = (v[8] - '0') * 10 + (v[9] - '0');
|
||||
m = (v[10] - '0') * 10 + (v[11] - '0');
|
||||
if (tm->length >= 14 &&
|
||||
(v[12] >= '0') && (v[12] <= '9') &&
|
||||
(v[13] >= '0') && (v[13] <= '9')) {
|
||||
s = (v[12] - '0') * 10 + (v[13] - '0');
|
||||
/* Check for fractions of seconds. */
|
||||
if (tm->length >= 15 && v[14] == '.') {
|
||||
int l = tm->length;
|
||||
f = &v[14]; /* The decimal point. */
|
||||
f_len = 1;
|
||||
while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
|
||||
++f_len;
|
||||
}
|
||||
}
|
||||
|
||||
if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
|
||||
_asn1_mon[M - 1], d, h, m, s, f_len, f, y,
|
||||
(gmt) ? " GMT" : "") <= 0)
|
||||
return (0);
|
||||
else
|
||||
return (1);
|
||||
err:
|
||||
BIO_write(bp, "Bad time value", 14);
|
||||
return (0);
|
||||
if (tm->type != V_ASN1_GENERALIZEDTIME)
|
||||
return 0;
|
||||
return ASN1_TIME_print(bp, tm);
|
||||
}
|
||||
@@ -22,12 +22,12 @@ int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x)
|
||||
|
||||
if ((b = BIO_new(BIO_s_file())) == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_I2D_FP, ERR_R_BUF_LIB);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
BIO_set_fp(b, out, BIO_NOCLOSE);
|
||||
ret = ASN1_i2d_bio(i2d, b, x);
|
||||
BIO_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -44,7 +44,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
|
||||
b = OPENSSL_malloc(n);
|
||||
if (b == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = (unsigned char *)b;
|
||||
@@ -62,7 +62,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
|
||||
n -= i;
|
||||
}
|
||||
OPENSSL_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -75,12 +75,12 @@ int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||
|
||||
if ((b = BIO_new(BIO_s_file())) == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_I2D_FP, ERR_R_BUF_LIB);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
BIO_set_fp(b, out, BIO_NOCLOSE);
|
||||
ret = ASN1_item_i2d_bio(it, b, x);
|
||||
BIO_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -92,7 +92,7 @@ int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
|
||||
n = ASN1_item_i2d(x, &b, it);
|
||||
if (b == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO, ERR_R_MALLOC_FAILURE);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
@@ -107,5 +107,5 @@ int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
|
||||
n -= i;
|
||||
}
|
||||
OPENSSL_free(b);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
+4
-4
@@ -396,7 +396,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL)) {
|
||||
if ((ret = ASN1_INTEGER_new()) == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
ret->type = V_ASN1_INTEGER;
|
||||
} else
|
||||
ret = (*a);
|
||||
@@ -438,12 +438,12 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
|
||||
if (a != NULL)
|
||||
(*a) = ret;
|
||||
*pp = p;
|
||||
return (ret);
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_UINTEGER, i);
|
||||
if ((a == NULL) || (*a != ret))
|
||||
ASN1_INTEGER_free(ret);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
|
||||
@@ -487,7 +487,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
|
||||
err:
|
||||
if (ret != ai)
|
||||
ASN1_INTEGER_free(ret);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,
|
||||
|
||||
+9
-61
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
@@ -22,8 +22,6 @@ static int cpy_asc(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_utf8(unsigned long value, void *arg);
|
||||
static int is_numeric(unsigned long value);
|
||||
static int is_printable(unsigned long value);
|
||||
|
||||
/*
|
||||
* These functions take a string in UTF8, ASCII or multibyte form and a mask
|
||||
@@ -271,13 +269,15 @@ static int out_utf8(unsigned long value, void *arg)
|
||||
|
||||
static int type_str(unsigned long value, void *arg)
|
||||
{
|
||||
unsigned long types;
|
||||
types = *((unsigned long *)arg);
|
||||
if ((types & B_ASN1_NUMERICSTRING) && !is_numeric(value))
|
||||
unsigned long types = *((unsigned long *)arg);
|
||||
const int native = value > INT_MAX ? INT_MAX : ossl_fromascii(value);
|
||||
|
||||
if ((types & B_ASN1_NUMERICSTRING) && !(ossl_isdigit(native)
|
||||
|| native == ' '))
|
||||
types &= ~B_ASN1_NUMERICSTRING;
|
||||
if ((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
|
||||
if ((types & B_ASN1_PRINTABLESTRING) && !ossl_isasn1print(native))
|
||||
types &= ~B_ASN1_PRINTABLESTRING;
|
||||
if ((types & B_ASN1_IA5STRING) && (value > 127))
|
||||
if ((types & B_ASN1_IA5STRING) && !ossl_isascii(native))
|
||||
types &= ~B_ASN1_IA5STRING;
|
||||
if ((types & B_ASN1_T61STRING) && (value > 0xff))
|
||||
types &= ~B_ASN1_T61STRING;
|
||||
@@ -341,55 +341,3 @@ static int cpy_utf8(unsigned long value, void *arg)
|
||||
*p += ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return 1 if the character is permitted in a PrintableString */
|
||||
static int is_printable(unsigned long value)
|
||||
{
|
||||
int ch;
|
||||
if (value > 0x7f)
|
||||
return 0;
|
||||
ch = (int)value;
|
||||
/*
|
||||
* Note: we can't use 'isalnum' because certain accented characters may
|
||||
* count as alphanumeric in some environments.
|
||||
*/
|
||||
#ifndef CHARSET_EBCDIC
|
||||
if ((ch >= 'a') && (ch <= 'z'))
|
||||
return 1;
|
||||
if ((ch >= 'A') && (ch <= 'Z'))
|
||||
return 1;
|
||||
if ((ch >= '0') && (ch <= '9'))
|
||||
return 1;
|
||||
if ((ch == ' ') || strchr("'()+,-./:=?", ch))
|
||||
return 1;
|
||||
#else /* CHARSET_EBCDIC */
|
||||
if ((ch >= os_toascii['a']) && (ch <= os_toascii['z']))
|
||||
return 1;
|
||||
if ((ch >= os_toascii['A']) && (ch <= os_toascii['Z']))
|
||||
return 1;
|
||||
if ((ch >= os_toascii['0']) && (ch <= os_toascii['9']))
|
||||
return 1;
|
||||
if ((ch == os_toascii[' ']) || strchr("'()+,-./:=?", os_toebcdic[ch]))
|
||||
return 1;
|
||||
#endif /* CHARSET_EBCDIC */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return 1 if the character is a digit or space */
|
||||
static int is_numeric(unsigned long value)
|
||||
{
|
||||
int ch;
|
||||
if (value > 0x7f)
|
||||
return 0;
|
||||
ch = (int)value;
|
||||
#ifndef CHARSET_EBCDIC
|
||||
if (!isdigit(ch) && ch != ' ')
|
||||
return 0;
|
||||
#else
|
||||
if (ch > os_toascii['9'])
|
||||
return 0;
|
||||
if (ch < os_toascii['0'] && ch != os_toascii[' '])
|
||||
return 0;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
+17
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1.h>
|
||||
@@ -23,7 +24,7 @@ int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
|
||||
int objsize;
|
||||
|
||||
if ((a == NULL) || (a->data == NULL))
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
objsize = ASN1_object_size(0, a->length, V_ASN1_OBJECT);
|
||||
if (pp == NULL || objsize == -1)
|
||||
@@ -35,7 +36,7 @@ int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
|
||||
p += a->length;
|
||||
|
||||
*pp = p;
|
||||
return (objsize);
|
||||
return objsize;
|
||||
}
|
||||
|
||||
int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
|
||||
@@ -48,7 +49,7 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
|
||||
BIGNUM *bl = NULL;
|
||||
|
||||
if (num == 0)
|
||||
return (0);
|
||||
return 0;
|
||||
else if (num == -1)
|
||||
num = strlen(buf);
|
||||
|
||||
@@ -84,7 +85,7 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
|
||||
c = *(p++);
|
||||
if ((c == ' ') || (c == '.'))
|
||||
break;
|
||||
if ((c < '0') || (c > '9')) {
|
||||
if (!ossl_isdigit(c)) {
|
||||
ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_INVALID_DIGIT);
|
||||
goto err;
|
||||
}
|
||||
@@ -157,12 +158,12 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
|
||||
if (tmp != ftmp)
|
||||
OPENSSL_free(tmp);
|
||||
BN_free(bl);
|
||||
return (len);
|
||||
return len;
|
||||
err:
|
||||
if (tmp != ftmp)
|
||||
OPENSSL_free(tmp);
|
||||
BN_free(bl);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a)
|
||||
@@ -176,7 +177,7 @@ int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a)
|
||||
int i;
|
||||
|
||||
if ((a == NULL) || (a->data == NULL))
|
||||
return (BIO_write(bp, "NULL", 4));
|
||||
return BIO_write(bp, "NULL", 4);
|
||||
i = i2t_ASN1_OBJECT(buf, sizeof(buf), a);
|
||||
if (i > (int)(sizeof(buf) - 1)) {
|
||||
p = OPENSSL_malloc(i + 1);
|
||||
@@ -192,7 +193,7 @@ int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a)
|
||||
BIO_write(bp, p, i);
|
||||
if (p != buf)
|
||||
OPENSSL_free(p);
|
||||
return (i);
|
||||
return i;
|
||||
}
|
||||
|
||||
ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||
@@ -220,7 +221,7 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_D2I_ASN1_OBJECT, i);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||
@@ -280,7 +281,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||
if ((a == NULL) || ((*a) == NULL) ||
|
||||
!((*a)->flags & ASN1_OBJECT_FLAG_DYNAMIC)) {
|
||||
if ((ret = ASN1_OBJECT_new()) == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
} else
|
||||
ret = (*a);
|
||||
|
||||
@@ -311,12 +312,12 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
|
||||
if (a != NULL)
|
||||
(*a) = ret;
|
||||
*pp = p;
|
||||
return (ret);
|
||||
return ret;
|
||||
err:
|
||||
ASN1err(ASN1_F_C2I_ASN1_OBJECT, i);
|
||||
if ((a == NULL) || (*a != ret))
|
||||
ASN1_OBJECT_free(ret);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ASN1_OBJECT *ASN1_OBJECT_new(void)
|
||||
@@ -326,10 +327,10 @@ ASN1_OBJECT *ASN1_OBJECT_new(void)
|
||||
ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
if (ret == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
ret->flags = ASN1_OBJECT_FLAG_DYNAMIC;
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ASN1_OBJECT_free(ASN1_OBJECT *a)
|
||||
@@ -366,5 +367,5 @@ ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
|
||||
o.length = len;
|
||||
o.flags = ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |
|
||||
ASN1_OBJECT_FLAG_DYNAMIC_DATA;
|
||||
return (OBJ_dup(&o));
|
||||
return OBJ_dup(&o);
|
||||
}
|
||||
+16
-30
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
@@ -21,34 +21,20 @@ int ASN1_PRINTABLE_type(const unsigned char *s, int len)
|
||||
if (len <= 0)
|
||||
len = -1;
|
||||
if (s == NULL)
|
||||
return (V_ASN1_PRINTABLESTRING);
|
||||
return V_ASN1_PRINTABLESTRING;
|
||||
|
||||
while ((*s) && (len-- != 0)) {
|
||||
c = *(s++);
|
||||
#ifndef CHARSET_EBCDIC
|
||||
if (!(((c >= 'a') && (c <= 'z')) ||
|
||||
((c >= 'A') && (c <= 'Z')) ||
|
||||
((c >= '0') && (c <= '9')) ||
|
||||
(c == ' ') || (c == '\'') ||
|
||||
(c == '(') || (c == ')') ||
|
||||
(c == '+') || (c == ',') ||
|
||||
(c == '-') || (c == '.') ||
|
||||
(c == '/') || (c == ':') || (c == '=') || (c == '?')))
|
||||
if (!ossl_isasn1print(c))
|
||||
ia5 = 1;
|
||||
if (c & 0x80)
|
||||
if (!ossl_isascii(c))
|
||||
t61 = 1;
|
||||
#else
|
||||
if (!isalnum(c) && (c != ' ') && strchr("'()+,-./:=?", c) == NULL)
|
||||
ia5 = 1;
|
||||
if (os_toascii[c] & 0x80)
|
||||
t61 = 1;
|
||||
#endif
|
||||
}
|
||||
if (t61)
|
||||
return (V_ASN1_T61STRING);
|
||||
return V_ASN1_T61STRING;
|
||||
if (ia5)
|
||||
return (V_ASN1_IA5STRING);
|
||||
return (V_ASN1_PRINTABLESTRING);
|
||||
return V_ASN1_IA5STRING;
|
||||
return V_ASN1_PRINTABLESTRING;
|
||||
}
|
||||
|
||||
int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
|
||||
@@ -57,9 +43,9 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
|
||||
unsigned char *p;
|
||||
|
||||
if (s->type != V_ASN1_UNIVERSALSTRING)
|
||||
return (0);
|
||||
return 0;
|
||||
if ((s->length % 4) != 0)
|
||||
return (0);
|
||||
return 0;
|
||||
p = s->data;
|
||||
for (i = 0; i < s->length; i += 4) {
|
||||
if ((p[0] != '\0') || (p[1] != '\0') || (p[2] != '\0'))
|
||||
@@ -68,7 +54,7 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
|
||||
p += 4;
|
||||
}
|
||||
if (i < s->length)
|
||||
return (0);
|
||||
return 0;
|
||||
p = s->data;
|
||||
for (i = 3; i < s->length; i += 4) {
|
||||
*(p++) = s->data[i];
|
||||
@@ -76,7 +62,7 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
|
||||
*(p) = '\0';
|
||||
s->length /= 4;
|
||||
s->type = ASN1_PRINTABLE_type(s->data, s->length);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
|
||||
@@ -86,7 +72,7 @@ int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
|
||||
const char *p;
|
||||
|
||||
if (v == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
n = 0;
|
||||
p = (const char *)v->data;
|
||||
for (i = 0; i < v->length; i++) {
|
||||
@@ -98,12 +84,12 @@ int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
|
||||
n++;
|
||||
if (n >= 80) {
|
||||
if (BIO_write(bp, buf, n) <= 0)
|
||||
return (0);
|
||||
return 0;
|
||||
n = 0;
|
||||
}
|
||||
}
|
||||
if (n > 0)
|
||||
if (BIO_write(bp, buf, n) <= 0)
|
||||
return (0);
|
||||
return (1);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
+10
-6
@@ -103,7 +103,7 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
|
||||
EVP_MD_CTX_free(ctx);
|
||||
OPENSSL_clear_free((char *)buf_in, (unsigned int)inl);
|
||||
OPENSSL_clear_free((char *)buf_out, outll);
|
||||
return (outl);
|
||||
return outl;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -144,7 +144,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
|
||||
type = EVP_MD_CTX_md(ctx);
|
||||
pkey = EVP_PKEY_CTX_get0_pkey(EVP_MD_CTX_pkey_ctx(ctx));
|
||||
|
||||
if (type == NULL || pkey == NULL) {
|
||||
if (pkey == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_CONTEXT_NOT_INITIALISED);
|
||||
goto err;
|
||||
}
|
||||
@@ -169,10 +169,15 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
|
||||
ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB);
|
||||
if (rv <= 1)
|
||||
goto err;
|
||||
} else
|
||||
} else {
|
||||
rv = 2;
|
||||
}
|
||||
|
||||
if (rv == 2) {
|
||||
if (type == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_CONTEXT_NOT_INITIALISED);
|
||||
goto err;
|
||||
}
|
||||
if (!OBJ_find_sigid_by_algs(&signid,
|
||||
EVP_MD_nid(type),
|
||||
pkey->ameth->pkey_id)) {
|
||||
@@ -202,8 +207,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EVP_DigestSignUpdate(ctx, buf_in, inl)
|
||||
|| !EVP_DigestSignFinal(ctx, buf_out, &outl)) {
|
||||
if (!EVP_DigestSign(ctx, buf_out, &outl, buf_in, inl)) {
|
||||
outl = 0;
|
||||
ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
@@ -221,5 +225,5 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
|
||||
err:
|
||||
OPENSSL_clear_free((char *)buf_in, (unsigned int)inl);
|
||||
OPENSSL_clear_free((char *)buf_out, outll);
|
||||
return (outl);
|
||||
return outl;
|
||||
}
|
||||
+17
-88
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/objects.h>
|
||||
@@ -50,6 +49,7 @@ int ASN1_STRING_set_default_mask_asc(const char *p)
|
||||
{
|
||||
unsigned long mask;
|
||||
char *end;
|
||||
|
||||
if (strncmp(p, "MASK:", 5) == 0) {
|
||||
if (!p[5])
|
||||
return 0;
|
||||
@@ -84,19 +84,20 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
|
||||
ASN1_STRING *str = NULL;
|
||||
unsigned long mask;
|
||||
int ret;
|
||||
if (!out)
|
||||
|
||||
if (out == NULL)
|
||||
out = &str;
|
||||
tbl = ASN1_STRING_TABLE_get(nid);
|
||||
if (tbl) {
|
||||
if (tbl != NULL) {
|
||||
mask = tbl->mask;
|
||||
if (!(tbl->flags & STABLE_NO_MASK))
|
||||
mask &= global_mask;
|
||||
ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask,
|
||||
tbl->minsize, tbl->maxsize);
|
||||
} else
|
||||
ret =
|
||||
ASN1_mbstring_copy(out, in, inlen, inform,
|
||||
DIRSTRING_TYPE & global_mask);
|
||||
} else {
|
||||
ret = ASN1_mbstring_copy(out, in, inlen, inform,
|
||||
DIRSTRING_TYPE & global_mask);
|
||||
}
|
||||
if (ret <= 0)
|
||||
return NULL;
|
||||
return *out;
|
||||
@@ -106,54 +107,7 @@ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
|
||||
* Now the tables and helper functions for the string table:
|
||||
*/
|
||||
|
||||
/* size limits: this stuff is taken straight from RFC3280 */
|
||||
|
||||
#define ub_name 32768
|
||||
#define ub_common_name 64
|
||||
#define ub_locality_name 128
|
||||
#define ub_state_name 128
|
||||
#define ub_organization_name 64
|
||||
#define ub_organization_unit_name 64
|
||||
#define ub_title 64
|
||||
#define ub_email_address 128
|
||||
#define ub_serial_number 64
|
||||
|
||||
/* From RFC4524 */
|
||||
|
||||
#define ub_rfc822_mailbox 256
|
||||
|
||||
/* This table must be kept in NID order */
|
||||
|
||||
static const ASN1_STRING_TABLE tbl_standard[] = {
|
||||
{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
|
||||
{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||
{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
|
||||
{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
|
||||
{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
|
||||
{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE,
|
||||
0},
|
||||
{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING,
|
||||
STABLE_NO_MASK},
|
||||
{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
|
||||
{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
|
||||
{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
|
||||
{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING,
|
||||
STABLE_NO_MASK},
|
||||
{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
|
||||
{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, 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_rfc822Mailbox, 1, ub_rfc822_mailbox, B_ASN1_IA5STRING,
|
||||
STABLE_NO_MASK},
|
||||
{NID_jurisdictionCountryName, 2, 2, B_ASN1_PRINTABLESTRING, 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}
|
||||
};
|
||||
#include "tbl_standard.h"
|
||||
|
||||
static int sk_table_cmp(const ASN1_STRING_TABLE *const *a,
|
||||
const ASN1_STRING_TABLE *const *b)
|
||||
@@ -174,6 +128,7 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
{
|
||||
int idx;
|
||||
ASN1_STRING_TABLE fnd;
|
||||
|
||||
fnd.nid = nid;
|
||||
if (stable) {
|
||||
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
|
||||
@@ -191,6 +146,7 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
static ASN1_STRING_TABLE *stable_get(int nid)
|
||||
{
|
||||
ASN1_STRING_TABLE *tmp, *rv;
|
||||
|
||||
/* Always need a string table so allocate one if NULL */
|
||||
if (stable == NULL) {
|
||||
stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp);
|
||||
@@ -198,7 +154,7 @@ static ASN1_STRING_TABLE *stable_get(int nid)
|
||||
return NULL;
|
||||
}
|
||||
tmp = ASN1_STRING_TABLE_get(nid);
|
||||
if (tmp && tmp->flags & STABLE_FLAGS_MALLOC)
|
||||
if (tmp != NULL && tmp->flags & STABLE_FLAGS_MALLOC)
|
||||
return tmp;
|
||||
rv = OPENSSL_zalloc(sizeof(*rv));
|
||||
if (rv == NULL)
|
||||
@@ -207,7 +163,7 @@ static ASN1_STRING_TABLE *stable_get(int nid)
|
||||
OPENSSL_free(rv);
|
||||
return NULL;
|
||||
}
|
||||
if (tmp) {
|
||||
if (tmp != NULL) {
|
||||
rv->nid = tmp->nid;
|
||||
rv->minsize = tmp->minsize;
|
||||
rv->maxsize = tmp->maxsize;
|
||||
@@ -227,8 +183,9 @@ int ASN1_STRING_TABLE_add(int nid,
|
||||
unsigned long flags)
|
||||
{
|
||||
ASN1_STRING_TABLE *tmp;
|
||||
|
||||
tmp = stable_get(nid);
|
||||
if (!tmp) {
|
||||
if (tmp == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
@@ -246,8 +203,9 @@ int ASN1_STRING_TABLE_add(int nid,
|
||||
void ASN1_STRING_TABLE_cleanup(void)
|
||||
{
|
||||
STACK_OF(ASN1_STRING_TABLE) *tmp;
|
||||
|
||||
tmp = stable;
|
||||
if (!tmp)
|
||||
if (tmp == NULL)
|
||||
return;
|
||||
stable = NULL;
|
||||
sk_ASN1_STRING_TABLE_pop_free(tmp, st_free);
|
||||
@@ -258,32 +216,3 @@ static void st_free(ASN1_STRING_TABLE *tbl)
|
||||
if (tbl->flags & STABLE_FLAGS_MALLOC)
|
||||
OPENSSL_free(tbl);
|
||||
}
|
||||
|
||||
|
||||
#ifdef STRING_TABLE_TEST
|
||||
|
||||
main()
|
||||
{
|
||||
ASN1_STRING_TABLE *tmp;
|
||||
int i, last_nid = -1;
|
||||
|
||||
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) {
|
||||
if (tmp->nid < last_nid) {
|
||||
last_nid = 0;
|
||||
break;
|
||||
}
|
||||
last_nid = tmp->nid;
|
||||
}
|
||||
|
||||
if (last_nid != 0) {
|
||||
printf("Table order OK\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++)
|
||||
printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
|
||||
OBJ_nid2ln(tmp->nid));
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+444
-61
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1t.h>
|
||||
#include "asn1_locl.h"
|
||||
@@ -24,6 +25,291 @@ IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
|
||||
|
||||
static int is_utc(const int year)
|
||||
{
|
||||
if (50 <= year && year <= 149)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int leap_year(const int year)
|
||||
{
|
||||
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the day of the week and the day of the year from the year, month
|
||||
* and day. The day of the year is straightforward, the day of the week uses
|
||||
* a form of Zeller's congruence. For this months start with March and are
|
||||
* numbered 4 through 15.
|
||||
*/
|
||||
static void determine_days(struct tm *tm)
|
||||
{
|
||||
static const int ydays[12] = {
|
||||
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
|
||||
};
|
||||
int y = tm->tm_year + 1900;
|
||||
int m = tm->tm_mon;
|
||||
int d = tm->tm_mday;
|
||||
int c;
|
||||
|
||||
tm->tm_yday = ydays[m] + d - 1;
|
||||
if (m >= 2) {
|
||||
/* March and onwards can be one day further into the year */
|
||||
tm->tm_yday += leap_year(y);
|
||||
m += 2;
|
||||
} else {
|
||||
/* Treat January and February as part of the previous year */
|
||||
m += 14;
|
||||
y--;
|
||||
}
|
||||
c = y / 100;
|
||||
y %= 100;
|
||||
/* Zeller's congruance */
|
||||
tm->tm_wday = (d + (13 * m) / 5 + y + y / 4 + c / 4 + 5 * c + 6) % 7;
|
||||
}
|
||||
|
||||
int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
{
|
||||
static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||
static const int mdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
char *a;
|
||||
int n, i, i2, l, o, min_l = 11, strict = 0, end = 6, btz = 5, md;
|
||||
struct tm tmp;
|
||||
|
||||
/*
|
||||
* ASN1_STRING_FLAG_X509_TIME is used to enforce RFC 5280
|
||||
* time string format, in which:
|
||||
*
|
||||
* 1. "seconds" is a 'MUST'
|
||||
* 2. "Zulu" timezone is a 'MUST'
|
||||
* 3. "+|-" is not allowed to indicate a time zone
|
||||
*/
|
||||
if (d->type == V_ASN1_UTCTIME) {
|
||||
if (d->flags & ASN1_STRING_FLAG_X509_TIME) {
|
||||
min_l = 13;
|
||||
strict = 1;
|
||||
}
|
||||
} else if (d->type == V_ASN1_GENERALIZEDTIME) {
|
||||
end = 7;
|
||||
btz = 6;
|
||||
if (d->flags & ASN1_STRING_FLAG_X509_TIME) {
|
||||
min_l = 15;
|
||||
strict = 1;
|
||||
} else {
|
||||
min_l = 13;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
l = d->length;
|
||||
a = (char *)d->data;
|
||||
o = 0;
|
||||
memset(&tmp, 0, sizeof(tmp));
|
||||
|
||||
/*
|
||||
* GENERALIZEDTIME is similar to UTCTIME except the year is represented
|
||||
* as YYYY. This stuff treats everything as a two digit field so make
|
||||
* first two fields 00 to 99
|
||||
*/
|
||||
|
||||
if (l < min_l)
|
||||
goto err;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (!strict && (i == btz) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
if (!ossl_isdigit(a[o]))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
/* incomplete 2-digital number */
|
||||
if (++o == l)
|
||||
goto err;
|
||||
|
||||
if (!ossl_isdigit(a[o]))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
/* no more bytes to read, but we haven't seen time-zone yet */
|
||||
if (++o == l)
|
||||
goto err;
|
||||
|
||||
i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i;
|
||||
|
||||
if ((n < min[i2]) || (n > max[i2]))
|
||||
goto err;
|
||||
switch (i2) {
|
||||
case 0:
|
||||
/* UTC will never be here */
|
||||
tmp.tm_year = n * 100 - 1900;
|
||||
break;
|
||||
case 1:
|
||||
if (d->type == V_ASN1_UTCTIME)
|
||||
tmp.tm_year = n < 50 ? n + 100 : n;
|
||||
else
|
||||
tmp.tm_year += n;
|
||||
break;
|
||||
case 2:
|
||||
tmp.tm_mon = n - 1;
|
||||
break;
|
||||
case 3:
|
||||
/* check if tm_mday is valid in tm_mon */
|
||||
if (tmp.tm_mon == 1) {
|
||||
/* it's February */
|
||||
md = mdays[1] + leap_year(tmp.tm_year + 1900);
|
||||
} else {
|
||||
md = mdays[tmp.tm_mon];
|
||||
}
|
||||
if (n > md)
|
||||
goto err;
|
||||
tmp.tm_mday = n;
|
||||
determine_days(&tmp);
|
||||
break;
|
||||
case 4:
|
||||
tmp.tm_hour = n;
|
||||
break;
|
||||
case 5:
|
||||
tmp.tm_min = n;
|
||||
break;
|
||||
case 6:
|
||||
tmp.tm_sec = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Optional fractional seconds: decimal point followed by one or more
|
||||
* digits.
|
||||
*/
|
||||
if (d->type == V_ASN1_GENERALIZEDTIME && a[o] == '.') {
|
||||
if (strict)
|
||||
/* RFC 5280 forbids fractional seconds */
|
||||
goto err;
|
||||
if (++o == l)
|
||||
goto err;
|
||||
i = o;
|
||||
while ((o < l) && ossl_isdigit(a[o]))
|
||||
o++;
|
||||
/* Must have at least one digit after decimal point */
|
||||
if (i == o)
|
||||
goto err;
|
||||
/* no more bytes to read, but we haven't seen time-zone yet */
|
||||
if (o == l)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* 'o' will never point to '\0' at this point, the only chance
|
||||
* 'o' can point to '\0' is either the subsequent if or the first
|
||||
* else if is true.
|
||||
*/
|
||||
if (a[o] == 'Z') {
|
||||
o++;
|
||||
} else if (!strict && ((a[o] == '+') || (a[o] == '-'))) {
|
||||
int offsign = a[o] == '-' ? 1 : -1;
|
||||
int offset = 0;
|
||||
|
||||
o++;
|
||||
/*
|
||||
* if not equal, no need to do subsequent checks
|
||||
* since the following for-loop will add 'o' by 4
|
||||
* and the final return statement will check if 'l'
|
||||
* and 'o' are equal.
|
||||
*/
|
||||
if (o + 4 != l)
|
||||
goto err;
|
||||
for (i = end; i < end + 2; i++) {
|
||||
if (!ossl_isdigit(a[o]))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
o++;
|
||||
if (!ossl_isdigit(a[o]))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i;
|
||||
if ((n < min[i2]) || (n > max[i2]))
|
||||
goto err;
|
||||
/* if tm is NULL, no need to adjust */
|
||||
if (tm != NULL) {
|
||||
if (i == end)
|
||||
offset = n * 3600;
|
||||
else if (i == end + 1)
|
||||
offset += n * 60;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
if (offset && !OPENSSL_gmtime_adj(&tmp, 0, offset * offsign))
|
||||
goto err;
|
||||
} else {
|
||||
/* not Z, or not +/- in non-strict mode */
|
||||
goto err;
|
||||
}
|
||||
if (o == l) {
|
||||
/* success, check if tm should be filled */
|
||||
if (tm != NULL)
|
||||
*tm = tmp;
|
||||
return 1;
|
||||
}
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)
|
||||
{
|
||||
char* p;
|
||||
ASN1_TIME *tmps = NULL;
|
||||
const size_t len = 20;
|
||||
|
||||
if (type == V_ASN1_UNDEF) {
|
||||
if (is_utc(ts->tm_year))
|
||||
type = V_ASN1_UTCTIME;
|
||||
else
|
||||
type = V_ASN1_GENERALIZEDTIME;
|
||||
} else if (type == V_ASN1_UTCTIME) {
|
||||
if (!is_utc(ts->tm_year))
|
||||
goto err;
|
||||
} else if (type != V_ASN1_GENERALIZEDTIME) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (s == NULL)
|
||||
tmps = ASN1_STRING_new();
|
||||
else
|
||||
tmps = s;
|
||||
if (tmps == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!ASN1_STRING_set(tmps, NULL, len))
|
||||
goto err;
|
||||
|
||||
tmps->type = type;
|
||||
p = (char*)tmps->data;
|
||||
|
||||
if (type == V_ASN1_GENERALIZEDTIME)
|
||||
tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ",
|
||||
ts->tm_year + 1900, ts->tm_mon + 1,
|
||||
ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||
ts->tm_sec);
|
||||
else
|
||||
tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ",
|
||||
ts->tm_year % 100, ts->tm_mon + 1,
|
||||
ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||
ts->tm_sec);
|
||||
|
||||
#ifdef CHARSET_EBCDIC_not
|
||||
ebcdic2ascii(tmps->data, tmps->data, tmps->length);
|
||||
#endif
|
||||
return tmps;
|
||||
err:
|
||||
if (tmps != s)
|
||||
ASN1_STRING_free(tmps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
|
||||
{
|
||||
return ASN1_TIME_adj(s, t, 0, 0);
|
||||
@@ -44,9 +330,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
|
||||
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||
return NULL;
|
||||
}
|
||||
if ((ts->tm_year >= 50) && (ts->tm_year < 150))
|
||||
return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
|
||||
return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
|
||||
return asn1_time_from_tm(s, ts, V_ASN1_UNDEF);
|
||||
}
|
||||
|
||||
int ASN1_TIME_check(const ASN1_TIME *t)
|
||||
@@ -63,108 +347,207 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
|
||||
ASN1_GENERALIZEDTIME **out)
|
||||
{
|
||||
ASN1_GENERALIZEDTIME *ret = NULL;
|
||||
char *str;
|
||||
int newlen;
|
||||
struct tm tm;
|
||||
|
||||
if (!ASN1_TIME_check(t))
|
||||
if (!ASN1_TIME_to_tm(t, &tm))
|
||||
return NULL;
|
||||
|
||||
if (out == NULL || *out == NULL) {
|
||||
if ((ret = ASN1_GENERALIZEDTIME_new()) == NULL)
|
||||
goto err;
|
||||
} else
|
||||
if (out != NULL)
|
||||
ret = *out;
|
||||
|
||||
/* If already GeneralizedTime just copy across */
|
||||
if (t->type == V_ASN1_GENERALIZEDTIME) {
|
||||
if (!ASN1_STRING_set(ret, t->data, t->length))
|
||||
goto err;
|
||||
goto done;
|
||||
}
|
||||
ret = asn1_time_from_tm(ret, &tm, V_ASN1_GENERALIZEDTIME);
|
||||
|
||||
/* grow the string */
|
||||
if (!ASN1_STRING_set(ret, NULL, t->length + 2))
|
||||
goto err;
|
||||
/* ASN1_STRING_set() allocated 'len + 1' bytes. */
|
||||
newlen = t->length + 2 + 1;
|
||||
str = (char *)ret->data;
|
||||
/* Work out the century and prepend */
|
||||
if (t->data[0] >= '5')
|
||||
OPENSSL_strlcpy(str, "19", newlen);
|
||||
else
|
||||
OPENSSL_strlcpy(str, "20", newlen);
|
||||
if (out != NULL && ret != NULL)
|
||||
*out = ret;
|
||||
|
||||
OPENSSL_strlcat(str, (const char *)t->data, newlen);
|
||||
|
||||
done:
|
||||
if (out != NULL && *out == NULL)
|
||||
*out = ret;
|
||||
return ret;
|
||||
|
||||
err:
|
||||
if (out == NULL || *out != ret)
|
||||
ASN1_GENERALIZEDTIME_free(ret);
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
|
||||
{
|
||||
/* Try UTC, if that fails, try GENERALIZED */
|
||||
if (ASN1_UTCTIME_set_string(s, str))
|
||||
return 1;
|
||||
return ASN1_GENERALIZEDTIME_set_string(s, str);
|
||||
}
|
||||
|
||||
int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str)
|
||||
{
|
||||
ASN1_TIME t;
|
||||
struct tm tm;
|
||||
int rv = 0;
|
||||
|
||||
t.length = strlen(str);
|
||||
t.data = (unsigned char *)str;
|
||||
t.flags = 0;
|
||||
t.flags = ASN1_STRING_FLAG_X509_TIME;
|
||||
|
||||
t.type = V_ASN1_UTCTIME;
|
||||
|
||||
if (!ASN1_TIME_check(&t)) {
|
||||
t.type = V_ASN1_GENERALIZEDTIME;
|
||||
if (!ASN1_TIME_check(&t))
|
||||
return 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
|
||||
return 0;
|
||||
/*
|
||||
* Per RFC 5280 (section 4.1.2.5.), the valid input time
|
||||
* strings should be encoded with the following rules:
|
||||
*
|
||||
* 1. UTC: YYMMDDHHMMSSZ, if YY < 50 (20YY) --> UTC: YYMMDDHHMMSSZ
|
||||
* 2. UTC: YYMMDDHHMMSSZ, if YY >= 50 (19YY) --> UTC: YYMMDDHHMMSSZ
|
||||
* 3. G'd: YYYYMMDDHHMMSSZ, if YYYY >= 2050 --> G'd: YYYYMMDDHHMMSSZ
|
||||
* 4. G'd: YYYYMMDDHHMMSSZ, if YYYY < 2050 --> UTC: YYMMDDHHMMSSZ
|
||||
*
|
||||
* Only strings of the 4th rule should be reformatted, but since a
|
||||
* UTC can only present [1950, 2050), so if the given time string
|
||||
* is less than 1950 (e.g. 19230419000000Z), we do nothing...
|
||||
*/
|
||||
|
||||
return 1;
|
||||
if (s != NULL && t.type == V_ASN1_GENERALIZEDTIME) {
|
||||
if (!asn1_time_to_tm(&tm, &t))
|
||||
goto out;
|
||||
if (is_utc(tm.tm_year)) {
|
||||
t.length -= 2;
|
||||
/*
|
||||
* it's OK to let original t.data go since that's assigned
|
||||
* to a piece of memory allocated outside of this function.
|
||||
* new t.data would be freed after ASN1_STRING_copy is done.
|
||||
*/
|
||||
t.data = OPENSSL_zalloc(t.length + 1);
|
||||
if (t.data == NULL)
|
||||
goto out;
|
||||
memcpy(t.data, str + 2, t.length);
|
||||
t.type = V_ASN1_UTCTIME;
|
||||
}
|
||||
}
|
||||
|
||||
if (s == NULL || ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
|
||||
rv = 1;
|
||||
|
||||
if (t.data != (unsigned char *)str)
|
||||
OPENSSL_free(t.data);
|
||||
out:
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t)
|
||||
int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm)
|
||||
{
|
||||
if (t == NULL) {
|
||||
if (s == NULL) {
|
||||
time_t now_t;
|
||||
|
||||
time(&now_t);
|
||||
if (OPENSSL_gmtime(&now_t, tm))
|
||||
memset(tm, 0, sizeof(*tm));
|
||||
if (OPENSSL_gmtime(&now_t, tm) != NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (t->type == V_ASN1_UTCTIME)
|
||||
return asn1_utctime_to_tm(tm, t);
|
||||
else if (t->type == V_ASN1_GENERALIZEDTIME)
|
||||
return asn1_generalizedtime_to_tm(tm, t);
|
||||
|
||||
return 0;
|
||||
return asn1_time_to_tm(tm, s);
|
||||
}
|
||||
|
||||
int ASN1_TIME_diff(int *pday, int *psec,
|
||||
const ASN1_TIME *from, const ASN1_TIME *to)
|
||||
{
|
||||
struct tm tm_from, tm_to;
|
||||
if (!asn1_time_to_tm(&tm_from, from))
|
||||
|
||||
if (!ASN1_TIME_to_tm(from, &tm_from))
|
||||
return 0;
|
||||
if (!asn1_time_to_tm(&tm_to, to))
|
||||
if (!ASN1_TIME_to_tm(to, &tm_to))
|
||||
return 0;
|
||||
return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
|
||||
}
|
||||
|
||||
static const char _asn1_mon[12][4] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
{
|
||||
if (tm->type == V_ASN1_UTCTIME)
|
||||
return ASN1_UTCTIME_print(bp, tm);
|
||||
if (tm->type == V_ASN1_GENERALIZEDTIME)
|
||||
return ASN1_GENERALIZEDTIME_print(bp, tm);
|
||||
char *v;
|
||||
int gmt = 0, l;
|
||||
struct tm stm;
|
||||
|
||||
if (!asn1_time_to_tm(&stm, tm)) {
|
||||
/* asn1_time_to_tm will check the time type */
|
||||
goto err;
|
||||
}
|
||||
|
||||
l = tm->length;
|
||||
v = (char *)tm->data;
|
||||
if (v[l - 1] == 'Z')
|
||||
gmt = 1;
|
||||
|
||||
if (tm->type == V_ASN1_GENERALIZEDTIME) {
|
||||
char *f = NULL;
|
||||
int f_len = 0;
|
||||
|
||||
/*
|
||||
* Try to parse fractional seconds. '14' is the place of
|
||||
* 'fraction point' in a GeneralizedTime string.
|
||||
*/
|
||||
if (tm->length > 15 && v[14] == '.') {
|
||||
f = &v[14];
|
||||
f_len = 1;
|
||||
while (14 + f_len < l && ossl_isdigit(f[f_len]))
|
||||
++f_len;
|
||||
}
|
||||
|
||||
return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
|
||||
_asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour,
|
||||
stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900,
|
||||
(gmt ? " GMT" : "")) > 0;
|
||||
} else {
|
||||
return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s",
|
||||
_asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour,
|
||||
stm.tm_min, stm.tm_sec, stm.tm_year + 1900,
|
||||
(gmt ? " GMT" : "")) > 0;
|
||||
}
|
||||
err:
|
||||
BIO_write(bp, "Bad time value", 14);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t)
|
||||
{
|
||||
struct tm stm, ttm;
|
||||
int day, sec;
|
||||
|
||||
if (!ASN1_TIME_to_tm(s, &stm))
|
||||
return -2;
|
||||
|
||||
if (!OPENSSL_gmtime(&t, &ttm))
|
||||
return -2;
|
||||
|
||||
if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
|
||||
return -2;
|
||||
|
||||
if (day > 0 || sec > 0)
|
||||
return 1;
|
||||
if (day < 0 || sec < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_TIME_normalize(ASN1_TIME *t)
|
||||
{
|
||||
struct tm tm;
|
||||
|
||||
if (!ASN1_TIME_to_tm(t, &tm))
|
||||
return 0;
|
||||
|
||||
return asn1_time_from_tm(t, &tm, V_ASN1_UNDEF) != NULL;
|
||||
}
|
||||
|
||||
int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b)
|
||||
{
|
||||
int day, sec;
|
||||
|
||||
if (!ASN1_TIME_diff(&day, &sec, b, a))
|
||||
return -2;
|
||||
if (day > 0 || sec > 0)
|
||||
return 1;
|
||||
if (day < 0 || sec < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@@ -16,9 +16,9 @@
|
||||
int ASN1_TYPE_get(const ASN1_TYPE *a)
|
||||
{
|
||||
if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
|
||||
return (a->type);
|
||||
return a->type;
|
||||
else
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
|
||||
|
||||
+24
-180
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -13,96 +13,13 @@
|
||||
#include <openssl/asn1.h>
|
||||
#include "asn1_locl.h"
|
||||
|
||||
/* This is the primary function used to parse ASN1_UTCTIME */
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
|
||||
{
|
||||
static const int min[8] = { 0, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const int max[8] = { 99, 12, 31, 23, 59, 59, 12, 59 };
|
||||
char *a;
|
||||
int n, i, l, o;
|
||||
|
||||
/* wrapper around ans1_time_to_tm */
|
||||
if (d->type != V_ASN1_UTCTIME)
|
||||
return (0);
|
||||
l = d->length;
|
||||
a = (char *)d->data;
|
||||
o = 0;
|
||||
|
||||
if (l < 11)
|
||||
goto err;
|
||||
for (i = 0; i < 6; i++) {
|
||||
if ((i == 5) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||
i++;
|
||||
if (tm)
|
||||
tm->tm_sec = 0;
|
||||
break;
|
||||
}
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
if (++o > l)
|
||||
goto err;
|
||||
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
if (++o > l)
|
||||
goto err;
|
||||
|
||||
if ((n < min[i]) || (n > max[i]))
|
||||
goto err;
|
||||
if (tm) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
tm->tm_year = n < 50 ? n + 100 : n;
|
||||
break;
|
||||
case 1:
|
||||
tm->tm_mon = n - 1;
|
||||
break;
|
||||
case 2:
|
||||
tm->tm_mday = n;
|
||||
break;
|
||||
case 3:
|
||||
tm->tm_hour = n;
|
||||
break;
|
||||
case 4:
|
||||
tm->tm_min = n;
|
||||
break;
|
||||
case 5:
|
||||
tm->tm_sec = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a[o] == 'Z')
|
||||
o++;
|
||||
else if ((a[o] == '+') || (a[o] == '-')) {
|
||||
int offsign = a[o] == '-' ? 1 : -1, offset = 0;
|
||||
o++;
|
||||
if (o + 4 > l)
|
||||
goto err;
|
||||
for (i = 6; i < 8; i++) {
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
o++;
|
||||
if ((a[o] < '0') || (a[o] > '9'))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
if ((n < min[i]) || (n > max[i]))
|
||||
goto err;
|
||||
if (tm) {
|
||||
if (i == 6)
|
||||
offset = n * 3600;
|
||||
else if (i == 7)
|
||||
offset += n * 60;
|
||||
}
|
||||
o++;
|
||||
}
|
||||
if (offset && !OPENSSL_gmtime_adj(tm, 0, offset * offsign))
|
||||
return 0;
|
||||
}
|
||||
return o == l;
|
||||
err:
|
||||
return 0;
|
||||
return 0;
|
||||
return asn1_time_to_tm(tm, d);
|
||||
}
|
||||
|
||||
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
|
||||
@@ -110,6 +27,7 @@ int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
|
||||
return asn1_utctime_to_tm(NULL, d);
|
||||
}
|
||||
|
||||
/* Sets the string via simple copy without cleaning it up */
|
||||
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
|
||||
{
|
||||
ASN1_UTCTIME t;
|
||||
@@ -117,15 +35,15 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
|
||||
t.type = V_ASN1_UTCTIME;
|
||||
t.length = strlen(str);
|
||||
t.data = (unsigned char *)str;
|
||||
if (ASN1_UTCTIME_check(&t)) {
|
||||
if (s != NULL) {
|
||||
if (!ASN1_STRING_set((ASN1_STRING *)s, str, t.length))
|
||||
return 0;
|
||||
s->type = V_ASN1_UTCTIME;
|
||||
}
|
||||
return (1);
|
||||
} else
|
||||
return (0);
|
||||
t.flags = 0;
|
||||
|
||||
if (!ASN1_UTCTIME_check(&t))
|
||||
return 0;
|
||||
|
||||
if (s != NULL && !ASN1_STRING_copy(s, &t))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||
@@ -136,55 +54,19 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
|
||||
ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
|
||||
int offset_day, long offset_sec)
|
||||
{
|
||||
char *p;
|
||||
struct tm *ts;
|
||||
struct tm data;
|
||||
size_t len = 20;
|
||||
int free_s = 0;
|
||||
|
||||
if (s == NULL) {
|
||||
s = ASN1_UTCTIME_new();
|
||||
if (s == NULL)
|
||||
goto err;
|
||||
free_s = 1;
|
||||
}
|
||||
|
||||
ts = OPENSSL_gmtime(&t, &data);
|
||||
if (ts == NULL)
|
||||
goto err;
|
||||
return NULL;
|
||||
|
||||
if (offset_day || offset_sec) {
|
||||
if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
|
||||
goto err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ts->tm_year < 50) || (ts->tm_year >= 150))
|
||||
goto err;
|
||||
|
||||
p = (char *)s->data;
|
||||
if ((p == NULL) || ((size_t)s->length < len)) {
|
||||
p = OPENSSL_malloc(len);
|
||||
if (p == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
OPENSSL_free(s->data);
|
||||
s->data = (unsigned char *)p;
|
||||
}
|
||||
|
||||
BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100,
|
||||
ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||
ts->tm_sec);
|
||||
s->length = strlen(p);
|
||||
s->type = V_ASN1_UTCTIME;
|
||||
#ifdef CHARSET_EBCDIC_not
|
||||
ebcdic2ascii(s->data, s->data, s->length);
|
||||
#endif
|
||||
return (s);
|
||||
err:
|
||||
if (free_s)
|
||||
ASN1_UTCTIME_free(s);
|
||||
return NULL;
|
||||
return asn1_time_from_tm(s, ts, V_ASN1_UTCTIME);
|
||||
}
|
||||
|
||||
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
|
||||
@@ -195,60 +77,22 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
|
||||
if (!asn1_utctime_to_tm(&stm, s))
|
||||
return -2;
|
||||
|
||||
if (!OPENSSL_gmtime(&t, &ttm))
|
||||
if (OPENSSL_gmtime(&t, &ttm) == NULL)
|
||||
return -2;
|
||||
|
||||
if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
|
||||
return -2;
|
||||
|
||||
if (day > 0)
|
||||
if (day > 0 || sec > 0)
|
||||
return 1;
|
||||
if (day < 0)
|
||||
return -1;
|
||||
if (sec > 0)
|
||||
return 1;
|
||||
if (sec < 0)
|
||||
if (day < 0 || sec < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
|
||||
{
|
||||
const char *v;
|
||||
int gmt = 0;
|
||||
int i;
|
||||
int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
|
||||
|
||||
i = tm->length;
|
||||
v = (const char *)tm->data;
|
||||
|
||||
if (i < 10)
|
||||
goto err;
|
||||
if (v[i - 1] == 'Z')
|
||||
gmt = 1;
|
||||
for (i = 0; i < 10; i++)
|
||||
if ((v[i] > '9') || (v[i] < '0'))
|
||||
goto err;
|
||||
y = (v[0] - '0') * 10 + (v[1] - '0');
|
||||
if (y < 50)
|
||||
y += 100;
|
||||
M = (v[2] - '0') * 10 + (v[3] - '0');
|
||||
if ((M > 12) || (M < 1))
|
||||
goto err;
|
||||
d = (v[4] - '0') * 10 + (v[5] - '0');
|
||||
h = (v[6] - '0') * 10 + (v[7] - '0');
|
||||
m = (v[8] - '0') * 10 + (v[9] - '0');
|
||||
if (tm->length >= 12 &&
|
||||
(v[10] >= '0') && (v[10] <= '9') && (v[11] >= '0') && (v[11] <= '9'))
|
||||
s = (v[10] - '0') * 10 + (v[11] - '0');
|
||||
|
||||
if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s",
|
||||
_asn1_mon[M - 1], d, h, m, s, y + 1900,
|
||||
(gmt) ? " GMT" : "") <= 0)
|
||||
return (0);
|
||||
else
|
||||
return (1);
|
||||
err:
|
||||
BIO_write(bp, "Bad time value", 14);
|
||||
return (0);
|
||||
if (tm->type != V_ASN1_UTCTIME)
|
||||
return 0;
|
||||
return ASN1_TIME_print(bp, tm);
|
||||
}
|
||||
+7
-16
@@ -76,7 +76,7 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -86,7 +86,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
|
||||
{
|
||||
EVP_MD_CTX *ctx = NULL;
|
||||
unsigned char *buf_in = NULL;
|
||||
int ret = -1, inl;
|
||||
int ret = -1, inl = 0;
|
||||
|
||||
int mdnid, pknid;
|
||||
|
||||
@@ -156,24 +156,15 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = EVP_DigestVerifyUpdate(ctx, buf_in, inl);
|
||||
|
||||
OPENSSL_clear_free(buf_in, (unsigned int)inl);
|
||||
|
||||
if (!ret) {
|
||||
ret = EVP_DigestVerify(ctx, signature->data, (size_t)signature->length,
|
||||
buf_in, inl);
|
||||
if (ret <= 0) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
ret = -1;
|
||||
|
||||
if (EVP_DigestVerifyFinal(ctx, signature->data,
|
||||
(size_t)signature->length) <= 0) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_EVP_LIB);
|
||||
ret = 0;
|
||||
goto err;
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
OPENSSL_clear_free(buf_in, (unsigned int)inl);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
+33
-42
@@ -7,59 +7,20 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "e_os.h" /* for strncasecmp */
|
||||
#include "internal/cryptlib.h"
|
||||
#include <stdio.h>
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/engine.h>
|
||||
#include "internal/asn1_int.h"
|
||||
#include "internal/evp_int.h"
|
||||
|
||||
/* Keep this sorted in type order !! */
|
||||
static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
&rsa_asn1_meths[0],
|
||||
&rsa_asn1_meths[1],
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
&dh_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
&dsa_asn1_meths[0],
|
||||
&dsa_asn1_meths[1],
|
||||
&dsa_asn1_meths[2],
|
||||
&dsa_asn1_meths[3],
|
||||
&dsa_asn1_meths[4],
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&eckey_asn1_meth,
|
||||
#endif
|
||||
&hmac_asn1_meth,
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
&cmac_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
&dhx_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ecx25519_asn1_meth
|
||||
#endif
|
||||
};
|
||||
#include "standard_methods.h"
|
||||
|
||||
typedef int sk_cmp_fn_type(const char *const *a, const char *const *b);
|
||||
static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL;
|
||||
|
||||
#ifdef TEST
|
||||
void main()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < OSSL_NELEM(standard_methods); i++)
|
||||
fprintf(stderr, "Number %d id=%d (%s)\n", i,
|
||||
standard_methods[i]->pkey_id,
|
||||
OBJ_nid2sn(standard_methods[i]->pkey_id));
|
||||
}
|
||||
#endif
|
||||
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *,
|
||||
const EVP_PKEY_ASN1_METHOD *, ameth);
|
||||
|
||||
@@ -301,6 +262,10 @@ void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
|
||||
dst->item_sign = src->item_sign;
|
||||
dst->item_verify = src->item_verify;
|
||||
|
||||
dst->siginf_set = src->siginf_set;
|
||||
|
||||
dst->pkey_check = src->pkey_check;
|
||||
|
||||
}
|
||||
|
||||
void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth)
|
||||
@@ -409,3 +374,29 @@ void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,
|
||||
ameth->item_sign = item_sign;
|
||||
ameth->item_verify = item_verify;
|
||||
}
|
||||
|
||||
void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,
|
||||
int (*siginf_set) (X509_SIG_INFO *siginf,
|
||||
const X509_ALGOR *alg,
|
||||
const ASN1_STRING *sig))
|
||||
{
|
||||
ameth->siginf_set = siginf_set;
|
||||
}
|
||||
|
||||
void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
|
||||
int (*pkey_check) (const EVP_PKEY *pk))
|
||||
{
|
||||
ameth->pkey_check = pkey_check;
|
||||
}
|
||||
|
||||
void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,
|
||||
int (*pkey_pub_check) (const EVP_PKEY *pk))
|
||||
{
|
||||
ameth->pkey_public_check = pkey_pub_check;
|
||||
}
|
||||
|
||||
void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,
|
||||
int (*pkey_param_check) (const EVP_PKEY *pk))
|
||||
{
|
||||
ameth->pkey_param_check = pkey_param_check;
|
||||
}
|
||||
+301
-241
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,251 +8,312 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1err.h>
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_ASN1,func,0)
|
||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_ASN1,0,reason)
|
||||
|
||||
static ERR_STRING_DATA ASN1_str_functs[] = {
|
||||
{ERR_FUNC(ASN1_F_A2D_ASN1_OBJECT), "a2d_ASN1_OBJECT"},
|
||||
{ERR_FUNC(ASN1_F_A2I_ASN1_INTEGER), "a2i_ASN1_INTEGER"},
|
||||
{ERR_FUNC(ASN1_F_A2I_ASN1_STRING), "a2i_ASN1_STRING"},
|
||||
{ERR_FUNC(ASN1_F_APPEND_EXP), "append_exp"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_BIT_STRING_SET_BIT), "ASN1_BIT_STRING_set_bit"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_CB), "asn1_cb"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_CHECK_TLEN), "asn1_check_tlen"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_COLLECT), "asn1_collect"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_D2I_EX_PRIMITIVE), "asn1_d2i_ex_primitive"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_D2I_FP), "ASN1_d2i_fp"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_D2I_READ_BIO), "asn1_d2i_read_bio"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_DIGEST), "ASN1_digest"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_DO_ADB), "asn1_do_adb"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_DO_LOCK), "asn1_do_lock"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_DUP), "ASN1_dup"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_EX_C2I), "asn1_ex_c2i"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_FIND_END), "asn1_find_end"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_ADJ), "ASN1_GENERALIZEDTIME_adj"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_GET_INT64), "asn1_get_int64"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_GET_UINT64), "asn1_get_uint64"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_D2I_FP), "ASN1_item_d2i_fp"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_DUP), "ASN1_item_dup"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_EMBED_D2I), "asn1_item_embed_d2i"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_EMBED_NEW), "asn1_item_embed_new"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_BIO), "ASN1_item_i2d_bio"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_FP), "ASN1_item_i2d_fp"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_PACK), "ASN1_item_pack"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN), "ASN1_item_sign"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN_CTX), "ASN1_item_sign_ctx"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_UNPACK), "ASN1_item_unpack"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_ITEM_VERIFY), "ASN1_item_verify"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_MBSTRING_NCOPY), "ASN1_mbstring_ncopy"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "asn1_output_data"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_new"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_SCTX_NEW), "ASN1_SCTX_new"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_SIGN), "ASN1_sign"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STR2TYPE), "asn1_str2type"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STRING_GET_INT64), "asn1_string_get_int64"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STRING_GET_UINT64), "asn1_string_get_uint64"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STRING_SET), "ASN1_STRING_set"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STRING_TABLE_ADD), "ASN1_STRING_TABLE_add"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STRING_TO_BN), "asn1_string_to_bn"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_STRING_TYPE_NEW), "ASN1_STRING_type_new"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "asn1_template_ex_d2i"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "asn1_template_new"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "asn1_template_noexp_d2i"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TIME_ADJ), "ASN1_TIME_adj"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING),
|
||||
static const ERR_STRING_DATA ASN1_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2D_ASN1_OBJECT, 0), "a2d_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2I_ASN1_INTEGER, 0), "a2i_ASN1_INTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2I_ASN1_STRING, 0), "a2i_ASN1_STRING"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_APPEND_EXP, 0), "append_exp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_BIT_STRING_SET_BIT, 0),
|
||||
"ASN1_BIT_STRING_set_bit"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_CB, 0), "asn1_cb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_CHECK_TLEN, 0), "asn1_check_tlen"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_COLLECT, 0), "asn1_collect"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_EX_PRIMITIVE, 0),
|
||||
"asn1_d2i_ex_primitive"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_FP, 0), "ASN1_d2i_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_READ_BIO, 0), "asn1_d2i_read_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DIGEST, 0), "ASN1_digest"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DO_ADB, 0), "asn1_do_adb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DO_LOCK, 0), "asn1_do_lock"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DUP, 0), "ASN1_dup"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_EX_C2I, 0), "asn1_ex_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_FIND_END, 0), "asn1_find_end"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GENERALIZEDTIME_ADJ, 0),
|
||||
"ASN1_GENERALIZEDTIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GENERATE_V3, 0), "ASN1_generate_v3"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_INT64, 0), "asn1_get_int64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_OBJECT, 0), "ASN1_get_object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_UINT64, 0), "asn1_get_uint64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_I2D_BIO, 0), "ASN1_i2d_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_I2D_FP, 0), "ASN1_i2d_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_D2I_FP, 0), "ASN1_item_d2i_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_DUP, 0), "ASN1_item_dup"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_EMBED_D2I, 0),
|
||||
"asn1_item_embed_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_EMBED_NEW, 0),
|
||||
"asn1_item_embed_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_I2D_BIO, 0), "ASN1_item_i2d_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_I2D_FP, 0), "ASN1_item_i2d_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_PACK, 0), "ASN1_item_pack"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_SIGN, 0), "ASN1_item_sign"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_SIGN_CTX, 0),
|
||||
"ASN1_item_sign_ctx"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_UNPACK, 0), "ASN1_item_unpack"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_VERIFY, 0), "ASN1_item_verify"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_MBSTRING_NCOPY, 0),
|
||||
"ASN1_mbstring_ncopy"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_OBJECT_NEW, 0), "ASN1_OBJECT_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_OUTPUT_DATA, 0), "asn1_output_data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_PCTX_NEW, 0), "ASN1_PCTX_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_SCTX_NEW, 0), "ASN1_SCTX_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_SIGN, 0), "ASN1_sign"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STR2TYPE, 0), "asn1_str2type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_GET_INT64, 0),
|
||||
"asn1_string_get_int64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_GET_UINT64, 0),
|
||||
"asn1_string_get_uint64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_SET, 0), "ASN1_STRING_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TABLE_ADD, 0),
|
||||
"ASN1_STRING_TABLE_add"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TO_BN, 0), "asn1_string_to_bn"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TYPE_NEW, 0),
|
||||
"ASN1_STRING_type_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_EX_D2I, 0),
|
||||
"asn1_template_ex_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_NEW, 0), "asn1_template_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, 0),
|
||||
"asn1_template_noexp_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TIME_ADJ, 0), "ASN1_TIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, 0),
|
||||
"ASN1_TYPE_get_int_octetstring"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_UTCTIME_ADJ), "ASN1_UTCTIME_adj"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"},
|
||||
{ERR_FUNC(ASN1_F_B64_READ_ASN1), "b64_read_asn1"},
|
||||
{ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_write_ASN1"},
|
||||
{ERR_FUNC(ASN1_F_BIO_NEW_NDEF), "BIO_new_NDEF"},
|
||||
{ERR_FUNC(ASN1_F_BITSTR_CB), "bitstr_cb"},
|
||||
{ERR_FUNC(ASN1_F_BN_TO_ASN1_STRING), "bn_to_asn1_string"},
|
||||
{ERR_FUNC(ASN1_F_C2I_ASN1_BIT_STRING), "c2i_ASN1_BIT_STRING"},
|
||||
{ERR_FUNC(ASN1_F_C2I_ASN1_INTEGER), "c2i_ASN1_INTEGER"},
|
||||
{ERR_FUNC(ASN1_F_C2I_ASN1_OBJECT), "c2i_ASN1_OBJECT"},
|
||||
{ERR_FUNC(ASN1_F_C2I_IBUF), "c2i_ibuf"},
|
||||
{ERR_FUNC(ASN1_F_C2I_UINT64_INT), "c2i_uint64_int"},
|
||||
{ERR_FUNC(ASN1_F_COLLECT_DATA), "collect_data"},
|
||||
{ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"},
|
||||
{ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"},
|
||||
{ERR_FUNC(ASN1_F_D2I_AUTOPRIVATEKEY), "d2i_AutoPrivateKey"},
|
||||
{ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"},
|
||||
{ERR_FUNC(ASN1_F_D2I_PUBLICKEY), "d2i_PublicKey"},
|
||||
{ERR_FUNC(ASN1_F_DO_TCREATE), "do_tcreate"},
|
||||
{ERR_FUNC(ASN1_F_I2D_ASN1_BIO_STREAM), "i2d_ASN1_bio_stream"},
|
||||
{ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"},
|
||||
{ERR_FUNC(ASN1_F_I2D_EC_PUBKEY), "i2d_EC_PUBKEY"},
|
||||
{ERR_FUNC(ASN1_F_I2D_PRIVATEKEY), "i2d_PrivateKey"},
|
||||
{ERR_FUNC(ASN1_F_I2D_PUBLICKEY), "i2d_PublicKey"},
|
||||
{ERR_FUNC(ASN1_F_I2D_RSA_PUBKEY), "i2d_RSA_PUBKEY"},
|
||||
{ERR_FUNC(ASN1_F_LONG_C2I), "long_c2i"},
|
||||
{ERR_FUNC(ASN1_F_OID_MODULE_INIT), "oid_module_init"},
|
||||
{ERR_FUNC(ASN1_F_PARSE_TAGGING), "parse_tagging"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_IV), "PKCS5_pbe2_set_iv"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_SCRYPT), "PKCS5_pbe2_set_scrypt"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE_SET0_ALGOR), "PKCS5_pbe_set0_algor"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBKDF2_SET), "PKCS5_pbkdf2_set"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_SCRYPT_SET), "pkcs5_scrypt_set"},
|
||||
{ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"},
|
||||
{ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"},
|
||||
{ERR_FUNC(ASN1_F_STBL_MODULE_INIT), "stbl_module_init"},
|
||||
{ERR_FUNC(ASN1_F_UINT32_C2I), "uint32_c2i"},
|
||||
{ERR_FUNC(ASN1_F_UINT64_C2I), "uint64_c2i"},
|
||||
{ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_add0_revoked"},
|
||||
{ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_new"},
|
||||
{ERR_FUNC(ASN1_F_X509_NAME_ENCODE), "x509_name_encode"},
|
||||
{ERR_FUNC(ASN1_F_X509_NAME_EX_D2I), "x509_name_ex_d2i"},
|
||||
{ERR_FUNC(ASN1_F_X509_NAME_EX_NEW), "x509_name_ex_new"},
|
||||
{ERR_FUNC(ASN1_F_X509_PKEY_NEW), "X509_PKEY_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TYPE_GET_OCTETSTRING, 0),
|
||||
"ASN1_TYPE_get_octetstring"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_UTCTIME_ADJ, 0), "ASN1_UTCTIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_VERIFY, 0), "ASN1_verify"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_B64_READ_ASN1, 0), "b64_read_asn1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_B64_WRITE_ASN1, 0), "B64_write_ASN1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BIO_NEW_NDEF, 0), "BIO_new_NDEF"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BITSTR_CB, 0), "bitstr_cb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BN_TO_ASN1_STRING, 0), "bn_to_asn1_string"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_BIT_STRING, 0),
|
||||
"c2i_ASN1_BIT_STRING"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_INTEGER, 0), "c2i_ASN1_INTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_OBJECT, 0), "c2i_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_IBUF, 0), "c2i_ibuf"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_UINT64_INT, 0), "c2i_uint64_int"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_COLLECT_DATA, 0), "collect_data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_ASN1_OBJECT, 0), "d2i_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_ASN1_UINTEGER, 0), "d2i_ASN1_UINTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_AUTOPRIVATEKEY, 0),
|
||||
"d2i_AutoPrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_PRIVATEKEY, 0), "d2i_PrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_PUBLICKEY, 0), "d2i_PublicKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_TCREATE, 0), "do_tcreate"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_ASN1_BIO_STREAM, 0),
|
||||
"i2d_ASN1_bio_stream"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_DSA_PUBKEY, 0), "i2d_DSA_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_EC_PUBKEY, 0), "i2d_EC_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_PRIVATEKEY, 0), "i2d_PrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_PUBLICKEY, 0), "i2d_PublicKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_RSA_PUBKEY, 0), "i2d_RSA_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_LONG_C2I, 0), "long_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_OID_MODULE_INIT, 0), "oid_module_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PARSE_TAGGING, 0), "parse_tagging"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE2_SET_IV, 0), "PKCS5_pbe2_set_iv"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE2_SET_SCRYPT, 0),
|
||||
"PKCS5_pbe2_set_scrypt"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE_SET, 0), "PKCS5_pbe_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE_SET0_ALGOR, 0),
|
||||
"PKCS5_pbe_set0_algor"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBKDF2_SET, 0), "PKCS5_pbkdf2_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_SCRYPT_SET, 0), "pkcs5_scrypt_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_SMIME_READ_ASN1, 0), "SMIME_read_ASN1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_SMIME_TEXT, 0), "SMIME_text"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_STBL_MODULE_INIT, 0), "stbl_module_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT32_C2I, 0), "uint32_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT64_C2I, 0), "uint64_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_CRL_ADD0_REVOKED, 0),
|
||||
"X509_CRL_add0_revoked"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_INFO_NEW, 0), "X509_INFO_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_ENCODE, 0), "x509_name_encode"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_EX_D2I, 0), "x509_name_ex_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_EX_NEW, 0), "x509_name_ex_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_PKEY_NEW, 0), "X509_PKEY_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
{ERR_REASON(ASN1_R_ADDING_OBJECT), "adding object"},
|
||||
{ERR_REASON(ASN1_R_ASN1_PARSE_ERROR), "asn1 parse error"},
|
||||
{ERR_REASON(ASN1_R_ASN1_SIG_PARSE_ERROR), "asn1 sig parse error"},
|
||||
{ERR_REASON(ASN1_R_AUX_ERROR), "aux error"},
|
||||
{ERR_REASON(ASN1_R_BAD_OBJECT_HEADER), "bad object header"},
|
||||
{ERR_REASON(ASN1_R_BMPSTRING_IS_WRONG_LENGTH),
|
||||
"bmpstring is wrong length"},
|
||||
{ERR_REASON(ASN1_R_BN_LIB), "bn lib"},
|
||||
{ERR_REASON(ASN1_R_BOOLEAN_IS_WRONG_LENGTH), "boolean is wrong length"},
|
||||
{ERR_REASON(ASN1_R_BUFFER_TOO_SMALL), "buffer too small"},
|
||||
{ERR_REASON(ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER),
|
||||
"cipher has no object identifier"},
|
||||
{ERR_REASON(ASN1_R_CONTEXT_NOT_INITIALISED), "context not initialised"},
|
||||
{ERR_REASON(ASN1_R_DATA_IS_WRONG), "data is wrong"},
|
||||
{ERR_REASON(ASN1_R_DECODE_ERROR), "decode error"},
|
||||
{ERR_REASON(ASN1_R_DEPTH_EXCEEDED), "depth exceeded"},
|
||||
{ERR_REASON(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED),
|
||||
"digest and key type not supported"},
|
||||
{ERR_REASON(ASN1_R_ENCODE_ERROR), "encode error"},
|
||||
{ERR_REASON(ASN1_R_ERROR_GETTING_TIME), "error getting time"},
|
||||
{ERR_REASON(ASN1_R_ERROR_LOADING_SECTION), "error loading section"},
|
||||
{ERR_REASON(ASN1_R_ERROR_SETTING_CIPHER_PARAMS),
|
||||
"error setting cipher params"},
|
||||
{ERR_REASON(ASN1_R_EXPECTING_AN_INTEGER), "expecting an integer"},
|
||||
{ERR_REASON(ASN1_R_EXPECTING_AN_OBJECT), "expecting an object"},
|
||||
{ERR_REASON(ASN1_R_EXPLICIT_LENGTH_MISMATCH), "explicit length mismatch"},
|
||||
{ERR_REASON(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED),
|
||||
"explicit tag not constructed"},
|
||||
{ERR_REASON(ASN1_R_FIELD_MISSING), "field missing"},
|
||||
{ERR_REASON(ASN1_R_FIRST_NUM_TOO_LARGE), "first num too large"},
|
||||
{ERR_REASON(ASN1_R_HEADER_TOO_LONG), "header too long"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_BITSTRING_FORMAT), "illegal bitstring format"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_BOOLEAN), "illegal boolean"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_CHARACTERS), "illegal characters"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_FORMAT), "illegal format"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_HEX), "illegal hex"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_IMPLICIT_TAG), "illegal implicit tag"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_INTEGER), "illegal integer"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_NEGATIVE_VALUE), "illegal negative value"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_NESTED_TAGGING), "illegal nested tagging"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_NULL), "illegal null"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_NULL_VALUE), "illegal null value"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_OBJECT), "illegal object"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_OPTIONAL_ANY), "illegal optional any"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE),
|
||||
"illegal options on item template"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_PADDING), "illegal padding"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_TAGGED_ANY), "illegal tagged any"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE), "illegal time value"},
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_ZERO_CONTENT), "illegal zero content"},
|
||||
{ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT), "integer not ascii format"},
|
||||
{ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG),
|
||||
"integer too large for long"},
|
||||
{ERR_REASON(ASN1_R_INVALID_BIT_STRING_BITS_LEFT),
|
||||
"invalid bit string bits left"},
|
||||
{ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH), "invalid bmpstring length"},
|
||||
{ERR_REASON(ASN1_R_INVALID_DIGIT), "invalid digit"},
|
||||
{ERR_REASON(ASN1_R_INVALID_MIME_TYPE), "invalid mime type"},
|
||||
{ERR_REASON(ASN1_R_INVALID_MODIFIER), "invalid modifier"},
|
||||
{ERR_REASON(ASN1_R_INVALID_NUMBER), "invalid number"},
|
||||
{ERR_REASON(ASN1_R_INVALID_OBJECT_ENCODING), "invalid object encoding"},
|
||||
{ERR_REASON(ASN1_R_INVALID_SCRYPT_PARAMETERS),
|
||||
"invalid scrypt parameters"},
|
||||
{ERR_REASON(ASN1_R_INVALID_SEPARATOR), "invalid separator"},
|
||||
{ERR_REASON(ASN1_R_INVALID_STRING_TABLE_VALUE),
|
||||
"invalid string table value"},
|
||||
{ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH),
|
||||
"invalid universalstring length"},
|
||||
{ERR_REASON(ASN1_R_INVALID_UTF8STRING), "invalid utf8string"},
|
||||
{ERR_REASON(ASN1_R_INVALID_VALUE), "invalid value"},
|
||||
{ERR_REASON(ASN1_R_LIST_ERROR), "list error"},
|
||||
{ERR_REASON(ASN1_R_MIME_NO_CONTENT_TYPE), "mime no content type"},
|
||||
{ERR_REASON(ASN1_R_MIME_PARSE_ERROR), "mime parse error"},
|
||||
{ERR_REASON(ASN1_R_MIME_SIG_PARSE_ERROR), "mime sig parse error"},
|
||||
{ERR_REASON(ASN1_R_MISSING_EOC), "missing eoc"},
|
||||
{ERR_REASON(ASN1_R_MISSING_SECOND_NUMBER), "missing second number"},
|
||||
{ERR_REASON(ASN1_R_MISSING_VALUE), "missing value"},
|
||||
{ERR_REASON(ASN1_R_MSTRING_NOT_UNIVERSAL), "mstring not universal"},
|
||||
{ERR_REASON(ASN1_R_MSTRING_WRONG_TAG), "mstring wrong tag"},
|
||||
{ERR_REASON(ASN1_R_NESTED_ASN1_STRING), "nested asn1 string"},
|
||||
{ERR_REASON(ASN1_R_NESTED_TOO_DEEP), "nested too deep"},
|
||||
{ERR_REASON(ASN1_R_NON_HEX_CHARACTERS), "non hex characters"},
|
||||
{ERR_REASON(ASN1_R_NOT_ASCII_FORMAT), "not ascii format"},
|
||||
{ERR_REASON(ASN1_R_NOT_ENOUGH_DATA), "not enough data"},
|
||||
{ERR_REASON(ASN1_R_NO_CONTENT_TYPE), "no content type"},
|
||||
{ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE), "no matching choice type"},
|
||||
{ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE),
|
||||
"no multipart body failure"},
|
||||
{ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY), "no multipart boundary"},
|
||||
{ERR_REASON(ASN1_R_NO_SIG_CONTENT_TYPE), "no sig content type"},
|
||||
{ERR_REASON(ASN1_R_NULL_IS_WRONG_LENGTH), "null is wrong length"},
|
||||
{ERR_REASON(ASN1_R_OBJECT_NOT_ASCII_FORMAT), "object not ascii format"},
|
||||
{ERR_REASON(ASN1_R_ODD_NUMBER_OF_CHARS), "odd number of chars"},
|
||||
{ERR_REASON(ASN1_R_SECOND_NUMBER_TOO_LARGE), "second number too large"},
|
||||
{ERR_REASON(ASN1_R_SEQUENCE_LENGTH_MISMATCH), "sequence length mismatch"},
|
||||
{ERR_REASON(ASN1_R_SEQUENCE_NOT_CONSTRUCTED), "sequence not constructed"},
|
||||
{ERR_REASON(ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG),
|
||||
"sequence or set needs config"},
|
||||
{ERR_REASON(ASN1_R_SHORT_LINE), "short line"},
|
||||
{ERR_REASON(ASN1_R_SIG_INVALID_MIME_TYPE), "sig invalid mime type"},
|
||||
{ERR_REASON(ASN1_R_STREAMING_NOT_SUPPORTED), "streaming not supported"},
|
||||
{ERR_REASON(ASN1_R_STRING_TOO_LONG), "string too long"},
|
||||
{ERR_REASON(ASN1_R_STRING_TOO_SHORT), "string too short"},
|
||||
{ERR_REASON(ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD),
|
||||
"the asn1 object identifier is not known for this md"},
|
||||
{ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT), "time not ascii format"},
|
||||
{ERR_REASON(ASN1_R_TOO_LARGE), "too large"},
|
||||
{ERR_REASON(ASN1_R_TOO_LONG), "too long"},
|
||||
{ERR_REASON(ASN1_R_TOO_SMALL), "too small"},
|
||||
{ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED), "type not constructed"},
|
||||
{ERR_REASON(ASN1_R_TYPE_NOT_PRIMITIVE), "type not primitive"},
|
||||
{ERR_REASON(ASN1_R_UNEXPECTED_EOC), "unexpected eoc"},
|
||||
{ERR_REASON(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH),
|
||||
"universalstring is wrong length"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_FORMAT), "unknown format"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM),
|
||||
"unknown message digest algorithm"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE), "unknown object type"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE), "unknown public key type"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),
|
||||
"unknown signature algorithm"},
|
||||
{ERR_REASON(ASN1_R_UNKNOWN_TAG), "unknown tag"},
|
||||
{ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),
|
||||
"unsupported any defined by type"},
|
||||
{ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),
|
||||
"unsupported public key type"},
|
||||
{ERR_REASON(ASN1_R_UNSUPPORTED_TYPE), "unsupported type"},
|
||||
{ERR_REASON(ASN1_R_WRONG_INTEGER_TYPE), "wrong integer type"},
|
||||
{ERR_REASON(ASN1_R_WRONG_PUBLIC_KEY_TYPE), "wrong public key type"},
|
||||
{ERR_REASON(ASN1_R_WRONG_TAG), "wrong tag"},
|
||||
static const ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ADDING_OBJECT), "adding object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ASN1_PARSE_ERROR), "asn1 parse error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ASN1_SIG_PARSE_ERROR),
|
||||
"asn1 sig parse error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_AUX_ERROR), "aux error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_BAD_OBJECT_HEADER), "bad object header"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_BMPSTRING_IS_WRONG_LENGTH),
|
||||
"bmpstring is wrong length"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_BN_LIB), "bn lib"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_BOOLEAN_IS_WRONG_LENGTH),
|
||||
"boolean is wrong length"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_BUFFER_TOO_SMALL), "buffer too small"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER),
|
||||
"cipher has no object identifier"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_CONTEXT_NOT_INITIALISED),
|
||||
"context not initialised"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_DATA_IS_WRONG), "data is wrong"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_DECODE_ERROR), "decode error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_DEPTH_EXCEEDED), "depth exceeded"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED),
|
||||
"digest and key type not supported"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ENCODE_ERROR), "encode error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ERROR_GETTING_TIME),
|
||||
"error getting time"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ERROR_LOADING_SECTION),
|
||||
"error loading section"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ERROR_SETTING_CIPHER_PARAMS),
|
||||
"error setting cipher params"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_EXPECTING_AN_INTEGER),
|
||||
"expecting an integer"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_EXPECTING_AN_OBJECT),
|
||||
"expecting an object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_EXPLICIT_LENGTH_MISMATCH),
|
||||
"explicit length mismatch"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED),
|
||||
"explicit tag not constructed"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_FIELD_MISSING), "field missing"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_FIRST_NUM_TOO_LARGE),
|
||||
"first num too large"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_HEADER_TOO_LONG), "header too long"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_BITSTRING_FORMAT),
|
||||
"illegal bitstring format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_BOOLEAN), "illegal boolean"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_CHARACTERS),
|
||||
"illegal characters"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_FORMAT), "illegal format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_HEX), "illegal hex"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_IMPLICIT_TAG),
|
||||
"illegal implicit tag"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_INTEGER), "illegal integer"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_NEGATIVE_VALUE),
|
||||
"illegal negative value"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_NESTED_TAGGING),
|
||||
"illegal nested tagging"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_NULL), "illegal null"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_NULL_VALUE),
|
||||
"illegal null value"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_OBJECT), "illegal object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_OPTIONAL_ANY),
|
||||
"illegal optional any"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE),
|
||||
"illegal options on item template"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_PADDING), "illegal padding"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_TAGGED_ANY),
|
||||
"illegal tagged any"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_TIME_VALUE),
|
||||
"illegal time value"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ILLEGAL_ZERO_CONTENT),
|
||||
"illegal zero content"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INTEGER_NOT_ASCII_FORMAT),
|
||||
"integer not ascii format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG),
|
||||
"integer too large for long"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_BIT_STRING_BITS_LEFT),
|
||||
"invalid bit string bits left"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_BMPSTRING_LENGTH),
|
||||
"invalid bmpstring length"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_DIGIT), "invalid digit"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_MIME_TYPE), "invalid mime type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_MODIFIER), "invalid modifier"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_NUMBER), "invalid number"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_OBJECT_ENCODING),
|
||||
"invalid object encoding"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_SCRYPT_PARAMETERS),
|
||||
"invalid scrypt parameters"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_SEPARATOR), "invalid separator"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_STRING_TABLE_VALUE),
|
||||
"invalid string table value"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_UNIVERSALSTRING_LENGTH),
|
||||
"invalid universalstring length"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_UTF8STRING),
|
||||
"invalid utf8string"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_INVALID_VALUE), "invalid value"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_LIST_ERROR), "list error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MIME_NO_CONTENT_TYPE),
|
||||
"mime no content type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MIME_PARSE_ERROR), "mime parse error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MIME_SIG_PARSE_ERROR),
|
||||
"mime sig parse error"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MISSING_EOC), "missing eoc"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MISSING_SECOND_NUMBER),
|
||||
"missing second number"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MISSING_VALUE), "missing value"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MSTRING_NOT_UNIVERSAL),
|
||||
"mstring not universal"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_MSTRING_WRONG_TAG), "mstring wrong tag"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NESTED_ASN1_STRING),
|
||||
"nested asn1 string"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NON_HEX_CHARACTERS),
|
||||
"non hex characters"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NOT_ASCII_FORMAT), "not ascii format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NOT_ENOUGH_DATA), "not enough data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NO_CONTENT_TYPE), "no content type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NO_MATCHING_CHOICE_TYPE),
|
||||
"no matching choice type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NO_MULTIPART_BODY_FAILURE),
|
||||
"no multipart body failure"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NO_MULTIPART_BOUNDARY),
|
||||
"no multipart boundary"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NO_SIG_CONTENT_TYPE),
|
||||
"no sig content type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_NULL_IS_WRONG_LENGTH),
|
||||
"null is wrong length"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_OBJECT_NOT_ASCII_FORMAT),
|
||||
"object not ascii format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ODD_NUMBER_OF_CHARS),
|
||||
"odd number of chars"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_SECOND_NUMBER_TOO_LARGE),
|
||||
"second number too large"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_SEQUENCE_LENGTH_MISMATCH),
|
||||
"sequence length mismatch"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_SEQUENCE_NOT_CONSTRUCTED),
|
||||
"sequence not constructed"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG),
|
||||
"sequence or set needs config"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_SHORT_LINE), "short line"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_SIG_INVALID_MIME_TYPE),
|
||||
"sig invalid mime type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_STREAMING_NOT_SUPPORTED),
|
||||
"streaming not supported"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_STRING_TOO_LONG), "string too long"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_STRING_TOO_SHORT), "string too short"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD),
|
||||
"the asn1 object identifier is not known for this md"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_TIME_NOT_ASCII_FORMAT),
|
||||
"time not ascii format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_TOO_LARGE), "too large"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_TOO_LONG), "too long"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_TOO_SMALL), "too small"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_TYPE_NOT_CONSTRUCTED),
|
||||
"type not constructed"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_TYPE_NOT_PRIMITIVE),
|
||||
"type not primitive"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNEXPECTED_EOC), "unexpected eoc"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH),
|
||||
"universalstring is wrong length"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_FORMAT), "unknown format"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM),
|
||||
"unknown message digest algorithm"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_OBJECT_TYPE),
|
||||
"unknown object type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),
|
||||
"unknown public key type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),
|
||||
"unknown signature algorithm"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_TAG), "unknown tag"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),
|
||||
"unsupported any defined by type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),
|
||||
"unsupported public key type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_TYPE), "unsupported type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_WRONG_INTEGER_TYPE),
|
||||
"wrong integer type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_WRONG_PUBLIC_KEY_TYPE),
|
||||
"wrong public key type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_WRONG_TAG), "wrong tag"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
@@ -261,10 +322,9 @@ static ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
int ERR_load_ASN1_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings(0, ASN1_str_functs);
|
||||
ERR_load_strings(0, ASN1_str_reasons);
|
||||
ERR_load_strings_const(ASN1_str_functs);
|
||||
ERR_load_strings_const(ASN1_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/cms.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/pkcs7.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
#include "asn1_item_list.h"
|
||||
|
||||
const ASN1_ITEM *ASN1_ITEM_lookup(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(asn1_item_list); i++) {
|
||||
const ASN1_ITEM *it = ASN1_ITEM_ptr(asn1_item_list[i]);
|
||||
|
||||
if (strcmp(it->sname, name) == 0)
|
||||
return it;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const ASN1_ITEM *ASN1_ITEM_get(size_t i)
|
||||
{
|
||||
if (i >= OSSL_NELEM(asn1_item_list))
|
||||
return NULL;
|
||||
return ASN1_ITEM_ptr(asn1_item_list[i]);
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
static ASN1_ITEM_EXP *asn1_item_list[] = {
|
||||
|
||||
ASN1_ITEM_ref(ACCESS_DESCRIPTION),
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
ASN1_ITEM_ref(ASIdOrRange),
|
||||
ASN1_ITEM_ref(ASIdentifierChoice),
|
||||
ASN1_ITEM_ref(ASIdentifiers),
|
||||
#endif
|
||||
ASN1_ITEM_ref(ASN1_ANY),
|
||||
ASN1_ITEM_ref(ASN1_BIT_STRING),
|
||||
ASN1_ITEM_ref(ASN1_BMPSTRING),
|
||||
ASN1_ITEM_ref(ASN1_BOOLEAN),
|
||||
ASN1_ITEM_ref(ASN1_ENUMERATED),
|
||||
ASN1_ITEM_ref(ASN1_FBOOLEAN),
|
||||
ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
|
||||
ASN1_ITEM_ref(ASN1_GENERALSTRING),
|
||||
ASN1_ITEM_ref(ASN1_IA5STRING),
|
||||
ASN1_ITEM_ref(ASN1_INTEGER),
|
||||
ASN1_ITEM_ref(ASN1_NULL),
|
||||
ASN1_ITEM_ref(ASN1_OBJECT),
|
||||
ASN1_ITEM_ref(ASN1_OCTET_STRING_NDEF),
|
||||
ASN1_ITEM_ref(ASN1_OCTET_STRING),
|
||||
ASN1_ITEM_ref(ASN1_PRINTABLESTRING),
|
||||
ASN1_ITEM_ref(ASN1_PRINTABLE),
|
||||
ASN1_ITEM_ref(ASN1_SEQUENCE_ANY),
|
||||
ASN1_ITEM_ref(ASN1_SEQUENCE),
|
||||
ASN1_ITEM_ref(ASN1_SET_ANY),
|
||||
ASN1_ITEM_ref(ASN1_T61STRING),
|
||||
ASN1_ITEM_ref(ASN1_TBOOLEAN),
|
||||
ASN1_ITEM_ref(ASN1_TIME),
|
||||
ASN1_ITEM_ref(ASN1_UNIVERSALSTRING),
|
||||
ASN1_ITEM_ref(ASN1_UTCTIME),
|
||||
ASN1_ITEM_ref(ASN1_UTF8STRING),
|
||||
ASN1_ITEM_ref(ASN1_VISIBLESTRING),
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
ASN1_ITEM_ref(ASRange),
|
||||
#endif
|
||||
ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
|
||||
ASN1_ITEM_ref(AUTHORITY_KEYID),
|
||||
ASN1_ITEM_ref(BASIC_CONSTRAINTS),
|
||||
ASN1_ITEM_ref(BIGNUM),
|
||||
ASN1_ITEM_ref(CBIGNUM),
|
||||
ASN1_ITEM_ref(CERTIFICATEPOLICIES),
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
ASN1_ITEM_ref(CMS_ContentInfo),
|
||||
ASN1_ITEM_ref(CMS_ReceiptRequest),
|
||||
#endif
|
||||
ASN1_ITEM_ref(CRL_DIST_POINTS),
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ASN1_ITEM_ref(DHparams),
|
||||
#endif
|
||||
ASN1_ITEM_ref(DIRECTORYSTRING),
|
||||
ASN1_ITEM_ref(DISPLAYTEXT),
|
||||
ASN1_ITEM_ref(DIST_POINT_NAME),
|
||||
ASN1_ITEM_ref(DIST_POINT),
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ASN1_ITEM_ref(ECPARAMETERS),
|
||||
ASN1_ITEM_ref(ECPKPARAMETERS),
|
||||
#endif
|
||||
ASN1_ITEM_ref(EDIPARTYNAME),
|
||||
ASN1_ITEM_ref(EXTENDED_KEY_USAGE),
|
||||
ASN1_ITEM_ref(GENERAL_NAMES),
|
||||
ASN1_ITEM_ref(GENERAL_NAME),
|
||||
ASN1_ITEM_ref(GENERAL_SUBTREE),
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
ASN1_ITEM_ref(IPAddressChoice),
|
||||
ASN1_ITEM_ref(IPAddressFamily),
|
||||
ASN1_ITEM_ref(IPAddressOrRange),
|
||||
ASN1_ITEM_ref(IPAddressRange),
|
||||
#endif
|
||||
ASN1_ITEM_ref(ISSUING_DIST_POINT),
|
||||
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||
ASN1_ITEM_ref(LONG),
|
||||
#endif
|
||||
ASN1_ITEM_ref(NAME_CONSTRAINTS),
|
||||
ASN1_ITEM_ref(NETSCAPE_CERT_SEQUENCE),
|
||||
ASN1_ITEM_ref(NETSCAPE_SPKAC),
|
||||
ASN1_ITEM_ref(NETSCAPE_SPKI),
|
||||
ASN1_ITEM_ref(NOTICEREF),
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
ASN1_ITEM_ref(OCSP_BASICRESP),
|
||||
ASN1_ITEM_ref(OCSP_CERTID),
|
||||
ASN1_ITEM_ref(OCSP_CERTSTATUS),
|
||||
ASN1_ITEM_ref(OCSP_CRLID),
|
||||
ASN1_ITEM_ref(OCSP_ONEREQ),
|
||||
ASN1_ITEM_ref(OCSP_REQINFO),
|
||||
ASN1_ITEM_ref(OCSP_REQUEST),
|
||||
ASN1_ITEM_ref(OCSP_RESPBYTES),
|
||||
ASN1_ITEM_ref(OCSP_RESPDATA),
|
||||
ASN1_ITEM_ref(OCSP_RESPID),
|
||||
ASN1_ITEM_ref(OCSP_RESPONSE),
|
||||
ASN1_ITEM_ref(OCSP_REVOKEDINFO),
|
||||
ASN1_ITEM_ref(OCSP_SERVICELOC),
|
||||
ASN1_ITEM_ref(OCSP_SIGNATURE),
|
||||
ASN1_ITEM_ref(OCSP_SINGLERESP),
|
||||
#endif
|
||||
ASN1_ITEM_ref(OTHERNAME),
|
||||
ASN1_ITEM_ref(PBE2PARAM),
|
||||
ASN1_ITEM_ref(PBEPARAM),
|
||||
ASN1_ITEM_ref(PBKDF2PARAM),
|
||||
ASN1_ITEM_ref(PKCS12_AUTHSAFES),
|
||||
ASN1_ITEM_ref(PKCS12_BAGS),
|
||||
ASN1_ITEM_ref(PKCS12_MAC_DATA),
|
||||
ASN1_ITEM_ref(PKCS12_SAFEBAGS),
|
||||
ASN1_ITEM_ref(PKCS12_SAFEBAG),
|
||||
ASN1_ITEM_ref(PKCS12),
|
||||
ASN1_ITEM_ref(PKCS7_ATTR_SIGN),
|
||||
ASN1_ITEM_ref(PKCS7_ATTR_VERIFY),
|
||||
ASN1_ITEM_ref(PKCS7_DIGEST),
|
||||
ASN1_ITEM_ref(PKCS7_ENCRYPT),
|
||||
ASN1_ITEM_ref(PKCS7_ENC_CONTENT),
|
||||
ASN1_ITEM_ref(PKCS7_ENVELOPE),
|
||||
ASN1_ITEM_ref(PKCS7_ISSUER_AND_SERIAL),
|
||||
ASN1_ITEM_ref(PKCS7_RECIP_INFO),
|
||||
ASN1_ITEM_ref(PKCS7_SIGNED),
|
||||
ASN1_ITEM_ref(PKCS7_SIGNER_INFO),
|
||||
ASN1_ITEM_ref(PKCS7_SIGN_ENVELOPE),
|
||||
ASN1_ITEM_ref(PKCS7),
|
||||
ASN1_ITEM_ref(PKCS8_PRIV_KEY_INFO),
|
||||
ASN1_ITEM_ref(PKEY_USAGE_PERIOD),
|
||||
ASN1_ITEM_ref(POLICYINFO),
|
||||
ASN1_ITEM_ref(POLICYQUALINFO),
|
||||
ASN1_ITEM_ref(POLICY_CONSTRAINTS),
|
||||
ASN1_ITEM_ref(POLICY_MAPPINGS),
|
||||
ASN1_ITEM_ref(POLICY_MAPPING),
|
||||
ASN1_ITEM_ref(PROXY_CERT_INFO_EXTENSION),
|
||||
ASN1_ITEM_ref(PROXY_POLICY),
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
ASN1_ITEM_ref(RSAPrivateKey),
|
||||
ASN1_ITEM_ref(RSAPublicKey),
|
||||
ASN1_ITEM_ref(RSA_OAEP_PARAMS),
|
||||
ASN1_ITEM_ref(RSA_PSS_PARAMS),
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
ASN1_ITEM_ref(SCRYPT_PARAMS),
|
||||
#endif
|
||||
ASN1_ITEM_ref(SXNETID),
|
||||
ASN1_ITEM_ref(SXNET),
|
||||
ASN1_ITEM_ref(USERNOTICE),
|
||||
ASN1_ITEM_ref(X509_ALGORS),
|
||||
ASN1_ITEM_ref(X509_ALGOR),
|
||||
ASN1_ITEM_ref(X509_ATTRIBUTE),
|
||||
ASN1_ITEM_ref(X509_CERT_AUX),
|
||||
ASN1_ITEM_ref(X509_CINF),
|
||||
ASN1_ITEM_ref(X509_CRL_INFO),
|
||||
ASN1_ITEM_ref(X509_CRL),
|
||||
ASN1_ITEM_ref(X509_EXTENSIONS),
|
||||
ASN1_ITEM_ref(X509_EXTENSION),
|
||||
ASN1_ITEM_ref(X509_NAME_ENTRY),
|
||||
ASN1_ITEM_ref(X509_NAME),
|
||||
ASN1_ITEM_ref(X509_PUBKEY),
|
||||
ASN1_ITEM_ref(X509_REQ_INFO),
|
||||
ASN1_ITEM_ref(X509_REQ),
|
||||
ASN1_ITEM_ref(X509_REVOKED),
|
||||
ASN1_ITEM_ref(X509_SIG),
|
||||
ASN1_ITEM_ref(X509_VAL),
|
||||
ASN1_ITEM_ref(X509),
|
||||
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||
ASN1_ITEM_ref(ZLONG),
|
||||
#endif
|
||||
ASN1_ITEM_ref(INT32),
|
||||
ASN1_ITEM_ref(UINT32),
|
||||
ASN1_ITEM_ref(ZINT32),
|
||||
ASN1_ITEM_ref(ZUINT32),
|
||||
ASN1_ITEM_ref(INT64),
|
||||
ASN1_ITEM_ref(UINT64),
|
||||
ASN1_ITEM_ref(ZINT64),
|
||||
ASN1_ITEM_ref(ZUINT64),
|
||||
};
|
||||
+32
-25
@@ -23,12 +23,12 @@ static int _asn1_check_infinite_end(const unsigned char **p, long len)
|
||||
* If there is 0 or 1 byte left, the length check should pick things up
|
||||
*/
|
||||
if (len <= 0)
|
||||
return (1);
|
||||
return 1;
|
||||
else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0)) {
|
||||
(*p) += 2;
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_check_infinite_end(unsigned char **p, long len)
|
||||
@@ -96,47 +96,54 @@ int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
|
||||
ret |= 0x80;
|
||||
}
|
||||
*pp = p;
|
||||
return (ret | inf);
|
||||
return ret | inf;
|
||||
err:
|
||||
ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG);
|
||||
return (0x80);
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode a length field.
|
||||
* The short form is a single byte defining a length 0 - 127.
|
||||
* The long form is a byte 0 - 127 with the top bit set and this indicates
|
||||
* the number of following octets that contain the length. These octets
|
||||
* are stored most significant digit first.
|
||||
*/
|
||||
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
|
||||
long max)
|
||||
{
|
||||
const unsigned char *p = *pp;
|
||||
unsigned long ret = 0;
|
||||
unsigned long i;
|
||||
int i;
|
||||
|
||||
if (max-- < 1)
|
||||
return 0;
|
||||
if (*p == 0x80) {
|
||||
*inf = 1;
|
||||
ret = 0;
|
||||
p++;
|
||||
} else {
|
||||
*inf = 0;
|
||||
i = *p & 0x7f;
|
||||
if (*(p++) & 0x80) {
|
||||
if (max < (long)i + 1)
|
||||
if (*p++ & 0x80) {
|
||||
if (max < i + 1)
|
||||
return 0;
|
||||
/* Skip leading zeroes */
|
||||
while (i && *p == 0) {
|
||||
while (i > 0 && *p == 0) {
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
if (i > sizeof(long))
|
||||
if (i > (int)sizeof(long))
|
||||
return 0;
|
||||
while (i-- > 0) {
|
||||
ret <<= 8L;
|
||||
ret |= *(p++);
|
||||
while (i > 0) {
|
||||
ret <<= 8;
|
||||
ret |= *p++;
|
||||
i--;
|
||||
}
|
||||
if (ret > LONG_MAX)
|
||||
return 0;
|
||||
} else
|
||||
ret = i;
|
||||
}
|
||||
if (ret > LONG_MAX)
|
||||
return 0;
|
||||
*pp = p;
|
||||
*rl = (long)ret;
|
||||
return 1;
|
||||
@@ -268,7 +275,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
|
||||
if (len < 0) {
|
||||
if (data == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
else
|
||||
len = strlen(data);
|
||||
}
|
||||
@@ -278,7 +285,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
if (str->data == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
|
||||
str->data = c;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
str->length = len;
|
||||
@@ -287,7 +294,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
/* an allowance for strings :-) */
|
||||
str->data[len] = '\0';
|
||||
}
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
|
||||
@@ -299,7 +306,7 @@ void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
|
||||
|
||||
ASN1_STRING *ASN1_STRING_new(void)
|
||||
{
|
||||
return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
|
||||
return ASN1_STRING_type_new(V_ASN1_OCTET_STRING);
|
||||
}
|
||||
|
||||
ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||
@@ -309,10 +316,10 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
|
||||
ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
if (ret == NULL) {
|
||||
ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
ret->type = type;
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void asn1_string_embed_free(ASN1_STRING *a, int embed)
|
||||
@@ -349,11 +356,11 @@ int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
|
||||
if (i == 0) {
|
||||
i = memcmp(a->data, b->data, a->length);
|
||||
if (i == 0)
|
||||
return (a->type - b->type);
|
||||
return a->type - b->type;
|
||||
else
|
||||
return (i);
|
||||
return i;
|
||||
} else
|
||||
return (i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int ASN1_STRING_length(const ASN1_STRING *x)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/* Internal ASN1 structures and functions: not for application use */
|
||||
|
||||
int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d);
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
|
||||
|
||||
@@ -42,9 +43,6 @@ DEFINE_STACK_OF(MIME_PARAM)
|
||||
typedef struct mime_header_st MIME_HEADER;
|
||||
DEFINE_STACK_OF(MIME_HEADER)
|
||||
|
||||
/* Month values for printing out times */
|
||||
extern const char *_asn1_mon[12];
|
||||
|
||||
void asn1_string_embed_free(ASN1_STRING *a, int embed);
|
||||
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
@@ -81,3 +79,5 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
|
||||
/* Internal functions used by x_int64.c */
|
||||
int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len);
|
||||
int i2c_uint64_int(unsigned char *p, uint64_t r, int neg);
|
||||
|
||||
ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -50,20 +50,20 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
|
||||
|
||||
if (BIO_printf(bp, fmt, p) <= 0)
|
||||
goto err;
|
||||
return (1);
|
||||
return 1;
|
||||
err:
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent)
|
||||
{
|
||||
return (asn1_parse2(bp, &pp, len, 0, 0, indent, 0));
|
||||
return asn1_parse2(bp, &pp, len, 0, 0, indent, 0);
|
||||
}
|
||||
|
||||
int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,
|
||||
int dump)
|
||||
{
|
||||
return (asn1_parse2(bp, &pp, len, 0, 0, indent, dump));
|
||||
return asn1_parse2(bp, &pp, len, 0, 0, indent, dump);
|
||||
}
|
||||
|
||||
static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
@@ -342,7 +342,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
|
||||
ASN1_OBJECT_free(o);
|
||||
ASN1_OCTET_STRING_free(os);
|
||||
*pp = p;
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *ASN1_tag2str(int tag)
|
||||
|
||||
+14
-30
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/x509.h>
|
||||
@@ -635,7 +635,7 @@ static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio)
|
||||
return NULL;
|
||||
while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {
|
||||
/* If whitespace at line start then continuation line */
|
||||
if (mhdr && isspace((unsigned char)linebuf[0]))
|
||||
if (mhdr && ossl_isspace(linebuf[0]))
|
||||
state = MIME_NAME;
|
||||
else
|
||||
state = MIME_START;
|
||||
@@ -759,7 +759,7 @@ static char *strip_start(char *name)
|
||||
/* Else null string */
|
||||
return NULL;
|
||||
}
|
||||
if (!isspace((unsigned char)c))
|
||||
if (!ossl_isspace(c))
|
||||
return p;
|
||||
}
|
||||
return NULL;
|
||||
@@ -780,7 +780,7 @@ static char *strip_end(char *name)
|
||||
*p = 0;
|
||||
return name;
|
||||
}
|
||||
if (isspace((unsigned char)c))
|
||||
if (ossl_isspace(c))
|
||||
*p = 0;
|
||||
else
|
||||
return name;
|
||||
@@ -792,29 +792,18 @@ static MIME_HEADER *mime_hdr_new(const char *name, const char *value)
|
||||
{
|
||||
MIME_HEADER *mhdr = NULL;
|
||||
char *tmpname = NULL, *tmpval = NULL, *p;
|
||||
int c;
|
||||
|
||||
if (name) {
|
||||
if ((tmpname = OPENSSL_strdup(name)) == NULL)
|
||||
return NULL;
|
||||
for (p = tmpname; *p; p++) {
|
||||
c = (unsigned char)*p;
|
||||
if (isupper(c)) {
|
||||
c = tolower(c);
|
||||
*p = c;
|
||||
}
|
||||
}
|
||||
for (p = tmpname; *p; p++)
|
||||
*p = ossl_tolower(*p);
|
||||
}
|
||||
if (value) {
|
||||
if ((tmpval = OPENSSL_strdup(value)) == NULL)
|
||||
goto err;
|
||||
for (p = tmpval; *p; p++) {
|
||||
c = (unsigned char)*p;
|
||||
if (isupper(c)) {
|
||||
c = tolower(c);
|
||||
*p = c;
|
||||
}
|
||||
}
|
||||
for (p = tmpval; *p; p++)
|
||||
*p = ossl_tolower(*p);
|
||||
}
|
||||
mhdr = OPENSSL_malloc(sizeof(*mhdr));
|
||||
if (mhdr == NULL)
|
||||
@@ -835,19 +824,14 @@ static MIME_HEADER *mime_hdr_new(const char *name, const char *value)
|
||||
static int mime_hdr_addparam(MIME_HEADER *mhdr, const char *name, const char *value)
|
||||
{
|
||||
char *tmpname = NULL, *tmpval = NULL, *p;
|
||||
int c;
|
||||
MIME_PARAM *mparam = NULL;
|
||||
|
||||
if (name) {
|
||||
tmpname = OPENSSL_strdup(name);
|
||||
if (!tmpname)
|
||||
goto err;
|
||||
for (p = tmpname; *p; p++) {
|
||||
c = (unsigned char)*p;
|
||||
if (isupper(c)) {
|
||||
c = tolower(c);
|
||||
*p = c;
|
||||
}
|
||||
}
|
||||
for (p = tmpname; *p; p++)
|
||||
*p = ossl_tolower(*p);
|
||||
}
|
||||
if (value) {
|
||||
tmpval = OPENSSL_strdup(value);
|
||||
@@ -876,7 +860,7 @@ static int mime_hdr_cmp(const MIME_HEADER *const *a,
|
||||
if (!(*a)->name || !(*b)->name)
|
||||
return ! !(*a)->name - ! !(*b)->name;
|
||||
|
||||
return (strcmp((*a)->name, (*b)->name));
|
||||
return strcmp((*a)->name, (*b)->name);
|
||||
}
|
||||
|
||||
static int mime_param_cmp(const MIME_PARAM *const *a,
|
||||
@@ -884,7 +868,7 @@ static int mime_param_cmp(const MIME_PARAM *const *a,
|
||||
{
|
||||
if (!(*a)->param_name || !(*b)->param_name)
|
||||
return ! !(*a)->param_name - ! !(*b)->param_name;
|
||||
return (strcmp((*a)->param_name, (*b)->param_name));
|
||||
return strcmp((*a)->param_name, (*b)->param_name);
|
||||
}
|
||||
|
||||
/* Find a header with a given name (if possible) */
|
||||
@@ -966,7 +950,7 @@ static int strip_eol(char *linebuf, int *plen, int flags)
|
||||
int len = *plen;
|
||||
char *p, c;
|
||||
int is_eol = 0;
|
||||
p = linebuf + len - 1;
|
||||
|
||||
for (p = linebuf + len - 1; len > 0; len--, p--) {
|
||||
c = *p;
|
||||
if (c == '\n')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/ctype.h"
|
||||
#include <openssl/crypto.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/conf.h>
|
||||
@@ -72,7 +72,7 @@ static int do_create(const char *value, const char *name)
|
||||
ostr = p + 1;
|
||||
if (!*ostr)
|
||||
return 0;
|
||||
while (isspace((unsigned char)*ostr))
|
||||
while (ossl_isspace(*ostr))
|
||||
ostr++;
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ static int do_create(const char *value, const char *name)
|
||||
|
||||
if (p) {
|
||||
ln = value;
|
||||
while (isspace((unsigned char)*ln))
|
||||
while (ossl_isspace(*ln))
|
||||
ln++;
|
||||
p--;
|
||||
while (isspace((unsigned char)*p)) {
|
||||
while (ossl_isspace(*p)) {
|
||||
if (p == ln)
|
||||
return 0;
|
||||
p--;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2012-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/conf.h>
|
||||
|
||||
+11
-5
@@ -14,8 +14,9 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <internal/bio.h>
|
||||
#include "internal/bio.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
/* Must be large enough for biggest tag+length */
|
||||
#define DEFAULT_ASN1_BUF_SIZE 20
|
||||
@@ -78,7 +79,11 @@ static int asn1_bio_setup_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx,
|
||||
static const BIO_METHOD methods_asn1 = {
|
||||
BIO_TYPE_ASN1,
|
||||
"asn1",
|
||||
/* TODO: Convert to new style write function */
|
||||
bwrite_conv,
|
||||
asn1_bio_write,
|
||||
/* TODO: Convert to new style read function */
|
||||
bread_conv,
|
||||
asn1_bio_read,
|
||||
asn1_bio_puts,
|
||||
asn1_bio_gets,
|
||||
@@ -90,7 +95,7 @@ static const BIO_METHOD methods_asn1 = {
|
||||
|
||||
const BIO_METHOD *BIO_f_asn1(void)
|
||||
{
|
||||
return (&methods_asn1);
|
||||
return &methods_asn1;
|
||||
}
|
||||
|
||||
static int asn1_bio_new(BIO *b)
|
||||
@@ -157,7 +162,6 @@ static int asn1_bio_write(BIO *b, const char *in, int inl)
|
||||
|
||||
for (;;) {
|
||||
switch (ctx->state) {
|
||||
|
||||
/* Setup prefix data, call it */
|
||||
case ASN1_STATE_START:
|
||||
if (!asn1_bio_setup_ex(b, ctx, ctx->prefix,
|
||||
@@ -178,7 +182,8 @@ static int asn1_bio_write(BIO *b, const char *in, int inl)
|
||||
|
||||
case ASN1_STATE_HEADER:
|
||||
ctx->buflen = ASN1_object_size(0, inl, ctx->asn1_tag) - inl;
|
||||
OPENSSL_assert(ctx->buflen <= ctx->bufsize);
|
||||
if (!ossl_assert(ctx->buflen <= ctx->bufsize))
|
||||
return 0;
|
||||
p = ctx->buf;
|
||||
ASN1_put_object(&p, 0, inl, ctx->asn1_tag, ctx->asn1_class);
|
||||
ctx->copylen = inl;
|
||||
@@ -223,7 +228,8 @@ static int asn1_bio_write(BIO *b, const char *in, int inl)
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case ASN1_STATE_POST_COPY:
|
||||
case ASN1_STATE_DONE:
|
||||
BIO_clear_retry_flags(b);
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -13,4 +13,4 @@ SOURCE[../../libcrypto]=\
|
||||
x_pkey.c bio_asn1.c bio_ndef.c asn_mime.c \
|
||||
asn1_gen.c asn1_par.c asn1_lib.c asn1_err.c a_strnid.c \
|
||||
evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p5_scrypt.c p8_pkey.c \
|
||||
asn_moid.c asn_mstbl.c
|
||||
asn_moid.c asn_mstbl.c asn1_item_list.c
|
||||
@@ -2,7 +2,7 @@
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/asn1/charmap.pl
|
||||
*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -82,12 +82,14 @@ $arr[ord("?")] |= $PSTRING_CHAR;
|
||||
|
||||
# Now generate the C code
|
||||
|
||||
# Output year depends on the year of the script.
|
||||
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
|
||||
print <<EOF;
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by crypto/asn1/charmap.pl
|
||||
*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -27,7 +27,7 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
if ((a == NULL) || (*a == NULL)) {
|
||||
if ((ret = EVP_PKEY_new()) == NULL) {
|
||||
ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_EVP_LIB);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
ret = *a;
|
||||
@@ -64,11 +64,11 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
*pp = p;
|
||||
if (a != NULL)
|
||||
(*a) = ret;
|
||||
return (ret);
|
||||
return ret;
|
||||
err:
|
||||
if (a == NULL || *a != ret)
|
||||
EVP_PKEY_free(ret);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -27,7 +27,7 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
if ((a == NULL) || (*a == NULL)) {
|
||||
if ((ret = EVP_PKEY_new()) == NULL) {
|
||||
ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
ret = *a;
|
||||
@@ -66,13 +66,12 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
default:
|
||||
ASN1err(ASN1_F_D2I_PUBLICKEY, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
|
||||
goto err;
|
||||
/* break; */
|
||||
}
|
||||
if (a != NULL)
|
||||
(*a) = ret;
|
||||
return (ret);
|
||||
return ret;
|
||||
err:
|
||||
if (a == NULL || *a != ret)
|
||||
EVP_PKEY_free(ret);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
@@ -17,13 +17,13 @@ int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len)
|
||||
ASN1_STRING *os;
|
||||
|
||||
if ((os = ASN1_OCTET_STRING_new()) == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
if (!ASN1_OCTET_STRING_set(os, data, len)) {
|
||||
ASN1_OCTET_STRING_free(os);
|
||||
return 0;
|
||||
}
|
||||
ASN1_TYPE_set(a, V_ASN1_OCTET_STRING, os);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* int max_len: for returned value */
|
||||
@@ -34,7 +34,7 @@ int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_l
|
||||
|
||||
if ((a->type != V_ASN1_OCTET_STRING) || (a->value.octet_string == NULL)) {
|
||||
ASN1err(ASN1_F_ASN1_TYPE_GET_OCTETSTRING, ASN1_R_DATA_IS_WRONG);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
p = ASN1_STRING_get0_data(a->value.octet_string);
|
||||
ret = ASN1_STRING_length(a->value.octet_string);
|
||||
@@ -43,16 +43,16 @@ int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_l
|
||||
else
|
||||
num = max_len;
|
||||
memcpy(data, p, num);
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
long num;
|
||||
int32_t num;
|
||||
ASN1_OCTET_STRING *oct;
|
||||
} asn1_int_oct;
|
||||
|
||||
ASN1_SEQUENCE(asn1_int_oct) = {
|
||||
ASN1_SIMPLE(asn1_int_oct, num, LONG),
|
||||
ASN1_EMBED(asn1_int_oct, num, INT32),
|
||||
ASN1_SIMPLE(asn1_int_oct, oct, ASN1_OCTET_STRING)
|
||||
} static_ASN1_SEQUENCE_END(asn1_int_oct)
|
||||
|
||||
|
||||
+6
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1.h>
|
||||
@@ -20,7 +20,7 @@ int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a)
|
||||
char buf[2];
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
if (a->type & V_ASN1_NEG) {
|
||||
if (BIO_write(bp, "-", 1) != 1)
|
||||
@@ -46,9 +46,9 @@ int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a)
|
||||
n += 2;
|
||||
}
|
||||
}
|
||||
return (n);
|
||||
return n;
|
||||
err:
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
|
||||
@@ -76,18 +76,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
|
||||
again = (buf[i - 1] == '\\');
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
#ifndef CHARSET_EBCDIC
|
||||
if (!(((buf[j] >= '0') && (buf[j] <= '9')) ||
|
||||
((buf[j] >= 'a') && (buf[j] <= 'f')) ||
|
||||
((buf[j] >= 'A') && (buf[j] <= 'F'))))
|
||||
#else
|
||||
/*
|
||||
* This #ifdef is not strictly necessary, since the characters
|
||||
* A...F a...f 0...9 are contiguous (yes, even in EBCDIC - but
|
||||
* not the whole alphabet). Nevertheless, isxdigit() is faster.
|
||||
*/
|
||||
if (!isxdigit(buf[j]))
|
||||
#endif
|
||||
if (!ossl_isxdigit(buf[j]))
|
||||
{
|
||||
i = j;
|
||||
break;
|
||||
|
||||
+7
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "internal/ctype.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1.h>
|
||||
@@ -20,7 +20,7 @@ int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type)
|
||||
char buf[2];
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
if (a->length == 0) {
|
||||
if (BIO_write(bp, "0", 1) != 1)
|
||||
@@ -40,14 +40,14 @@ int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type)
|
||||
n += 2;
|
||||
}
|
||||
}
|
||||
return (n);
|
||||
return n;
|
||||
err:
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
|
||||
{
|
||||
int i, j, k, m, n, again, bufsize, spec_char;
|
||||
int i, j, k, m, n, again, bufsize;
|
||||
unsigned char *s = NULL, *sp;
|
||||
unsigned char *bufp;
|
||||
int num = 0, slen = 0, first = 1;
|
||||
@@ -74,19 +74,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
|
||||
again = (buf[i - 1] == '\\');
|
||||
|
||||
for (j = i - 1; j > 0; j--) {
|
||||
#ifndef CHARSET_EBCDIC
|
||||
spec_char = (!(((buf[j] >= '0') && (buf[j] <= '9')) ||
|
||||
((buf[j] >= 'a') && (buf[j] <= 'f')) ||
|
||||
((buf[j] >= 'A') && (buf[j] <= 'F'))));
|
||||
#else
|
||||
/*
|
||||
* This #ifdef is not strictly necessary, since the characters
|
||||
* A...F a...f 0...9 are contiguous (yes, even in EBCDIC - but
|
||||
* not the whole alphabet). Nevertheless, isxdigit() is faster.
|
||||
*/
|
||||
spec_char = (!isxdigit(buf[j]));
|
||||
#endif
|
||||
if (spec_char) {
|
||||
if (!ossl_isxdigit(buf[j])) {
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ NON_EMPTY_TRANSLATION_UNIT
|
||||
# ifndef OPENSSL_NO_RC4
|
||||
|
||||
typedef struct netscape_pkey_st {
|
||||
long version;
|
||||
int32_t version;
|
||||
X509_ALGOR *algor;
|
||||
ASN1_OCTET_STRING *private_key;
|
||||
} NETSCAPE_PKEY;
|
||||
@@ -48,7 +48,7 @@ DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY,NETSCAPE_ENCRYPTED_P
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY)
|
||||
|
||||
ASN1_SEQUENCE(NETSCAPE_PKEY) = {
|
||||
ASN1_SIMPLE(NETSCAPE_PKEY, version, LONG),
|
||||
ASN1_EMBED(NETSCAPE_PKEY, version, INT32),
|
||||
ASN1_SIMPLE(NETSCAPE_PKEY, algor, X509_ALGOR),
|
||||
ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING)
|
||||
} static_ASN1_SEQUENCE_END(NETSCAPE_PKEY)
|
||||
|
||||
+2
-11
@@ -18,24 +18,15 @@
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
/* PKCS#5 scrypt password based encryption structures */
|
||||
|
||||
typedef struct {
|
||||
ASN1_OCTET_STRING *salt;
|
||||
ASN1_INTEGER *costParameter;
|
||||
ASN1_INTEGER *blockSize;
|
||||
ASN1_INTEGER *parallelizationParameter;
|
||||
ASN1_INTEGER *keyLength;
|
||||
} SCRYPT_PARAMS;
|
||||
|
||||
ASN1_SEQUENCE(SCRYPT_PARAMS) = {
|
||||
ASN1_SIMPLE(SCRYPT_PARAMS, salt, ASN1_OCTET_STRING),
|
||||
ASN1_SIMPLE(SCRYPT_PARAMS, costParameter, ASN1_INTEGER),
|
||||
ASN1_SIMPLE(SCRYPT_PARAMS, blockSize, ASN1_INTEGER),
|
||||
ASN1_SIMPLE(SCRYPT_PARAMS, parallelizationParameter, ASN1_INTEGER),
|
||||
ASN1_OPT(SCRYPT_PARAMS, keyLength, ASN1_INTEGER),
|
||||
} static_ASN1_SEQUENCE_END(SCRYPT_PARAMS)
|
||||
} ASN1_SEQUENCE_END(SCRYPT_PARAMS)
|
||||
|
||||
DECLARE_ASN1_ALLOC_FUNCTIONS(SCRYPT_PARAMS)
|
||||
IMPLEMENT_ASN1_ALLOC_FUNCTIONS(SCRYPT_PARAMS)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(SCRYPT_PARAMS)
|
||||
|
||||
static X509_ALGOR *pkcs5_scrypt_set(const unsigned char *salt, size_t saltlen,
|
||||
size_t keylen, uint64_t N, uint64_t r,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* This table MUST be kept in ascending order of the NID each method
|
||||
* represents (corresponding to the pkey_id field) as OBJ_bsearch
|
||||
* is used to search it.
|
||||
*/
|
||||
static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
&rsa_asn1_meths[0],
|
||||
&rsa_asn1_meths[1],
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
&dh_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
&dsa_asn1_meths[0],
|
||||
&dsa_asn1_meths[1],
|
||||
&dsa_asn1_meths[2],
|
||||
&dsa_asn1_meths[3],
|
||||
&dsa_asn1_meths[4],
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&eckey_asn1_meth,
|
||||
#endif
|
||||
&hmac_asn1_meth,
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
&cmac_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
&rsa_pss_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
&dhx_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ecx25519_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_POLY1305
|
||||
&poly1305_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SIPHASH
|
||||
&siphash_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
&ed25519_asn1_meth,
|
||||
#endif
|
||||
};
|
||||
|
||||
+17
-34
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -17,18 +17,9 @@
|
||||
#include "internal/numbers.h"
|
||||
#include "asn1_locl.h"
|
||||
|
||||
/*
|
||||
* Constructed types with a recursive definition (such as can be found in PKCS7)
|
||||
* could eventually exceed the stack given malicious input with excessive
|
||||
* recursion. Therefore we limit the stack depth. This is the maximum number of
|
||||
* recursive invocations of asn1_item_embed_d2i().
|
||||
*/
|
||||
#define ASN1_MAX_CONSTRUCTED_NEST 30
|
||||
|
||||
static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
long len, const ASN1_ITEM *it,
|
||||
int tag, int aclass, char opt, ASN1_TLC *ctx,
|
||||
int depth);
|
||||
int tag, int aclass, char opt, ASN1_TLC *ctx);
|
||||
|
||||
static int asn1_check_eoc(const unsigned char **in, long len);
|
||||
static int asn1_find_end(const unsigned char **in, long len, char inf);
|
||||
@@ -46,11 +37,11 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
|
||||
static int asn1_template_ex_d2i(ASN1_VALUE **pval,
|
||||
const unsigned char **in, long len,
|
||||
const ASN1_TEMPLATE *tt, char opt,
|
||||
ASN1_TLC *ctx, int depth);
|
||||
ASN1_TLC *ctx);
|
||||
static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
const unsigned char **in, long len,
|
||||
const ASN1_TEMPLATE *tt, char opt,
|
||||
ASN1_TLC *ctx, int depth);
|
||||
ASN1_TLC *ctx);
|
||||
static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
const unsigned char **in, long len,
|
||||
const ASN1_ITEM *it,
|
||||
@@ -120,7 +111,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
int tag, int aclass, char opt, ASN1_TLC *ctx)
|
||||
{
|
||||
int rv;
|
||||
rv = asn1_item_embed_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0);
|
||||
rv = asn1_item_embed_d2i(pval, in, len, it, tag, aclass, opt, ctx);
|
||||
if (rv <= 0)
|
||||
ASN1_item_ex_free(pval, it);
|
||||
return rv;
|
||||
@@ -133,8 +124,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
|
||||
static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
long len, const ASN1_ITEM *it,
|
||||
int tag, int aclass, char opt, ASN1_TLC *ctx,
|
||||
int depth)
|
||||
int tag, int aclass, char opt, ASN1_TLC *ctx)
|
||||
{
|
||||
const ASN1_TEMPLATE *tt, *errtt = NULL;
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
@@ -155,11 +145,6 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
else
|
||||
asn1_cb = 0;
|
||||
|
||||
if (++depth > ASN1_MAX_CONSTRUCTED_NEST) {
|
||||
ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_NESTED_TOO_DEEP);
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch (it->itype) {
|
||||
case ASN1_ITYPE_PRIMITIVE:
|
||||
if (it->templates) {
|
||||
@@ -175,7 +160,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
goto err;
|
||||
}
|
||||
return asn1_template_ex_d2i(pval, in, len,
|
||||
it->templates, opt, ctx, depth);
|
||||
it->templates, opt, ctx);
|
||||
}
|
||||
return asn1_d2i_ex_primitive(pval, in, len, it,
|
||||
tag, aclass, opt, ctx);
|
||||
@@ -236,7 +221,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
/*
|
||||
* We mark field as OPTIONAL so its absence can be recognised.
|
||||
*/
|
||||
ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx, depth);
|
||||
ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx);
|
||||
/* If field not present, try the next one */
|
||||
if (ret == -1)
|
||||
continue;
|
||||
@@ -359,8 +344,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
* attempt to read in field, allowing each to be OPTIONAL
|
||||
*/
|
||||
|
||||
ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx,
|
||||
depth);
|
||||
ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx);
|
||||
if (!ret) {
|
||||
errtt = seqtt;
|
||||
goto err;
|
||||
@@ -436,7 +420,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
static int asn1_template_ex_d2i(ASN1_VALUE **val,
|
||||
const unsigned char **in, long inlen,
|
||||
const ASN1_TEMPLATE *tt, char opt,
|
||||
ASN1_TLC *ctx, int depth)
|
||||
ASN1_TLC *ctx)
|
||||
{
|
||||
int flags, aclass;
|
||||
int ret;
|
||||
@@ -471,7 +455,7 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val,
|
||||
return 0;
|
||||
}
|
||||
/* We've found the field so it can't be OPTIONAL now */
|
||||
ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx, depth);
|
||||
ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx);
|
||||
if (!ret) {
|
||||
ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
|
||||
return 0;
|
||||
@@ -495,7 +479,7 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val,
|
||||
}
|
||||
}
|
||||
} else
|
||||
return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx, depth);
|
||||
return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx);
|
||||
|
||||
*in = p;
|
||||
return 1;
|
||||
@@ -507,7 +491,7 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val,
|
||||
static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
const unsigned char **in, long len,
|
||||
const ASN1_TEMPLATE *tt, char opt,
|
||||
ASN1_TLC *ctx, int depth)
|
||||
ASN1_TLC *ctx)
|
||||
{
|
||||
int flags, aclass;
|
||||
int ret;
|
||||
@@ -554,7 +538,7 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
} else if (ret == -1)
|
||||
return -1;
|
||||
if (!*val)
|
||||
*val = (ASN1_VALUE *)OPENSSL_sk_new_null();
|
||||
*val = (ASN1_VALUE *)sk_ASN1_VALUE_new_null();
|
||||
else {
|
||||
/*
|
||||
* We've got a valid STACK: free up any items present
|
||||
@@ -589,8 +573,7 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
}
|
||||
skfield = NULL;
|
||||
if (!asn1_item_embed_d2i(&skfield, &p, len,
|
||||
ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx,
|
||||
depth)) {
|
||||
ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) {
|
||||
ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I,
|
||||
ERR_R_NESTED_ASN1_ERROR);
|
||||
/* |skfield| may be partially allocated despite failure. */
|
||||
@@ -612,7 +595,7 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
/* IMPLICIT tagging */
|
||||
ret = asn1_item_embed_d2i(val, &p, len,
|
||||
ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt,
|
||||
ctx, depth);
|
||||
ctx);
|
||||
if (!ret) {
|
||||
ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR);
|
||||
goto err;
|
||||
@@ -621,7 +604,7 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
} else {
|
||||
/* Nothing special */
|
||||
ret = asn1_item_embed_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item),
|
||||
-1, 0, opt, ctx, depth);
|
||||
-1, 0, opt, ctx);
|
||||
if (!ret) {
|
||||
ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR);
|
||||
goto err;
|
||||
|
||||
@@ -315,7 +315,8 @@ static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
pctx))
|
||||
return 0;
|
||||
}
|
||||
if (!i && BIO_printf(out, "%*s<EMPTY>\n", indent + 2, "") <= 0)
|
||||
if (i == 0 && BIO_printf(out, "%*s<%s>\n", indent + 2, "",
|
||||
stack == NULL ? "ABSENT" : "EMPTY") <= 0)
|
||||
return 0;
|
||||
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_SEQUENCE) {
|
||||
if (BIO_printf(out, "%*s}\n", indent, "") <= 0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <internal/cryptlib.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/refcount.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/objects.h>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* size limits: this stuff is taken straight from RFC3280 */
|
||||
|
||||
#define ub_name 32768
|
||||
#define ub_common_name 64
|
||||
#define ub_locality_name 128
|
||||
#define ub_state_name 128
|
||||
#define ub_organization_name 64
|
||||
#define ub_organization_unit_name 64
|
||||
#define ub_title 64
|
||||
#define ub_email_address 128
|
||||
#define ub_serial_number 64
|
||||
|
||||
/* From RFC4524 */
|
||||
|
||||
#define ub_rfc822_mailbox 256
|
||||
|
||||
/* This table must be kept in NID order */
|
||||
|
||||
static const ASN1_STRING_TABLE tbl_standard[] = {
|
||||
{NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0},
|
||||
{NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||
{NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0},
|
||||
{NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0},
|
||||
{NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0},
|
||||
{NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE,
|
||||
0},
|
||||
{NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING,
|
||||
STABLE_NO_MASK},
|
||||
{NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0},
|
||||
{NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0},
|
||||
{NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0},
|
||||
{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING,
|
||||
STABLE_NO_MASK},
|
||||
{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
|
||||
{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
|
||||
{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, 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_rfc822Mailbox, 1, ub_rfc822_mailbox, B_ASN1_IA5STRING,
|
||||
STABLE_NO_MASK},
|
||||
{NID_jurisdictionCountryName, 2, 2, B_ASN1_PRINTABLESTRING, 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},
|
||||
{NID_countryCode3c, 3, 3, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
|
||||
{NID_countryCode3n, 3, 3, B_ASN1_NUMERICSTRING, STABLE_NO_MASK},
|
||||
{NID_dnsName, 0, -1, B_ASN1_UTF8STRING, STABLE_NO_MASK}
|
||||
};
|
||||
|
||||
@@ -28,18 +28,19 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_ALGOR)
|
||||
|
||||
int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval)
|
||||
{
|
||||
if (!alg)
|
||||
if (alg == NULL)
|
||||
return 0;
|
||||
|
||||
if (ptype != V_ASN1_UNDEF) {
|
||||
if (alg->parameter == NULL)
|
||||
alg->parameter = ASN1_TYPE_new();
|
||||
if (alg->parameter == NULL)
|
||||
return 0;
|
||||
}
|
||||
if (alg) {
|
||||
ASN1_OBJECT_free(alg->algorithm);
|
||||
alg->algorithm = aobj;
|
||||
}
|
||||
|
||||
ASN1_OBJECT_free(alg->algorithm);
|
||||
alg->algorithm = aobj;
|
||||
|
||||
if (ptype == 0)
|
||||
return 1;
|
||||
if (ptype == V_ASN1_UNDEF) {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/asn1t.h"
|
||||
#include "internal/numbers.h"
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "asn1_locl.h"
|
||||
|
||||
@@ -102,8 +102,8 @@ static int uint64_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
|
||||
return BIO_printf(out, "%"BIO_PRI64"d\n", **(int64_t **)pval);
|
||||
return BIO_printf(out, "%"BIO_PRI64"u\n", **(uint64_t **)pval);
|
||||
return BIO_printf(out, "%jd\n", **(int64_t **)pval);
|
||||
return BIO_printf(out, "%ju\n", **(uint64_t **)pval);
|
||||
}
|
||||
|
||||
/* 32-bit variants */
|
||||
|
||||
+16
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -11,6 +11,12 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/asn1t.h>
|
||||
|
||||
#if !(OPENSSL_API_COMPAT < 0x10200000L)
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
#define COPY_SIZE(a, b) (sizeof(a) < sizeof(b) ? sizeof(a) : sizeof(b))
|
||||
|
||||
/*
|
||||
* Custom primitive type for long handling. This converts between an
|
||||
* ASN1_INTEGER and a long directly.
|
||||
@@ -46,13 +52,13 @@ ASN1_ITEM_end(ZLONG)
|
||||
|
||||
static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
*(long *)pval = it->size;
|
||||
memcpy(pval, &it->size, COPY_SIZE(*pval, it->size));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
*(long *)pval = it->size;
|
||||
memcpy(pval, &it->size, COPY_SIZE(*pval, it->size));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -86,12 +92,8 @@ static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
long ltmp;
|
||||
unsigned long utmp, sign;
|
||||
int clen, pad, i;
|
||||
/* this exists to bypass broken gcc optimization */
|
||||
char *cp = (char *)pval;
|
||||
|
||||
/* use memcpy, because we may not be long aligned */
|
||||
memcpy(<mp, cp, sizeof(long));
|
||||
|
||||
memcpy(<mp, pval, COPY_SIZE(*pval, ltmp));
|
||||
if (ltmp == it->size)
|
||||
return -1;
|
||||
/*
|
||||
@@ -133,7 +135,6 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int i;
|
||||
long ltmp;
|
||||
unsigned long utmp = 0, sign = 0x100;
|
||||
char *cp = (char *)pval;
|
||||
|
||||
if (len > 1) {
|
||||
/*
|
||||
@@ -185,12 +186,16 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
|
||||
return 0;
|
||||
}
|
||||
memcpy(cp, <mp, sizeof(long));
|
||||
memcpy(pval, <mp, COPY_SIZE(*pval, ltmp));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
return BIO_printf(out, "%ld\n", *(long *)pval);
|
||||
long l;
|
||||
|
||||
memcpy(&l, pval, COPY_SIZE(*pval, l));
|
||||
return BIO_printf(out, "%ld\n", l);
|
||||
}
|
||||
#endif
|
||||
@@ -7,11 +7,6 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* This module was send to me my Pat Richards <patr@x509.com> who wrote it.
|
||||
* It is under my Copyright with his permission
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/x509.h>
|
||||
|
||||
Reference in New Issue
Block a user