42"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
52 unsigned long buf = 0;
59 buf |= *s << (pos << 3);
86 *p++ = (pos == 0) ?
_base64[(
buf >> 6) & 0x3f] :
'=';
102 unsigned long buf = 0;
109 if (
c >=
'A' &&
c <=
'Z')
111 else if (
c >=
'a' &&
c <=
'z')
113 else if (
c >=
'0' &&
c <=
'9')
135 else if (
c ==
' ' ||
c ==
'\t' ||
c ==
'\n' ||
c ==
'\r')
147 *p++ = (
buf >> 16) & 255;
148 if (end == 0 || end > 1)
149 *p++ = (
buf >> 8) & 255;
150 if (end == 0 || end > 2)
181static const char *
const armor_header =
"-----BEGIN PGP MESSAGE-----\n";
182static const char *
const armor_footer =
"\n-----END PGP MESSAGE-----\n";
185#define CRC24_INIT 0x00b704ceL
186#define CRC24_POLY 0x01864cfbL
196 for (
i = 0;
i < 8;
i++)
203 return crc & 0xffffffL;
227 elog(
FATAL,
"overflow - encode estimate too small");
230 if (*(
dst->data +
dst->len - 1) !=
'\n')
256 if (p +
strlen > data_end)
270 static const char *
start_sep =
"-----BEGIN";
271 static const char *
end_sep =
"-----END";
281 if (p ==
data || *(p - 1) ==
'\n')
289 for (; p <
datend && *p !=
'-'; p++)
303 if (*p !=
'\n' && *p !=
'\r')
307 if (p <
datend && *p ==
'\n')
316 const uint8 *p = src;
339 while (p <
armor_end && *p !=
'\n' && *p !=
'\r')
370 elog(
FATAL,
"overflow - decode estimate too small");
391 int *nheaders,
char ***keys,
char ***
values)
422 while (p <
armor_end && *p !=
'\n' && *p !=
'\r')
461 if (
eol > line && *(
eol - 1) ==
'\r')
473 elog(
ERROR,
"unexpected number of armor header lines");
476 (*values)[n] =
colon + 2;
484 elog(
ERROR,
"unexpected number of armor header lines");
static Datum values[MAXATTR]
static char buf[DEFAULT_XLOG_SEG_SIZE]
static long crc24(const uint8 *data, unsigned len)
int pgp_extract_armor_headers(const uint8 *src, unsigned len, int *nheaders, char ***keys, char ***values)
static int find_header(const uint8 *data, const uint8 *datend, const uint8 **start_p, int is_end)
static const char *const armor_footer
static unsigned pg_base64_enc_len(unsigned srclen)
int pgp_armor_decode(const uint8 *src, int len, StringInfo dst)
static int pg_base64_decode(const uint8 *src, unsigned len, uint8 *dst)
void pgp_armor_encode(const uint8 *src, unsigned len, StringInfo dst, int num_headers, char **keys, char **values)
static const char *const armor_header
static unsigned pg_base64_dec_len(unsigned srclen)
static int pg_base64_encode(const uint8 *src, unsigned len, uint8 *dst)
static const uint8 * find_str(const uint8 *data, const uint8 *data_end, const char *str, int strlen)
static const unsigned char _base64[]
#define PXE_PGP_CORRUPT_ARMOR
void appendStringInfo(StringInfo str, const char *fmt,...)
void enlargeStringInfo(StringInfo str, int needed)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)