/* * 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 * * (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 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 ."; * */ #include #include #include #include #include #include #include #include #include #include #ifdef WIN32 #include #define EBADE 1 #define NETDB_SUCCESS 0 #else #include #include #include #include #endif #if 0 #include #include #include #endif #include #include #include int sxt_init(void) { return 0; } int sxt_finish(void) { return 0; } int sxt_get_random(void *data, int len, int pseudo) { if(pseudo) return RAND_bytes(data, len); else #if OPENSSL_API_COMPAT < 0x10100000L RAND_pseudo_bytes(data, len); #else RAND_bytes(data, len); #endif return 1; } /* wrappers */ SHA512CTX sha512_init(void){ SHA512CTX c = malloc(sizeof(*c)); if (c == NULL) { return NULL; } SHA512_Init(c); return c; } void sha512_update(SHA512CTX c, const void *data, unsigned long len){ SHA512_Update(c,data,len); } void sha512_final(unsigned char *md, SHA512CTX c) { SHA512_Final(md, c); if(c) free(c); }