X-Git-Url: https://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost12sum.c;h=7c02c8e8918cfff81ab7c0b059a57b00c3a94820;hb=399eccc97e64df2cb5d8ef8101b04d888d8f4952;hp=f59bc05e4c2f1e43f080e34f7f2b10f28a7662cb;hpb=05690cd479ec4ed9646afbc764f0dcb264b861e8;p=openssl-gost%2Fengine.git diff --git a/gost12sum.c b/gost12sum.c index f59bc05..7c02c8e 100644 --- a/gost12sum.c +++ b/gost12sum.c @@ -34,17 +34,18 @@ int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, int mode); int hash_stream(gost_hash_ctx * ctx, int fd, char *sum); int get_line(FILE *f, char *hash, char *filename, int verbose); -void help() +void help(const char *progname) { fprintf(stderr, "Calculates GOST R 34.11-2012 hash function\n\n"); - fprintf(stderr, "gostsum12 [-bvl] [-c [file]]| [files]|-x\n" + fprintf(stderr, "%s [-bvl] [-c [file]]| [files]|-x\n" "\t-c check message digests (default is generate)\n" "\t-v verbose, print file names when checking\n" "\t-b read files in binary mode\n" "\t-l use 512 bit hash (default 256 bit)\n" "\t-x read filenames from stdin rather than from arguments \n" "The input for -c should be the list of message digests and file names\n" - "that is printed on stdout by this program when it generates digests.\n"); + "that is printed on stdout by this program when it generates" + "digests.\n", progname); exit(3); } @@ -107,7 +108,7 @@ int main(int argc, char **argv) break; default: fprintf(stderr, "invalid option %c", optopt); - help(); + help(argv[0]); } } if (check_file) { @@ -214,18 +215,18 @@ int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, int mode) int hash_stream(gost_hash_ctx * ctx, int fd, char *sum) { unsigned char buffer[BUF_SIZE]; - unsigned char reverted_buffer[BUF_SIZE]; ssize_t bytes; + size_t i; start_hash12(ctx); while ((bytes = read(fd, buffer, BUF_SIZE)) > 0) { - hash12_block(ctx, reverted_buffer, bytes); + hash12_block(ctx, buffer, bytes); } if (bytes < 0) { return 0; } finish_hash12(ctx, buffer); - for (size_t i = 0; i < (hashsize / 8); i++) { + for (i = 0; i < (hashsize / 8); i++) { sprintf(sum + 2 * i, "%02x", buffer[i]); } return 1;