* Jonathan McDowell <noodles@earth.li>
*
* Copyright 2002 Project Purple
- *
- * $Id: armor.c,v 1.7 2003/09/30 20:40:10 noodles Exp $
*/
-#include <assert.h>
#include <stdlib.h>
#include "armor.h"
#include "keystructs.h"
+#include "log.h"
#include "onak-conf.h"
#include "parsekey.h"
} else if (c == 63) {
c = '/';
} else {
- assert(c < 64);
+ log_assert(c < 64);
}
return c;
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);
unsigned char t;
int i;
- assert(ctx != NULL);
+ log_assert(ctx != NULL);
state = (struct armor_context *) ctx;
switch (state->curoctet++) {
unsigned char tmpc;
int i;
- assert(ctx != NULL);
+ log_assert(ctx != NULL);
state = (struct dearmor_context *) ctx;
*c = 0;