rijndael.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* $OpenBSD: rijndael.h,v 1.14 2014/04/29 15:42:07 markus Exp $ */
  2. /**
  3. * rijndael-alg-fst.h
  4. *
  5. * @version 3.0 (December 2000)
  6. *
  7. * Optimised ANSI C code for the Rijndael cipher (now AES)
  8. *
  9. * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
  10. * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
  11. * @author Paulo Barreto <paulo.barreto@terra.com.br>
  12. *
  13. * This code is hereby placed in the public domain.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
  16. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
  19. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  22. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  24. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef _PRIVATE_RIJNDAEL_H
  28. #define _PRIVATE_RIJNDAEL_H
  29. #define AES_MAXKEYBITS (256)
  30. #define AES_MAXKEYBYTES (AES_MAXKEYBITS/8)
  31. /* for 256-bit keys, fewer for less */
  32. #define AES_MAXROUNDS 14
  33. typedef unsigned char u8;
  34. typedef unsigned short u16;
  35. typedef unsigned int u32;
  36. int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int);
  37. void rijndaelEncrypt(const unsigned int [], int, const unsigned char [],
  38. unsigned char []);
  39. /* The structure for key information */
  40. typedef struct {
  41. int decrypt;
  42. int Nr; /* key-length-dependent number of rounds */
  43. u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */
  44. u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */
  45. } rijndael_ctx;
  46. void rijndael_set_key(rijndael_ctx *, u_char *, int, int);
  47. void rijndael_decrypt(rijndael_ctx *, u_char *, u_char *);
  48. void rijndael_encrypt(rijndael_ctx *, u_char *, u_char *);
  49. #endif /* _PRIVATE_RIJNDAEL_H */