aboutsummaryrefslogtreecommitdiffstats
path: root/sm/base64.c
diff options
context:
space:
mode:
Diffstat (limited to 'sm/base64.c')
-rw-r--r--sm/base64.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/sm/base64.c b/sm/base64.c
index f6329c96b..1539e2a47 100644
--- a/sm/base64.c
+++ b/sm/base64.c
@@ -1,4 +1,4 @@
-/* base64.c
+/* base64.c
* Copyright (C) 2001, 2003, 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <unistd.h>
+#include <unistd.h>
#include <time.h>
#include <assert.h>
@@ -40,10 +40,10 @@
#endif
/* Data used by the reader callbacks. */
-struct reader_cb_parm_s
+struct reader_cb_parm_s
{
estream_t fp;
-
+
unsigned char line[1024];
int linelen;
int readpos;
@@ -61,7 +61,7 @@ struct reader_cb_parm_s
int stop_seen;
int might_be_smime;
- int eof_seen;
+ int eof_seen;
struct {
int idx;
@@ -72,12 +72,12 @@ struct reader_cb_parm_s
/* Data used by the writer callbacks. */
-struct writer_cb_parm_s
+struct writer_cb_parm_s
{
estream_t stream; /* Output stream. */
-
+
const char *pem_name;
-
+
int wrote_begin;
int did_finish;
@@ -105,33 +105,33 @@ struct base64_context_s {
/* The base-64 character list */
-static char bintoasc[64] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
+static char bintoasc[64] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
/* The reverse base-64 list */
static unsigned char asctobin[256] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
- 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
- 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
+ 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
+ 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
+ 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff
};
@@ -187,7 +187,7 @@ base64_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
parm->eof_seen = 1;
if (es_ferror (parm->fp))
return -1;
- break;
+ break;
}
parm->line[n++] = c;
if (c == '\n')
@@ -212,7 +212,7 @@ base64_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
{
/* wait for the header line */
parm->linelen = parm->readpos = 0;
- if (!parm->have_lf
+ if (!parm->have_lf
|| strncmp ((char*)parm->line, "-----BEGIN ", 11)
|| !strncmp ((char*)parm->line+11, "PGP ", 4))
goto next;
@@ -274,14 +274,14 @@ base64_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
parm->base64.stop_seen = 0;
parm->base64.idx = 0;
}
-
+
n = 0;
if (parm->is_pem || parm->is_base64)
- {
+ {
if (parm->is_pem && parm->have_lf
&& !strncmp ((char*)parm->line, "-----END ", 9))
- {
+ {
parm->identified = 0;
parm->linelen = parm->readpos = 0;
@@ -318,32 +318,32 @@ base64_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
if (c == '=')
{ /* pad character: stop */
if (idx == 1)
- buffer[n++] = val;
+ buffer[n++] = val;
parm->stop_seen = 1;
break;
}
- if( (c = asctobin[(c2=c)]) == 255 )
+ if( (c = asctobin[(c2=c)]) == 255 )
{
log_error (_("invalid radix64 character %02x skipped\n"),
c2);
continue;
}
- switch (idx)
+ switch (idx)
{
- case 0:
+ case 0:
val = c << 2;
break;
- case 1:
+ case 1:
val |= (c>>4)&3;
buffer[n++] = val;
val = (c<<4)&0xf0;
break;
- case 2:
+ case 2:
val |= (c>>2)&15;
buffer[n++] = val;
val = (c<<6)&0xc0;
break;
- case 3:
+ case 3:
val |= c&0x3f;
buffer[n++] = val;
break;
@@ -448,7 +448,7 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
es_putc (c, stream);
c = bintoasc[radbuf[2]&077];
es_putc (c, stream);
- if (++quad_count >= (64/4))
+ if (++quad_count >= (64/4))
{
es_fputs (LF, stream);
quad_count = 0;
@@ -508,8 +508,8 @@ base64_finish_write (struct writer_cb_parm_s *parm)
es_putc ('=', stream);
es_putc ('=', stream);
}
- else
- {
+ else
+ {
c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077];
es_putc (c, stream);
c = bintoasc[((radbuf[1] << 2) & 074) & 077];
@@ -517,7 +517,7 @@ base64_finish_write (struct writer_cb_parm_s *parm)
es_putc ('=', stream);
}
- if (++quad_count >= (64/4))
+ if (++quad_count >= (64/4))
{
es_fputs (LF, stream);
quad_count = 0;
@@ -614,7 +614,7 @@ gpgsm_destroy_reader (Base64Context ctx)
if (!ctx)
return;
- ksba_reader_release (ctx->u2.reader);
+ ksba_reader_release (ctx->u2.reader);
xfree (ctx);
}
@@ -678,7 +678,7 @@ int
gpgsm_finish_writer (Base64Context ctx)
{
struct writer_cb_parm_s *parm;
-
+
if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE);
parm = &ctx->u.wparm;