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
3da822d0
Commit
3da822d0
authored
Apr 27, 2011
by
Niels Möller
Browse files
(find_algorithm): Require exact match.
Rev: nettle/tools/nettle-hash.c:1.2
parent
a5cc380b
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/nettle-hash.c
View file @
3da822d0
...
...
@@ -54,31 +54,14 @@ list_algorithms (void)
static
const
struct
nettle_hash
*
find_algorithm
(
const
char
*
name
)
{
size_t
length
=
strlen
(
name
);
const
struct
nettle_hash
*
alg
;
const
struct
nettle_hash
*
found
=
NULL
;
unsigned
i
;
for
(
i
=
0
;
(
alg
=
nettle_hashes
[
i
]);
i
++
)
{
if
(
!
strncmp
(
name
,
alg
->
name
,
length
))
{
/* Luckily, no valid algorithm name is a prefix of any
other, so we don't need to handle exact matches
specially. */
if
(
found
)
die
(
"Hash algorithm `%s' is ambiguous (%s or %s or ...?).
\n
"
"Use nettle-hash --list to list all available algorithms.
\n
"
,
name
,
alg
->
name
,
found
->
name
);
found
=
alg
;
}
}
if
(
!
found
)
die
(
"Hash algorithm `%s' is not supported.
\n
"
"Use nettle-hash --list to list all available algorithms.
\n
"
,
name
);
return
found
;
if
(
!
strcmp
(
name
,
alg
->
name
))
return
alg
;
return
NULL
;
}
/* Also in examples/io.c */
...
...
@@ -143,6 +126,9 @@ digest_file(const struct nettle_hash *alg,
return
1
;
}
/* FIXME: Be more compatible with md5sum and sha1sum. Options -c
(check), -b (binary), -t (text), and output format with hex hash
sum, optional star (meaning binary mode), and file name. */
int
main
(
int
argc
,
char
**
argv
)
{
...
...
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