Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include <endianness.h> also in base64 #985

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading