~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to contrib/pgcrypto/pgp-decrypt.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
27
 * SUCH DAMAGE.
28
28
 *
29
 
 * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.7 2005/11/22 18:17:04 momjian Exp $
 
29
 * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.8 2009/06/11 14:48:52 momjian Exp $
30
30
 */
31
31
 
32
32
#include "postgres.h"
49
49
#define MAX_CHUNK (16*1024*1024)
50
50
 
51
51
static int
52
 
parse_new_len(PullFilter * src, int *len_p)
 
52
parse_new_len(PullFilter *src, int *len_p)
53
53
{
54
54
        uint8           b;
55
55
        int                     len;
92
92
}
93
93
 
94
94
static int
95
 
parse_old_len(PullFilter * src, int *len_p, int lentype)
 
95
parse_old_len(PullFilter *src, int *len_p, int lentype)
96
96
{
97
97
        uint8           b;
98
98
        int                     len;
126
126
 
127
127
/* returns pkttype or 0 on eof */
128
128
int
129
 
pgp_parse_pkt_hdr(PullFilter * src, uint8 *tag, int *len_p, int allow_ctx)
 
129
pgp_parse_pkt_hdr(PullFilter *src, uint8 *tag, int *len_p, int allow_ctx)
130
130
{
131
131
        int                     lentype;
132
132
        int                     res;
172
172
};
173
173
 
174
174
static int
175
 
pktreader_pull(void *priv, PullFilter * src, int len,
 
175
pktreader_pull(void *priv, PullFilter *src, int len,
176
176
                           uint8 **data_p, uint8 *buf, int buflen)
177
177
{
178
178
        int                     res;
220
220
 
221
221
/* needs helper function to pass several parameters */
222
222
int
223
 
pgp_create_pkt_reader(PullFilter ** pf_p, PullFilter * src, int len,
224
 
                                          int pkttype, PGP_Context * ctx)
 
223
pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len,
 
224
                                          int pkttype, PGP_Context *ctx)
225
225
{
226
226
        int                     res;
227
227
        struct PktData *pkt = px_alloc(sizeof(*pkt));
239
239
 */
240
240
 
241
241
static int
242
 
prefix_init(void **priv_p, void *arg, PullFilter * src)
 
242
prefix_init(void **priv_p, void *arg, PullFilter *src)
243
243
{
244
244
        PGP_Context *ctx = arg;
245
245
        int                     len;
294
294
 */
295
295
 
296
296
static int
297
 
decrypt_init(void **priv_p, void *arg, PullFilter * src)
 
297
decrypt_init(void **priv_p, void *arg, PullFilter *src)
298
298
{
299
299
        PGP_CFB    *cfb = arg;
300
300
 
305
305
}
306
306
 
307
307
static int
308
 
decrypt_read(void *priv, PullFilter * src, int len,
 
308
decrypt_read(void *priv, PullFilter *src, int len,
309
309
                         uint8 **data_p, uint8 *buf, int buflen)
310
310
{
311
311
        PGP_CFB    *cfb = priv;
331
331
 */
332
332
 
333
333
static int
334
 
mdc_init(void **priv_p, void *arg, PullFilter * src)
 
334
mdc_init(void **priv_p, void *arg, PullFilter *src)
335
335
{
336
336
        PGP_Context *ctx = arg;
337
337
 
351
351
}
352
352
 
353
353
static int
354
 
mdc_finish(PGP_Context * ctx, PullFilter * src,
 
354
mdc_finish(PGP_Context *ctx, PullFilter *src,
355
355
                   int len, uint8 **data_p)
356
356
{
357
357
        int                     res;
407
407
}
408
408
 
409
409
static int
410
 
mdc_read(void *priv, PullFilter * src, int len,
 
410
mdc_read(void *priv, PullFilter *src, int len,
411
411
                 uint8 **data_p, uint8 *buf, int buflen)
412
412
{
413
413
        int                     res;
460
460
};
461
461
 
462
462
static int
463
 
mdcbuf_init(void **priv_p, void *arg, PullFilter * src)
 
463
mdcbuf_init(void **priv_p, void *arg, PullFilter *src)
464
464
{
465
465
        PGP_Context *ctx = arg;
466
466
        struct MDCBufData *st;
520
520
}
521
521
 
522
522
static int
523
 
mdcbuf_refill(struct MDCBufData * st, PullFilter * src)
 
523
mdcbuf_refill(struct MDCBufData * st, PullFilter *src)
524
524
{
525
525
        uint8      *data;
526
526
        int                     res;
564
564
}
565
565
 
566
566
static int
567
 
mdcbuf_read(void *priv, PullFilter * src, int len,
 
567
mdcbuf_read(void *priv, PullFilter *src, int len,
568
568
                        uint8 **data_p, uint8 *buf, int buflen)
569
569
{
570
570
        struct MDCBufData *st = priv;
606
606
 * Decrypt separate session key
607
607
 */
608
608
static int
609
 
decrypt_key(PGP_Context * ctx, const uint8 *src, int len)
 
609
decrypt_key(PGP_Context *ctx, const uint8 *src, int len)
610
610
{
611
611
        int                     res;
612
612
        uint8           algo;
639
639
 * Handle key packet
640
640
 */
641
641
static int
642
 
parse_symenc_sesskey(PGP_Context * ctx, PullFilter * src)
 
642
parse_symenc_sesskey(PGP_Context *ctx, PullFilter *src)
643
643
{
644
644
        uint8      *p;
645
645
        int                     res;
708
708
}
709
709
 
710
710
static int
711
 
copy_crlf(MBuf * dst, uint8 *data, int len, int *got_cr)
 
711
copy_crlf(MBuf *dst, uint8 *data, int len, int *got_cr)
712
712
{
713
713
        uint8      *data_end = data + len;
714
714
        uint8           tmpbuf[1024];
757
757
}
758
758
 
759
759
static int
760
 
parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt)
 
760
parse_literal_data(PGP_Context *ctx, MBuf *dst, PullFilter *pkt)
761
761
{
762
762
        int                     type;
763
763
        int                     name_len;
824
824
}
825
825
 
826
826
/* process_data_packets and parse_compressed_data call each other */
827
 
static int process_data_packets(PGP_Context * ctx, MBuf * dst,
828
 
                                         PullFilter * src, int allow_compr, int need_mdc);
 
827
static int process_data_packets(PGP_Context *ctx, MBuf *dst,
 
828
                                         PullFilter *src, int allow_compr, int need_mdc);
829
829
 
830
830
static int
831
 
parse_compressed_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt)
 
831
parse_compressed_data(PGP_Context *ctx, MBuf *dst, PullFilter *pkt)
832
832
{
833
833
        int                     res;
834
834
        uint8           type;
868
868
}
869
869
 
870
870
static int
871
 
process_data_packets(PGP_Context * ctx, MBuf * dst, PullFilter * src,
 
871
process_data_packets(PGP_Context *ctx, MBuf *dst, PullFilter *src,
872
872
                                         int allow_compr, int need_mdc)
873
873
{
874
874
        uint8           tag;
975
975
}
976
976
 
977
977
static int
978
 
parse_symenc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst)
 
978
parse_symenc_data(PGP_Context *ctx, PullFilter *pkt, MBuf *dst)
979
979
{
980
980
        int                     res;
981
981
        PGP_CFB    *cfb = NULL;
1009
1009
}
1010
1010
 
1011
1011
static int
1012
 
parse_symenc_mdc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst)
 
1012
parse_symenc_mdc_data(PGP_Context *ctx, PullFilter *pkt, MBuf *dst)
1013
1013
{
1014
1014
        int                     res;
1015
1015
        PGP_CFB    *cfb = NULL;
1061
1061
 * skip over packet contents
1062
1062
 */
1063
1063
int
1064
 
pgp_skip_packet(PullFilter * pkt)
 
1064
pgp_skip_packet(PullFilter *pkt)
1065
1065
{
1066
1066
        int                     res = 1;
1067
1067
        uint8      *tmp;
1075
1075
 * expect to be at packet end, any data is error
1076
1076
 */
1077
1077
int
1078
 
pgp_expect_packet_end(PullFilter * pkt)
 
1078
pgp_expect_packet_end(PullFilter *pkt)
1079
1079
{
1080
1080
        int                     res = 1;
1081
1081
        uint8      *tmp;
1093
1093
}
1094
1094
 
1095
1095
int
1096
 
pgp_decrypt(PGP_Context * ctx, MBuf * msrc, MBuf * mdst)
 
1096
pgp_decrypt(PGP_Context *ctx, MBuf *msrc, MBuf *mdst)
1097
1097
{
1098
1098
        int                     res;
1099
1099
        PullFilter *src = NULL;