/* * 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 * * Ciphers API * * (c) Alexander Vdolainen 2016 * * 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 ."; * */ #ifndef __SXT_CIPHERS_H__ #define __SXT_CIPHERS_H__ struct _lcrypt_cipher_priv; struct __cipher_stype; struct _cipher_ops { int (*set_encrypt_key)(struct __cipher_stype *c, void *key, void *ivec); int (*set_decrypt_key)(struct __cipher_stype *c, void *key, void *ivec); void (*encrypt)(struct __cipher_stype *c, void *in, void *out, unsigned long len); void (*decrypt)(struct __cipher_stype *c, void *in, void *out, unsigned long len); }; typedef struct __cipher_stype { const char *name; /* applied to the all ciphers */ unsigned int blksize; /* block size */ unsigned int keylen; /* max key length */ unsigned int keysize; /* actual used key size */ /* since sxt will try to use different crypto libraries do that stuff now */ union { struct _lcrypt_cipher_priv *lcp; void *priv; }; /* functions */ struct _cipher_ops *f; } sxt_cipher_t; /* API */ /* API for workout with table */ sxt_cipher_t *sxt_cipher_get(const char *); void sxt_cipher_free(sxt_cipher_t *); /* a little bit of internals TODO: move it out there */ int sxt_cipher_add(const char *name, unsigned int blksize, unsigned int keylen, unsigned int keysz, struct _cipher_ops *f); /* API to deal with cipher */ const char *sxt_cipher_getname(sxt_cipher_t *); int sxt_cipher_set_encrypt_key(sxt_cipher_t *, void *, void *); int sxt_cipher_set_decrypt_key(sxt_cipher_t *, void *, void *); void sxt_cipher_encrypt(sxt_cipher_t *, void *, void *, unsigned long); void sxt_cipher_decrypt(sxt_cipher_t *, void *, void *, unsigned long); #endif /* __SXT_CIPHERS_H__ */