version 1.13, 2023/03/06 14:32:05 |
version 1.14, 2023/03/07 05:53:17 |
|
|
|
|
in = BIO_new(BIO_s_file()); |
in = BIO_new(BIO_s_file()); |
out = BIO_new(BIO_s_file()); |
out = BIO_new(BIO_s_file()); |
if ((in == NULL) || (out == NULL)) { |
if (in == NULL || out == NULL) { |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
goto end; |
goto end; |
} |
} |
|
|
} |
} |
} |
} |
|
|
if (cfg.derfile) { |
if (cfg.derfile != NULL) { |
if (!(derout = BIO_new_file(cfg.derfile, "wb"))) { |
if ((derout = BIO_new_file(cfg.derfile, "wb")) == NULL) { |
BIO_printf(bio_err, "problems opening %s\n", |
BIO_printf(bio_err, "problems opening %s\n", |
cfg.derfile); |
cfg.derfile); |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
|
|
if ((buf = BUF_MEM_new()) == NULL) |
if ((buf = BUF_MEM_new()) == NULL) |
goto end; |
goto end; |
if (!BUF_MEM_grow(buf, BUFSIZ * 8)) |
if (!BUF_MEM_grow(buf, BUFSIZ * 8)) |
goto end; /* Pre-allocate :-) */ |
goto end; |
|
|
if (cfg.genstr || cfg.genconf) { |
if (cfg.genstr != NULL || cfg.genconf) { |
num = do_generate(bio_err, cfg.genstr, |
num = do_generate(bio_err, cfg.genstr, cfg.genconf, buf); |
cfg.genconf, buf); |
|
if (num < 0) { |
if (num < 0) { |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
goto end; |
goto end; |
} |
} |
} else { |
} else { |
|
|
if (cfg.informat == FORMAT_PEM) { |
if (cfg.informat == FORMAT_PEM) { |
BIO *tmp; |
BIO *tmp; |
|
|
|
|
|
|
/* If any structs to parse go through in sequence */ |
/* If any structs to parse go through in sequence */ |
|
|
if (sk_OPENSSL_STRING_num(cfg.osk)) { |
if (sk_OPENSSL_STRING_num(cfg.osk) > 0) { |
tmpbuf = (unsigned char *) str; |
tmpbuf = (unsigned char *) str; |
tmplen = num; |
tmplen = num; |
for (i = 0; i < sk_OPENSSL_STRING_num(cfg.osk); |
for (i = 0; i < sk_OPENSSL_STRING_num(cfg.osk); i++) { |
i++) { |
|
ASN1_TYPE *atmp; |
ASN1_TYPE *atmp; |
int typ; |
int typ; |
j = strtonum( |
j = strtonum(sk_OPENSSL_STRING_value(cfg.osk, i), |
sk_OPENSSL_STRING_value(cfg.osk, i), |
|
1, INT_MAX, &errstr); |
1, INT_MAX, &errstr); |
if (errstr) { |
if (errstr) { |
BIO_printf(bio_err, |
BIO_printf(bio_err, |
"'%s' is an invalid number: %s\n", |
"'%s' is an invalid number: %s\n", |
sk_OPENSSL_STRING_value(cfg.osk, |
sk_OPENSSL_STRING_value(cfg.osk, i), errstr); |
i), errstr); |
|
continue; |
continue; |
} |
} |
tmpbuf += j; |
tmpbuf += j; |
|
|
goto end; |
goto end; |
} |
} |
typ = ASN1_TYPE_get(at); |
typ = ASN1_TYPE_get(at); |
if ((typ == V_ASN1_OBJECT) || |
if (typ == V_ASN1_OBJECT || typ == V_ASN1_NULL) { |
(typ == V_ASN1_NULL)) { |
|
BIO_printf(bio_err, "Can't parse %s type\n", |
BIO_printf(bio_err, "Can't parse %s type\n", |
typ == V_ASN1_NULL ? "NULL" : "OBJECT"); |
typ == V_ASN1_NULL ? "NULL" : "OBJECT"); |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
|
|
} |
} |
num -= cfg.offset; |
num -= cfg.offset; |
|
|
if ((cfg.length == 0) || |
if (cfg.length == 0 || (long)cfg.length > num) |
((long)cfg.length > num)) |
|
cfg.length = (unsigned int) num; |
cfg.length = (unsigned int) num; |
if (derout) { |
if (derout != NULL) { |
if (BIO_write(derout, str + cfg.offset, |
if (BIO_write(derout, str + cfg.offset, |
cfg.length) != (int)cfg.length) { |
cfg.length) != (int)cfg.length) { |
BIO_printf(bio_err, "Error writing output\n"); |
BIO_printf(bio_err, "Error writing output\n"); |
|
|
goto end; |
goto end; |
} |
} |
} |
} |
if (!cfg.noout && |
if (!cfg.noout && !ASN1_parse_dump(out, |
!ASN1_parse_dump(out, |
(unsigned char *)&str[cfg.offset], cfg.length, cfg.indent, cfg.dump)) { |
(unsigned char *)&(str[cfg.offset]), |
|
cfg.length, cfg.indent, |
|
cfg.dump)) { |
|
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
goto end; |
goto end; |
} |
} |