Suggestions for cryptosystem designers |
char
', does not assume that
signed types are twos-complement, and does not use compiler-specific
directives, or any other non-portable tricks. Test it with several
compilers on different platforms.
Ideally use <inttypes.h>
for integer types, and
provide a minimal version of this (which can just be a few lines in
most cases) for compilers that don't have it. "Byte-order independent"
means using code that accesses individual bytes/octets, not
BIG_ENDIAN
and LITTLE_ENDIAN
conditional compilation and pointer casts. Use macros only where it
clarifies rather than obfuscates the code.
uint8_t
from <inttypes.h>
), to correspond with the mathematical
definition in terms of octets. Put test code that checks an implementation
against test vectors in a separate source file, that can be compiled with
either the reference or the optimised implementation.
byte
type and octet values). Look at other optimised Java crypto code to see
how to fake unsigned types efficiently, and various other tricks. Put test
code in a separate class from the algorithm.
Author: David Hopwood <david.hopwood@zetnet.co.uk> Current maintainer: David Hopwood <david.hopwood@zetnet.co.uk> Copyright © 1995-2001 The Cryptix Foundation Limited and David Hopwood. All rights reserved. Cryptix is a trademark of The Cryptix Foundation Limited. |