BitPunch McEliece  v0.0.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sha512.c
Go to the documentation of this file.
1 /*
2 This file is part of BitPunch
3 Copyright (C) 2015 Frantisek Uhrecky <frantisek.uhrecky[what here]gmail.com>
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "sha512.h"
19 
20 #ifdef BPU_CONF_SHA_512
22 
23 #include <bitpunch/debugio.h>
24 #include <bitpunch/math/gf2.h>
25 
27  uint8_t md[BPU_HASH_LEN];
28 
29  if (out->len != BPU_HASH_LEN * 8) {
30  BPU_printError("Wrong vector len %d", out->len);
31 
32  return -1;
33  }
34  // if input len is not divisible by 4, then it is not complete vector
35  if (in->len % 8) {
36 // BPU_printError("Wrong input vector len %d, should be divisible by 8", in->len);
37  BPU_printWarning("input vector len %d, should be divisible by 8", in->len);
38  }
39  // hash vector
40  sha512((uint8_t *)in->elements, in->len / 8, md, 0);
41  // copy digest to vector
42  memcpy(out->elements, md, BPU_HASH_LEN);
43 
44  return 0;
45 }
46 #endif
int BPU_gf2VecHash(BPU_T_GF2_Vector *out, const BPU_T_GF2_Vector *in)
Definition: sha512.c:26
void sha512(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = SHA-512( input buffer )
Definition: sha512.c:336
#define BPU_printWarning(fmt,...)
print warning message with filename, line
Definition: debugio.h:55
#define BPU_printError(fmt,...)
print error message with filename, line
Definition: debugio.h:47
BPU_T_GF2 * elements
all element of matrix
Definition: gf2types.h:33
uint32_t len
cols
Definition: gf2types.h:36
#define BPU_HASH_LEN
Definition: sha512.h:28