library: Add version check macro

I really should have noticed this in libopenconnect and done the same
in libstoken from the beginning, but alas...

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
library: Add token_version and uses_pin to struct token_info

uses_pin may be needed by some callers to figure out whether to
concatenate a PIN.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Change securid_encode_token() to take a version argument

To prevent surprises, the output token version should be passed in
explicitly, not inferred from the original format.  As a side effect
this prevents clobbering ctx->t->version, which is now reported via
stoken_get_info().

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
library: Add stoken_get_guid_list()

Let library callers retrieve the list of known class GUIDs, i.e. strings
used to bind a seed file to a specific type of device.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
cli: Try to guess the bound device ID from the class GUID list

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
man: Document the --devid option

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
library: Add stoken_format_tokencode()

Pretty much every GUI client will need this, so we might as well roll
it into the library.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
common: Fix --force on stoken-gui

This option actually is allowed, so move it into the "GUI OK" list.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Export securid_unix_exp_date() to internal CLI/GUI code

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
gui: Rewrite code to use GTK+3 and glade

Define most windows and dialogs in XML instead of C.  Add next tokencode
and other info to the "detailed" stoken-gui window, making it look more
like Easy Token on Android.  Use a custom progressbar widget to avoid GTK+
quirks/decorations.

Also, this splits the password and PIN prompts, as v3 tokens need to be
decrypted with the password before we know whether a PIN is needed.

Closes #6.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
gui: Move more support files under gui/

With all of the new *.ui files these are starting to clutter up the top
level.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
debian: Rename to ppa/

This worked out fairly well on ocproxy so we'll mirror the same change
here.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Fix compatibility with older versions of libgtk

The original rewrite targeted 3.10, but we'll try to support 3.4
(maybe earlier).

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
gui: Fix problems copying to clipboard

The "clicked" and "button-press-event" callbacks have different arguments,
so add two simple wrapper functions to handle the differences.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Bypass securid_decrypt_seed() sanity checks when testing device IDs

securid_decrypt_seed() will abort immediately if the token requires a
password but a password isn't provided.  This is *usually* what we want,
but when we're just trying to guess the bound device ID it causes
the function to return prematurely.  In this case we will pass in "." as
the password so that we can see whether the devid hash check returns
ERR_BAD_DEVID or (anything else).

This is still safe on passwordless tokens, because in that case the logic
just ignores the supplied password.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
cli: Keep prompting for required devid/password

These are not optional fields, and skipping them will prevent the token
from being decrypted.  Keep asking the user until they enter something
or hit ^C.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Add workaround for missing mkstemps() declaration on Android

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
cli: Add --qr and --show-qr export options

These just invoke external utilities (qrencode and image viewers) but
it is more convenient than remembering the long-ish command lines needed
to convert a token into a QR code.

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

Update QR info; fix formatting and TODO list.

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