[sxt] added ciphers API;

master
Alexander Vdolainen 9 years ago
parent 7edcd44503
commit e87de77b3f

@ -0,0 +1,74 @@
/*
* 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
*
* PublicPrivateKeyPairs operation API
*
* (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 3 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_CIPHERS_H__
#define __SXT_CIPHERS_H__
#include <sxt/lcrypt.h>
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 *);
/* a little bit of internals TODO: move it out there */
int sxt_cipher_add(const char *name, unsigned int blksize, unsigned int keylen,
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__ */

@ -33,6 +33,12 @@ typedef SHA512_CTX* SHA512CTX;
#define SHA512_DIGEST_LEN SHA512_DIGEST_LENGTH #define SHA512_DIGEST_LEN SHA512_DIGEST_LENGTH
struct _lcrypt_cipher_priv
{
void *key;
void *ivec;
};
/* sxt wrapper around random numbers */ /* sxt wrapper around random numbers */
int sxt_get_random(void *data, int len, int pseudo); int sxt_get_random(void *data, int len, int pseudo);

Loading…
Cancel
Save