00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef VSL_UTIL_H
00015 #define VSL_UTIL_H
00016
00017 #include "vsl_api.h"
00018 #include <stdarg.h>
00019 #include <stdbool.h>
00020
00021
00022 #define RANDDEV "/dev/urandom"
00023
00024
00025
00026 int gen_key (unsigned char* key);
00027 void init_keys_c (vsl_sock* sock, const unsigned char* key);
00028 void init_keys_s (vsl_sock* sock, const unsigned char* key);
00029 void sha256 (const unsigned char* s1, int l1,
00030 const unsigned char* s2, int l2, unsigned char *hash);
00031 void md5 (const unsigned char* s1, int l1,
00032 const unsigned char* s2, int l2, unsigned char *hash);
00033 bool is_blocking (vsl_sock* socket);
00034 void set_blocking (vsl_sock* socket, bool mode);
00035 unsigned char* write_objs (size_t* total, ...);
00036 unsigned char* read_objs (unsigned char* src, size_t max, ...);
00037 inline uint64_t ntohll (uint64_t val);
00038 inline uint64_t htonll (uint64_t val);
00039 void aes_ctr (unsigned char* ctr,
00040 const unsigned char* key,
00041 unsigned char* buf,
00042 const size_t len);
00043
00044 inline void ctr_inc (unsigned char* ctr);
00045 inline void xor16 (unsigned char* b1, unsigned char* b2);
00046
00047 typedef ssize_t (*transmit_fn)(vfer_fd, void*, size_t);
00048 int transfer ( vsl_sock *sock, transmit_fn fn,
00049 unsigned char* buf, size_t min, size_t len);
00050
00051
00052
00053
00054
00055 #endif
00056
00057
00058
00059
00060
00061
00062