Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Hoffmann
nettle
Commits
3da822d0
Commit
3da822d0
authored
14 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
(find_algorithm): Require exact match.
Rev: nettle/tools/nettle-hash.c:1.2
parent
a5cc380b
No related branches found
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/nettle-hash.c
+7
-21
7 additions, 21 deletions
tools/nettle-hash.c
with
7 additions
and
21 deletions
tools/nettle-hash.c
+
7
−
21
View file @
3da822d0
...
@@ -54,31 +54,14 @@ list_algorithms (void)
...
@@ -54,31 +54,14 @@ list_algorithms (void)
static
const
struct
nettle_hash
*
static
const
struct
nettle_hash
*
find_algorithm
(
const
char
*
name
)
find_algorithm
(
const
char
*
name
)
{
{
size_t
length
=
strlen
(
name
);
const
struct
nettle_hash
*
alg
;
const
struct
nettle_hash
*
alg
;
const
struct
nettle_hash
*
found
=
NULL
;
unsigned
i
;
unsigned
i
;
for
(
i
=
0
;
(
alg
=
nettle_hashes
[
i
]);
i
++
)
for
(
i
=
0
;
(
alg
=
nettle_hashes
[
i
]);
i
++
)
{
if
(
!
strcmp
(
name
,
alg
->
name
))
if
(
!
strncmp
(
name
,
alg
->
name
,
length
))
return
alg
;
{
/* Luckily, no valid algorithm name is a prefix of any
return
NULL
;
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
;
}
}
/* Also in examples/io.c */
/* Also in examples/io.c */
...
@@ -143,6 +126,9 @@ digest_file(const struct nettle_hash *alg,
...
@@ -143,6 +126,9 @@ digest_file(const struct nettle_hash *alg,
return
1
;
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
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment