1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Refactor space allocation for base64 encoding/decoding in pgcrypto.

Instead of trying to accurately calculate the space needed, use a StringInfo
that's enlarged as needed. This is just moving things around currently - the
old code was not wrong - but this is in preparation for a patch that adds
support for extra armor headers, and would make the space calculation more
complicated.

Marko Tiikkaja
This commit is contained in:
Heikki Linnakangas
2014-09-25 16:32:27 +03:00
parent 56a312aac8
commit 1dcfb8da09
3 changed files with 59 additions and 73 deletions

View File

@ -29,6 +29,8 @@
* contrib/pgcrypto/pgp.h
*/
#include "lib/stringinfo.h"
#include "mbuf.h"
#include "px.h"
@ -274,10 +276,8 @@ void pgp_cfb_free(PGP_CFB *ctx);
int pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst);
int pgp_cfb_decrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst);
int pgp_armor_encode(const uint8 *src, unsigned len, uint8 *dst);
int pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst);
unsigned pgp_armor_enc_len(unsigned len);
unsigned pgp_armor_dec_len(unsigned len);
void pgp_armor_encode(const uint8 *src, int len, StringInfo dst);
int pgp_armor_decode(const uint8 *src, int len, StringInfo dst);
int pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst);
int pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src);