crypto-token-0.0.1: crypto tokens
Safe HaskellNone
LanguageHaskell2010

Crypto.Token

Description

Encrypted tokens/tickets to keep state in the client side. For security reasons, Storable data types MUST be fixed-size when stored (i.e. serialized into the memory).

Synopsis

Configuration

data Config Source #

Configuration for token manager.

Constructors

Config 

Fields

  • interval :: Int

    The interval to generate a new secret and remove the oldest one in minutes.

  • maxEntries :: Int

    Maximum size of secret entries. Minimum is 256 and maximum is 32767.

defaultConfig :: Config Source #

Default configuration to update secrets in 30 minutes and keep them for 10 days.

Token manager

data TokenManager Source #

The abstract data type for token manager.

spawnTokenManager :: Config -> IO TokenManager Source #

Spawning a token manager.

killTokenManager :: TokenManager -> IO () Source #

Killing a token manager.

Encryption and decryption

encryptToken :: (Storable a, ByteArray ba) => TokenManager -> a -> IO ba Source #

Encrypting a target value to get a token.

decryptToken :: (Storable a, ByteArray ba) => TokenManager -> ba -> IO (Maybe a) Source #

Decrypting a token to get a target value.