1
0

rijndael.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * contrib/pgcrypto/rijndael.h
  3. *
  4. * $OpenBSD: rijndael.h,v 1.3 2001/05/09 23:01:32 markus Exp $ */
  5. /* This is an independent implementation of the encryption algorithm: */
  6. /* */
  7. /* RIJNDAEL by Joan Daemen and Vincent Rijmen */
  8. /* */
  9. /* which is a candidate algorithm in the Advanced Encryption Standard */
  10. /* programme of the US National Institute of Standards and Technology. */
  11. /* */
  12. /* Copyright in this implementation is held by Dr B R Gladman but I */
  13. /* hereby give permission for its free direct or derivative use subject */
  14. /* to acknowledgment of its origin and compliance with any conditions */
  15. /* that the originators of the algorithm place on its exploitation. */
  16. /* */
  17. /* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */
  18. typedef struct rijndaelCtx rijndaelCtx;
  19. struct rijndaelCtx
  20. {
  21. uint32_t k_len;
  22. int decrypt;
  23. uint32_t e_key[64];
  24. uint32_t d_key[64];
  25. };
  26. /* Standard interface for AES cryptographic routines */
  27. /* These are all based on 32 bit unsigned values and will therefore */
  28. /* require endian conversions for big-endian architectures */
  29. rijndaelCtx *
  30. rijndael_set_key(rijndaelCtx *, const uint32_t *, const uint32_t, int);
  31. void rijndael_encrypt(rijndaelCtx *, const uint32_t *, uint32_t *);
  32. void rijndael_decrypt(rijndaelCtx *, const uint32_t *, uint32_t *);
  33. /* conventional interface */
  34. void aes_set_key(rijndaelCtx *ctx, const uint8_t *key, unsigned keybits, int enc);
  35. void aes_ecb_encrypt(rijndaelCtx *ctx, uint8_t *data, unsigned len);
  36. void aes_ecb_decrypt(rijndaelCtx *ctx, uint8_t *data, unsigned len);
  37. void aes_cbc_encrypt(rijndaelCtx *ctx, uint8_t *iva, uint8_t *data, unsigned len);
  38. void aes_cbc_decrypt(rijndaelCtx *ctx, uint8_t *iva, uint8_t *data, unsigned len);