-/* $OpenBSD: print.c,v 1.26 2023/01/10 13:26:34 job Exp $ */
+/* $OpenBSD: print.c,v 1.27 2023/03/07 14:49:32 job Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
} else {
printf("Trust anchor name: %s\n", p->descr);
printf("Subject key identifier: %s\n", pretty_key_id(ski));
- printf("Trust anchor locations:\n");
- for (i = 0; i < p->urisz; i++)
- printf("%5zu: %s\n", i + 1, p->uri[i]);
+ printf("Trust anchor locations: ");
+ for (i = 0; i < p->urisz; i++) {
+ if (i > 0)
+ printf("%26s", "");
+ printf("%s\n", p->uri[i]);
+ }
}
EVP_PKEY_free(pk);
} else
printf("Certificate valid until: %s\n",
time2str(p->expires));
- printf("Subordinate resources:\n");
+ printf("Subordinate resources: ");
}
for (i = 0; i < p->asz; i++) {
case CERT_AS_ID:
if (outformats & FORMAT_JSON)
printf("\t\t{ \"asid\": %u }", p->as[i].id);
- else
- printf("%5zu: AS: %u", i + 1, p->as[i].id);
+ else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("AS: %u", p->as[i].id);
+ }
break;
case CERT_AS_INHERIT:
if (outformats & FORMAT_JSON)
printf("\t\t{ \"asid_inherit\": \"true\" }");
- else
- printf("%5zu: AS: inherit", i + 1);
+ else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("AS: inherit");
+ }
break;
case CERT_AS_RANGE:
if (outformats & FORMAT_JSON)
printf("\t\t{ \"asrange\": { \"min\": %u, "
"\"max\": %u }}", p->as[i].range.min,
p->as[i].range.max);
- else
- printf("%5zu: AS: %u -- %u", i + 1,
- p->as[i].range.min, p->as[i].range.max);
+ else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("AS: %u -- %u", p->as[i].range.min,
+ p->as[i].range.max);
+ }
break;
}
if (outformats & FORMAT_JSON && i + 1 < p->asz + p->ipsz)
case CERT_IP_INHERIT:
if (outformats & FORMAT_JSON)
printf("\t\t{ \"ip_inherit\": \"true\" }");
- else
- printf("%5zu: IP: inherit", i + j + 1);
+ else {
+ if (i > 0 || j > 0)
+ printf("%26s", "");
+ printf("IP: inherit");
+ }
break;
case CERT_IP_ADDR:
ip_addr_print(&p->ips[j].ip,
p->ips[j].afi, buf1, sizeof(buf1));
if (outformats & FORMAT_JSON)
printf("\t\t{ \"ip_prefix\": \"%s\" }", buf1);
- else
- printf("%5zu: IP: %s", i + j + 1, buf1);
+ else {
+ if (i > 0 || j > 0)
+ printf("%26s", "");
+ printf("IP: %s", buf1);
+ }
break;
case CERT_IP_RANGE:
sockt = (p->ips[j].afi == AFI_IPV4) ?
if (outformats & FORMAT_JSON)
printf("\t\t{ \"ip_range\": { \"min\": \"%s\""
", \"max\": \"%s\" }}", buf1, buf2);
- else
- printf("%5zu: IP: %s -- %s", i + j + 1, buf1,
- buf2);
+ else {
+ if (i > 0 || j > 0)
+ printf("%26s", "");
+ printf("IP: %s -- %s", buf1, buf2);
+ }
break;
}
if (outformats & FORMAT_JSON && i + j + 1 < p->asz + p->ipsz)
printf(",");
printf("\n");
} else
- printf(" Serial: %8s Revocation Date: %s"
- "\n", serial, time2str(t));
+ printf("%25s Serial: %8s Revocation Date: %s"
+ "\n", "", serial, time2str(t));
}
free(serial);
}
printf("Manifest Number: %s\n", p->seqnum);
printf("Manifest valid since: %s\n", time2str(p->valid_since));
printf("Manifest valid until: %s\n", time2str(p->valid_until));
- printf("Files and hashes:\n");
+ printf("Files and hashes: ");
}
for (i = 0; i < p->filesz; i++) {
printf(",");
printf("\n");
} else {
- printf("%5zu: %s\n", i + 1, p->files[i].file);
- printf("\thash %s\n", hash);
+ if (i > 0)
+ printf("%26s", "");
+ printf("%zu: %s (hash: %s)\n", i + 1, p->files[i].file,
+ hash);
}
free(hash);
printf("Subject info access: %s\n", p->sia);
printf("ROA valid until: %s\n", time2str(p->expires));
printf("asID: %u\n", p->asid);
- printf("IP address blocks:\n");
+ printf("IP address blocks: ");
}
for (i = 0; i < p->ipsz; i++) {
if (i + 1 < p->ipsz)
printf(",");
printf("\n");
- } else
- printf("%5zu: %s maxlen: %hhu\n", i + 1, buf,
- p->ips[i].maxlength);
+ } else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("%s maxlen: %hhu\n", buf, p->ips[i].maxlength);
+ }
}
if (outformats & FORMAT_JSON)
x509_print(x);
printf("Authority info access: %s\n", p->aia);
printf("RSC valid until: %s\n", time2str(p->expires));
- printf("Signed with resources:\n");
+ printf("Signed with resources: ");
}
for (i = 0; i < p->asz; i++) {
case CERT_AS_ID:
if (outformats & FORMAT_JSON)
printf("\t\t{ \"asid\": %u }", p->as[i].id);
- else
- printf("%5zu: AS: %u", i + 1, p->as[i].id);
+ else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("AS: %u", p->as[i].id);
+ }
break;
case CERT_AS_RANGE:
if (outformats & FORMAT_JSON)
printf("\t\t{ \"asrange\": { \"min\": %u, "
"\"max\": %u }}", p->as[i].range.min,
p->as[i].range.max);
- else
- printf("%5zu: AS: %u -- %u", i + 1,
- p->as[i].range.min, p->as[i].range.max);
+ else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("AS: %u -- %u", p->as[i].range.min,
+ p->as[i].range.max);
+ }
break;
case CERT_AS_INHERIT:
/* inheritance isn't possible in RSC */
p->ips[j].afi, buf1, sizeof(buf1));
if (outformats & FORMAT_JSON)
printf("\t\t{ \"ip_prefix\": \"%s\" }", buf1);
- else
- printf("%5zu: IP: %s", i + j + 1, buf1);
+ else {
+ if (i > 0 || j > 0)
+ printf("%26s", "");
+ printf("IP: %s", buf1);
+ }
break;
case CERT_IP_RANGE:
sockt = (p->ips[j].afi == AFI_IPV4) ?
if (outformats & FORMAT_JSON)
printf("\t\t{ \"ip_range\": { \"min\": \"%s\""
", \"max\": \"%s\" }}", buf1, buf2);
- else
- printf("%5zu: IP: %s -- %s", i + j + 1, buf1,
- buf2);
+ else {
+ if (i > 0 || j > 0)
+ printf("%26s", "");
+ printf("IP: %s -- %s", buf1, buf2);
+ }
break;
case CERT_IP_INHERIT:
/* inheritance isn't possible in RSC */
printf("\t],\n");
printf("\t\"filenamesandhashes\": [\n");
} else
- printf("Filenames and hashes:\n");
+ printf("Filenames and hashes: ");
for (i = 0; i < p->filesz; i++) {
if (base64_encode(p->files[i].hash, sizeof(p->files[i].hash),
printf(",");
printf("\n");
} else {
- printf("%5zu: %s\n", i + 1, p->files[i].filename
- ? p->files[i].filename : "no filename");
- printf("\thash %s\n", hash);
+ if (i > 0)
+ printf("%26s", "");
+ printf("%zu: %s (hash: %s)\n", i + 1,
+ p->files[i].filename ? p->files[i].filename
+ : "no filename", hash);
}
free(hash);
printf("Subject info access: %s\n", p->sia);
printf("ASPA valid until: %s\n", time2str(p->expires));
printf("Customer AS: %u\n", p->custasid);
- printf("Provider Set:\n");
+ printf("Provider Set: ");
for (i = 0; i < p->providersz; i++) {
- printf("%5zu: AS: %d", i + 1, p->providers[i].as);
+ if (i > 0)
+ printf("%26s", "");
+ printf("AS: %d", p->providers[i].as);
switch (p->providers[i].afi) {
case AFI_IPV4:
printf(" (IPv4 only)");
if (outformats & FORMAT_JSON)
printf("\t\t{ \"prefix\": \"%s\", \"location\": \"%s\""
"}", buf, p->geoips[i].loc);
- else
- printf("%5zu: IP: %s (%s)", i + 1, buf,
- p->geoips[i].loc);
+ else {
+ if (i > 0)
+ printf("%26s", "");
+ printf("IP: %s (%s)", buf, p->geoips[i].loc);
+ }
if (outformats & FORMAT_JSON && i + 1 < p->geoipsz)
printf(",\n");