]> git.codecow.com Git - Monocypher.git/commitdiff
doc: custom hash: clean up C-only-isms
authorFabio Scotoni <34964387+fscoto@users.noreply.github.com>
Sat, 11 Jan 2020 06:30:43 +0000 (07:30 +0100)
committerFabio Scotoni <34964387+fscoto@users.noreply.github.com>
Sat, 11 Jan 2020 06:30:43 +0000 (07:30 +0100)
Related to e1520e87d.

doc/man/man3/crypto_sign_init_first_pass_custom_hash.3monocypher

index e818303f22ca5d4e3314de9fcbc2c9296d1f705d..5302f9da47f9dd685977bfd4aad5888e60acca24 100644 (file)
@@ -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");