Compare commits
5 commits
46ec3184cd
...
28271a1c63
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28271a1c63 | ||
|
|
afcd1d6d05 | ||
|
|
2721fdb48b | ||
|
|
68e443b62a | ||
|
|
66b0a2cb66 |
23 changed files with 312 additions and 136 deletions
|
|
@ -5,19 +5,17 @@
|
|||
#include <libft_ssl.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define SSL_MAX_STRINGS 64
|
||||
#define DIGEST_MAX_STRINGS 64
|
||||
|
||||
struct ssl_config
|
||||
struct digest_config
|
||||
{
|
||||
const struct digest_algo *algo;
|
||||
const char *cmd_name;
|
||||
uint8_t flags;
|
||||
const char *strings[SSL_MAX_STRINGS];
|
||||
const char *strings[DIGEST_MAX_STRINGS];
|
||||
int nb_strings;
|
||||
char **files;
|
||||
int nb_files;
|
||||
};
|
||||
|
||||
enum cli_code cli_parse_arguments(int argc, char **argv, struct ssl_config *config);
|
||||
int ssl_run(const struct ssl_config *config);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include <cli.h>
|
||||
|
||||
extern const struct option_descriptor g_options[];
|
||||
|
||||
int cli_handle_help(const char *arg, void *config);
|
||||
int cli_handle_version(const char *arg, void *config);
|
||||
int cli_handle_p(const char *arg, void *config);
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef FT_SSL_INTERACTIVE_H
|
||||
#define FT_SSL_INTERACTIVE_H
|
||||
|
||||
#include <cli.h>
|
||||
|
||||
enum cli_code run_interactive(void);
|
||||
|
||||
#endif
|
||||
26
includes/internal/cmd/command.h
Normal file
26
includes/internal/cmd/command.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef FT_SSL_CMD_COMMAND_H
|
||||
#define FT_SSL_CMD_COMMAND_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cli.h>
|
||||
|
||||
enum command_category {
|
||||
CMD_DIGEST,
|
||||
CMD_CIPHER
|
||||
};
|
||||
|
||||
struct command_descriptor {
|
||||
const char *name;
|
||||
enum command_category category;
|
||||
const struct option_descriptor *opts;
|
||||
size_t nb_opts;
|
||||
const void *impl;
|
||||
int (*run)(int argc, char **argv, const struct command_descriptor *self);
|
||||
};
|
||||
|
||||
const struct command_descriptor *find_command(const char *name);
|
||||
void print_commands(FILE *out);
|
||||
|
||||
#endif
|
||||
84
includes/internal/cmd/digest_cmd.h
Normal file
84
includes/internal/cmd/digest_cmd.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#ifndef FT_SSL_CMD_DIGEST_H
|
||||
#define FT_SSL_CMD_DIGEST_H
|
||||
|
||||
#include <getopt.h>
|
||||
#include <cli.h>
|
||||
|
||||
#include "internal/cli/cli_handlers.h"
|
||||
#include "internal/cmd/command.h"
|
||||
|
||||
#define DIGEST_OPTION_LIST \
|
||||
X( \
|
||||
'h', \
|
||||
"help", \
|
||||
no_argument, \
|
||||
cli_handle_help, \
|
||||
OPT_ARG_NONE, \
|
||||
"Display this help and exit", \
|
||||
0 \
|
||||
) \
|
||||
X( \
|
||||
'V', \
|
||||
"version", \
|
||||
no_argument, \
|
||||
cli_handle_version, \
|
||||
OPT_ARG_NONE, \
|
||||
"Display version information and exit", \
|
||||
0 \
|
||||
) \
|
||||
X( \
|
||||
'p', \
|
||||
"stdin", \
|
||||
no_argument, \
|
||||
cli_handle_p, \
|
||||
OPT_ARG_NONE, \
|
||||
"Echo stdin to stdout and append checksum to output", \
|
||||
0 \
|
||||
) \
|
||||
X( \
|
||||
'q', \
|
||||
"quiet", \
|
||||
no_argument, \
|
||||
cli_handle_q, \
|
||||
OPT_ARG_NONE, \
|
||||
"Quiet mode: only print the digest", \
|
||||
0 \
|
||||
) \
|
||||
X( \
|
||||
'r', \
|
||||
"reverse", \
|
||||
no_argument, \
|
||||
cli_handle_r, \
|
||||
OPT_ARG_NONE, \
|
||||
"Reverse the output format (digest then filename)", \
|
||||
0 \
|
||||
) \
|
||||
X( \
|
||||
's', \
|
||||
"string", \
|
||||
required_argument, \
|
||||
cli_handle_s, \
|
||||
OPT_ARG_STRING, \
|
||||
"Hash a string", \
|
||||
CLI_OPT_F_REPEATABLE \
|
||||
)
|
||||
|
||||
#undef X
|
||||
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) + 1
|
||||
enum { DIGEST_OPT_LEN = (0 DIGEST_OPTION_LIST) };
|
||||
|
||||
#undef X
|
||||
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) \
|
||||
+ (1 * (has_arg == no_argument) \
|
||||
+ (2 * (has_arg == required_argument) \
|
||||
+ (3 * (has_arg == optional_argument))))
|
||||
enum { DIGEST_OPTSTR_LEN = (2 DIGEST_OPTION_LIST) };
|
||||
/* +2 for ':' to disable getopt error messages and \0 */
|
||||
|
||||
#undef X
|
||||
|
||||
extern const struct option_descriptor g_digest_opts[];
|
||||
int digest_run(int argc, char **argv,
|
||||
const struct command_descriptor *self);
|
||||
|
||||
#endif
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
#define MAX_DIGEST_SIZE 64
|
||||
#define READ_BUFSIZE 4096
|
||||
|
||||
int run_string(const struct ssl_config *config, const char *s);
|
||||
int run_file(const struct ssl_config *config, const char *path);
|
||||
int run_stdin(const struct ssl_config *config);
|
||||
int digest_stream(const struct ssl_config *config, int fd,
|
||||
int run_string(const struct digest_config *config, const char *s);
|
||||
int run_file(const struct digest_config *config, const char *path);
|
||||
int run_stdin(const struct digest_config *config);
|
||||
int digest_stream(const struct digest_config *config, int fd,
|
||||
const char *label, int show_algo, int echo);
|
||||
void print_digest(const struct ssl_config *config, const uint8_t *digest,
|
||||
void print_digest(const struct digest_config *config, const uint8_t *digest,
|
||||
const char *label, int show_algo);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 27d2c8d21a122aa0c0cb623668657188f9d95444
|
||||
Subproject commit 7e3c4bd5068ae159d71b5dd8fed9e141dcef60f8
|
||||
|
|
@ -41,15 +41,14 @@ FORCE:
|
|||
|
||||
ft_ssl_SOURCES = \
|
||||
main.c \
|
||||
ssl_run.c \
|
||||
cmd/command_table.c \
|
||||
cmd/digest_run.c \
|
||||
ssl/run_stdin.c \
|
||||
ssl/run_string.c \
|
||||
ssl/run_file.c \
|
||||
ssl/digest.c \
|
||||
ssl/output.c \
|
||||
cli/parse.c \
|
||||
cli/version.c \
|
||||
cli/interactive.c \
|
||||
cli/handlers/option_map.c \
|
||||
cli/handlers/handle_help.c \
|
||||
cli/handlers/handle_version.c \
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
#include <cli.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "ft_ssl.h"
|
||||
#include "internal/cmd/digest_cmd.h"
|
||||
#include "version_gen.h"
|
||||
#include "internal/cli/option.h"
|
||||
#include "internal/cli/cli_handlers.h"
|
||||
|
||||
int
|
||||
cli_handle_help(__unused const char *arg, __unused void *config_void)
|
||||
cli_handle_help(__unused const char *arg, void *config_void)
|
||||
{
|
||||
print_usage(g_prog_name);
|
||||
printf("\n");
|
||||
cli_print_options(g_options, FT_SSL_OPT_LEN, cli_arg_type_to_str);
|
||||
struct digest_config *config = (struct digest_config *)config_void;
|
||||
|
||||
printf("Usage: %s %s [OPTIONS] [FILE...]\n\n", g_prog_name, config->cmd_name);
|
||||
cli_print_options(g_digest_opts, DIGEST_OPT_LEN, cli_arg_type_to_str);
|
||||
return CLI_EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
int
|
||||
cli_handle_p(__unused const char *arg, void *config_void)
|
||||
{
|
||||
struct ssl_config *config = (struct ssl_config *)config_void;
|
||||
struct digest_config *config = (struct digest_config *)config_void;
|
||||
|
||||
SET_FLAG(config->flags, FLAG_P);
|
||||
return CLI_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
int
|
||||
cli_handle_q(__unused const char *arg, void *config_void)
|
||||
{
|
||||
struct ssl_config *config = (struct ssl_config *)config_void;
|
||||
struct digest_config *config = (struct digest_config *)config_void;
|
||||
|
||||
SET_FLAG(config->flags, FLAG_Q);
|
||||
return CLI_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
int
|
||||
cli_handle_r(__unused const char *arg, void *config_void)
|
||||
{
|
||||
struct ssl_config *config = (struct ssl_config *)config_void;
|
||||
struct digest_config *config = (struct digest_config *)config_void;
|
||||
|
||||
SET_FLAG(config->flags, FLAG_R);
|
||||
return CLI_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
int
|
||||
cli_handle_s(const char *arg, void *config_void)
|
||||
{
|
||||
struct ssl_config *config = (struct ssl_config *)config_void;
|
||||
struct digest_config *config = (struct digest_config *)config_void;
|
||||
|
||||
if (config->nb_strings >= SSL_MAX_STRINGS)
|
||||
if (config->nb_strings >= DIGEST_MAX_STRINGS)
|
||||
return CLI_ERROR;
|
||||
config->strings[config->nb_strings++] = arg;
|
||||
return CLI_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
#include "internal/cli/cli_handlers.h"
|
||||
#include "internal/cli/option.h"
|
||||
#include "internal/cmd/digest_cmd.h"
|
||||
|
||||
#undef X
|
||||
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) \
|
||||
{ short_opt, long_opt, has_arg, handler, arg_type, desc, flags },
|
||||
|
||||
const struct option_descriptor g_options[] = {
|
||||
FT_SSL_OPTION_LIST
|
||||
const struct option_descriptor g_digest_opts[] = {
|
||||
DIGEST_OPTION_LIST
|
||||
{0, NULL, 0, NULL, OPT_ARG_NONE, NULL, 0}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <cli.h>
|
||||
#include <libft_ssl.h>
|
||||
|
||||
#include "ft_ssl.h"
|
||||
#include "internal/cli/interactive.h"
|
||||
|
||||
#define INTERACTIVE_BUFSIZ 4096
|
||||
|
||||
static const struct digest_algo * const s_algos[] = {
|
||||
#define DIGEST_ALGO(lower, ds, bs) &g_##lower,
|
||||
#include <digest_algos.h>
|
||||
#undef DIGEST_ALGO
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct digest_algo *find_algo(const char *name);
|
||||
static void print_available(void);
|
||||
|
||||
enum cli_code
|
||||
run_interactive(void)
|
||||
{
|
||||
char buf[INTERACTIVE_BUFSIZ];
|
||||
const struct digest_algo *algo;
|
||||
struct ssl_config config;
|
||||
|
||||
while (fgets(buf, (int)sizeof(buf), stdin))
|
||||
{
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
if (buf[0] == '\0')
|
||||
continue;
|
||||
algo = find_algo(buf);
|
||||
if (NULL == algo)
|
||||
{
|
||||
fprintf(stderr, "ft_ssl: unknown command -- '%s'\n", buf);
|
||||
print_available();
|
||||
continue;
|
||||
}
|
||||
memset(&config, 0, sizeof(config));
|
||||
config.algo = algo;
|
||||
ssl_run(&config);
|
||||
}
|
||||
return CLI_EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static const struct digest_algo *
|
||||
find_algo(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; s_algos[i]; ++i)
|
||||
{
|
||||
if (0 == strcmp(s_algos[i]->name, name))
|
||||
return s_algos[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
print_available(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
fprintf(stderr, "available commands:");
|
||||
for (i = 0; s_algos[i]; ++i)
|
||||
fprintf(stderr, " %s", s_algos[i]->name);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
54
src/cmd/command_table.c
Normal file
54
src/cmd/command_table.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libft_ssl.h>
|
||||
|
||||
#include "internal/cmd/command.h"
|
||||
#include "internal/cmd/digest_cmd.h"
|
||||
|
||||
/* Forward-declare all digest algo globals */
|
||||
#define DIGEST_ALGO(lower, ds, bs) extern const struct digest_algo g_##lower;
|
||||
#include <digest_algos.h>
|
||||
#undef DIGEST_ALGO
|
||||
|
||||
static const struct command_descriptor s_commands[] = {
|
||||
/* Digest commands */
|
||||
#define DIGEST_ALGO(lower, ds, bs) \
|
||||
{ #lower, CMD_DIGEST, g_digest_opts, DIGEST_OPT_LEN, &g_##lower, digest_run },
|
||||
#include <digest_algos.h>
|
||||
#undef DIGEST_ALGO
|
||||
/* Cipher commands (not yet implemented) */
|
||||
{ "base64", CMD_CIPHER, NULL, 0, NULL, NULL },
|
||||
{ "des", CMD_CIPHER, NULL, 0, NULL, NULL },
|
||||
{ "des-ecb", CMD_CIPHER, NULL, 0, NULL, NULL },
|
||||
{ "des-cbc", CMD_CIPHER, NULL, 0, NULL, NULL },
|
||||
/* Sentinel */
|
||||
{ NULL, 0, NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
const struct command_descriptor *
|
||||
find_command(const char *name)
|
||||
{
|
||||
const struct command_descriptor *cmd;
|
||||
|
||||
for (cmd = s_commands; NULL != cmd->name; cmd++)
|
||||
if (0 == strcmp(cmd->name, name))
|
||||
return cmd;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
print_commands(FILE *out)
|
||||
{
|
||||
const struct command_descriptor *cmd;
|
||||
|
||||
fprintf(out, "\nStandard commands:\n");
|
||||
fprintf(out, "\nMessage Digest commands:\n");
|
||||
for (cmd = s_commands; NULL != cmd->name; cmd++)
|
||||
if (CMD_DIGEST == cmd->category)
|
||||
fprintf(out, " %s\n", cmd->name);
|
||||
fprintf(out, "\nCipher commands:\n");
|
||||
for (cmd = s_commands; NULL != cmd->name; cmd++)
|
||||
if (CMD_CIPHER == cmd->category)
|
||||
fprintf(out, " %s\n", cmd->name);
|
||||
}
|
||||
75
src/cmd/digest_run.c
Normal file
75
src/cmd/digest_run.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cli.h>
|
||||
#include <libft_ssl.h>
|
||||
|
||||
#include "compiler.h"
|
||||
#include "ft_ssl.h"
|
||||
#include "ft_ssl_flags.h"
|
||||
#include "internal/cmd/command.h"
|
||||
#include "internal/cmd/digest_cmd.h"
|
||||
#include "internal/ssl/ssl.h"
|
||||
#include "version_gen.h"
|
||||
|
||||
/* Forward declarations */
|
||||
static int check_algo(const struct digest_config *config);
|
||||
static void update_ret(int *ret, int result);
|
||||
/* ------------------- */
|
||||
|
||||
int
|
||||
digest_run(int argc, char **argv, const struct command_descriptor *self)
|
||||
{
|
||||
struct digest_config config = {0};
|
||||
char opt_str[DIGEST_OPTSTR_LEN + 1];
|
||||
struct option long_opts[DIGEST_OPT_LEN + 1];
|
||||
enum cli_code ret;
|
||||
int ret_val;
|
||||
int has_input;
|
||||
int i;
|
||||
|
||||
config.algo = (const struct digest_algo *)self->impl;
|
||||
config.cmd_name = self->name;
|
||||
|
||||
ret = cli_parse(argc, argv, &config, self->opts, self->nb_opts,
|
||||
opt_str, long_opts);
|
||||
if (CLI_SUCCESS != ret)
|
||||
return (int)ret;
|
||||
|
||||
config.files = argv + optind;
|
||||
config.nb_files = argc - optind;
|
||||
|
||||
if (CLI_SUCCESS != check_algo(&config))
|
||||
return (int)CLI_ERROR;
|
||||
|
||||
ret_val = (int)CLI_SUCCESS;
|
||||
has_input = (0 < config.nb_strings || 0 < config.nb_files);
|
||||
if (HAS_FLAG(config.flags, FLAG_P) || !has_input)
|
||||
update_ret(&ret_val, run_stdin(&config));
|
||||
for (i = 0; i < config.nb_strings; i++)
|
||||
update_ret(&ret_val, run_string(&config, config.strings[i]));
|
||||
for (i = 0; i < config.nb_files; i++)
|
||||
update_ret(&ret_val, run_file(&config, config.files[i]));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
static int
|
||||
check_algo(const struct digest_config *config)
|
||||
{
|
||||
if (NULL == config->algo->init
|
||||
|| NULL == config->algo->update
|
||||
|| NULL == config->algo->final)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: not yet implemented\n",
|
||||
g_prog_name, config->algo->name);
|
||||
return (int)CLI_ERROR;
|
||||
}
|
||||
return (int)CLI_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
update_ret(int *ret, int result)
|
||||
{
|
||||
if ((int)CLI_ERROR == result)
|
||||
*ret = (int)CLI_ERROR;
|
||||
}
|
||||
41
src/main.c
41
src/main.c
|
|
@ -1,24 +1,45 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cli.h>
|
||||
|
||||
#include "ft_ssl.h"
|
||||
#include "internal/cmd/command.h"
|
||||
#include "version_gen.h"
|
||||
|
||||
char *g_prog_name = NULL;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct ssl_config config = {0};
|
||||
int ret = CLI_ERROR;
|
||||
const struct command_descriptor *cmd;
|
||||
int ret;
|
||||
|
||||
g_prog_name = argv[0];
|
||||
cli_set_prog_name(g_prog_name);
|
||||
ret = cli_parse_arguments(argc, argv, &config);
|
||||
if (CLI_SUCCESS != ret)
|
||||
goto cleanup;
|
||||
ret = ssl_run(&config);
|
||||
|
||||
cleanup:
|
||||
return (CLI_ERROR == ret) ? 2 : EXIT_SUCCESS;
|
||||
if (argc < 2)
|
||||
{
|
||||
print_commands(stderr);
|
||||
return 2;
|
||||
}
|
||||
if (0 == strcmp(argv[1], "-h") || 0 == strcmp(argv[1], "--help"))
|
||||
{
|
||||
print_commands(stdout);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
cmd = find_command(argv[1]);
|
||||
if (NULL == cmd)
|
||||
{
|
||||
fprintf(stderr, "%s: Error: %s is an invalid command.\n",
|
||||
argv[0], argv[1]);
|
||||
print_commands(stderr);
|
||||
return 2;
|
||||
}
|
||||
if (NULL == cmd->run)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: not yet implemented\n", argv[0], argv[1]);
|
||||
return 2;
|
||||
}
|
||||
ret = cmd->run(argc - 1, argv + 1, cmd);
|
||||
return ((int)CLI_ERROR == ret) ? 2 : EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
#include "internal/ssl/ssl.h"
|
||||
|
||||
/* Forward declarations */
|
||||
static void process_chunk(const struct ssl_config *config, union digest_ctx *ctx,
|
||||
static void process_chunk(const struct digest_config *config, union digest_ctx *ctx,
|
||||
const uint8_t *buf, size_t n, int echo);
|
||||
/* ------------------- */
|
||||
|
||||
int
|
||||
digest_stream(const struct ssl_config *config, int fd,
|
||||
digest_stream(const struct digest_config *config, int fd,
|
||||
const char *label, int show_algo, int echo)
|
||||
{
|
||||
union digest_ctx ctx;
|
||||
|
|
@ -31,7 +31,7 @@ digest_stream(const struct ssl_config *config, int fd,
|
|||
}
|
||||
|
||||
static void
|
||||
process_chunk(const struct ssl_config *config, union digest_ctx *ctx,
|
||||
process_chunk(const struct digest_config *config, union digest_ctx *ctx,
|
||||
const uint8_t *buf, size_t n, int echo)
|
||||
{
|
||||
if (echo)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ typedef void (*t_formatter)(const char *hex, const char *name_upper,
|
|||
const char *label);
|
||||
|
||||
/* Forward declarations */
|
||||
static enum fmt_mode resolve_fmt(const struct ssl_config *config,
|
||||
static enum fmt_mode resolve_fmt(const struct digest_config *config,
|
||||
int show_algo);
|
||||
static void build_hex(char *buf, const uint8_t *digest, size_t size);
|
||||
static void build_upper(char *buf, const char *src, size_t size);
|
||||
|
|
@ -42,7 +42,7 @@ static const t_formatter s_formatters[] = {
|
|||
};
|
||||
|
||||
void
|
||||
print_digest(const struct ssl_config *config, const uint8_t *digest,
|
||||
print_digest(const struct digest_config *config, const uint8_t *digest,
|
||||
const char *label, int show_algo)
|
||||
{
|
||||
char hex[MAX_DIGEST_SIZE * 2 + 1];
|
||||
|
|
@ -54,7 +54,7 @@ print_digest(const struct ssl_config *config, const uint8_t *digest,
|
|||
}
|
||||
|
||||
static enum fmt_mode
|
||||
resolve_fmt(const struct ssl_config *config, int show_algo)
|
||||
resolve_fmt(const struct digest_config *config, int show_algo)
|
||||
{
|
||||
if (HAS_FLAG(config->flags, FLAG_Q))
|
||||
return FMT_QUIET;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "version_gen.h"
|
||||
|
||||
int
|
||||
run_file(const struct ssl_config *config, const char *path)
|
||||
run_file(const struct digest_config *config, const char *path)
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
#include "internal/ssl/ssl.h"
|
||||
|
||||
/* Forward declarations */
|
||||
static int run_stdin_p(const struct ssl_config *config);
|
||||
static ssize_t read_and_hash(const struct ssl_config *config, union digest_ctx
|
||||
static int run_stdin_p(const struct digest_config *config);
|
||||
static ssize_t read_and_hash(const struct digest_config *config, union digest_ctx
|
||||
*ctx, char *label, size_t cap);
|
||||
/* ------------------- */
|
||||
|
||||
int
|
||||
run_stdin(const struct ssl_config *config)
|
||||
run_stdin(const struct digest_config *config)
|
||||
{
|
||||
if (HAS_FLAG(config->flags, FLAG_P) && !HAS_FLAG(config->flags, FLAG_Q))
|
||||
return run_stdin_p(config);
|
||||
|
|
@ -26,7 +26,7 @@ run_stdin(const struct ssl_config *config)
|
|||
}
|
||||
|
||||
static ssize_t
|
||||
read_and_hash(const struct ssl_config *config, union digest_ctx *ctx,
|
||||
read_and_hash(const struct digest_config *config, union digest_ctx *ctx,
|
||||
char *label, size_t cap)
|
||||
{
|
||||
uint8_t buf[READ_BUFSIZE];
|
||||
|
|
@ -47,7 +47,7 @@ read_and_hash(const struct ssl_config *config, union digest_ctx *ctx,
|
|||
}
|
||||
|
||||
static int
|
||||
run_stdin_p(const struct ssl_config *config)
|
||||
run_stdin_p(const struct digest_config *config)
|
||||
{
|
||||
union digest_ctx ctx;
|
||||
uint8_t digest[MAX_DIGEST_SIZE];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "internal/ssl/ssl.h"
|
||||
|
||||
int
|
||||
run_string(const struct ssl_config *config, const char *s)
|
||||
run_string(const struct digest_config *config, const char *s)
|
||||
{
|
||||
union digest_ctx ctx;
|
||||
uint8_t digest[MAX_DIGEST_SIZE];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue