-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfscrypt_plugin.h
More file actions
90 lines (74 loc) · 3.41 KB
/
fscrypt_plugin.h
File metadata and controls
90 lines (74 loc) · 3.41 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef FITSEC_PLUGIN_H
#define FITSEC_PLUGIN_H
#include "fscrypt.h"
#include <cring.h>
#include <stdlib.h>
#include <stdbool.h>
#ifndef FSCRYPT_EXPORT
#define FSCRYPT_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct FSSignature FSSignature;
typedef bool (FSCrypt_Init_Fn) (FSCrypt * e, const char * params);
typedef void (FSRandom_Fn)(FSCrypt * e, void * ptr, size_t length);
typedef struct {
bool (*Sign) (FSCrypt * e, const FSPrivateKey * key,
FSSignature * s, const uint8_t * digest, const uint8_t * k);
bool (*Verify) (FSCrypt * e, const FSPublicKey * pk,
const FSSignature * s, const uint8_t * digest);
}FSSignatureOps;
typedef struct {
// allocate new private key
FSPrivateKey* (*Import) (FSCrypt* c, FSCurve curve, const uint8_t * data, size_t len);
bool (*Generate) (FSCrypt* c, FSCurve curve,
FSPrivateKey** pPrivateKey, FSPublicKey * publicKey);
void (*FreePrivate) (FSCrypt* c, FSPrivateKey* k);
void (*FreePublic) (FSCrypt* c, FSPublicKey* k);
bool (*ExportPublic)(FSCrypt* c,
const FSPrivateKey* k, FSPublicKey * publicKey);
size_t (*ExportPrivate)(FSCrypt* c, const FSPrivateKey* priv, uint8_t * buf);
bool (*ReconstructPublic) (FSCrypt* c, FSPublicKey* rv, const FSPublicKey * ca, const uint8_t * digest);
size_t (*Derive) (FSCrypt* e,
const FSPublicKey* k, const FSPrivateKey* eph,
const void* salt, size_t salt_len,
void* digest, size_t digest_len);
}FSEccKeyOps;
typedef struct FSCryptSymmOps {
size_t (*Encrypt) (FSCrypt* e, FSSymmAlg alg,
const uint8_t * key, const uint8_t * nonce,
const uint8_t* in_buf, size_t in_size,
uint8_t* out_buf, size_t out_size);
size_t (*Decrypt) (FSCrypt* e, FSSymmAlg alg,
const uint8_t* key, const uint8_t* nonce,
const uint8_t* in_buf, size_t in_size,
uint8_t* out_buf, size_t out_size);
}FSCryptSymmOps;
typedef struct FSMACOps {
size_t (*mac)(FSCrypt * e, FSMAC alg, const uint8_t * data, size_t size, const uint8_t * key, size_t key_len, uint8_t * out);
}FSMACOps;
typedef struct FSHashOps
{
size_t (*Calc) (FSCrypt * e, FSHashAlg alg, const void* data, size_t len, uint8_t* digest);
}FSHashOps;
struct FSCrypt
{
FSCrypt* _next;
const char* name;
const char* description;
FSCrypt_Init_Fn * Init;
FSCrypt_Init_Fn * Deinit;
const FSHashOps * HashOps;
const FSSignatureOps * SignatureOps;
const FSEccKeyOps * KeyOps;
const FSCryptSymmOps * SymmOps;
const FSMACOps * MACOps;
FSRandom_Fn * Random;
// to be extended in plugin
};
FSCRYPT_EXPORT void FSCrypt_Register(FSCrypt* e);
#ifdef __cplusplus
}
#endif
#endif