diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 8608ba3647..f4f7de1e13 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -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 diff --git a/sys/shell/commands/sc_vfs.c b/sys/shell/commands/sc_vfs.c index 8ac26a530b..9d70293416 100644 --- a/sys/shell/commands/sc_vfs.c +++ b/sys/shell/commands/sc_vfs.c @@ -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 diff --git a/sys/shell/commands/shell_commands.c b/sys/shell/commands/shell_commands.c index 7c1a1d2b90..9161391b75 100644 --- a/sys/shell/commands/shell_commands.c +++ b/sys/shell/commands/shell_commands.c @@ -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