umac.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* $OpenBSD: umac.h,v 1.4 2019/06/07 14:18:48 dtucker Exp $ */
  2. /* -----------------------------------------------------------------------
  3. *
  4. * umac.h -- C Implementation UMAC Message Authentication
  5. *
  6. * Version 0.93a of rfc4418.txt -- 2006 July 14
  7. *
  8. * For a full description of UMAC message authentication see the UMAC
  9. * world-wide-web page at http://www.cs.ucdavis.edu/~rogaway/umac
  10. * Please report bugs and suggestions to the UMAC webpage.
  11. *
  12. * Copyright (c) 1999-2004 Ted Krovetz
  13. *
  14. * Permission to use, copy, modify, and distribute this software and
  15. * its documentation for any purpose and with or without fee, is hereby
  16. * granted provided that the above copyright notice appears in all copies
  17. * and in supporting documentation, and that the name of the copyright
  18. * holder not be used in advertising or publicity pertaining to
  19. * distribution of the software without specific, written prior permission.
  20. *
  21. * Comments should be directed to Ted Krovetz (tdk@acm.org)
  22. *
  23. * ---------------------------------------------------------------------- */
  24. /* ////////////////////// IMPORTANT NOTES /////////////////////////////////
  25. *
  26. * 1) This version does not work properly on messages larger than 16MB
  27. *
  28. * 2) If you set the switch to use SSE2, then all data must be 16-byte
  29. * aligned
  30. *
  31. * 3) When calling the function umac(), it is assumed that msg is in
  32. * a writable buffer of length divisible by 32 bytes. The message itself
  33. * does not have to fill the entire buffer, but bytes beyond msg may be
  34. * zeroed.
  35. *
  36. * 4) Two free AES implementations are supported by this implementation of
  37. * UMAC. Paulo Barreto's version is in the public domain and can be found
  38. * at http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ (search for
  39. * "Barreto"). The only two files needed are rijndael-alg-fst.c and
  40. * rijndael-alg-fst.h.
  41. * Brian Gladman's version is distributed with GNU Public license
  42. * and can be found at http://fp.gladman.plus.com/AES/index.htm. It
  43. * includes a fast IA-32 assembly version.
  44. *
  45. /////////////////////////////////////////////////////////////////////// */
  46. #ifndef HEADER_UMAC_H
  47. #define HEADER_UMAC_H
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. struct umac_ctx *umac_new(const u_char key[]);
  52. /* Dynamically allocate a umac_ctx struct, initialize variables,
  53. * generate subkeys from key.
  54. */
  55. #if 0
  56. int umac_reset(struct umac_ctx *ctx);
  57. /* Reset a umac_ctx to begin authenicating a new message */
  58. #endif
  59. int umac_update(struct umac_ctx *ctx, const u_char *input, long len);
  60. /* Incorporate len bytes pointed to by input into context ctx */
  61. int umac_final(struct umac_ctx *ctx, u_char tag[], const u_char nonce[8]);
  62. /* Incorporate any pending data and the ctr value, and return tag.
  63. * This function returns error code if ctr < 0.
  64. */
  65. int umac_delete(struct umac_ctx *ctx);
  66. /* Deallocate the context structure */
  67. #if 0
  68. int umac(struct umac_ctx *ctx, u_char *input,
  69. long len, u_char tag[],
  70. u_char nonce[8]);
  71. /* All-in-one implementation of the functions Reset, Update and Final */
  72. #endif
  73. /* uhash.h */
  74. #if 0
  75. typedef struct uhash_ctx *uhash_ctx_t;
  76. /* The uhash_ctx structure is defined by the implementation of the */
  77. /* UHASH functions. */
  78. uhash_ctx_t uhash_alloc(u_char key[16]);
  79. /* Dynamically allocate a uhash_ctx struct and generate subkeys using */
  80. /* the kdf and kdf_key passed in. If kdf_key_len is 0 then RC6 is */
  81. /* used to generate key with a fixed key. If kdf_key_len > 0 but kdf */
  82. /* is NULL then the first 16 bytes pointed at by kdf_key is used as a */
  83. /* key for an RC6 based KDF. */
  84. int uhash_free(uhash_ctx_t ctx);
  85. int uhash_set_params(uhash_ctx_t ctx,
  86. void *params);
  87. int uhash_reset(uhash_ctx_t ctx);
  88. int uhash_update(uhash_ctx_t ctx,
  89. u_char *input,
  90. long len);
  91. int uhash_final(uhash_ctx_t ctx,
  92. u_char output[]);
  93. int uhash(uhash_ctx_t ctx,
  94. u_char *input,
  95. long len,
  96. u_char output[]);
  97. #endif
  98. /* matching umac-128 API, we reuse umac_ctx, since it's opaque */
  99. struct umac_ctx *umac128_new(const u_char key[]);
  100. int umac128_update(struct umac_ctx *ctx, const u_char *input, long len);
  101. int umac128_final(struct umac_ctx *ctx, u_char tag[], const u_char nonce[8]);
  102. int umac128_delete(struct umac_ctx *ctx);
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif /* HEADER_UMAC_H */