File: sha2.h

package info (click to toggle)
ufoai 2.5-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 82,128 kB
  • sloc: cpp: 225,227; python: 5,111; ansic: 4,133; php: 2,209; perl: 1,931; sh: 1,517; xml: 1,115; makefile: 401; sed: 11
file content (34 lines) | stat: -rw-r--r-- 814 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include "../shared/ufotypes.h"

typedef struct {
	uint64_t total[2];
	uint64_t state[8];
	byte buffer[64];
} sha2_context;

/**
 * Core SHA-256 functions
 */
void Com_SHA2Starts (sha2_context *ctx);
void Com_SHA2Update (sha2_context *ctx, const byte* input, uint32_t length);
void Com_SHA2Finish (sha2_context *ctx, byte digest[32]);

/**
 * @brief Output SHA-256(file contents)
 * @return @c true if successful
 */
bool Com_SHA2File (const char* filename, byte digest[32]);

/**
 * @brief Output SHA-256(buf)
 */
void Com_SHA2Csum (const byte* buf, uint32_t buflen, byte digest[32]);

/**
 * @brief Output HMAC-SHA-256(buf,key)
 */
void Com_SHA2Hmac (const byte* buf, uint32_t buflen, const byte* key, uint32_t keylen, byte digest[32]);

void Com_SHA2ToHex (const byte digest[32], char final[65]);