-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcrypto_api.h
More file actions
executable file
·63 lines (52 loc) · 1.83 KB
/
Copy pathcrypto_api.h
File metadata and controls
executable file
·63 lines (52 loc) · 1.83 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
#ifndef CRYPTO_API_H
#define CRYPTO_API_H
#define DIGEST_SIZE 32
#define KEY_SIZE 2048
#define SIG_FOOTER_SIZE 64
#define SIGNATURE_SIZE 96
enum crypto_range {
_TYPE_CRYPTO_START = _NEXT_RANGE_START,
TYPE_ECKEY,
TYPE_ECKEY_PUB,
TYPE_TLS_CTX,
TYPE_TLS_INFO,
TYPE_TLS_CAPSULE,
_TYPE_CRYPTO_END,
};
#undef _NEXT_RANGE_START
#define _NEXT_RANGE_START _TYPE_CRYPTO_END
typedef struct crypto_tls_ctx {
Type type;
void *tlsCtx;
} TlsCtx;
typedef struct crypto_tls_info {
Type type;
i32 fd;
void *tls;
TlsCtx *ctx;
} TlsInfo;
typedef byte digest[DIGEST_SIZE];
void Tls_Init(MemCh *m);
TlsCtx *TlsCtx_Make(MemCh *m, StrVec *cert, StrVec *key);
void TlsCtx_Destroy(MemCh *m, TlsCtx *ctx);
TlsInfo *TlsInfo_Make(MemCh *m, i32 fd, TlsCtx *ctx);
status Str_ToSha256(MemCh *m, Str *s, digest *hash);
status StrVec_ToSha256(MemCh *m, StrVec *v, digest *hash);
status StrVec_SaltedDigest(MemCh *m,
StrVec *v, Str *salt, digest *hash, util nonce);
status SignPair_Make(MemCh *m, Single *public, Single *secret);
status SignPair_FromPhrase(MemCh *m, Single *public, Single *secret, StrVec *phrase);
Str *SignPair_Sign(MemCh *m, StrVec *content, Single *secret);
status SignPair_Verify(MemCh *m, StrVec *content, Str *sig, Single *public);
status BoxPair_Make(MemCh *m, Str *public, Str *secret, StrVec *phrase);
status BoxPair_Enc(MemCh *m, Str *secret, StrVec *content);
status BoxPair_Dec(MemCh *m, Str *public, StrVec *content);
status Str_HmacEnc(MemCh *m, Str *s, Str *hmac);
status Str_HmacDec(MemCh *m, Str *s, Str *hmac);
Str *Str_DigestAlloc(MemCh *m);
status SignPair_PrivateFromPem(Buff *bf, Single *secret);
status SignPair_PublicFromPem(Buff *bf, Single *public);
status SignPair_PrivateToPem(Buff *bf, Single *secret);
status SignPair_PublicToPem(Buff *bf, Single *public);
status Crypto_Init(MemCh *m);
#endif