1
0
Fork 0
mirror of https://github.com/HACKERALERT/Picocrypt.git synced 2024-12-28 10:24:19 +00:00

Create BLAKE2s.c

This commit is contained in:
Evan Su 2021-03-22 09:29:29 -04:00 committed by GitHub
parent 1d5da295d6
commit bf2fc59ca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

67
audit/BLAKE2s.c Normal file
View file

@ -0,0 +1,67 @@
/* ===================================================================
*
* Copyright (c) 2014, Legrandin <helderijs@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* ===================================================================
*/
#include "common.h"
#define F_ROUNDS 10
#define MAX_DIGEST_BYTES 32
#define MAX_KEY_BYTES 32
#define BLAKE2_WORD_SIZE 32
#define G_R1 16
#define G_R2 12
#define G_R3 8
#define G_R4 7
typedef uint32_t blake2_word;
#define STORE_WORD_LITTLE(p, w) STORE_U32_LITTLE(p, w)
#define LOAD_WORD_LITTLE(p) LOAD_U32_LITTLE(p)
static const uint32_t iv[8] = {
0x6A09E667U,
0xBB67AE85U,
0x3C6EF372U,
0xA54FF53AU,
0x510E527FU,
0x9B05688CU,
0x1F83D9ABU,
0x5BE0CD19U
};
#define blake2_init blake2s_init
#define blake2_copy blake2s_copy
#define blake2_destroy blake2s_destroy
#define blake2_digest blake2s_digest
#define blake2_update blake2s_update
FAKE_INIT(BLAKE2s)
#include "blake2.c"