diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2008-04-25 06:39:41 +0000 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2008-04-25 06:39:41 +0000 |
commit | 36fecdb8a35e275eaf8aa1caed48674fcf30d76f (patch) | |
tree | dca74d6fb26fea769f469d073fde1120932cccf8 /src/openac/openac.c | |
parent | 5e6bbf4f772915fa98e0bc47b802ef84d02746f8 (diff) | |
download | strongswan-36fecdb8a35e275eaf8aa1caed48674fcf30d76f.tar.bz2 strongswan-36fecdb8a35e275eaf8aa1caed48674fcf30d76f.tar.xz |
chunk_to_hex() adaptations
Diffstat (limited to 'src/openac/openac.c')
-rwxr-xr-x | src/openac/openac.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/openac/openac.c b/src/openac/openac.c index d0d20b108..f2d879f7a 100755 --- a/src/openac/openac.c +++ b/src/openac/openac.c @@ -37,7 +37,6 @@ #include <debug.h> #include <asn1/asn1.h> #include <asn1/pem.h> -#include <asn1/ttodata.h> #include <credentials/certificates/x509.h> #include <credentials/certificates/ac.h> #include <utils/optionsfrom.h> @@ -115,7 +114,8 @@ static chunk_t read_serial(void) mpz_t number; char buf[BUF_LEN], buf1[BUF_LEN]; - chunk_t last_serial = { buf1, BUF_LEN}; + chunk_t hex_serial = { buf, BUF_LEN }; + chunk_t last_serial = { buf1, BUF_LEN }; chunk_t serial; FILE *fd = fopen(OPENAC_SERIAL, "r"); @@ -126,15 +126,10 @@ static chunk_t read_serial(void) if (fd) { - if (fscanf(fd, "%s", buf)) + if (fscanf(fd, "%s", hex_serial.ptr)) { - err_t ugh = ttodata(buf, 0, 16, last_serial.ptr, BUF_LEN, &last_serial.len); - - if (ugh != NULL) - { - DBG1(" error reading serial number from %s: %s", - OPENAC_SERIAL, ugh); - } + hex_serial.len = strlen(hex_serial.ptr); + last_serial = chunk_from_hex(hex_serial, last_serial.ptr); } fclose(fd); } @@ -166,9 +161,13 @@ static void write_serial(chunk_t serial) if (fd) { + chunk_t hex_serial; + DBG1(" serial number is %#B", &serial); - fprintf(fd, "%#B\n", &serial); + hex_serial = chunk_to_hex(serial, NULL, FALSE); + fprintf(fd, "%.*s\n", hex_serial.len, hex_serial.ptr); fclose(fd); + free(hex_serial.ptr); } else { |