aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-02-27 21:47:30 +0000
committerRob Austein <sra@hactrn.net>2014-02-27 21:47:30 +0000
commit4746ce20b72170f310876c4e3c676bcc5b51048c (patch)
treef22638e90aac473268092ab91b542b14c608bba4 /utils
parent7342e8b86600df2d7dea52805979d0ebc3fbf4d9 (diff)
Both manifest serial numbers and ROA autonomous system numbers can be
longer than 31 bits, so we have to use OpenSSL's bignum routines to print them properly. Closes #683. svn path=/trunk/; revision=5693
Diffstat (limited to 'utils')
-rw-r--r--utils/print_roa/print_roa.c13
-rw-r--r--utils/print_rpki_manifest/print_rpki_manifest.c12
2 files changed, 22 insertions, 3 deletions
diff --git a/utils/print_roa/print_roa.c b/utils/print_roa/print_roa.c
index a1088958..cb186251 100644
--- a/utils/print_roa/print_roa.c
+++ b/utils/print_roa/print_roa.c
@@ -33,6 +33,7 @@
#include <getopt.h>
#include <openssl/bio.h>
+#include <openssl/bn.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/x509.h>
@@ -137,6 +138,8 @@ static ROA *read_roa(const char *filename,
unsigned char addr[ADDR_RAW_BUF_LEN];
CMS_ContentInfo *cms = NULL;
const ASN1_OBJECT *oid = NULL;
+ char *asID = NULL;
+ BIGNUM *bn = NULL;
ROA *r = NULL;
char buf[512];
BIO *b = NULL;
@@ -199,6 +202,9 @@ static ROA *read_roa(const char *filename,
if (print_roa) {
+ bn = ASN1_INTEGER_to_BN(r->asID, NULL);
+ asID = BN_bn2dec(bn);
+
if (print_brief) {
if (print_signingtime) {
@@ -208,7 +214,7 @@ static ROA *read_roa(const char *filename,
printf("%s ", buffer);
}
- printf("%ld", ASN1_INTEGER_get(r->asID));
+ fputs(asID, stdout);
} else {
@@ -221,7 +227,7 @@ static ROA *read_roa(const char *filename,
printf("version: %ld\n", ASN1_INTEGER_get(r->version));
else
printf("version: 0 [Defaulted]\n");
- printf("asID: %ld\n", ASN1_INTEGER_get(r->asID));
+ printf("asID: %s\n", asID);
}
for (i = 0; i < sk_ROAIPAddressFamily_num(r->ipAddrBlocks); i++) {
@@ -303,6 +309,9 @@ static ROA *read_roa(const char *filename,
if (ERR_peek_error())
ERR_print_errors_fp(stderr);
BIO_free(b);
+ BN_free(bn);
+ if (asID)
+ OPENSSL_free(asID);
CMS_ContentInfo_free(cms);
return r;
}
diff --git a/utils/print_rpki_manifest/print_rpki_manifest.c b/utils/print_rpki_manifest/print_rpki_manifest.c
index ac26c801..f55f9916 100644
--- a/utils/print_rpki_manifest/print_rpki_manifest.c
+++ b/utils/print_rpki_manifest/print_rpki_manifest.c
@@ -31,6 +31,7 @@
#include <unistd.h>
#include <getopt.h>
+#include <openssl/bn.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/err.h>
@@ -61,6 +62,8 @@ static const Manifest *read_manifest(const char *filename,
CMS_ContentInfo *cms = NULL;
const ASN1_OBJECT *oid = NULL;
const Manifest *m = NULL;
+ char *mftnum = NULL;
+ BIGNUM *bn = NULL;
char buf[512];
BIO *b = NULL;
int i, j;
@@ -131,7 +134,11 @@ static const Manifest *read_manifest(const char *filename,
printf("version: %ld\n", ASN1_INTEGER_get(m->version));
else
printf("version: 0 [Defaulted]\n");
- printf("manifestNumber: %ld\n", ASN1_INTEGER_get(m->manifestNumber));
+
+ bn = ASN1_INTEGER_to_BN(m->manifestNumber, NULL);
+ mftnum = BN_bn2dec(bn);
+ printf("manifestNumber: %s\n", mftnum);
+
printf("thisUpdate: %s\n", m->thisUpdate->data);
printf("nextUpdate: %s\n", m->nextUpdate->data);
OBJ_obj2txt(buf, sizeof(buf), m->fileHashAlg, 0);
@@ -165,6 +172,9 @@ static const Manifest *read_manifest(const char *filename,
if (ERR_peek_error())
ERR_print_errors_fp(stderr);
BIO_free(b);
+ BN_free(bn);
+ if (mftnum)
+ OPENSSL_free(mftnum);
CMS_ContentInfo_free(cms);
return m;
}