ubi.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* ubi.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /*
  17. * \author Daniel Otte
  18. * \email daniel.otte@rub.de
  19. * \date 2009-03-12
  20. * \license GPLv3 or later
  21. *
  22. */
  23. #ifndef UBI_H_
  24. #define UBI_H_
  25. #include <stdint.h>
  26. #define UBI_TYPE_KEY 0
  27. #define UBI_TYPE_CFG 4
  28. #define UBI_TYPE_PRS 8
  29. #define UBI_TYPE_PK 12
  30. #define UBI_TYPE_KDF 16
  31. #define UBI_TYPE_NON 20
  32. #define UBI_TYPE_MSG 48
  33. #define UBI_TYPE_OUT 63
  34. #define UBI256_BLOCKSIZE 256
  35. #define UBI256_BLOCKSIZE_B ((UBI256_BLOCKSIZE+7)/8)
  36. #define UBI512_BLOCKSIZE 512
  37. #define UBI512_BLOCKSIZE_B ((UBI512_BLOCKSIZE+7)/8)
  38. #define UBI1024_BLOCKSIZE 1024
  39. #define UBI1024_BLOCKSIZE_B ((UBI1024_BLOCKSIZE+7)/8)
  40. typedef struct{
  41. union {
  42. uint8_t v8[16];
  43. uint16_t v16[8];
  44. uint32_t v32[4];
  45. uint64_t v64[2];
  46. } tweak;
  47. uint8_t g[32];
  48. }ubi256_ctx_t;
  49. typedef struct{
  50. union {
  51. uint8_t v8[16];
  52. uint16_t v16[8];
  53. uint32_t v32[4];
  54. uint64_t v64[2];
  55. } tweak;
  56. uint8_t g[64];
  57. }ubi512_ctx_t;
  58. typedef struct{
  59. union {
  60. uint8_t v8[16];
  61. uint16_t v16[8];
  62. uint32_t v32[4];
  63. uint64_t v64[2];
  64. } tweak;
  65. uint8_t g[128];
  66. }ubi1024_ctx_t;
  67. void ubi256_init(ubi256_ctx_t* ctx, const void* g, uint8_t type);
  68. void ubi256_nextBlock(ubi256_ctx_t* ctx, const void* block);
  69. void ubi256_lastBlock(ubi256_ctx_t* ctx, const void* block, uint16_t length_b);
  70. void ubi256_ctx2hash(void* dest, const ubi256_ctx_t* ctx);
  71. void ubi512_init(ubi512_ctx_t* ctx, const void* g, uint8_t type);
  72. void ubi512_nextBlock(ubi512_ctx_t* ctx, const void* block);
  73. void ubi512_lastBlock(ubi512_ctx_t* ctx, const void* block, uint16_t length_b);
  74. void ubi512_ctx2hash(void* dest, const ubi512_ctx_t* ctx);
  75. void ubi1024_init(ubi1024_ctx_t* ctx, const void* g, uint8_t type);
  76. void ubi1024_nextBlock(ubi1024_ctx_t* ctx, const void* block);
  77. void ubi1024_lastBlock(ubi1024_ctx_t* ctx, const void* block, uint16_t length_b);
  78. void ubi1024_ctx2hash(void* dest, const ubi1024_ctx_t* ctx);
  79. typedef struct{
  80. char schema[4];
  81. uint16_t version;
  82. uint16_t reserved1;
  83. uint64_t out_length;
  84. uint8_t tree_leaf_size;
  85. uint8_t tree_fan_out;
  86. uint8_t tree_max_height;
  87. uint8_t reserved2[13];
  88. }skein_config_t;
  89. #endif /* UBI_H_ */