• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 
11 
12 #ifndef GMSSL_MD5_H
13 #define GMSSL_MD5_H
14 
15 
16 #include <string.h>
17 #include <stdint.h>
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 #define MD5_IS_BIG_ENDIAN	0
26 
27 #define MD5_DIGEST_SIZE		16
28 #define MD5_BLOCK_SIZE		64
29 #define MD5_STATE_WORDS		(MD5_BLOCK_SIZE/sizeof(uint32_t))
30 
31 typedef struct {
32 	uint32_t state[MD5_STATE_WORDS];
33 	uint64_t nblocks;
34 	uint8_t block[MD5_BLOCK_SIZE];
35 	size_t num;
36 } MD5_CTX;
37 
38 
39 void md5_init(MD5_CTX *ctx);
40 void md5_update(MD5_CTX *ctx, const uint8_t *data, size_t datalen);
41 void md5_finish(MD5_CTX *ctx, uint8_t dgst[MD5_DIGEST_SIZE]);
42 void md5_digest(const uint8_t *data, size_t datalen, uint8_t dgst[MD5_DIGEST_SIZE]);
43 
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 #endif
49