summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--runtime/librsgt.c10
-rw-r--r--runtime/librsgt.h3
-rw-r--r--runtime/librsgt_read.c4
-rw-r--r--tools/rsgtutil.c8
5 files changed, 24 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 0413a7d1..d91523ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,14 @@ Version 7.5.0 [devel] 2013-06-11
Thanks to Axel Rau for the patch.
---------------------------------------------------------------------------
Version 7.4.4 [v7.4-stable] 2013-0?-??
+- better error messages in GuardTime signature provider
+ Thanks to Ahto Truu for providing the patch.
+- bugfix: TLV16 flag encoding error in signature files from GT provider
+ This fixes a problem where the TLV16 flag was improperly encoded.
+ Unfortunately, existing files already have the bug and may not properly
+ be processed. The fix uses constants from the GuardTime API lib to
+ prevent such problems in the future.
+ Thanks to Ahto Truu for providing the patch.
- bugfix: imtcp addtlframedelimiter could not be set to zero
Thanks to Chris Norton for alerting us.
- doc bugfix: remove no-longer existing omtemplate from developer doc
diff --git a/runtime/librsgt.c b/runtime/librsgt.c
index 85fc7742..a8124568 100644
--- a/runtime/librsgt.c
+++ b/runtime/librsgt.c
@@ -75,7 +75,7 @@ reportGTAPIErr(gtctx ctx, gtfile gf, char *apiname, int ecode)
char errbuf[4096];
snprintf(errbuf, sizeof(errbuf), "%s[%s:%d]: %s",
(gf == NULL) ? (uchar*)"" : gf->sigfilename,
- apiname, ecode, GT_getErrorString(ecode));
+ apiname, ecode, GTHTTP_getErrorString(ecode));
errbuf[sizeof(errbuf)-1] = '\0';
reportErr(ctx, errbuf);
}
@@ -285,7 +285,9 @@ int
tlv8Write(gtfile gf, int flags, int tlvtype, int len)
{
int r;
- r = tlvbufAddOctet(gf, (flags << 5)|tlvtype);
+ assert((flags & RSGT_TYPE_MASK) == 0);
+ assert((tlvtype & RSGT_TYPE_MASK) == tlvtype);
+ r = tlvbufAddOctet(gf, (flags & ~RSGT_FLAG_TLV16) | tlvtype);
if(r != 0) goto done;
r = tlvbufAddOctet(gf, len & 0xff);
done: return r;
@@ -296,7 +298,9 @@ tlv16Write(gtfile gf, int flags, int tlvtype, uint16_t len)
{
uint16_t typ;
int r;
- typ = ((flags|1) << 15)|tlvtype;
+ assert((flags & RSGT_TYPE_MASK) == 0);
+ assert((tlvtype >> 8 & RSGT_TYPE_MASK) == (tlvtype >> 8));
+ typ = ((flags | RSGT_FLAG_TLV16) << 8) | tlvtype;
r = tlvbufAddOctet(gf, typ >> 8);
if(r != 0) goto done;
r = tlvbufAddOctet(gf, typ & 0xff);
diff --git a/runtime/librsgt.h b/runtime/librsgt.h
index bfcc4628..bf9c9c31 100644
--- a/runtime/librsgt.h
+++ b/runtime/librsgt.h
@@ -151,7 +151,10 @@ struct rsgtstatefile {
};
/* Flags and record types for TLV handling */
+#define RSGT_FLAG_NONCRIT 0x80
+#define RSGT_FLAG_FORWARD 0x40
#define RSGT_FLAG_TLV16 0x20
+#define RSGT_TYPE_MASK 0x1f
/* error states */
#define RSGTE_IO 1 /* any kind of io error */
diff --git a/runtime/librsgt_read.c b/runtime/librsgt_read.c
index a6e33160..a9a50798 100644
--- a/runtime/librsgt_read.c
+++ b/runtime/librsgt_read.c
@@ -249,7 +249,7 @@ rsgt_tlvRecRead(FILE *fp, tlvrecord_t *rec)
NEXTC;
rec->hdr[0] = c;
rec->tlvtype = c & 0x1f;
- if(c & 0x80) { /* tlv16? */
+ if(c & RSGT_FLAG_TLV16) { /* tlv16? */
rec->lenHdr = 4;
NEXTC;
rec->hdr[1] = c;
@@ -290,7 +290,7 @@ rsgt_tlvDecodeSUBREC(tlvrecord_t *rec, uint16_t *stridx, tlvrecord_t *newrec)
c = rec->data[(*stridx)++];
newrec->hdr[0] = c;
newrec->tlvtype = c & 0x1f;
- if(c & 0x80) { /* tlv16? */
+ if(c & RSGT_FLAG_TLV16) { /* tlv16? */
newrec->lenHdr = 4;
if(rec->tlvlen == *stridx) {r=RSGTE_LEN; goto done;}
c = rec->data[(*stridx)++];
diff --git a/tools/rsgtutil.c b/tools/rsgtutil.c
index 095b8066..567dcf4c 100644
--- a/tools/rsgtutil.c
+++ b/tools/rsgtutil.c
@@ -74,7 +74,7 @@ dumpFile(char *name)
if(fp != stdin)
fclose(fp);
return;
-err: fprintf(stderr, "error %d processing file %s\n", r, name);
+err: fprintf(stderr, "error %d (%s) processing file %s\n", r, RSGTE2String(r), name);
}
static void
@@ -113,7 +113,7 @@ showSigblkParams(char *name)
return;
err:
if(r != RSGTE_EOF)
- fprintf(stderr, "error %d processing file %s\n", r, name);
+ fprintf(stderr, "error %d (%s) processing file %s\n", r, RSGTE2String(r), name);
}
static void
@@ -145,7 +145,7 @@ detectFileType(char *name)
if(fp != stdin)
fclose(fp);
return;
-err: fprintf(stderr, "error %d processing file %s\n", r, name);
+err: fprintf(stderr, "error %d (%s) processing file %s\n", r, RSGTE2String(r), name);
}
static inline int
@@ -327,7 +327,7 @@ done:
return;
err:
- fprintf(stderr, "error %d processing file %s\n", r, name);
+ fprintf(stderr, "error %d (%s) processing file %s\n", r, RSGTE2String(r), name);
if(logfp != NULL)
fclose(logfp);
if(sigfp != NULL)