2
0

modes.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* ====================================================================
  2. * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
  3. *
  4. * Rights for redistribution and usage in source and binary
  5. * forms are granted according to the OpenSSL license.
  6. */
  7. #include <stddef.h>
  8. typedef void (*block128_f)(const unsigned char in[16],
  9. unsigned char out[16],
  10. const void *key);
  11. typedef void (*cbc128_f)(const unsigned char *in, unsigned char *out,
  12. size_t len, const void *key,
  13. unsigned char ivec[16], int enc);
  14. typedef void (*ctr128_f)(const unsigned char *in, unsigned char *out,
  15. size_t blocks, const void *key,
  16. const unsigned char ivec[16]);
  17. typedef void (*ccm128_f)(const unsigned char *in, unsigned char *out,
  18. size_t blocks, const void *key,
  19. const unsigned char ivec[16],unsigned char cmac[16]);
  20. void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
  21. size_t len, const void *key,
  22. unsigned char ivec[16], block128_f block);
  23. void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
  24. size_t len, const void *key,
  25. unsigned char ivec[16], block128_f block);
  26. void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
  27. size_t len, const void *key,
  28. unsigned char ivec[16], unsigned char ecount_buf[16],
  29. unsigned int *num, block128_f block);
  30. void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
  31. size_t len, const void *key,
  32. unsigned char ivec[16], unsigned char ecount_buf[16],
  33. unsigned int *num, ctr128_f ctr);
  34. void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
  35. size_t len, const void *key,
  36. unsigned char ivec[16], int *num,
  37. block128_f block);
  38. void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
  39. size_t len, const void *key,
  40. unsigned char ivec[16], int *num,
  41. int enc, block128_f block);
  42. void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
  43. size_t length, const void *key,
  44. unsigned char ivec[16], int *num,
  45. int enc, block128_f block);
  46. void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
  47. size_t bits, const void *key,
  48. unsigned char ivec[16], int *num,
  49. int enc, block128_f block);
  50. size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out,
  51. size_t len, const void *key,
  52. unsigned char ivec[16], block128_f block);
  53. size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
  54. size_t len, const void *key,
  55. unsigned char ivec[16], cbc128_f cbc);
  56. size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out,
  57. size_t len, const void *key,
  58. unsigned char ivec[16], block128_f block);
  59. size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
  60. size_t len, const void *key,
  61. unsigned char ivec[16], cbc128_f cbc);
  62. size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, unsigned char *out,
  63. size_t len, const void *key,
  64. unsigned char ivec[16], block128_f block);
  65. size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
  66. size_t len, const void *key,
  67. unsigned char ivec[16], cbc128_f cbc);
  68. size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *out,
  69. size_t len, const void *key,
  70. unsigned char ivec[16], block128_f block);
  71. size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
  72. size_t len, const void *key,
  73. unsigned char ivec[16], cbc128_f cbc);
  74. typedef struct gcm128_context GCM128_CONTEXT;
  75. GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
  76. void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block);
  77. void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
  78. size_t len);
  79. int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
  80. size_t len);
  81. int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
  82. const unsigned char *in, unsigned char *out,
  83. size_t len);
  84. int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
  85. const unsigned char *in, unsigned char *out,
  86. size_t len);
  87. int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
  88. const unsigned char *in, unsigned char *out,
  89. size_t len, ctr128_f stream);
  90. int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
  91. const unsigned char *in, unsigned char *out,
  92. size_t len, ctr128_f stream);
  93. int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const unsigned char *tag,
  94. size_t len);
  95. void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
  96. void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
  97. typedef struct ccm128_context CCM128_CONTEXT;
  98. void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
  99. unsigned int M, unsigned int L, void *key,block128_f block);
  100. int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx,
  101. const unsigned char *nonce, size_t nlen, size_t mlen);
  102. void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx,
  103. const unsigned char *aad, size_t alen);
  104. int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
  105. const unsigned char *inp, unsigned char *out, size_t len);
  106. int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
  107. const unsigned char *inp, unsigned char *out, size_t len);
  108. int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx,
  109. const unsigned char *inp, unsigned char *out, size_t len,
  110. ccm128_f stream);
  111. int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx,
  112. const unsigned char *inp, unsigned char *out, size_t len,
  113. ccm128_f stream);
  114. size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
  115. typedef struct xts128_context XTS128_CONTEXT;
  116. int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16],
  117. const unsigned char *inp, unsigned char *out, size_t len, int enc);