Edgio / ectoken

Token Generator for Edgio Token-Based Authentication from Edgio
22 stars 40 forks source link

ectoken

C implementation of Edgio token (ectoken)

Table of Contents

Background

C implementation of the "Edgio Token" (ectoken), an AES-GCM token.

Install

The C implementation requires gcc to build and OpenSSL libcryptoto link.

Building with Make

To build, run the make command.

ectoken>make
gcc -O2 -Wall -Werror -std=gnu99 util/ectoken_cmd.c -I. ectoken.c base64.c -o ectoken -lcrypto  -lm
cc    -c -o ectoken.o ectoken.c
cc    -c -o base64.o base64.c
ar rcs libectoken.a ectoken.o base64.o

This will build a library and an executable (ectoken) for command line usage.

Running tests

Run make test from the project directory.

ectoken>make test
gcc -O2 -Wall -Werror -std=gnu99 util/ectoken_cmd.c -I. ectoken.c base64.c -o ectoken -lcrypto  -lm
cc    -c -o ectoken.o ectoken.c
cc    -c -o base64.o base64.c
ar rcs libectoken.a ectoken.o base64.o
gcc -std=c99 -I. tests/ectoken_test.c -lcrypto -lm -o ectoken_test
./ectoken_test
test_short_size_calculations
success
...
test_full_flow
success

test_full_flow
success

Usage

Help

>./ectoken 
Error wrong number of arguments specified
Usage: 
 To Encrypt:
     ectoken <key> <text>
 or:
     ectoken encrypt <key> <text>
 To Decrypt:
     ectoken decrypt <key> <text>

Encrypt

Encrypt clear text token <token> with key: <key>:

>./ectoken encrypt MY_SECRET_KEY MY_COOL_TOKEN
fVSYBBTynMkvQECGV-Kdfp333R-MGY2fsrrpVyuqd7OiuAUsQ8ITrL0

Decrypt

Decrypt ciphertext token <token> with key: <key>:

>./ectoken decrypt MY_SECRET_KEY fVSYBBTynMkvQECGV-Kdfp333R-MGY2fsrrpVyuqd7OiuAUsQ8ITrL0
MY_COOL_TOKEN

Contribute

License

This project is licensed under the terms of the Apache 2.0 open source license. Please refer to the LICENSE-2.0.txt file for the full terms.