PostgreSQL Source Code: contrib/pgcrypto/pgp.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

33

35#include "px.h"

36

37

38

39

52

54{

57};

58

60{

66};

67

76 {NULL, 0}

77};

78

80 {"3des", PGP_SYM_DES3, "3des-ecb", 192 / 8, 64 / 8},

81 {"cast5", PGP_SYM_CAST5, "cast5-ecb", 128 / 8, 64 / 8},

88 {"twofish", PGP_SYM_TWOFISH, "twofish-ecb", 256 / 8, 128 / 8},

89 {NULL, 0, NULL}

90};

91

94{

96

98 if (i->code == code)

99 return i;

100 return NULL;

101}

102

103int

105{

107

110 return i->code;

112}

113

114int

116{

118

121 return i->code;

123}

124

125const char *

127{

129

131 if (i->code == code)

132 return i->name;

133 return NULL;

134}

135

136int

138{

140

141 if (i != NULL)

142 return i->key_len;

143 return 0;

144}

145

146int

148{

150

151 if (i != NULL)

152 return i->block_len;

153 return 0;

154}

155

156int

158{

161

162 if (i == NULL)

164

166 if (err == 0)

167 return 0;

168

170}

171

172int

174{

177

178 if (name == NULL)

180

182 if (err == 0)

183 return 0;

184

186}

187

188int

190{

192

193 ctx = palloc0(sizeof *ctx);

194

207

208 *ctx_p = ctx;

209 return 0;

210}

211

212int

214{

219 return 0;

220}

221

222int

224{

226 return 0;

227}

228

229int

231{

233 return 0;

234}

235

236int

238{

240 return 0;

241}

242

243int

245{

247

248 switch (mode)

249 {

254 break;

255 default:

257 break;

258 }

259 return err;

260}

261

262int

264{

266 {

269 }

271}

272

273int

275{

276 switch (algo)

277 {

283 return 0;

284 }

286}

287

288int

290{

291 if (level >= 0 && level <= 9)

292 {

294 return 0;

295 }

297}

298

299int

301{

303 return 0;

304}

305

306int

308{

310

311 if (code < 0)

314 return 0;

315}

316

317int

319{

321

322 if (code < 0)

325 return 0;

326}

327

328int

330{

332

333 if (code < 0)

336 return 0;

337}

338

339int

341{

343}

344

345int

347{

349 return 0;

350}

351

352int

354{

355 if (key == NULL || len < 1)

359 return 0;

360}

void err(int eval, const char *fmt,...)

void pfree(void *pointer)

void * palloc0(Size size)

int px_find_digest(const char *name, PX_MD **res)

int px_find_cipher(const char *name, PX_Cipher **res)

static PgChecksumMode mode

void pgp_key_free(PGP_PubKey *pk)

int pgp_disable_mdc(PGP_Context *ctx, int disable)

int pgp_get_cipher_code(const char *name)

int pgp_init(PGP_Context **ctx_p)

static int def_compress_algo

static int def_s2k_cipher_algo

static int def_convert_crlf

static int def_compress_level

int pgp_set_text_mode(PGP_Context *ctx, int mode)

int pgp_set_s2k_digest_algo(PGP_Context *ctx, const char *name)

const char * pgp_get_digest_name(int code)

int pgp_set_s2k_mode(PGP_Context *ctx, int mode)

static int def_s2k_digest_algo

int pgp_get_digest_code(const char *name)

static int def_unicode_mode

int pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int len)

static const struct digest_info digest_list[]

int pgp_get_cipher_block_size(int code)

int pgp_load_cipher(int code, PX_Cipher **res)

static int def_cipher_algo

int pgp_set_s2k_cipher_algo(PGP_Context *ctx, const char *name)

int pgp_set_compress_algo(PGP_Context *ctx, int algo)

int pgp_get_unicode_mode(PGP_Context *ctx)

static const struct cipher_info cipher_list[]

int pgp_set_cipher_algo(PGP_Context *ctx, const char *name)

static int def_disable_mdc

int pgp_set_convert_crlf(PGP_Context *ctx, int doit)

int pgp_set_unicode_mode(PGP_Context *ctx, int mode)

int pgp_get_cipher_key_size(int code)

int pgp_free(PGP_Context *ctx)

int pgp_set_s2k_count(PGP_Context *ctx, int count)

int pgp_set_sess_key(PGP_Context *ctx, int use)

int pgp_load_digest(int code, PX_MD **res)

int pgp_set_compress_level(PGP_Context *ctx, int level)

static const struct cipher_info * get_cipher_info(int code)

static int def_use_sess_key

int pg_strcasecmp(const char *s1, const char *s2)

void px_memset(void *ptr, int c, size_t len)

#define PXE_ARGUMENT_ERROR

#define PXE_PGP_CORRUPT_DATA

#define PXE_PGP_UNSUPPORTED_CIPHER

#define PXE_PGP_UNSUPPORTED_HASH