Skip to content

Commit

Permalink
Include <endianness.h> also in base64
Browse files Browse the repository at this point in the history
Without this, base64 decoder (used to encode/decrypt the PKeys)
does not work, resulting in division by zero
  • Loading branch information
th-otto authored and OmniBlade committed Mar 25, 2024
1 parent 77e2da0 commit 4ed8f34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion common/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "base64.h"
#include <stddef.h>
#include "endianness.h"

/*
** This is the magic padding character used to fill out the encoded data to a multiple of
Expand Down Expand Up @@ -425,4 +426,4 @@ implementations.
within base64-encoded parts of multipart entities because no hyphen
characters are used in the base64 encoding.
*/
*/
9 changes: 8 additions & 1 deletion common/mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ void XMP_DER_Decode(digit* result, unsigned char const* input, int precision)
}
}

#ifndef __BIG_ENDIAN__
// FIXME: does not for work big-endian
/***********************************************************************************************
* XMP_Encode -- Encode MP number into buffer. *
* *
Expand Down Expand Up @@ -308,6 +310,7 @@ unsigned XMP_Encode(unsigned char* to, unsigned tobytes, digit const* from, int

return (tobytes);
}
#endif

/***********************************************************************************************
* XMP_Encode -- Encode MP number into buffer as compactly as possible. *
Expand Down Expand Up @@ -358,7 +361,8 @@ unsigned XMP_Encode(unsigned char* to, digit const* from, int precision)
unsigned char* number_ptr;

unsigned char* const end = (unsigned char*)from;
for (number_ptr = (unsigned char*)end + precision - 1; number_ptr > (unsigned char*)end; number_ptr--) {
for (number_ptr = (unsigned char*)end + precision * sizeof(digit) - 1; number_ptr > (unsigned char*)end;
number_ptr--) {
if (*number_ptr != filler)
break;
}
Expand Down Expand Up @@ -922,6 +926,8 @@ unsigned XMP_Count_Bits(const digit* number, int precision)
return (total_bit_count);
}

#ifndef __BIG_ENDIAN__
// FIXME: does not work for big-endian
/***********************************************************************************************
* XMP_Count_Bytes -- Counts the number of precision bytes in MP number. *
* *
Expand Down Expand Up @@ -951,6 +957,7 @@ int XMP_Count_Bytes(const digit* number, int precision)
}
return (count);
}
#endif

/***********************************************************************************************
* XMP_Move -- Assign one MP number to another. *
Expand Down

0 comments on commit 4ed8f34

Please sign in to comment.