PostgreSQL Source Code: src/common/cryptohash.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18#ifndef FRONTEND

20#else

22#endif

23

25

30

31

32

33

34

35#ifndef FRONTEND

36#define ALLOC(size) palloc(size)

37#define FREE(ptr) pfree(ptr)

38#else

39#define ALLOC(size) malloc(size)

40#define FREE(ptr) free(ptr)

41#endif

42

43

45{

49

50

52{

55

56 union

57 {

65};

66

67

68

69

70

71

72

75{

77

78

79

80

81

82

83

85 if (ctx == NULL)

86 return NULL;

87

91 return ctx;

92}

93

94

95

96

97

98

99int

101{

102 if (ctx == NULL)

103 return -1;

104

105 switch (ctx->type)

106 {

109 break;

112 break;

115 break;

118 break;

121 break;

124 break;

125 }

126

127 return 0;

128}

129

130

131

132

133

134

135int

137{

138 if (ctx == NULL)

139 return -1;

140

141 switch (ctx->type)

142 {

145 break;

148 break;

151 break;

154 break;

157 break;

160 break;

161 }

162

163 return 0;

164}

165

166

167

168

169

170

171int

173{

174 if (ctx == NULL)

175 return -1;

176

177 switch (ctx->type)

178 {

181 {

183 return -1;

184 }

186 break;

189 {

191 return -1;

192 }

194 break;

197 {

199 return -1;

200 }

202 break;

205 {

207 return -1;

208 }

210 break;

213 {

215 return -1;

216 }

218 break;

221 {

223 return -1;

224 }

226 break;

227 }

228

229 return 0;

230}

231

232

233

234

235

236

237void

239{

240 if (ctx == NULL)

241 return;

242

245}

246

247

248

249

250

251

252

253const char *

255{

256

257

258

259

260 if (ctx == NULL)

261 return _("out of memory");

262

263 switch (ctx->error)

264 {

266 return _("success");

268 return _("destination buffer too small");

269 }

270

272 return _("success");

273}

const char * pg_cryptohash_error(pg_cryptohash_ctx *ctx)

int pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)

pg_cryptohash_ctx * pg_cryptohash_create(pg_cryptohash_type type)

int pg_cryptohash_init(pg_cryptohash_ctx *ctx)

@ PG_CRYPTOHASH_ERROR_DEST_LEN

@ PG_CRYPTOHASH_ERROR_NONE

void pg_cryptohash_free(pg_cryptohash_ctx *ctx)

int pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len)

Assert(PointerIsAligned(start, uint64))

void pg_md5_init(pg_md5_ctx *ctx)

void pg_md5_update(pg_md5_ctx *ctx, const uint8 *data, size_t len)

void pg_md5_final(pg_md5_ctx *ctx, uint8 *dest)

#define MD5_DIGEST_LENGTH

void explicit_bzero(void *buf, size_t len)

void pg_sha1_update(pg_sha1_ctx *ctx, const uint8 *data, size_t len)

void pg_sha1_init(pg_sha1_ctx *ctx)

void pg_sha1_final(pg_sha1_ctx *ctx, uint8 *dest)

#define SHA1_DIGEST_LENGTH

void pg_sha512_final(pg_sha512_ctx *context, uint8 *digest)

void pg_sha384_init(pg_sha384_ctx *context)

void pg_sha256_init(pg_sha256_ctx *context)

void pg_sha512_update(pg_sha512_ctx *context, const uint8 *data, size_t len)

void pg_sha224_update(pg_sha224_ctx *context, const uint8 *data, size_t len)

void pg_sha512_init(pg_sha512_ctx *context)

void pg_sha224_init(pg_sha224_ctx *context)

void pg_sha256_final(pg_sha256_ctx *context, uint8 *digest)

void pg_sha224_final(pg_sha224_ctx *context, uint8 *digest)

void pg_sha384_final(pg_sha384_ctx *context, uint8 *digest)

void pg_sha384_update(pg_sha384_ctx *context, const uint8 *data, size_t len)

void pg_sha256_update(pg_sha256_ctx *context, const uint8 *data, size_t len)

#define PG_SHA256_DIGEST_LENGTH

#define PG_SHA384_DIGEST_LENGTH

#define PG_SHA512_DIGEST_LENGTH

#define PG_SHA224_DIGEST_LENGTH

pg_cryptohash_errno error

union pg_cryptohash_ctx::@39 data