| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /* ===================================================================
- *
- * 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 "pycrypto_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;
- static const uint32_t iv[8] = {
- 0x6A09E667,
- 0xBB67AE85,
- 0x3C6EF372,
- 0xA54FF53A,
- 0x510E527F,
- 0x9B05688C,
- 0x1F83D9AB,
- 0x5BE0CD19
- };
- static void byteswap(uint32_t *v)
- {
- union {
- uint32_t w;
- uint8_t b[4];
- } x, y;
- x.w = *v;
- y.b[0] = x.b[3];
- y.b[1] = x.b[2];
- y.b[2] = x.b[1];
- y.b[3] = x.b[0];
- *v = y.w;
- }
- #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"
|