sdtid: Trim whitespace on sensitive header fields

Extra whitespace can cause wrong results in some of the key calculations.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
sdtid: Clean up XML entity mangling

Get rid of mangle_encoding() as the RSA tools now decode &amp; &lt; &gt;
correctly.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Introduce new BASE64_INPUT_LEN() macro

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: Make hex2byte() more generic

We will use this function to handle URL-encoded data like "%2B" now, as
these show up in the base64-encoded v3 tokens.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: First attempt at decrypting v3 tokens

I have no idea why anyone would use these bulky, cumbersome base64
strings over the nice simple v1/v2 numeric sequences, but since some
sysadmin somewhere is likely to start issuing them, we might as well
add code to parse them.

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

Move the public functions to the end, and improve consistency between the
v2 and v3 implementations.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Use ERR_DECRYPT_FAILED to indicate an incorrect password

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: Move common v2/v3 logic into securid_encode_token()

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Fix base64-related constants

These strings can actually get quite long after URL-encoding; adjust
our constants accordingly.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Add aes256_cbc_encrypt() and v3_encode_date()

Round out the v3-related utility functions so we're ready for both
reading and writing v3 tokens.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Add support for "stoken export --v3"

Now we can read and write v3 token strings.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Bypass expiration check on locked tokens

We might not have access to the decrypted exp_date field at the time when
the function is called.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Translate devid before using it

The RSA algorithms only look at numbers and uppercase letters; all other
characters are skipped over.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Minor fixes to new code

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Support 30-second tokens

Current mobile clients seem to support both 60-second tokens and 30-second
tokens.  (And, FWIW, other values cause an import error.)

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
jni: Update Java API to populate StokenInfo.interval

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

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
debian: Update libstoken1.symbols with new internal symbol

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
securid: v3: Clean up BASE64_* constants

Use different constants for allocated string size versus minimum strlen()
size.  Add "URL" to the constant defining the size of the urlencoded
string.  Prefix all v3-related strings with "V3_".

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