1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

sys/shell: add sha1sum command

This commit is contained in:
Benjamin Valentin 2022-04-30 18:11:02 +02:00
parent 845450c663
commit a250c2b5ad
3 changed files with 35 additions and 0 deletions

View File

@ -197,6 +197,7 @@ PSEUDOMODULES += semtech_loramac_rx
PSEUDOMODULES += senml_cbor
PSEUDOMODULES += senml_phydat
PSEUDOMODULES += senml_saul
PSEUDOMODULES += sha1sum
PSEUDOMODULES += shell_hooks
PSEUDOMODULES += slipdev_stdio
PSEUDOMODULES += slipdev_l2addr

View File

@ -672,4 +672,31 @@ int _vfs_md5sum_cmd(int argc, char **argv)
return 0;
}
#endif
#if MODULE_SHA1SUM
#include "hashes/sha1.h"
int _vfs_sha1sum_cmd(int argc, char **argv)
{
int res;
uint8_t digest[SHA1_DIGEST_LENGTH];
if (argc < 2) {
printf("usage: %s [file] …\n", argv[0]);
return -1;
}
for (int i = 1; i < argc; ++i) {
const char *file = argv[i];
res = vfs_file_sha1(file, digest,
_shell_vfs_data_buffer, sizeof(_shell_vfs_data_buffer));
if (res < 0) {
printf("%s: error %d\n", file, res);
} else {
_print_digest(digest, sizeof(digest), file);
}
}
return 0;
}
#endif
#endif

View File

@ -219,6 +219,10 @@ extern int _gnrc_udp_cmd(int argc, char **argv);
extern int _vfs_md5sum_cmd(int argc, char **argv);
#endif
#ifdef MODULE_SHA1SUM
extern int _vfs_sha1sum_cmd(int argc, char **argv);
#endif
const shell_command_t _shell_command_list[] = {
{"reboot", "Reboot the node", _reboot_handler},
{"version", "Prints current RIOT_VERSION", _version_handler},
@ -275,6 +279,9 @@ const shell_command_t _shell_command_list[] = {
#ifdef MODULE_MD5SUM
{"md5sum", "Compute and check MD5 message digest", _vfs_md5sum_cmd},
#endif
#ifdef MODULE_SHA1SUM
{"sha1sum", "Compute and check SHA1 message digest", _vfs_sha1sum_cmd},
#endif
#ifdef MODULE_GNRC_IPV6_NIB
{"nib", "Configure neighbor information base", _gnrc_ipv6_nib},
#endif