On Fri, 2014-11-28 at 19:20 +0100, Niels Möller wrote:
> Nikos Mavrogiannopoulos <[email protected]> writes:
> 
> > Do you mean something like:
> > struct gcm_cast_st { struct gcm_key key; struct gcm_ctx gcm; char xx[1]; };
> > #define GCM_CTX_GET_KEY(ptr) (&((struct gcm_cast_st*)ptr)->key)
> > #define GCM_CTX_GET_CTX(ptr) (&((struct gcm_cast_st*)ptr)->gcm)
> > #define GCM_CTX_GET_CIPHER(ptr) ((void*)&((struct gcm_cast_st*)ptr)->xx)
> >
> > It looks indeed simpler. Not sure how valid is the GCM_CTX_GET_CIPHER
> > cast though. It would be nice if nettle's gcm.h provided such macros.
> 
> Only potential problem I see is alignment. 

Indeed, and that's why I'd prefer for the library to provide such
macros. Maybe changing the GCM structure to something like 
{ struct gcm_key key; struct gcm_ctx gcm; void *c; type cipher; }

Where c will be set by GCM_SET_KEY to point to cipher?

> You could make it an unsigned
> long array rather than a char array. And I'd drop the GET_KEY and
> GET_CTX macros; they're perfectly normal struct accesses.

They are needed as I cast from void*.

regards,
Nikos


_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to