PostgreSQL Source Code: contrib/pgcrypto/px.c File Reference (original) (raw)
#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include "[px.h](px%5F8h%5Fsource.html)"
Go to the source code of this file.
Functions | |
---|---|
void | px_THROW_ERROR (int err) |
const char * | px_strerror (int err) |
void | px_memset (void *ptr, int c, size_t len) |
const char * | px_resolve_alias (const PX_Alias *list, const char *name) |
void | px_set_debug_handler (void(*handler)(const char *)) |
void | px_debug (const char *fmt,...) |
static unsigned | combo_encrypt_len (PX_Combo *cx, unsigned dlen) |
static unsigned | combo_decrypt_len (PX_Combo *cx, unsigned dlen) |
static int | combo_init (PX_Combo *cx, const uint8 *key, unsigned klen, const uint8 *iv, unsigned ivlen) |
static int | combo_encrypt (PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen) |
static int | combo_decrypt (PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen) |
static void | combo_free (PX_Combo *cx) |
static int | parse_cipher_name (char *full, char **cipher, char **pad) |
int | px_find_combo (const char *name, PX_Combo **res) |
◆ combo_decrypt()
static int combo_decrypt ( PX_Combo * cx, const uint8 * data, unsigned dlen, uint8 * res, unsigned * rlen ) | static |
---|
Definition at line 225 of file px.c.
227{
229}
int cx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
#define px_cipher_decrypt(c, padding, data, dlen, res, rlen)
References cx(), data, and px_cipher_decrypt.
Referenced by px_find_combo().
◆ combo_decrypt_len()
static unsigned combo_decrypt_len ( PX_Combo * cx, unsigned dlen ) | static |
---|
◆ combo_encrypt()
static int combo_encrypt ( PX_Combo * cx, const uint8 * data, unsigned dlen, uint8 * res, unsigned * rlen ) | static |
---|
◆ combo_encrypt_len()
static unsigned combo_encrypt_len ( PX_Combo * cx, unsigned dlen ) | static |
---|
◆ combo_free()
static void combo_free ( PX_Combo * cx) | static |
---|
◆ combo_init()
static int combo_init ( PX_Combo * cx, const uint8 * key, unsigned klen, const uint8 * iv, unsigned ivlen ) | static |
---|
Definition at line 181 of file px.c.
183{
185 unsigned ks,
186 ivs;
188 uint8 *ivbuf = NULL;
190
192
194 if (ivs > 0)
195 {
197 if (ivlen > ivs)
198 memcpy(ivbuf, iv, ivs);
199 else if (ivlen > 0)
200 memcpy(ivbuf, iv, ivlen);
201 }
202
203 if (klen > ks)
204 klen = ks;
206 memcpy(keybuf, key, klen);
207
209
210 if (ivbuf)
213
214 return err;
215}
void err(int eval, const char *fmt,...)
void * palloc0(Size size)
#define px_cipher_iv_size(c)
#define px_cipher_init(c, k, klen, iv)
#define px_cipher_key_size(c)
References cx(), err(), sort-test::key, palloc0(), pfree(), px_cipher_init, px_cipher_iv_size, and px_cipher_key_size.
Referenced by px_find_combo().
◆ parse_cipher_name()
static int parse_cipher_name ( char * full, char ** cipher, char ** pad ) | static |
---|
Definition at line 243 of file px.c.
244{
245 char *p,
246 *p2,
247 *q;
248
249 *cipher = full;
250 *pad = NULL;
251
252 p = strchr(full, '/');
253 if (p != NULL)
254 *p++ = 0;
255 while (p != NULL)
256 {
257 if ((q = strchr(p, '/')) != NULL)
258 *q++ = 0;
259
260 if (!*p)
261 {
262 p = q;
263 continue;
264 }
265 p2 = strchr(p, ':');
266 if (p2 != NULL)
267 {
268 *p2++ = 0;
269 if (strcmp(p, "pad") == 0)
270 *pad = p2;
271 else
273 }
274 else
276
277 p = q;
278 }
279 return 0;
280}
References PXE_BAD_FORMAT, and PXE_BAD_OPTION.
Referenced by px_find_combo().
◆ px_debug()
void px_debug | ( | const char * | fmt, |
---|---|---|---|
... | |||
) |
Definition at line 149 of file px.c.
150{
151 va_list ap;
152
153 va_start(ap, fmt);
155 {
156 char buf[512];
157
160 }
161 va_end(ap);
162}
static void(* debug_handler)(const char *)
References buf, debug_handler, and vsnprintf.
Referenced by _pgp_read_public_key(), bn_to_mpi(), check_key_cksum(), check_key_sha1(), control_cksum(), decrypt_key(), internal_read_key(), mbuf_append(), mdc_finish(), mdc_read(), mdcbuf_finish(), mpi_to_bn(), parse_compressed_data(), parse_literal_data(), parse_new_len(), parse_old_len(), parse_symenc_mdc_data(), parse_symenc_sesskey(), pgp_decrypt(), pgp_expect_packet_end(), pgp_mpi_alloc(), pgp_parse_pkt_hdr(), pgp_parse_pubenc_sesskey(), pgp_write_pubenc_sesskey(), prefix_init(), process_data_packets(), process_secret_key(), and pullf_read_fixed().
◆ px_find_combo()
int px_find_combo | ( | const char * | name, |
---|---|---|---|
PX_Combo ** | res | ||
) |
Definition at line 285 of file px.c.
286{
288 char *buf,
289 *s_cipher,
290 *s_pad;
291
293
296
299 {
302 return err;
303 }
304
307 goto err1;
308
309 if (s_pad != NULL)
310 {
311 if (strcmp(s_pad, "pkcs") == 0)
312 cx->padding = 1;
313 else if (strcmp(s_pad, "none") == 0)
314 cx->padding = 0;
315 else
316 goto err1;
317 }
318 else
319 cx->padding = 1;
320
327
329
330 *res = cx;
331
332 return 0;
333
334err1:
335 if (cx->cipher)
340}
char * pstrdup(const char *in)
int px_find_cipher(const char *name, PX_Cipher **res)
static void combo_free(PX_Combo *cx)
static int combo_encrypt(PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen)
static int parse_cipher_name(char *full, char **cipher, char **pad)
static int combo_decrypt(PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen)
static unsigned combo_decrypt_len(PX_Combo *cx, unsigned dlen)
static unsigned combo_encrypt_len(PX_Combo *cx, unsigned dlen)
static int combo_init(PX_Combo *cx, const uint8 *key, unsigned klen, const uint8 *iv, unsigned ivlen)
References buf, combo_decrypt(), combo_decrypt_len(), combo_encrypt(), combo_encrypt_len(), combo_free(), combo_init(), cx(), err(), name, palloc0(), parse_cipher_name(), pfree(), pstrdup(), px_cipher_free, px_find_cipher(), and PXE_NO_CIPHER.
Referenced by pg_decrypt(), pg_decrypt_iv(), pg_encrypt(), and pg_encrypt_iv().
◆ px_memset()
void px_memset | ( | void * | ptr, |
---|---|---|---|
int | c, | ||
size_t | len | ||
) |
Definition at line 123 of file px.c.
124{
126}
References len.
Referenced by _crypt_blowfish_rn(), calc_key_id(), calc_s2k_iter_salted(), calc_s2k_salted(), calc_s2k_simple(), check_key_sha1(), clear_and_pfree(), combo_free(), copy_crlf(), create_secmsg(), encrypt_free(), hmac_finish(), hmac_free(), hmac_init(), mbuf_free(), mdc_finish(), mdc_flush(), mdcbuf_finish(), mdcbuf_free(), pad_eme_pkcs1_v15(), parse_literal_data(), parse_symenc_sesskey(), pgp_cfb_free(), pgp_free(), pgp_key_free(), pgp_mpi_free(), pkt_stream_free(), pktreader_free(), prefix_init(), pullf_free(), pullf_read_max(), pushf_free(), px_crypt_md5(), px_crypt_shacrypt(), px_gen_salt(), write_prefix(), and write_symenc_sesskey().
◆ px_resolve_alias()
const char * px_resolve_alias | ( | const PX_Alias * | list, |
---|---|---|---|
const char * | name | ||
) |
◆ px_set_debug_handler()
void px_set_debug_handler | ( | void(*)(const char *) | handler | ) |
---|
◆ px_strerror()
const char * px_strerror | ( | int | err | ) |
---|
◆ px_THROW_ERROR()
void px_THROW_ERROR | ( | int | err | ) |
---|
Definition at line 93 of file px.c.
94{
96 {
98 (errcode(ERRCODE_INTERNAL_ERROR),
99 errmsg("could not generate a random number")));
100 }
101 else
102 {
103
105 (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
107 }
108}
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
const char * px_strerror(int err)
References ereport, err(), errcode(), errmsg(), ERROR, px_strerror(), and PXE_NO_RANDOM.
Referenced by decrypt_internal(), encrypt_internal(), init_work(), pg_dearmor(), pg_random_bytes(), pgp_armor_headers(), and pgp_key_id_w().
◆ debug_handler
void(* debug_handler) (const char *) ( const char * ) = NULL | static |
---|