aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/installer/fetcher/crypto.h
blob: d5f846fc65cd010e76e205fe6899ef749a017356 (plain) (blame)
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
/* SPDX-License-Identifier: GPL-2.0
 *
 * Copyright (C) 2020-2021 Jason A. Donenfeld. All Rights Reserved.
 */

#ifndef _CRYPTO_H
#define _CRYPTO_H

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

struct blake2b256_state {
	uint64_t h[8];
	uint64_t t[2];
	uint64_t f[2];
	uint8_t buf[128];
	size_t buflen;
};

void blake2b256_init(struct blake2b256_state *state);
void blake2b256_update(struct blake2b256_state *state, const uint8_t *in,
		       unsigned int inlen);
void blake2b256_final(struct blake2b256_state *state, uint8_t out[32]);

bool ed25519_verify(const uint8_t signature[64], const uint8_t public_key[32],
		    const void *message, size_t message_size);

#endif