Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
9911b3a5
Commit
9911b3a5
authored
Jan 12, 2017
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use nettle_lookup_hash.
parent
e9f3d8a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
27 deletions
+15
-27
ChangeLog
ChangeLog
+5
-0
testsuite/meta-hash-test.c
testsuite/meta-hash-test.c
+9
-13
tools/nettle-hash.c
tools/nettle-hash.c
+1
-14
No files found.
ChangeLog
View file @
9911b3a5
2017-01-12 Niels Möller <nisse@lysator.liu.se>
* tools/nettle-hash.c (find_algorithm): Deleted function.
(main): Replaced by call to nettle_lookup_hash.
* testsuite/meta-hash-test.c (test_main): Use nettle_lookup_hash.
* nettle-meta.h (nettle_hashes): New macro, expanding to a call to
nettle_get_hashes. Direct access to the array causes the array
size to leak into the ABI, since a plain un-relocatable executable
...
...
testsuite/meta-hash-test.c
View file @
9911b3a5
...
...
@@ -21,20 +21,16 @@ const char* hashes[] = {
void
test_main
(
void
)
{
int
i
,
j
;
int
i
;
int
count
=
sizeof
(
hashes
)
/
sizeof
(
*
hashes
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
j
=
0
;
NULL
!=
nettle_hashes
[
j
];
j
++
)
{
if
(
0
==
strcmp
(
hashes
[
i
],
nettle_hashes
[
j
]
->
name
))
break
;
}
ASSERT
(
NULL
!=
nettle_hashes
[
j
]);
/* make sure we found a matching hash */
/* make sure we found a matching hash */
ASSERT
(
nettle_lookup_hash
(
hashes
[
i
])
!=
NULL
);
}
j
=
0
;
while
(
NULL
!=
nettle_hashes
[
j
])
j
++
;
ASSERT
(
j
==
count
);
/* we are not missing testing any hashes */
for
(
j
=
0
;
NULL
!=
nettle_hashes
[
j
];
j
++
)
ASSERT
(
nettle_hashes
[
j
]
->
digest_size
<=
NETTLE_MAX_HASH_DIGEST_SIZE
);
while
(
NULL
!=
nettle_hashes
[
i
])
i
++
;
ASSERT
(
i
==
count
);
/* we are not missing testing any hashes */
for
(
i
=
0
;
NULL
!=
nettle_hashes
[
i
];
i
++
)
ASSERT
(
nettle_hashes
[
i
]
->
digest_size
<=
NETTLE_MAX_HASH_DIGEST_SIZE
);
}
tools/nettle-hash.c
View file @
9911b3a5
...
...
@@ -60,19 +60,6 @@ list_algorithms (void)
alg
->
name
,
alg
->
digest_size
,
alg
->
block_size
);
};
static
const
struct
nettle_hash
*
find_algorithm
(
const
char
*
name
)
{
const
struct
nettle_hash
*
alg
;
unsigned
i
;
for
(
i
=
0
;
(
alg
=
nettle_hashes
[
i
]);
i
++
)
if
(
!
strcmp
(
name
,
alg
->
name
))
return
alg
;
return
NULL
;
}
/* Also in examples/io.c */
static
int
hash_file
(
const
struct
nettle_hash
*
hash
,
void
*
ctx
,
FILE
*
f
)
...
...
@@ -211,7 +198,7 @@ main (int argc, char **argv)
die
(
"Algorithm argument (-a option) is mandatory.
\n
"
"See nettle-hash --help for further information.
\n
"
);
alg
=
find_algorithm
(
alg_name
);
alg
=
nettle_lookup_hash
(
alg_name
);
if
(
!
alg
)
die
(
"Hash algorithm `%s' not supported or .
\n
"
"Use nettle-hash --list to list available algorithms.
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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