You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libsxmp/include/sxt/sxt.h

108 lines
2.5 KiB
C

/*
* Secure eXtended Message Passing framework
* Secure eXtended Transport layer implementation: (libsxt)
* - very similar to SSH2/TLS
* - using already proven and tested crypto algos
* - better than TLS for message passing
*
* General sxt API and structures
*
* (c) Alexander Vdolainen 2016 <avdolainen@zoho.com>
*
* libsxmp is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* libsxmp is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
*
*/
#ifndef __SXT_SXT_H__
#define __SXT_SXT_H__
#define SXT_AUTH_PASSWORD (1 << 1)
#define SXT_AUTH_PEERKEY (1 << 2)
#define SXT_AUTH_PEERHASH (1 << 3)
#define SXTPROTO_VERSION 1
#define SXTBEER_TYPE "lager"
typedef struct __sxtlink_type {
uint64_t unuuid;
uint8_t unique[16];
uint8_t state;
/* sets keys */
sxtkey_t *pubkey;
sxtkey_t *privkey;
/* peer stuff */
ndbuf_t *loginpass_pair;
sxtkey_t *peer_pubkey;
/* socket */
sxtsocket_t *socket;
void *priv;
} sxtlink_t;
typedef struct __sxtset_type {
/* flags for authentification */
uint8_t auth_types;
/* timeouts in secs */
uint32_t session_tm; /* timeout for session i.e. secs to forget about session while socket io error */
uint32_t session_lt; /* session life time i.e. when session will be closed, 0 if infinite */
sxtkey_t *pubkey;
sxtkey_t *privkey;
/* authentification ops */
struct {
int (*auth_loginpass_pair)(sxtlink_t *, void *);
int (*auth_key_peer)(sxtlink_t *, void *);
} auth_ops;
/* options */
uint64_t hash;
const char *strctx;
void *priv;
} sxtset_t;
typedef struct __sxtsession_type {
uint8_t unique[16];
uint8_t state;
sxtlink_t *link;
sxtset_t *linkset;
int sxt_version;
uint64_t peer_swhash;
sxtsafebuffer_t *peerbeer;
/* stats */
uint64_t rcv_pck;
uint64_t snd_pck;
} sxtsession_t;
int sxt_init(void);
int sxt_finish(void);
int sxt_reseed(void);
/* plain text beer exchange :) */
int sxt_scanbeer(sxtsession_t *, const char *, size_t);
int sxt_genbeer(sxtsession_t *, sxtsafebuffer_t *);
#endif /* __SXT_SXT_H__ */