Fix iCj for PE (#13579)

This commit is contained in:
Florian Märkl 2019-03-31 18:21:47 +02:00 committed by radare
parent bb823232f4
commit a98ddf66b2
3 changed files with 25 additions and 22 deletions

View File

@ -107,16 +107,12 @@ static char *signature (RBinFile *bf, bool json) {
return NULL;
}
struct PE_ (r_bin_pe_obj_t) * bin = bf->o->bin_obj;
char *json_str = NULL;
if (json) {
PJ *pj = r_pkcs7_cms_json (bin->cms);
if (pj) {
json_str = strdup((char *)pj_string(pj));
pj_free (pj);
return json_str;
return pj_drain (pj);
}
json_str = strdup ("{}");
return json_str;
return strdup ("{}");
}
return r_pkcs7_cms_to_string (bin->cms);
}

View File

@ -569,12 +569,14 @@ R_API void r_x509_signedinfo_json(PJ *pj, RPKCS7SignerInfo *si) {
if (!attr) {
continue;
}
pj_o (pj);
if (attr->oid) {
pj_ks (pj, "oid", attr->oid->string);
}
if (attr->data) {
pj_ki (pj, "length", attr->data->length);
}
pj_end (pj);
}
pj_end (pj);
pj_end (pj);
@ -611,13 +613,14 @@ R_API PJ *r_pkcs7_cms_json (RCMS *container) {
r_x509_certificate_json (pj, container->signedData.certificates.elements[i]);
}
pj_end (pj);
pj_end (pj);
pj_k (pj, "CRL");
pj_a (pj);
for (i = 0; i < container->signedData.crls.length; ++i) {
r_x509_crl_json (pj, container->signedData.crls.elements[i]);
}
pj_end (pj);
pj_k (pj, "SignerInfos");
pj_a (pj);
if (container->signedData.signerinfos.elements) {

View File

@ -670,6 +670,7 @@ R_API void r_x509_extensions_json(PJ *pj, RX509Extensions *exts) {
if (!e) {
continue;
}
pj_o (pj);
if (e->extnID) {
pj_ks (pj, "OID", e->extnID->string);
}
@ -684,6 +685,7 @@ R_API void r_x509_extensions_json(PJ *pj, RX509Extensions *exts) {
}
r_asn1_free_string (m);
}
pj_end (pj);
}
pj_end (pj);
pj_end (pj);
@ -778,20 +780,22 @@ R_API void r_x509_tbscertificate_json(PJ *pj, RX509TBSCertificate *tbsc) {
}
R_API void r_x509_certificate_json(PJ *pj, RX509Certificate *certificate) {
if (certificate) {
RASN1String *m = NULL;
pj_o (pj);
pj_k (pj, "TBSCertificate");
r_x509_tbscertificate_json (pj, &certificate->tbsCertificate);
if (certificate->algorithmIdentifier.algorithm) {
pj_ks (pj, "Algorithm", certificate->algorithmIdentifier.algorithm->string);
}
if (certificate->signature) {
m = r_asn1_stringify_integer (certificate->signature->binary, certificate->signature->length);
if (m) {
pj_ks (pj, "Signature", m->string);
}
r_asn1_free_string (m);
}
if (!certificate) {
return;
}
RASN1String *m = NULL;
pj_o (pj);
pj_k (pj, "TBSCertificate");
r_x509_tbscertificate_json (pj, &certificate->tbsCertificate);
if (certificate->algorithmIdentifier.algorithm) {
pj_ks (pj, "Algorithm", certificate->algorithmIdentifier.algorithm->string);
}
if (certificate->signature) {
m = r_asn1_stringify_integer (certificate->signature->binary, certificate->signature->length);
if (m) {
pj_ks (pj, "Signature", m->string);
}
r_asn1_free_string (m);
}
pj_end (pj);
}