Revert "Merge branch 'upstream' into tizen"
[platform/upstream/nettle.git] / examples / io.h
1 /* io.c
2  *
3  * Miscellaneous functions used by the example programs.
4  */
5
6 /* nettle, low-level cryptographics library
7  *
8  * Copyright (C) 2002 Niels Möller
9  *  
10  * The nettle library is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or (at your
13  * option) any later version.
14  * 
15  * The nettle library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18  * License for more details.
19  * 
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the nettle library; see the file COPYING.LIB.  If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23  * MA 02111-1301, USA.
24  */
25
26 #ifndef NETTLE_EXAMPLES_IO_H_INCLUDED
27 #define NETTLE_EXAMPLES_IO_H_INCLUDED
28
29 #include "nettle-meta.h"
30 #include "yarrow.h"
31
32 #include <stdio.h>
33
34 extern int quiet_flag;
35
36 void *
37 xalloc(size_t size);
38
39 void
40 werror(const char *format, ...) PRINTF_STYLE(1, 2);
41
42 /* If size is > 0, read at most that many bytes. If size == 0, read
43  * until EOF. Allocates the buffer dynamically. An empty file is
44  * treated as an error; return value is zero, and no space is
45  * allocated. The returned data is NUL-terminated, for convenience. */
46
47 unsigned
48 read_file(const char *name, unsigned size, char **buffer);
49
50 int
51 write_file(const char *name, unsigned size, const char *buffer);
52
53 int
54 write_string(FILE *f, unsigned size, const char *buffer);
55
56 int
57 simple_random(struct yarrow256_ctx *ctx, const char *name);
58
59 int
60 hash_file(const struct nettle_hash *hash, void *ctx, FILE *f);
61
62 #if WITH_HOGWEED
63 struct rsa_public_key;
64 struct rsa_private_key;
65
66 int
67 read_rsa_key(const char *name,
68              struct rsa_public_key *pub,
69              struct rsa_private_key *priv);
70 #endif /* WITH_HOGWEED */
71
72 #endif /* NETTLE_EXAMPLES_IO_H_INCLUDED */