From: Fabio Scotoni <34964387+fscoto@users.noreply.github.com> Date: Sat, 11 Jan 2020 06:30:43 +0000 (+0100) Subject: doc: custom hash: clean up C-only-isms X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=87186464692bb43e2e72ccf9f3a238a68ef6fc53;p=Monocypher.git doc: custom hash: clean up C-only-isms Related to e1520e87d. --- diff --git a/doc/man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher b/doc/man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher index e818303..5302f9d 100644 --- a/doc/man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher +++ b/doc/man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher @@ -8,7 +8,7 @@ .\" .\" ---------------------------------------------------------------------------- .\" -.\" Copyright (c) 2019 Fabio Scotoni +.\" Copyright (c) 2019-2020 Fabio Scotoni .\" All rights reserved. .\" .\" @@ -38,7 +38,7 @@ .\" .\" ---------------------------------------------------------------------------- .\" -.\" Written in 2019 by Fabio Scotoni +.\" Written in 2019-2020 by Fabio Scotoni .\" .\" To the extent possible under law, the author(s) have dedicated all copyright .\" and related neighboring rights to this software to the public domain @@ -225,21 +225,21 @@ my_hash(uint8_t hash[64], const uint8_t *msg, size_t len) static void my_init(void *ctx) { - struct outer_ctx *octx = ctx; + struct outer_ctx *octx = (struct outer_ctx *)ctx; SHA512Init(&octx->hash_ctx); } static void my_update(void *ctx, const uint8_t *msg, size_t len) { - struct outer_ctx *octx = ctx; + struct outer_ctx *octx = (struct outer_ctx *)ctx; SHA512Update(&octx->hash_ctx, msg, len); } static void my_final(void *ctx, uint8_t *hash) { - struct outer_ctx *octx = ctx; + struct outer_ctx *octx = (struct outer_ctx *)ctx; SHA512Final(hash, &octx->hash_ctx); } @@ -263,13 +263,14 @@ main(void) crypto_ed25519_sign(theirs, sk, NULL, msg, sizeof(msg)); struct outer_ctx ctx; - crypto_sign_init_first_pass_custom_hash((void*)&ctx, + crypto_sign_ctx_abstract *actx = (crypto_sign_ctx_abstract*)&ctx; + crypto_sign_init_first_pass_custom_hash(actx, sk, NULL, &my_vtable); crypto_wipe(sk, sizeof(sk)); - crypto_sign_update( (void*)&ctx, msg, sizeof(msg)); - crypto_sign_init_second_pass((void*)&ctx); - crypto_sign_update( (void*)&ctx, msg, sizeof(msg)); - crypto_sign_final( (void*)&ctx, mine); + crypto_sign_update( actx, msg, sizeof(msg)); + crypto_sign_init_second_pass(actx); + crypto_sign_update( actx, msg, sizeof(msg)); + crypto_sign_final( actx, mine); if (crypto_verify64(theirs, mine) != 0) { fprintf(stderr, "theirs != mine\en");