[Swan-dev] Use of "struct chunk", "chunk_t", or "chunk_t *" or ...?
Andrew Cagney
andrew.cagney at gmail.com
Fri Dec 19 19:10:23 EET 2014
Hi,
I'm looking to change the "dat/datasize" and "Iv" parameters in:
void (*do_crypt)(u_int8_t *dat,
size_t datasize,
PK11SymKey *key,
u_int8_t *iv,
bool enc);
to chunks. While the first is somewhat cosmetic, the second ("iv") is
motivated by a bug - for aes_ctr the caller/callee didn't agree on the
length of the parameter named "iv" (ctr calls it counter-block).
To that end I've a few questions:
- is chunk_t or "struct chunk" prefered?
I'm guessing chunk_t but that seems to contradict Chapter 5: Typedefs in
https://www.kernel.org/doc/Documentation/CodingStyle :-)
- for a parameter, is pass by value (struct chunk) or reference
prefered (struct chunk *)? My hunch, from looking at lswalloc.h, is
that the preference is for the former as in:
void (*do_crypt)(struct chunk *data,
PK11SymKey *key,
struct chunk iv,
bool enc);
or:
void (*do_crypt)(chunk_t dat,
size_t datasize,
PK11SymKey *key,
chunk_t iv,
bool enc);
Andrew
More information about the Swan-dev
mailing list