Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dmitry Baryshkov
nettle
Commits
748e2c54
Commit
748e2c54
authored
Aug 05, 2016
by
Niels Möller
Browse files
Helper read_file: Use size_t for sizes, and uint8_t for the contents.
parent
544b4047
Changes
5
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
748e2c54
2016-08-05 Niels Möller <nisse@lysator.liu.se>
* examples/io.c (read_file): Use size_t for sizes, and uint8_t for
the contents.
2016-08-04 Niels Möller <nisse@lysator.liu.se>
* dsa-sign.c (dsa_sign): Return failure if p is even, so that an
...
...
examples/io.c
View file @
748e2c54
...
...
@@ -74,11 +74,11 @@ werror(const char *format, ...)
}
}
unsigned
read_file
(
const
char
*
name
,
unsigned
max_size
,
char
**
contents
)
size_t
read_file
(
const
char
*
name
,
size_t
max_size
,
uint8_t
**
contents
)
{
unsigned
size
,
done
;
char
*
buffer
;
size_t
size
,
done
;
uint8_t
*
buffer
;
FILE
*
f
;
f
=
fopen
(
name
,
"rb"
);
...
...
@@ -92,7 +92,7 @@ read_file(const char *name, unsigned max_size, char **contents)
for
(
buffer
=
NULL
,
done
=
0
;;
size
*=
2
)
{
char
*
p
;
uint8_t
*
p
;
if
(
max_size
&&
size
>
max_size
)
size
=
max_size
;
...
...
@@ -167,7 +167,7 @@ int
simple_random
(
struct
yarrow256_ctx
*
ctx
,
const
char
*
name
)
{
unsigned
length
;
char
*
buffer
;
uint8_t
*
buffer
;
if
(
name
)
length
=
read_file
(
name
,
0
,
&
buffer
);
...
...
examples/io.h
View file @
748e2c54
...
...
@@ -52,8 +52,8 @@ werror(const char *format, ...) PRINTF_STYLE(1, 2);
* treated as an error; return value is zero, and no space is
* allocated. The returned data is NUL-terminated, for convenience. */
unsigned
read_file
(
const
char
*
name
,
unsigned
size
,
char
**
buffer
);
size_t
read_file
(
const
char
*
name
,
size_t
size
,
uint8_t
**
buffer
);
int
write_file
(
const
char
*
name
,
unsigned
size
,
const
char
*
buffer
);
...
...
examples/read_rsa_key.c
View file @
748e2c54
...
...
@@ -47,7 +47,7 @@ read_rsa_key(const char *name,
struct
rsa_private_key
*
priv
)
{
unsigned
length
;
char
*
buffer
;
uint8_t
*
buffer
;
int
res
;
length
=
read_file
(
name
,
0
,
&
buffer
);
...
...
examples/rsa-verify.c
View file @
748e2c54
...
...
@@ -44,7 +44,7 @@
static
int
read_signature
(
const
char
*
name
,
mpz_t
s
)
{
char
*
buffer
;
uint8_t
*
buffer
;
unsigned
length
;
int
res
;
...
...
@@ -52,7 +52,7 @@ read_signature(const char *name, mpz_t s)
if
(
!
length
)
return
0
;
res
=
(
mpz_set_str
(
s
,
buffer
,
16
)
==
0
);
res
=
(
mpz_set_str
(
s
,
(
const
char
*
)
buffer
,
16
)
==
0
);
free
(
buffer
);
return
res
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment