|
Packit |
141393 |
/*
|
|
Packit |
141393 |
* Copyright (c) 2014 Vincent Hanquez <vincent@snarc.org>
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* All rights reserved.
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
141393 |
* modification, are permitted provided that the following conditions
|
|
Packit |
141393 |
* are met:
|
|
Packit |
141393 |
* 1. Redistributions of source code must retain the above copyright
|
|
Packit |
141393 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
141393 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit |
141393 |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit |
141393 |
* documentation and/or other materials provided with the distribution.
|
|
Packit |
141393 |
* 3. Neither the name of the author nor the names of his contributors
|
|
Packit |
141393 |
* may be used to endorse or promote products derived from this software
|
|
Packit |
141393 |
* without specific prior written permission.
|
|
Packit |
141393 |
*
|
|
Packit |
141393 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
Packit |
141393 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
141393 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
141393 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
|
Packit |
141393 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
141393 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
Packit |
141393 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
Packit |
141393 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
Packit |
141393 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
Packit |
141393 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
Packit |
141393 |
* SUCH DAMAGE.
|
|
Packit |
141393 |
*/
|
|
Packit |
141393 |
#ifndef CRYPTONITE_SALSA
|
|
Packit |
141393 |
#define CRYPTONITE_SALSA
|
|
Packit |
141393 |
|
|
Packit |
141393 |
typedef union {
|
|
Packit |
141393 |
uint64_t q[8];
|
|
Packit |
141393 |
uint32_t d[16];
|
|
Packit |
141393 |
uint8_t b[64];
|
|
Packit |
141393 |
} block;
|
|
Packit |
141393 |
|
|
Packit |
141393 |
typedef block cryptonite_salsa_state;
|
|
Packit |
141393 |
|
|
Packit |
141393 |
typedef struct {
|
|
Packit |
141393 |
cryptonite_salsa_state st;
|
|
Packit |
141393 |
uint8_t prev[64];
|
|
Packit |
141393 |
uint8_t prev_ofs;
|
|
Packit |
141393 |
uint8_t prev_len;
|
|
Packit |
141393 |
uint8_t nb_rounds;
|
|
Packit |
141393 |
} cryptonite_salsa_context;
|
|
Packit |
141393 |
|
|
Packit |
141393 |
/* for scrypt */
|
|
Packit |
141393 |
void cryptonite_salsa_core_xor(int rounds, block *out, block *in);
|
|
Packit |
141393 |
|
|
Packit |
141393 |
void cryptonite_salsa_init_core(cryptonite_salsa_state *st, uint32_t keylen, const uint8_t *key, uint32_t ivlen, const uint8_t *iv);
|
|
Packit |
141393 |
void cryptonite_salsa_init(cryptonite_salsa_context *ctx, uint8_t nb_rounds, uint32_t keylen, const uint8_t *key, uint32_t ivlen, const uint8_t *iv);
|
|
Packit |
141393 |
void cryptonite_salsa_combine(uint8_t *dst, cryptonite_salsa_context *st, const uint8_t *src, uint32_t bytes);
|
|
Packit |
141393 |
void cryptonite_salsa_generate(uint8_t *dst, cryptonite_salsa_context *st, uint32_t bytes);
|
|
Packit |
141393 |
|
|
Packit |
141393 |
#endif
|