-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypto.h
33 lines (28 loc) · 985 Bytes
/
crypto.h
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
#pragma once
#include <glib.h>
#include <nettle/rsa.h>
#include "manifest.h"
#define CRYPTO_KEYNAME_RSA_PUB "rsa.pub"
#define CRYPTO_KEYNAME_RSA_PRIV "rsa.priv"
struct crypto_keys {
struct rsa_public_key pubkey;
struct rsa_private_key privatekey;
};
struct crypto_checksigcntx {
const gchar* what;
guint8* data;
gsize len;
struct crypto_keys* keys;
gboolean cont;
};
struct manifest_signature* crypto_sign(enum manifest_signaturetype sigtype,
struct crypto_keys* keys, guint8* data, gsize len);
gboolean crypto_verify(struct manifest_signature* signature,
struct crypto_keys* keys, guint8* data, gsize len);
gboolean crypto_keygen(struct crypto_keys* keys);
void crypto_writekeys(struct crypto_keys* keys, const gchar* rsapubkeypath,
const gchar* rsaprivkeypath);
struct crypto_keys* crypto_readkeys(const gchar* rsapubkeypath,
const gchar* rsaprivkeypath);
void crypto_keys_free(struct crypto_keys* keys);
void crypto_checksig(gpointer data, gpointer user_data);