* Jonathan McDowell <noodles@earth.li>
*
* Copyright 2002 Project Purple
+ *
+ * $Id: armor.c,v 1.8 2003/11/01 19:23:38 noodles Exp $
*/
#include <assert.h>
state->putchar_func(state->ctx, 1, &c);
state->putchar_func(state->ctx, 1, (unsigned char *) "=");
state->putchar_func(state->ctx, 1, (unsigned char *) "=");
+ state->count += 3;
+ if ((state->count % ARMOR_WIDTH) == 0) {
+ state->putchar_func(state->ctx, 1,
+ (unsigned char *) "\n");
+ }
break;
case 2:
c = encode64((state->lastoctet & 0xF) << 2);
state->putchar_func(state->ctx, 1, &c);
state->putchar_func(state->ctx, 1, (unsigned char *) "=");
+ state->count += 2;
+ if ((state->count % ARMOR_WIDTH) == 0) {
+ state->putchar_func(state->ctx, 1,
+ (unsigned char *) "\n");
+ }
break;
}
state->crc24 &= 0xffffffL;
- state->putchar_func(state->ctx, 1, (unsigned char *) "\n");
+ if ((state->count % ARMOR_WIDTH) != 0) {
+ state->putchar_func(state->ctx, 1, (unsigned char *) "\n");
+ }
state->putchar_func(state->ctx, 1, (unsigned char *) "=");
c = encode64(state->crc24 >> 18);
state->putchar_func(state->ctx, 1, &c);
static void dearmor_finish(struct dearmor_context *state)
{
- // Check the checksum,
+ /*
+ * Check the checksum
+ */
state->crc24 &= 0xffffffL;
-// state->putchar_func(state->ctx, '\n');
-// state->putchar_func(state->ctx, '=');
-// state->putchar_func(state->ctx, encode64(state->crc24 >> 18));
-// state->putchar_func(state->ctx, encode64((state->crc24 >> 12) & 0x3F));
-// state->putchar_func(state->ctx, encode64((state->crc24 >> 6) & 0x3F));
-// state->putchar_func(state->ctx, encode64(state->crc24 & 0x3F));
-
+ /*
+ state->putchar_func(state->ctx, '\n');
+ state->putchar_func(state->ctx, '=');
+ state->putchar_func(state->ctx, encode64(state->crc24 >> 18));
+ state->putchar_func(state->ctx, encode64((state->crc24 >> 12) & 0x3F));
+ state->putchar_func(state->ctx, encode64((state->crc24 >> 6) & 0x3F));
+ state->putchar_func(state->ctx, encode64(state->crc24 & 0x3F));
+ */
}
/*
* Print armor header
*/
- putchar_func(ctx, sizeof("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),
+ putchar_func(ctx, sizeof("-----BEGIN PGP PUBLIC KEY BLOCK-----\n") - 1,
(unsigned char *) "-----BEGIN PGP PUBLIC KEY BLOCK-----\n");
- putchar_func(ctx, sizeof("Version: onak " VERSION "\n\n"),
+ putchar_func(ctx, sizeof("Version: onak " VERSION "\n\n") - 1,
(unsigned char *) "Version: onak " VERSION "\n\n");
armor_init(&armor_ctx);
/*
* Print armor footer
*/
- putchar_func(ctx, sizeof("-----END PGP PUBLIC KEY BLOCK-----\n"),
+ putchar_func(ctx, sizeof("-----END PGP PUBLIC KEY BLOCK-----\n") - 1,
(unsigned char *) "-----END PGP PUBLIC KEY BLOCK-----\n");
return 0;
dearmor_init(&dearmor_ctx);
dearmor_ctx.getchar_func = getchar_func;
dearmor_ctx.ctx = ctx;
- read_openpgp_stream(dearmor_getchar_c, &dearmor_ctx, packets);
+ read_openpgp_stream(dearmor_getchar_c, &dearmor_ctx,
+ packets, 0);
dearmor_finish(&dearmor_ctx);
- // TODO: Look for armor footer
+ /*
+ * TODO: Look for armor footer
+ */
}
return 0;