|
@@ -29,35 +29,43 @@
|
|
|
*/
|
|
|
#include "digests.h"
|
|
|
#include "user_config.h"
|
|
|
+#include "rom.h"
|
|
|
#include "lwip/mem.h"
|
|
|
-#include "lwip/arch.h"
|
|
|
-#include "ssl/ssl_crypto.h"
|
|
|
-#include "sha2.h"
|
|
|
#include <string.h>
|
|
|
#include <c_errno.h>
|
|
|
|
|
|
+#ifdef MD2_ENABLE
|
|
|
+#include "ssl/ssl_crypto.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef SHA2_ENABLE
|
|
|
+#include "sha2.h"
|
|
|
+#endif
|
|
|
+
|
|
|
typedef char ensure_int_and_size_t_same[(sizeof(int)==sizeof(size_t)) ? 0 : -1];
|
|
|
|
|
|
/* None of the functions match the prototype fully due to the void *, and in
|
|
|
some cases also the int vs size_t len, so wrap declarations in a macro. */
|
|
|
-#define MECH(pfx, ds, bs) \
|
|
|
+#define MECH(pfx, u, ds, bs) \
|
|
|
{ #pfx, \
|
|
|
- (create_ctx_fn)pfx ## _Init, \
|
|
|
- (update_ctx_fn)pfx ## _Update, \
|
|
|
- (finalize_ctx_fn)pfx ## _Final, \
|
|
|
+ (create_ctx_fn)pfx ## u ## Init, \
|
|
|
+ (update_ctx_fn)pfx ## u ## Update, \
|
|
|
+ (finalize_ctx_fn)pfx ## u ## Final, \
|
|
|
sizeof(pfx ## _CTX), \
|
|
|
ds, \
|
|
|
bs }
|
|
|
|
|
|
static const digest_mech_info_t hash_mechs[] =
|
|
|
{
|
|
|
- MECH(MD2, MD2_SIZE, 16)
|
|
|
- ,MECH(MD5, MD5_SIZE, 64)
|
|
|
- ,MECH(SHA1, SHA1_SIZE, 64)
|
|
|
+#ifdef MD2_ENABLE
|
|
|
+ MECH(MD2, _ , MD2_SIZE, 16),
|
|
|
+#endif
|
|
|
+ MECH(MD5, , MD5_DIGEST_LENGTH, 64)
|
|
|
+ ,MECH(SHA1, , SHA1_DIGEST_LENGTH, 64)
|
|
|
#ifdef SHA2_ENABLE
|
|
|
- ,MECH(SHA256, SHA256_DIGEST_LENGTH, SHA256_BLOCK_LENGTH)
|
|
|
- ,MECH(SHA384, SHA384_DIGEST_LENGTH, SHA384_BLOCK_LENGTH)
|
|
|
- ,MECH(SHA512, SHA512_DIGEST_LENGTH, SHA512_BLOCK_LENGTH)
|
|
|
+ ,MECH(SHA256, _ , SHA256_DIGEST_LENGTH, SHA256_BLOCK_LENGTH)
|
|
|
+ ,MECH(SHA384, _ , SHA384_DIGEST_LENGTH, SHA384_BLOCK_LENGTH)
|
|
|
+ ,MECH(SHA512, _ , SHA512_DIGEST_LENGTH, SHA512_BLOCK_LENGTH)
|
|
|
#endif
|
|
|
};
|
|
|
|