diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..d6d0fc5 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +## [xchapolybox](https://git.zx2c4.com/xchapolybox/about/) + +by Jason A. Donenfeld + +_Warning: you probably shouldn't use this. It hasn't actually ever been used._ + +This is a very simple "crypto box", meant for being included as a single C file inside your project. It presents an extremely simple API: + +### Constants + + - `XCHAPOLYBOX_OVERHEAD_LEN` + - `XCHAPOLYBOX_KEY_LEN` + +### Functions + + - `void xchapolybox_seal(uint8_t *dst, const uint8_t *src, size_t src_len, const uint8_t key[XCHAPOLYBOX_KEY_LEN]);` + - `bool xchapolybox_open(uint8_t *dst, const uint8_t *src, size_t src_len, const uint8_t key[XCHAPOLYBOX_KEY_LEN]);` + - `void xchapolybox_genkey(uint8_t key[XCHAPOLYBOX_KEY_LEN]);` + +### Example + +```c +uint8_t key[XCHAPOLYBOX_KEY_LEN]; +uint8_t *output, *input, *input2; +size_t input_len, output_len; + +xchapolybox_genkey(key); + +input = get_input_from_somewhere(&input_len); +assert(input); +output_len = input_len + XCHAPOLYBOX_OVERHEAD_LEN; +output = malloc(output_len); +assert(output); + +xchapolybox_seal(output, input, input_len, key); + +input2 = malloc(input_len); +assert(input2); + +if (!xchapolybox_open(input2, output, output_len, key)) { + // Always remember to check the auth tag. + return -1; +} +assert(!memcmp(input, input2, input_len)); +``` |