sdtid: Generate valid TKNTrailer sections

The BatchSignature uses v1.5 PKCS#1 signatures, SHA1+RSA, no salt
(RFC 3447).

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
sdtid: Fix valgrind errors in replace_b64()

We actually need to allocate one more byte than BASE64_INPUT_LEN()
specifies, because of the '=' hack on <Seed>.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
sdtid: Fix memory leak on "stoken issue --template"

We can't use pairs->value and a __lookup_common() result interchangeably
because the latter item is caller-freed.  Restructure the function to
make sure this is handled properly.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
gui: Allow --use-time with an offset

Prior to this patch, --use-time only worked on the CLI as it was a
"one-shot" computation.  But it may be useful to specify a time offset
when using the GUI to compensate for time skew on other copies of the
same token (either hard or soft).

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
sdtid: Add leading S/N zeroes when parsing hard token XML files

There are a couple of assumptions built into the code that token serial
numbers are 12 digits long:

 - The tokencode calculation (key_from_time()) uses 8 digits from the
   serial number.  If we pick the wrong 8 digits, then the wrong result
   will be generated.

 - Generation of V2 ctf strings assumes that the serial number is 12
   digits long, because the serial number is copied verbatim into a fixed
   12-character-long field of the output string.

In some places like decrypt_seed() we'll still need to use the short
number (struct sdtid->sn) but in other places we need the padded number
(struct securid_token->serial).

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Add sanity check on serial number length

Short serial numbers can cause various other modules to malfunction and
may lead to bad memory accesses.  Ban them.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
added tests

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
tests: Add a few more cases for --sdtid and --v3 tokens

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
added configure option --with-valgrind
travis: Run "make check" under valgrind on each new commit

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>