Skip to content

Commit e70701d

Browse files
committed
initial version
0 parents  commit e70701d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+14679
-0
lines changed

Diff for: LICENSE

Whitespace-only changes.

Diff for: Lyra2.c

+382
Large diffs are not rendered by default.

Diff for: Lyra2.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Header file for the Lyra2 Password Hashing Scheme (PHS).
3+
*
4+
* Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014.
5+
*
6+
* This software is hereby placed in the public domain.
7+
*
8+
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
9+
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
11+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
12+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
13+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
14+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
15+
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
16+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
17+
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
18+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19+
*/
20+
#ifndef LYRA2_H_
21+
#define LYRA2_H_
22+
23+
#include <stdint.h>
24+
25+
typedef unsigned char byte;
26+
27+
//Block length required so Blake2's Initialization Vector (IV) is not overwritten (THIS SHOULD NOT BE MODIFIED)
28+
#define BLOCK_LEN_BLAKE2_SAFE_INT64 8 //512 bits (=64 bytes, =8 uint64_t)
29+
#define BLOCK_LEN_BLAKE2_SAFE_BYTES (BLOCK_LEN_BLAKE2_SAFE_INT64 * 8) //same as above, in bytes
30+
31+
32+
#ifdef BLOCK_LEN_BITS
33+
#define BLOCK_LEN_INT64 (BLOCK_LEN_BITS/64) //Block length: 768 bits (=96 bytes, =12 uint64_t)
34+
#define BLOCK_LEN_BYTES (BLOCK_LEN_BITS/8) //Block length, in bytes
35+
#else //default block lenght: 768 bits
36+
#define BLOCK_LEN_INT64 12 //Block length: 768 bits (=96 bytes, =12 uint64_t)
37+
#define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes
38+
#endif
39+
40+
int LYRA2(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const void *salt, uint64_t saltlen, uint64_t timeCost, uint64_t nRows, uint64_t nCols);
41+
42+
int LYRA2_old(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const void *salt, uint64_t saltlen, uint64_t timeCost, uint64_t nRows, uint64_t nCols);
43+
44+
#endif /* LYRA2_H_ */

Diff for: Lyra2RE.c

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*-
2+
* Copyright 2009 Colin Percival, 2011 ArtForz, 2013 Neisklar, 2014 James Lovejoy
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGE.
25+
*
26+
* This file was originally written by Colin Percival as part of the Tarsnap
27+
* online backup system.
28+
*/
29+
30+
#include "Lyra2RE.h"
31+
#include <stdlib.h>
32+
#include <stdint.h>
33+
#include <string.h>
34+
#include <stdio.h>
35+
#include "sph_blake.h"
36+
#include "sph_groestl.h"
37+
#include "sph_cubehash.h"
38+
#include "sph_bmw.h"
39+
#include "sph_keccak.h"
40+
#include "sph_skein.h"
41+
#include "Lyra2.h"
42+
43+
void lyra2re_hash(const char* input, char* output)
44+
{
45+
sph_blake256_context ctx_blake;
46+
sph_groestl256_context ctx_groestl;
47+
sph_keccak256_context ctx_keccak;
48+
sph_skein256_context ctx_skein;
49+
50+
uint32_t hashA[8], hashB[8];
51+
52+
sph_blake256_init(&ctx_blake);
53+
sph_blake256 (&ctx_blake, input, 80);
54+
sph_blake256_close (&ctx_blake, hashA);
55+
56+
sph_keccak256_init(&ctx_keccak);
57+
sph_keccak256 (&ctx_keccak,hashA, 32);
58+
sph_keccak256_close(&ctx_keccak, hashB);
59+
60+
LYRA2_old(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
61+
62+
sph_skein256_init(&ctx_skein);
63+
sph_skein256 (&ctx_skein, hashA, 32);
64+
sph_skein256_close(&ctx_skein, hashB);
65+
66+
sph_groestl256_init(&ctx_groestl);
67+
sph_groestl256 (&ctx_groestl, hashB, 32);
68+
sph_groestl256_close(&ctx_groestl, hashA);
69+
70+
memcpy(output, hashA, 32);
71+
}
72+
73+
void lyra2re2_hash(const char* input, char* output)
74+
{
75+
sph_blake256_context ctx_blake;
76+
sph_cubehash256_context ctx_cubehash;
77+
sph_keccak256_context ctx_keccak;
78+
sph_skein256_context ctx_skein;
79+
sph_bmw256_context ctx_bmw;
80+
81+
uint32_t hashA[8], hashB[8];
82+
83+
sph_blake256_init(&ctx_blake);
84+
sph_blake256(&ctx_blake, input, 80);
85+
sph_blake256_close (&ctx_blake, hashA);
86+
87+
sph_keccak256_init(&ctx_keccak);
88+
sph_keccak256(&ctx_keccak, hashA, 32);
89+
sph_keccak256_close(&ctx_keccak, hashB);
90+
91+
sph_cubehash256_init(&ctx_cubehash);
92+
sph_cubehash256(&ctx_cubehash, hashB, 32);
93+
sph_cubehash256_close(&ctx_cubehash, hashA);
94+
95+
LYRA2(hashB, 32, hashA, 32, hashA, 32, 1, 4, 4);
96+
97+
sph_skein256_init(&ctx_skein);
98+
sph_skein256(&ctx_skein, hashB, 32);
99+
sph_skein256_close(&ctx_skein, hashA);
100+
101+
sph_cubehash256_init(&ctx_cubehash);
102+
sph_cubehash256(&ctx_cubehash, hashA, 32);
103+
sph_cubehash256_close(&ctx_cubehash, hashB);
104+
105+
sph_bmw256_init(&ctx_bmw);
106+
sph_bmw256(&ctx_bmw, hashB, 32);
107+
sph_bmw256_close(&ctx_bmw, hashA);
108+
109+
memcpy(output, hashA, 32);
110+
}

Diff for: Lyra2RE.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef LYRA2RE_H
2+
#define LYRA2RE_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
void lyra2re_hash(const char* input, char* output);
9+
void lyra2re2_hash(const char* input, char* output);
10+
11+
#ifdef __cplusplus
12+
}
13+
#endif
14+
15+
#endif

Diff for: MANIFEST.in

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include sha3/hashblock.h
2+
include sha3/sph_blake.h
3+
include sha3/sph_bmw.h
4+
include sha3/sph_cubehash.h
5+
include sha3/sph_groestl.h
6+
include sha3/sph_keccak.h
7+
include sha3/sph_skein.h
8+
include sha3/sph_types.h
9+
include Lyra2RE.h
10+
include Lyra2.h
11+
include Sponge.h

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lyra2re-hash-python
2+
=====================
3+
4+
Python module with Vertcoin's hashing algorithm used by some other tools

0 commit comments

Comments
 (0)