symm/{chacha.c,salsa20.c}: Fix random generator allocation sizes.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 13 Apr 2017 13:47:11 +0000 (14:47 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 13 Apr 2017 17:27:44 +0000 (18:27 +0100)
This makes a real mess.

symm/chacha.c
symm/salsa20.c

index abcc1bd..4dcfcef 100644 (file)
@@ -706,7 +706,7 @@ static void grdestroy(grand *r)
                                                                        \
   grand *chacha##rr##_rand(const void *k, size_t ksz, const void *n)   \
   {                                                                    \
-    grctx *g = S_CREATE(g);                                            \
+    grctx *g = S_CREATE(grctx);                                                \
     g->r.r.ops = &grops_rand_##rr;                                     \
     g->r.ops = &grops_##rr;                                            \
     chacha_init(&g->ctx, k, ksz, n);                                   \
@@ -748,7 +748,7 @@ CHACHA_VARS(DEFGRAND)
                                                                        \
   grand *xchacha##rr##_rand(const void *k, size_t ksz, const void *n)  \
   {                                                                    \
-    grxctx_##rr *g = S_CREATE(g);                                      \
+    grxctx_##rr *g = S_CREATE(grxctx_##rr);                            \
     g->r.r.ops = &grxops_rand_##rr;                                    \
     g->r.ops = &grxops_##rr;                                           \
     XCHACHA_INIT(rr, &g->ctx, k, ksz, n);                              \
index 29a43f0..92631b1 100644 (file)
@@ -707,7 +707,7 @@ static void grdestroy(grand *r)
   grand *SALSA20_DECOR(salsa20, rr, _rand)                             \
     (const void *k, size_t ksz, const void *n)                         \
   {                                                                    \
-    grctx *g = S_CREATE(g);                                            \
+    grctx *g = S_CREATE(grctx);                                                \
     g->r.r.ops = &grops_rand_##rr;                                     \
     g->r.ops = &grops_##rr;                                            \
     salsa20_init(&g->ctx, k, ksz, n);                                  \
@@ -750,7 +750,7 @@ SALSA20_VARS(DEFGRAND)
   grand *SALSA20_DECOR(xsalsa20, rr, _rand)                            \
     (const void *k, size_t ksz, const void *n)                         \
   {                                                                    \
-    grxctx_##rr *g = S_CREATE(g);                                      \
+    grxctx_##rr *g = S_CREATE(grxctx_##rr);                            \
     g->r.r.ops = &grxops_rand_##rr;                                    \
     g->r.ops = &grxops_##rr;                                           \
     XSALSA20_INIT(rr, &g->ctx, k, ksz, n);                             \