- broken - reimplementing z85 decoder, using hyphens again, doesn't work yet...

This commit is contained in:
git@daemon.de
2014-03-01 11:58:10 +01:00
parent 32b24a08c5
commit b8552af5e9
11 changed files with 363 additions and 68 deletions

View File

@@ -8,6 +8,7 @@ extern "C" {
#include "pcp/config.h"
#include "pcp/base85.h"
#include "pcp/buffer.h"
#include "pcp/config.h"
#include "pcp/crypto.h"
#include "pcp/defines.h"
#include "pcp/digital_crc32.h"

View File

@@ -74,6 +74,15 @@ typedef unsigned int qbyte; /* Quad byte = 32 bits */
#define PCP_KEY_VERSION 6
#define PCP_KEY_PRIMITIVE "CURVE25519-ED25519-SALSA20-POLY1305"
typedef enum _ZBEGINS {
PCP_ENCRYPTED_FILE,
Z85_ENCODED_FILE,
ED25519_SIGNED_MESSAGE,
ED25519_SIGNATURE,
ED25519_CURVE29915_PUBLIC_KEY,
ED25519_CURVE29915_PRIVATE_KEY,
} ZBEGINS;
/**
\addtogroup KEYS
@{

View File

@@ -62,6 +62,7 @@ struct _pcp_stream_t {
Buffer *b; /**< The backend Buffer object */
Buffer *cache; /**< The caching Buffer object (for look ahead read) */
Buffer *next; /**< The caching Next-Buffer object (for look ahead read) */
Buffer *save; /**< Temporary buffer to backup overflow data */
uint8_t is_buffer; /**< Set to 1 if the backend is a Buffer */
uint8_t eof; /**< Set to 1 if EOF reached */
uint8_t err; /**< Set to 1 if an error occured */
@@ -71,9 +72,15 @@ struct _pcp_stream_t {
size_t linewr; /**< Used for Z85 writing, number of chars written on last line */
size_t blocksize; /**< Blocksize used for z85, if requested */
uint8_t is_output; /**< marks the stream as output stream */
uint8_t have_begin; /**< flag to indicate we already got the begin header, if any */
size_t pos; /**< remember i/o position */
};
typedef enum _PSVARS {
PSMAXLINE = 20000
} PSVARS;
/** The name used everywhere */
typedef struct _pcp_stream_t Pcpstream;
@@ -268,7 +275,7 @@ void ps_unarmor(Pcpstream *stream);
/* read from primary source, decode z85 and out into cache.
if buf != NULL, consider it as the start of encoded data
and remove headers and comments, then continue as normal. */
size_t ps_read_decode(Pcpstream *stream, void *buf, size_t bufsize);
size_t ps_read_decode(Pcpstream *stream);
/* determine if primary source is z85 encoded, put the data
read from it into the cache */
@@ -294,6 +301,16 @@ size_t ps_write_buf(Pcpstream *stream, Buffer *z);
/* tell if we really reached eof, caching or not. 1=eof, 0=ok */
int ps_left(Pcpstream *stream);
/** Read a line from the stream.
\param[in] stream The stream object.
\param[out] line Linecontent will be written to this Buffer.
\return Returns the number of bytes read or -1 if PSMAXLINE have been
reached or the input doesn't have any newlines at all.
*/
int ps_readline(Pcpstream *stream, Buffer *line);
#endif // HAVE_PCP_PCPSTEAM_H

View File

@@ -74,7 +74,7 @@ char *_lc(char *in);
\return Returns the offset or -1 of the offset were not found.
*/
size_t _findoffset(byte *bin, size_t binlen, char *sigstart, size_t hlen);
long int _findoffset(byte *bin, size_t binlen, char *sigstart, size_t hlen);
/** XOR an input buffer with another buffer.

View File

@@ -156,6 +156,15 @@ size_t _buffer_is_binary(byte *buf, size_t len);
*/
uint8_t _parse_zchar(Buffer *z, uint8_t c, uint8_t is_comment);
long int z85_header_startswith(Buffer *buf, char *what);
int z85_isheader(Buffer *buf);
int z85_isend(Buffer *buf);
int z85_isbegin(Buffer *buf);
int z85_iscomment(Buffer *buf);
int z85_isempty(Buffer *line);
#endif /* _HAVE_PCP_Z85_H */
/**@}*/