|Project Name||Stars||Downloads||Repos Using This||Packages Using This||Most Recent Commit||Total Releases||Latest Release||Open Issues||License||Language|
|Encapsulated tokens (encrypted and mac'ed objects)|
|Kissme||295||3 years ago||10||apache-2.0||Kotlin|
|Kissme: Kotlin Secure Storage Multiplatform|
|Branca Spec||168||2 years ago||7|
|Authenticated and encrypted API tokens using modern crypto|
|Branca||129||5||40||3 years ago||May 27, 2021||1||mit||Go|
|:key: Secure alternative to JWT. Authenticated Encrypted API Tokens for Go.|
|Keyspace||123||10 years ago||Ruby|
|Capability-based secure key management and credential storage|
|Bash Otp||112||7 months ago||1||mit||Shell|
|One-time Password generator for CLI using bash, oathtool|
|Snitun||67||2 months ago||4||gpl-3.0||Python|
|End-to-End encryption with SNI proxy on top of a TCP multiplexer|
|Padre||60||12 days ago||2||March 02, 2021||1||Go|
|Blazing fast, advanced Padding Oracle exploit|
Authenticated and encrypted API tokens using modern crypto.
Branca is a secure, easy to use token format which makes it hard to shoot yourself in the foot. It uses IETF XChaCha20-Poly1305 AEAD symmetric encryption to create encrypted and tamperproof tokens. The payload itself is an arbitrary sequence of bytes. You can use for example a JSON object, plain text string or even binary data serialized by MessagePack or Protocol Buffers.
Although not a goal, it is possible to use Branca as an alternative to JWT. Also see getting started instructions.
This specification defines the external format and encryption scheme of the token to help developers create their own implementations. Branca is closely based on the Fernet specification.
A Branca token consists of a header, ciphertext and an authentication tag. The header consists of a version, timestamp and nonce. Putting them all together we get following structure:
Version (1B) || Timestamp (4B) || Nonce (24B) || Ciphertext (*B) || Tag (16B)
String representation of the above binary token must use base62 encoding with the following character set.
Version is 8 bits ie. one byte. Currently, the only version is
0xBA. This is a magic byte which you can use to quickly identify a given token. Version number guarantees the token format and encryption algorithm.
Timestamp is 32 bits ie. unsigned big-endian 4 byte UNIX timestamp. By having a timestamp instead of expiration time enables the consuming side to decide how long tokens are valid. You cannot accidentally create tokens which are valid for the next 10 years.
Storing the timestamp as an unsigned integer allows us to avoid the 2038 problem. Unsigned integer overflow will happen in the year 2106. Possible values are 0 - 4294967295.
This is a symmetric key of 32 arbitrary bytes. The key can be randomly generated using a CSPRNG or created during a key-exchange for example.
It is the responsibility of the user of Branca, to ensure the strength and confidentiality of the secret key used. See libsodium for more information on the difference between a password and a secret key.
Nonce is 192 bits ie. 24 bytes. It should be cryptographically secure random bytes. A nonce should never be used more than once with the same secret key between different payloads. It should be generated automatically by the implementing library. Allowing end users to provide their own nonce is a foot gun.
Payload is an arbitrary sequence of bytes of any length.
Payload is encrypted and authenticated using IETF XChaCha20-Poly1305. Note that this is Authenticated Encryption with Additional Data (AEAD) where the header part of the token is the additional data. This means the data in the header (version, timestamp and nonce) is not encrypted, it is only authenticated. In laymans terms, header can be seen but it cannot be tampered with.
The authentication tag is 128 bits ie. 16 bytes. This is the Poly1305 message authentication code. It is used to make sure that the payload, as well as the non-encrypted header have not been tampered with.
Instructions below assume your crypto library supports combined mode. In combined mode, the authentication tag and the encrypted message are stored together. If your crypto library does not provide combined mode, then the
tag is last 16 bytes of the
Given a 256 bit ie. 32 byte secret
key and an arbitrary
payload, generate a token with the following steps in order:
timestampis provided, use the current unixtime.
headeras the additional data for the AEAD.
headerand the returned
ciphertext|tagcombination from step 4.
Given a 256 bit ie. 32 byte secret
key and a
token to verify that the
token is valid and recover the original unencrypted
payload, perform the following steps, in order.
headerie. the first 29 bytes from the decoded token.
nonceie. the last 24 bytes from the
timestampie. bytes 2 to 5 from the
ciphertext|tagcombination ie. everything starting from byte 30.
ciphertext|tagcombination with IETF XChaCha20-Poly1305 AEAD using the secret
headeras the additional data for AEAD.
Optionally the implementing library may use the
timestamp for additional verification. For example the library could provide a non-negative
ttl parameter which is used to check if token is expired by adding the
ttl to the
timestamp and comparing the result with the current unixtime. Any optional timestamp check must happen as the last step after decrypting and verifying the token. Further, the implementing library must ensure adding
timestamp does not overflow 4294967295.
Currently known implementations in the wild.
|Language||Repository||License||Crypto library used|
All test vectors can be found here.
The MIT License (MIT). Please see License File for more information.