1 |
/* wptGPGMEData.cpp - WinPT specifc data extensions |
/* wptGPGMEData.cpp - WinPT specifc data extensions |
2 |
* Copyright (C) 2001-2005 Timo Schulz |
* Copyright (C) 2001-2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
30 |
#include "wptUtil.h" |
#include "wptUtil.h" |
31 |
#include "wptGPG.h" |
#include "wptGPG.h" |
32 |
|
|
33 |
|
|
34 |
/* Implement a word based line break. @inp is the input buffer |
/* Implement a word based line break. @inp is the input buffer |
35 |
and @wraplen is the maximal line length. |
and @wraplen is the maximal line length. |
36 |
Return value: the wrapped buffer on success. */ |
Return value: the wrapped buffer on success. */ |
144 |
} |
} |
145 |
|
|
146 |
|
|
147 |
|
static int |
148 |
|
is_armor_header (const char *line) |
149 |
|
{ |
150 |
|
const char *header[] = { |
151 |
|
"Version:", |
152 |
|
"Comment:", |
153 |
|
"Charset:", |
154 |
|
"Hash:", |
155 |
|
"MessageID", |
156 |
|
NULL |
157 |
|
}; |
158 |
|
int i; |
159 |
|
|
160 |
|
for (i=0; header[i] != NULL; i++) { |
161 |
|
if (!strncmp (line, header[i], strlen (header[i]))) |
162 |
|
return -1; |
163 |
|
} |
164 |
|
return 0; |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
/* Extract the plaintext data from the escaped data object @sig. |
/* Extract the plaintext data from the escaped data object @sig. |
170 |
The plaintxt is stored in @r_plain. |
The plaintxt is stored in @r_plain. |
171 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
185 |
|
|
186 |
while (gpg_data_readline (sig, line, 128) > 0) { |
while (gpg_data_readline (sig, line, 128) > 0) { |
187 |
if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) || |
if (!strncmp (line, "-----BEGIN PGP SIGNED MESSAGE", 29) || |
188 |
!strncmp (line, "Version:", 8) || |
is_armor_header (line)) |
|
!strncmp (line, "Comment:", 8) || |
|
|
!strncmp (line, "Charset:", 8) || |
|
|
!strncmp (line, "Hash:", 5) || |
|
|
!strncmp (line, "MessageID", 9)) |
|
189 |
continue; |
continue; |
190 |
if (strlen (line) <= 2) |
if (strlen (line) <= 2) |
191 |
break; /* parsed all headers, now we reached the body */ |
break; /* parsed all headers, now we reached the body */ |
192 |
} |
} |
193 |
/* XXX handle multi dash escaped sequences */ |
|
194 |
|
/* We just support 1 nesting level. */ |
195 |
while (gpg_data_readline (sig, line, 128) > 0 ) { |
while (gpg_data_readline (sig, line, 128) > 0 ) { |
196 |
if (!strncmp( line, "-----BEGIN PGP SIGNATURE", 24)) |
if (!strncmp( line, "-----BEGIN PGP SIGNATURE", 24)) |
197 |
break; /* end of plaintext */ |
break; /* end of plaintext */ |