crypto.h
Go to the documentation of this file.
1 /**
2  * @file crypto.h
3  * @brief serval-dna plugin functionality for signing/verifying
4  * using Serval keys
5  *
6  * @author Dan Staples (dismantl), danstaples@opentechinstitute.org
7  *
8  * @internal
9  * Created 12/18/2013
10  * Compiler gcc/g++
11  * Company The Open Technology Institute
12  * Copyright Copyright (c) 2013, Dan Staples
13  *
14  * This file is part of Commotion, Copyright (c) 2013, Josh King
15  *
16  * Commotion is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published
18  * by the Free Software Foundation, either version 3 of the License,
19  * or (at your option) any later version.
20  *
21  * Commotion is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with Commotion. If not, see <http://www.gnu.org/licenses/>.
28  *
29  * =====================================================================================
30  */
31 
32 #ifndef __CO_SERVAL_CRYPTO_H
33 #define __CO_SERVAL_CRYPTO_H
34 
35 #include <serval.h>
36 
37 #include "obj.h"
38 
39 #define KEYRING_PIN NULL
40 #define BUF_SIZE 1024
41 #define crypto_sign_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES
42 #define crypto_sign_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_SECRETKEYBYTES
43 #define SIGNATURE_BYTES crypto_sign_edwards25519sha512batch_BYTES
44 
46  char *keyring_path;
47  size_t keyring_len;
48  keyring_file *keyring_file;
49  unsigned char sid[SID_SIZE]; // SID public key
50  unsigned char sas_public[crypto_sign_PUBLICKEYBYTES]; // SAS public key
51  unsigned char sas_private[crypto_sign_SECRETKEYBYTES]; // SAS private key
52  unsigned char signature[SIGNATURE_BYTES];
53  unsigned char *msg; // byte array used to create signature
54  size_t msg_len;
55 };
56 typedef struct svl_crypto_ctx svl_crypto_ctx;
57 
58 svl_crypto_ctx *svl_crypto_ctx_new(void);
59 void svl_crypto_ctx_free(svl_crypto_ctx *ctx);
60 
61 int serval_crypto_register(void);
62 
63 int olsrd_mdp_register(void);
64 
65 int olsrd_mdp_sign_register(void);
66 
67 int serval_crypto_handler(co_obj_t *self, co_obj_t **output, co_obj_t *params);
68 
69 int olsrd_mdp_init(co_obj_t *self, co_obj_t **output, co_obj_t *params);
70 
71 int olsrd_mdp_sign(co_obj_t *self, co_obj_t **output, co_obj_t *params);
72 
73 int serval_open_keyring(svl_crypto_ctx *ctx);
74 
75 int serval_init_keyring(svl_crypto_ctx *ctx);
76 
77 int cmd_serval_sign(svl_crypto_ctx *ctx);
78 
79 int cmd_serval_verify(svl_crypto_ctx *ctx);
80 
81 int serval_verify_client(svl_crypto_ctx *ctx);
82 
83 #endif
Commotion object model.
int olsrd_mdp_register(void)
Definition: crypto.c:417
int serval_crypto_register(void)
Definition: crypto.c:387
Definition: obj.h:131
int olsrd_mdp_sign(co_obj_t *self, co_obj_t **output, co_obj_t *params)
Definition: crypto.c:572
Definition: crypto.h:45
int olsrd_mdp_sign_register(void)
Definition: crypto.c:434