mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 03:50:57 +01:00
changed z85 padding (incompatible to previous pcp versions!):
now we padd with zeroes as usual but append 4 bytes to the raw input, the last one indicates the pad count. It's always present, even if no padding occurred (the pad blob will then read 0000). This fixes the issue of earlier versions where trailing zeroes in the original input (between block boundaries) have been removed. Since we now add the pad counter, we know how many zeroes to remove. If the original chunk already ended with zeroes they will left untouched. Re-created all test keys/data to match the change. Also, the pcp_z85_encode() function now haves another flag doblock. If set to 1, the function does the 72 chars per line block creation itself, otherwise it just returns the z85 string without any newlines added. Required by pcpstream class.
This commit is contained in:
@@ -53,9 +53,9 @@ we pad the input with zeroes and remove them after decoding.
|
||||
the original pointer into it and adds a number of zeros so that the
|
||||
result has a size divisable by 4.
|
||||
|
||||
\param[in] src Unpadded data.
|
||||
\param[in] srclen Size of unpadded data.
|
||||
\param[in] dstlen Returned size of padded data (pointer to int).
|
||||
\param[in] src Unpadded data.
|
||||
\param[in] srclen Size of unpadded data.
|
||||
\param[out] dstlen Returned size of padded data (pointer to int).
|
||||
|
||||
\return Returns a pointer to the padded data.
|
||||
*/
|
||||
@@ -95,13 +95,14 @@ byte *pcp_z85_decode(PCPCTX *ptx, char *z85block, size_t *dstlen);
|
||||
It allocates the memory for the returned char pointer. The caller
|
||||
is responsible the free() it.
|
||||
|
||||
\param[in] raw Pointer to raw data.
|
||||
\param[in] srclen Size of the data.
|
||||
\param[in] dstlen Returned size of encoded data (pointer to int).
|
||||
\param[in] raw Pointer to raw data.
|
||||
\param[in] srclen Size of the data.
|
||||
\param[out] dstlen Returned size of encoded data (pointer to int).
|
||||
\param[in] doblock If set to 1, turn the encoded data into a 72 chars wide block.
|
||||
|
||||
\return Returns a string (char array) containing the Z85 encoded data.
|
||||
*/
|
||||
char *pcp_z85_encode(byte *raw, size_t srclen, size_t *dstlen);
|
||||
char *pcp_z85_encode(byte *raw, size_t srclen, size_t *dstlen, int doblock);
|
||||
|
||||
/** Read a Z85 encoded file.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user