diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2012-03-27 15:05:36 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2012-03-27 15:05:36 +0200 |
commit | e464894e8b44f7b5d3bbbb8f7553a7fd47663d96 (patch) | |
tree | e81e6dcad9da6414871481ec05501aca069f98c9 /src | |
parent | a281494abde0df94fd3598220eb45037293f3c03 (diff) | |
download | strongswan-e464894e8b44f7b5d3bbbb8f7553a7fd47663d96.tar.bz2 strongswan-e464894e8b44f7b5d3bbbb8f7553a7fd47663d96.tar.xz |
remove leading zeros in ASN.1 encoded serial numbers
Diffstat (limited to 'src')
-rw-r--r-- | src/pki/commands/print.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/pki/commands/print.c b/src/pki/commands/print.c index ee6f30c98..02d0cec17 100644 --- a/src/pki/commands/print.c +++ b/src/pki/commands/print.c @@ -24,6 +24,23 @@ #include <time.h> /** + * Print a chunk without leading zero byte + */ +static chunk_t chunk_skip_zero(chunk_t chunk) +{ + if (chunk.len && *chunk.ptr == 0x00) + { + if (chunk.len == 1) + { + return chunk_empty; + } + chunk.ptr++; + chunk.len--; + } + return chunk; +} + +/** * Print public key information */ static void print_pubkey(public_key_t *key) @@ -79,7 +96,7 @@ static void print_x509(x509_t *x509) x509_cert_policy_t *policy; x509_policy_mapping_t *mapping; - chunk = x509->get_serial(x509); + chunk = chunk_skip_zero(x509->get_serial(x509)); printf("serial: %#B\n", &chunk); first = TRUE; @@ -329,10 +346,12 @@ static void print_crl(crl_t *crl) struct tm tm; x509_cdp_t *cdp; - chunk = crl->get_serial(crl); + chunk = chunk_skip_zero(crl->get_serial(crl)); printf("serial: %#B\n", &chunk); + if (crl->is_delta_crl(crl, &chunk)) { + chunk = chunk_skip_zero(chunk); printf("delta CRL: for serial %#B\n", &chunk); } chunk = crl->get_authKeyIdentifier(crl); @@ -371,6 +390,7 @@ static void print_crl(crl_t *crl) enumerator = crl->create_enumerator(crl); while (enumerator->enumerate(enumerator, &chunk, &ts, &reason)) { + chunk = chunk_skip_zero(chunk); localtime_r(&ts, &tm); strftime(buf, sizeof(buf), "%F %T", &tm); printf(" %#B %N %s\n", &chunk, crl_reason_names, reason, buf); |