3 * Miscellaneous functions used by the example programs.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2002 Niels Möller
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.
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.
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,
26 #ifndef NETTLE_EXAMPLES_IO_H_INCLUDED
27 #define NETTLE_EXAMPLES_IO_H_INCLUDED
29 #include "nettle-meta.h"
34 extern int quiet_flag
;
40 werror(const char *format
, ...) PRINTF_STYLE(1, 2);
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. */
48 read_file(const char *name
, unsigned size
, char **buffer
);
51 write_file(const char *name
, unsigned size
, const char *buffer
);
54 write_string(FILE *f
, unsigned size
, const char *buffer
);
57 simple_random(struct yarrow256_ctx
*ctx
, const char *name
);
60 hash_file(const struct nettle_hash
*hash
, void *ctx
, FILE *f
);
63 struct rsa_public_key
;
64 struct rsa_private_key
;
67 read_rsa_key(const char *name
,
68 struct rsa_public_key
*pub
,
69 struct rsa_private_key
*priv
);
70 #endif /* WITH_HOGWEED */
72 #endif /* NETTLE_EXAMPLES_IO_H_INCLUDED */