apr_md4.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* This is derived from material copyright RSA Data Security, Inc.
  17. * Their notice is reproduced below in its entirety.
  18. *
  19. * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  20. * rights reserved.
  21. *
  22. * License to copy and use this software is granted provided that it
  23. * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
  24. * Algorithm" in all material mentioning or referencing this software
  25. * or this function.
  26. *
  27. * License is also granted to make and use derivative works provided
  28. * that such works are identified as "derived from the RSA Data
  29. * Security, Inc. MD4 Message-Digest Algorithm" in all material
  30. * mentioning or referencing the derived work.
  31. *
  32. * RSA Data Security, Inc. makes no representations concerning either
  33. * the merchantability of this software or the suitability of this
  34. * software for any particular purpose. It is provided "as is"
  35. * without express or implied warranty of any kind.
  36. *
  37. * These notices must be retained in any copies of any part of this
  38. * documentation and/or software.
  39. */
  40. #ifndef APR_MD4_H
  41. #define APR_MD4_H
  42. #include "apu.h"
  43. #include "apr_xlate.h"
  44. /**
  45. * @file apr_md4.h
  46. * @brief APR-UTIL MD4 Library
  47. */
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. /**
  52. * @defgroup APR_Util_MD4 MD4 Library
  53. * @ingroup APR_Util
  54. * @{
  55. */
  56. /** The digestsize for MD4 */
  57. #define APR_MD4_DIGESTSIZE 16
  58. /** @see apr_md4_ctx_t */
  59. typedef struct apr_md4_ctx_t apr_md4_ctx_t;
  60. /** MD4 context. */
  61. struct apr_md4_ctx_t {
  62. /** state (ABCD) */
  63. apr_uint32_t state[4];
  64. /** number of bits, modulo 2^64 (lsb first) */
  65. apr_uint32_t count[2];
  66. /** input buffer */
  67. unsigned char buffer[64];
  68. #if APR_HAS_XLATE
  69. /** translation handle */
  70. apr_xlate_t *xlate;
  71. #endif
  72. };
  73. /**
  74. * MD4 Initialize. Begins an MD4 operation, writing a new context.
  75. * @param context The MD4 context to initialize.
  76. */
  77. APU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context);
  78. #if APR_HAS_XLATE
  79. /**
  80. * MDr4 translation setup. Provides the APR translation handle to be used
  81. * for translating the content before calculating the digest.
  82. * @param context The MD4 content to set the translation for.
  83. * @param xlate The translation handle to use for this MD4 context
  84. */
  85. APU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context,
  86. apr_xlate_t *xlate);
  87. #else
  88. #define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL
  89. #endif
  90. /**
  91. * MD4 block update operation. Continue an MD4 message-digest operation,
  92. * processing another message block, and updating the context.
  93. * @param context The MD4 content to update.
  94. * @param input next message block to update
  95. * @param inputLen The length of the next message block
  96. */
  97. APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context,
  98. const unsigned char *input,
  99. apr_size_t inputLen);
  100. /**
  101. * MD4 finalization. Ends an MD4 message-digest operation, writing the
  102. * message digest and zeroing the context
  103. * @param digest The final MD4 digest
  104. * @param context The MD4 content we are finalizing.
  105. */
  106. APU_DECLARE(apr_status_t) apr_md4_final(
  107. unsigned char digest[APR_MD4_DIGESTSIZE],
  108. apr_md4_ctx_t *context);
  109. /**
  110. * MD4 digest computation
  111. * @param digest The MD4 digest
  112. * @param input message block to use
  113. * @param inputLen The length of the message block
  114. */
  115. APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE],
  116. const unsigned char *input,
  117. apr_size_t inputLen);
  118. /** @} */
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* !APR_MD4_H */