2 * Copyright (C) 2011 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file gcrypt.c Libgrcypt-based encryption/decryption routines. */
10 #include <sys/types.h>
11 #include <sys/socket.h>
19 struct asymmetric_key {
23 void get_random_bytes_or_die(unsigned char *buf, int num)
27 void init_random_seed_or_die(void)
31 int get_asymmetric_key(const char *key_file, int private,
32 struct asymmetric_key **result)
37 void free_asymmetric_key(struct asymmetric_key *key)
41 int priv_decrypt(const char *key_file, unsigned char *outbuf,
42 unsigned char *inbuf, int inlen)
47 int pub_encrypt(struct asymmetric_key *pub, unsigned char *inbuf,
48 unsigned len, unsigned char *outbuf)
53 struct stream_cipher {
57 struct stream_cipher *sc_new(const unsigned char *data, int len)
62 void sc_free(struct stream_cipher *sc)
66 int sc_send_bin_buffer(struct stream_cipher_context *scc, const char *buf,
72 int sc_send_buffer(struct stream_cipher_context *scc, const char *buf)
77 __printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc,
83 int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf,
89 int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size)
94 void hash_function(const char *data, unsigned long len, unsigned char *hash)