| 1 | /* salsa208.h --- The Salsa20/8 stream cipher |
| 2 | * Copyright (C) 2018 Mark Wooding |
| 3 | * |
| 4 | * This file is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published |
| 6 | * by the Free Software Foundation; either version 2, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * This file is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this file; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 | * 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | /** @file lib/salsa208.h |
| 21 | * @brief Salsa20/8 stream cipher implementation |
| 22 | */ |
| 23 | |
| 24 | #ifndef SALSA208_H |
| 25 | # define SALSA208_H |
| 26 | |
| 27 | # include <stddef.h> |
| 28 | # include <stdint.h> |
| 29 | |
| 30 | /** @brief Context structure for Salsa208 stream cipher */ |
| 31 | typedef struct { |
| 32 | uint32_t m[16]; /* the raw state matrix */ |
| 33 | uint8_t buf[64]; /* current output buffer */ |
| 34 | unsigned i; /* cursor in output buffer */ |
| 35 | } salsa208_context; |
| 36 | |
| 37 | extern void salsa208_stream(salsa208_context *context, |
| 38 | const void *inbuf, void *outbuf, size_t length); |
| 39 | extern void salsa208_setkey(salsa208_context *context, |
| 40 | const void *key, size_t keylen); |
| 41 | extern void salsa208_setnonce(salsa208_context *context, |
| 42 | const void *nonce, size_t noncelen); |
| 43 | |
| 44 | #endif /* SALSA208_H */ |