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

#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include "[mbuf.h](mbuf%5F8h%5Fsource.html)"
#include "[pgp.h](pgp%5F8h%5Fsource.html)"
#include "[px.h](px%5F8h%5Fsource.html)"

Go to the source code of this file.

Functions
static int read_pubkey_keyid (PullFilter *pkt, uint8 *keyid_buf)
static int read_pubenc_keyid (PullFilter *pkt, uint8 *keyid_buf)
static int print_key (uint8 *keyid, char *dst)
int pgp_get_keyid (MBuf *pgp_data, char *dst)

pgp_get_keyid()

int pgp_get_keyid ( MBuf * pgp_data,
char * dst
)

Definition at line 112 of file pgp-info.c.

113{

114 int res;

119 int got_pub_key = 0,

120 got_symenc_key = 0,

121 got_pubenc_key = 0;

122 int got_data = 0;

123 uint8 keyid_buf[8];

124 int got_main_key = 0;

125

126

128 if (res < 0)

129 return res;

130

131 while (1)

132 {

134 if (res <= 0)

135 break;

137 if (res < 0)

138 break;

139

140 switch (tag)

141 {

144

145 if (!got_main_key)

146 {

147 got_main_key = 1;

149 }

150 else

152 break;

156 if (res < 0)

157 break;

158 if (res > 0)

159 got_pub_key++;

160 break;

162 got_pubenc_key++;

164 break;

167

168 got_data = 1;

169 break;

171 got_symenc_key++;

172

180 break;

181 default:

183 }

184

185 if (pkt)

187 pkt = NULL;

188

189 if (res < 0 || got_data)

190 break;

191 }

192

194 if (pkt)

196

197 if (res < 0)

198 return res;

199

200

201 if (got_pub_key && got_pubenc_key)

203

204 if (got_pub_key > 1)

206

207 if (got_pubenc_key > 1)

209

210

211

212

213 if (res >= 0)

214 {

215 if (got_pubenc_key || got_pub_key)

216 {

217 if (memcmp(keyid_buf, any_key, 8) == 0)

218 {

219 memcpy(dst, "ANYKEY", 7);

220 res = 6;

221 }

222 else

224 }

225 else if (got_symenc_key)

226 {

227 memcpy(dst, "SYMKEY", 7);

228 res = 6;

229 }

230 else

232 }

233

234 return res;

235}

int pullf_create_mbuf_reader(PullFilter **mp_p, MBuf *src)

void pullf_free(PullFilter *pf)

int pgp_parse_pkt_hdr(PullFilter *src, uint8 *tag, int *len_p, int allow_ctx)

int pgp_skip_packet(PullFilter *pkt)

int pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len, int pkttype, PGP_Context *ctx)

static const uint8 any_key[]

static int read_pubkey_keyid(PullFilter *pkt, uint8 *keyid_buf)

static int print_key(uint8 *keyid, char *dst)

static int read_pubenc_keyid(PullFilter *pkt, uint8 *keyid_buf)

@ PGP_PKT_SYMENCRYPTED_DATA

@ PGP_PKT_SYMENCRYPTED_SESSKEY

@ PGP_PKT_SYMENCRYPTED_DATA_MDC

@ PGP_PKT_PUBENCRYPTED_SESSKEY

#define PXE_PGP_MULTIPLE_KEYS

#define PXE_PGP_NO_USABLE_KEY

#define PXE_PGP_CORRUPT_DATA

References any_key, len, pgp_create_pkt_reader(), pgp_parse_pkt_hdr(), PGP_PKT_MARKER, PGP_PKT_PRIV_61, PGP_PKT_PUBENCRYPTED_SESSKEY, PGP_PKT_PUBLIC_KEY, PGP_PKT_PUBLIC_SUBKEY, PGP_PKT_SECRET_KEY, PGP_PKT_SECRET_SUBKEY, PGP_PKT_SIGNATURE, PGP_PKT_SYMENCRYPTED_DATA, PGP_PKT_SYMENCRYPTED_DATA_MDC, PGP_PKT_SYMENCRYPTED_SESSKEY, PGP_PKT_TRUST, PGP_PKT_USER_ATTR, PGP_PKT_USER_ID, pgp_skip_packet(), print_key(), pullf_create_mbuf_reader(), pullf_free(), PXE_PGP_CORRUPT_DATA, PXE_PGP_MULTIPLE_KEYS, PXE_PGP_NO_USABLE_KEY, read_pubenc_keyid(), and read_pubkey_keyid().

Referenced by pgp_key_id_w().

print_key()

static int print_key ( uint8 * keyid, char * dst ) static

Definition at line 90 of file pgp-info.c.

91{

92 int i;

93 unsigned c;

94

95 for (i = 0; i < 8; i++)

96 {

97 c = keyid[i];

98 *dst++ = hextbl[(c >> 4) & 0x0F];

99 *dst++ = hextbl[c & 0x0F];

100 }

101 *dst = 0;

102 return 8 * 2;

103}

static const char hextbl[]

References hextbl, and i.

Referenced by pgp_get_keyid().

read_pubenc_keyid()

static int read_pubenc_keyid ( PullFilter * pkt, uint8 * keyid_buf ) static

read_pubkey_keyid()

static int read_pubkey_keyid ( PullFilter * pkt, uint8 * keyid_buf ) static

Definition at line 38 of file pgp-info.c.

39{

40 int res;

42

44 if (res < 0)

46

47

49 if (res < 0)

51

52

53 switch (pk->algo)

54 {

58 memcpy(keyid_buf, pk->key_id, 8);

59 res = 1;

60 break;

61 default:

62 res = 0;

63 }

64

67 return res;

68}

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

void pgp_key_free(PGP_PubKey *pk)

int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p)

@ PGP_PUB_RSA_ENCRYPT_SIGN

References _pgp_read_public_key(), PGP_PubKey::algo, err(), PGP_PubKey::key_id, pgp_key_free(), PGP_PUB_ELG_ENCRYPT, PGP_PUB_RSA_ENCRYPT, PGP_PUB_RSA_ENCRYPT_SIGN, and pgp_skip_packet().

Referenced by pgp_get_keyid().

any_key

hextbl

const char hextbl[] = "0123456789ABCDEF" static