Make OST buildable w/ Apple Clang with -std=c++17. Changes are mostly avoiding conflict w/ std::byte, and replacing std::ptr_fun with lambdas, and getting rid of set_unexpected calls
This commit is contained in:
parent
ee71c537a8
commit
432efb34fb
|
@ -360,7 +360,7 @@ cFile::File_t cFile::Read(void* buffer, File_t nBytes) const //throw(eFile)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iBytesRead = fread(buffer, sizeof(byte), nBytes, mpData->mpCurrStream);
|
iBytesRead = fread(buffer, sizeof(uint8_t), nBytes, mpData->mpCurrStream);
|
||||||
if (ferror(mpData->mpCurrStream) != 0)
|
if (ferror(mpData->mpCurrStream) != 0)
|
||||||
{
|
{
|
||||||
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||||
|
@ -382,7 +382,7 @@ cFile::File_t cFile::Write(const void* buffer, File_t nBytes) //throw(eFile)
|
||||||
ASSERT(mpData->mpCurrStream != NULL);
|
ASSERT(mpData->mpCurrStream != NULL);
|
||||||
ASSERT(isWritable);
|
ASSERT(isWritable);
|
||||||
|
|
||||||
if ((actual_count = fwrite(buffer, sizeof(byte), nBytes, mpData->mpCurrStream)) < nBytes)
|
if ((actual_count = fwrite(buffer, sizeof(uint8_t), nBytes, mpData->mpCurrStream)) < nBytes)
|
||||||
throw eFileWrite(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
throw eFileWrite(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||||
else
|
else
|
||||||
return actual_count;
|
return actual_count;
|
||||||
|
|
|
@ -32,11 +32,11 @@
|
||||||
// hashtable.h : a template class for mapping tuples using TCHAR*'s
|
// hashtable.h : a template class for mapping tuples using TCHAR*'s
|
||||||
//
|
//
|
||||||
// implements cHashTable, which maps a key of arbitrary type to a value
|
// implements cHashTable, which maps a key of arbitrary type to a value
|
||||||
// of arbitrary type. The key data type MUST have the const byte*()
|
// of arbitrary type. The key data type MUST have the const uint8_t*()
|
||||||
// operator overloaded in order for this to work. TSTRINGS will always
|
// operator overloaded in order for this to work. TSTRINGS will always
|
||||||
// work as the key value because of the overloaded-template-function
|
// work as the key value because of the overloaded-template-function
|
||||||
//
|
//
|
||||||
// Note: Any overloaded const byte*() operator must return an
|
// Note: Any overloaded const uint8_t*() operator must return an
|
||||||
// length of key as well. see cDefaultConvert
|
// length of key as well. see cDefaultConvert
|
||||||
//
|
//
|
||||||
// IMPORTANT -- cDefaultConvert only works for pointers to objects
|
// IMPORTANT -- cDefaultConvert only works for pointers to objects
|
||||||
|
@ -85,26 +85,26 @@ template<> inline bool cDefaultCompare<TSTRING>::operator()(const TSTRING& lhs,
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Conversion function objects ... used by the hash table to locate the key in KEY_TYPE
|
// Conversion function objects ... used by the hash table to locate the key in KEY_TYPE
|
||||||
// into a byte* and a key length (for hashing purposes). The default implementation
|
// into a uint8_t* and a key length (for hashing purposes). The default implementation
|
||||||
// just does a cast. A specialization is also provided for TSTRINGs.
|
// just does a cast. A specialization is also provided for TSTRINGs.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T> class cDefaultConvert
|
template<class T> class cDefaultConvert
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const byte* operator()(const T& obj, int* const pcbKeyLen)
|
const uint8_t* operator()(const T& obj, int* const pcbKeyLen)
|
||||||
{
|
{
|
||||||
// HACK! TODO: in the interest of time, I've left this as it is.....
|
// HACK! TODO: in the interest of time, I've left this as it is.....
|
||||||
*pcbKeyLen = sizeof(TCHAR) * _tcslen(obj);
|
*pcbKeyLen = sizeof(TCHAR) * _tcslen(obj);
|
||||||
return (byte*)obj;
|
return (uint8_t*)obj;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// specialization for TSTRINGS
|
// specialization for TSTRINGS
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
template<> inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int* const pcbKeyLen)
|
template<> inline const uint8_t* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int* const pcbKeyLen)
|
||||||
{
|
{
|
||||||
*pcbKeyLen = sizeof(TCHAR) * obj.length();
|
*pcbKeyLen = sizeof(TCHAR) * obj.length();
|
||||||
return (byte*)obj.c_str();
|
return (uint8_t*)obj.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -113,8 +113,8 @@ template<> inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING
|
||||||
// VAL -- the value you want associated with that key
|
// VAL -- the value you want associated with that key
|
||||||
// CMP -- a function object that takes (KEY, KEY) and returns true if they
|
// CMP -- a function object that takes (KEY, KEY) and returns true if they
|
||||||
// are equal.
|
// are equal.
|
||||||
// CONVERTER -- function object that takes (KEY, int* pcbKeyLen) and returns a const byte*
|
// CONVERTER -- function object that takes (KEY, int* pcbKeyLen) and returns a const uint8_t*
|
||||||
// ( points to start of key ) and a byte length (in pcbKeyLen) that tells the hashtable
|
// ( points to start of key ) and a uint8_t length (in pcbKeyLen) that tells the hashtable
|
||||||
// how long the key is
|
// how long the key is
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// these were moved outside of the class because it sucks to have to name the class with template parameters
|
// these were moved outside of the class because it sucks to have to name the class with template parameters
|
||||||
|
@ -510,7 +510,7 @@ uint32 cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Hash(const KEY_TYP
|
||||||
{
|
{
|
||||||
CONVERTER converter;
|
CONVERTER converter;
|
||||||
int len;
|
int len;
|
||||||
const byte* pb = converter(key, &len); //locates key
|
const uint8_t* pb = converter(key, &len); //locates key
|
||||||
uint32 hindex;
|
uint32 hindex;
|
||||||
|
|
||||||
hindex = *pb;
|
hindex = *pb;
|
||||||
|
|
|
@ -222,27 +222,27 @@ static uint8 padding[128] = { /* constants for padding */
|
||||||
#define rotate_right(x, n) (((x) >> (n)) | ((x) << (32-(n))))
|
#define rotate_right(x, n) (((x) >> (n)) | ((x) << (32-(n))))
|
||||||
|
|
||||||
#define FF_1(x7, x6, x5, x4, x3, x2, x1, x0, w) { \
|
#define FF_1(x7, x6, x5, x4, x3, x2, x1, x0, w) { \
|
||||||
register haval_word temp = Fphi_1(x6, x5, x4, x3, x2, x1, x0); \
|
haval_word temp = Fphi_1(x6, x5, x4, x3, x2, x1, x0); \
|
||||||
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w); \
|
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FF_2(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
#define FF_2(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
||||||
register haval_word temp = Fphi_2(x6, x5, x4, x3, x2, x1, x0); \
|
haval_word temp = Fphi_2(x6, x5, x4, x3, x2, x1, x0); \
|
||||||
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FF_3(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
#define FF_3(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
||||||
register haval_word temp = Fphi_3(x6, x5, x4, x3, x2, x1, x0); \
|
haval_word temp = Fphi_3(x6, x5, x4, x3, x2, x1, x0); \
|
||||||
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FF_4(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
#define FF_4(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
||||||
register haval_word temp = Fphi_4(x6, x5, x4, x3, x2, x1, x0); \
|
haval_word temp = Fphi_4(x6, x5, x4, x3, x2, x1, x0); \
|
||||||
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FF_5(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
#define FF_5(x7, x6, x5, x4, x3, x2, x1, x0, w, c) { \
|
||||||
register haval_word temp = Fphi_5(x6, x5, x4, x3, x2, x1, x0); \
|
haval_word temp = Fphi_5(x6, x5, x4, x3, x2, x1, x0); \
|
||||||
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
(x7) = rotate_right(temp, 7) + rotate_right((x7), 11) + (w) + (c); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ void haval_end (haval_state* state, uint8 final_fpt[FPTLEN >> 3])
|
||||||
/* hash a 32-word block */
|
/* hash a 32-word block */
|
||||||
void haval_hash_block (haval_state* state)
|
void haval_hash_block (haval_state* state)
|
||||||
{
|
{
|
||||||
register haval_word t0 = state->fingerprint[0], /* make use of */
|
haval_word t0 = state->fingerprint[0], /* make use of */
|
||||||
t1 = state->fingerprint[1], /* internal registers */
|
t1 = state->fingerprint[1], /* internal registers */
|
||||||
t2 = state->fingerprint[2],
|
t2 = state->fingerprint[2],
|
||||||
t3 = state->fingerprint[3],
|
t3 = state->fingerprint[3],
|
||||||
|
|
|
@ -227,7 +227,7 @@ char *getenv(); /* get variable from environment */
|
||||||
char *str;
|
char *str;
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
register char *p; /* temp pointer */
|
char *p; /* temp pointer */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* allocate space for the string, and copy if successful
|
* allocate space for the string, and copy if successful
|
||||||
|
@ -253,7 +253,7 @@ char **old;
|
||||||
int *sz_alloc;
|
int *sz_alloc;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int i; /* counter in a for loop */
|
int i; /* counter in a for loop */
|
||||||
union xyzzy x; /* used to cast malloc properly */
|
union xyzzy x; /* used to cast malloc properly */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -284,8 +284,8 @@ static int initenv(void)
|
||||||
static int initenv()
|
static int initenv()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register int rval;
|
int rval;
|
||||||
|
|
||||||
if (envp != NULL)
|
if (envp != NULL)
|
||||||
le_clobber();
|
le_clobber();
|
||||||
|
@ -306,7 +306,7 @@ void le_clobber(void)
|
||||||
void le_clobber()
|
void le_clobber()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int i; /* counter in a for loop */
|
int i; /* counter in a for loop */
|
||||||
union {
|
union {
|
||||||
char **ep;
|
char **ep;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -344,8 +344,8 @@ static int le_getenv(var)
|
||||||
char *var;
|
char *var;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int i; /* counter in a for loop */
|
int i; /* counter in a for loop */
|
||||||
register char *p, *q; /* used to compare two strings */
|
char *p, *q; /* used to compare two strings */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check for no environment
|
* check for no environment
|
||||||
|
@ -385,8 +385,8 @@ int le_set(env)
|
||||||
char *env;
|
char *env;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register char *p, *q; /* what is to be put into env */
|
char *p, *q; /* what is to be put into env */
|
||||||
register int n; /* where a previous definition is */
|
int n; /* where a previous definition is */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if you need to create the environment list
|
* see if you need to create the environment list
|
||||||
|
@ -475,7 +475,7 @@ int le_unset(env)
|
||||||
char *env;
|
char *env;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int i; /* counter in a for loop */
|
int i; /* counter in a for loop */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* delete it from the environment
|
* delete it from the environment
|
||||||
|
@ -595,8 +595,8 @@ static const char *shellenv(void)
|
||||||
static const char *shellenv()
|
static const char *shellenv()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int i; /* counter in a for loop */
|
int i; /* counter in a for loop */
|
||||||
register const char *shptr; /* points to shell name */
|
const char *shptr; /* points to shell name */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* error check; should never happen
|
* error check; should never happen
|
||||||
|
@ -631,9 +631,9 @@ char *cmd;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const char *argv[5]; /* argument list */
|
const char *argv[5]; /* argument list */
|
||||||
register const char *p; /* temoporary pointers */
|
const char *p; /* temoporary pointers */
|
||||||
register const char* shptr; /* the program to be run */
|
const char* shptr; /* the program to be run */
|
||||||
register int i; /* index number of child */
|
int i; /* index number of child */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if it's NULL, initialize it
|
* if it's NULL, initialize it
|
||||||
|
@ -684,10 +684,10 @@ char *mode;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const char *argv[5]; /* argument list */
|
const char *argv[5]; /* argument list */
|
||||||
register const char *p; /* temoporary pointers */
|
const char *p; /* temoporary pointers */
|
||||||
register const char *shptr; /* the program to be run */
|
const char *shptr; /* the program to be run */
|
||||||
FILE *fpa[3]; /* process communication descriptors */
|
FILE *fpa[3]; /* process communication descriptors */
|
||||||
register int indx; /* index number of child */
|
int indx; /* index number of child */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if anything is available
|
* see if anything is available
|
||||||
|
@ -733,8 +733,8 @@ int mpclose(fp)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int indx; /* used to look for corresponding pid */
|
int indx; /* used to look for corresponding pid */
|
||||||
register int rstatus; /* return status of command */
|
int rstatus; /* return status of command */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop until you find the right process
|
* loop until you find the right process
|
||||||
|
@ -771,9 +771,9 @@ FILE *fpa[];
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const char *argv[5]; /* argument list */
|
const char *argv[5]; /* argument list */
|
||||||
register const char *p; /* temoporary pointers */
|
const char *p; /* temoporary pointers */
|
||||||
register const char *shptr; /* the program to be run */
|
const char *shptr; /* the program to be run */
|
||||||
register int indx; /* index number of child */
|
int indx; /* index number of child */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if anything is available
|
* see if anything is available
|
||||||
|
@ -816,7 +816,7 @@ int indx;
|
||||||
FILE *fp[];
|
FILE *fp[];
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int rstatus; /* return status of command */
|
int rstatus; /* return status of command */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop until you find the right process
|
* loop until you find the right process
|
||||||
|
@ -850,7 +850,7 @@ char *argv[];
|
||||||
FILE *fpa[];
|
FILE *fpa[];
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
register int indx; /* index number of child */
|
int indx; /* index number of child */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if anything is available
|
* see if anything is available
|
||||||
|
@ -910,9 +910,9 @@ int mask;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int p[3][2]; /* pipes to/from child */
|
int p[3][2]; /* pipes to/from child */
|
||||||
register int i; /* counter in for loop */
|
int i; /* counter in for loop */
|
||||||
register int ch_pid; /* child PID */
|
int ch_pid; /* child PID */
|
||||||
register int euid, egid; /* in case reset[gu]id is -1 */
|
int euid, egid; /* in case reset[gu]id is -1 */
|
||||||
/*
|
/*
|
||||||
* create 1 pipe for each of standard input, output, error
|
* create 1 pipe for each of standard input, output, error
|
||||||
*/
|
*/
|
||||||
|
@ -1029,7 +1029,7 @@ int pid;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
register int r; /* PID of process just exited */
|
int r; /* PID of process just exited */
|
||||||
int status; /* status of wait call */
|
int status; /* status of wait call */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -84,10 +84,10 @@
|
||||||
class tss_hash_key_convert
|
class tss_hash_key_convert
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const byte* operator()(const wc16_string& s, int* const pcbKeyLen)
|
const uint8_t* operator()(const wc16_string& s, int* const pcbKeyLen)
|
||||||
{
|
{
|
||||||
*pcbKeyLen = sizeof(WCHAR16) * s.length();
|
*pcbKeyLen = sizeof(WCHAR16) * s.length();
|
||||||
return (byte*)s.c_str();
|
return (uint8_t*)s.c_str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,9 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// standard TSS types
|
// standard TSS types
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#if __cplusplus < 201103L
|
||||||
typedef unsigned char byte; // platform-independent
|
typedef unsigned char uint8_t
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef signed char int8;
|
typedef signed char int8;
|
||||||
typedef short int16;
|
typedef short int16;
|
||||||
|
|
|
@ -6,19 +6,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
unsigned int DERLengthEncode(unsigned int length, byte *output)
|
unsigned int DERLengthEncode(unsigned int length, uint8_t *output)
|
||||||
{
|
{
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
if (length <= 0x7f)
|
if (length <= 0x7f)
|
||||||
{
|
{
|
||||||
output[i++] = byte(length);
|
output[i++] = uint8_t(length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output[i++] = byte(BytePrecision(length) | 0x80);
|
output[i++] = uint8_t(BytePrecision(length) | 0x80);
|
||||||
for (int j=BytePrecision(length); j; --j)
|
for (int j=BytePrecision(length); j; --j)
|
||||||
{
|
{
|
||||||
output[i++] = byte (length >> (j-1)*8);
|
output[i++] = uint8_t (length >> (j-1)*8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -26,7 +26,7 @@ unsigned int DERLengthEncode(unsigned int length, byte *output)
|
||||||
|
|
||||||
unsigned int DERLengthEncode(unsigned int length, BufferedTransformation &bt)
|
unsigned int DERLengthEncode(unsigned int length, BufferedTransformation &bt)
|
||||||
{
|
{
|
||||||
byte buf[10]; // should be more than enough
|
uint8_t buf[10]; // should be more than enough
|
||||||
unsigned int i = DERLengthEncode(length, buf);
|
unsigned int i = DERLengthEncode(length, buf);
|
||||||
assert(i <= 10);
|
assert(i <= 10);
|
||||||
bt.Put(buf, i);
|
bt.Put(buf, i);
|
||||||
|
@ -35,7 +35,7 @@ unsigned int DERLengthEncode(unsigned int length, BufferedTransformation &bt)
|
||||||
|
|
||||||
bool BERLengthDecode(BufferedTransformation &bt, unsigned int &length)
|
bool BERLengthDecode(BufferedTransformation &bt, unsigned int &length)
|
||||||
{
|
{
|
||||||
byte b;
|
uint8_t b;
|
||||||
|
|
||||||
if (!bt.Get(b))
|
if (!bt.Get(b))
|
||||||
BERDecodeError();
|
BERDecodeError();
|
||||||
|
@ -76,7 +76,7 @@ bool BERLengthDecode(BufferedTransformation &bt, unsigned int &length)
|
||||||
BERSequenceDecoder::BERSequenceDecoder(BufferedTransformation &inQueue)
|
BERSequenceDecoder::BERSequenceDecoder(BufferedTransformation &inQueue)
|
||||||
: inQueue(inQueue)
|
: inQueue(inQueue)
|
||||||
{
|
{
|
||||||
byte b;
|
uint8_t b;
|
||||||
if (!inQueue.Get(b) || b != (SEQUENCE | CONSTRUCTED))
|
if (!inQueue.Get(b) || b != (SEQUENCE | CONSTRUCTED))
|
||||||
BERDecodeError();
|
BERDecodeError();
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
enum ASNTag {INTEGER=0x02, BIT_STRING=0x03, SEQUENCE=0x10};
|
enum ASNTag {INTEGER=0x02, BIT_STRING=0x03, SEQUENCE=0x10};
|
||||||
enum ASNIdFlag {CONSTRUCTED = 0x20};
|
enum ASNIdFlag {CONSTRUCTED = 0x20};
|
||||||
|
|
||||||
unsigned int DERLengthEncode(unsigned int length, byte *output);
|
unsigned int DERLengthEncode(unsigned int length, uint8_t *output);
|
||||||
unsigned int DERLengthEncode(unsigned int length, BufferedTransformation &);
|
unsigned int DERLengthEncode(unsigned int length, BufferedTransformation &);
|
||||||
|
|
||||||
#ifdef THROW_EXCEPTIONS
|
#ifdef THROW_EXCEPTIONS
|
||||||
|
@ -27,16 +27,16 @@ public:
|
||||||
BERSequenceDecoder(BufferedTransformation &inQueue);
|
BERSequenceDecoder(BufferedTransformation &inQueue);
|
||||||
~BERSequenceDecoder();
|
~BERSequenceDecoder();
|
||||||
|
|
||||||
void Put(byte) {}
|
void Put(uint8_t) {}
|
||||||
void Put(const byte *, unsigned int) {}
|
void Put(const uint8_t *, unsigned int) {}
|
||||||
|
|
||||||
unsigned long MaxRetrieveable()
|
unsigned long MaxRetrieveable()
|
||||||
{return inQueue.MaxRetrieveable();}
|
{return inQueue.MaxRetrieveable();}
|
||||||
unsigned int Get(byte &outByte)
|
unsigned int Get(uint8_t &outByte)
|
||||||
{return inQueue.Get(outByte);}
|
{return inQueue.Get(outByte);}
|
||||||
unsigned int Get(byte *outString, unsigned int getMax)
|
unsigned int Get(uint8_t *outString, unsigned int getMax)
|
||||||
{return inQueue.Get(outString, getMax);}
|
{return inQueue.Get(outString, getMax);}
|
||||||
unsigned int Peek(byte &outByte) const
|
unsigned int Peek(uint8_t &outByte) const
|
||||||
{return inQueue.Peek(outByte);}
|
{return inQueue.Peek(outByte);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -82,7 +82,10 @@
|
||||||
|
|
||||||
// Make sure these typedefs are correct for your computer
|
// Make sure these typedefs are correct for your computer
|
||||||
|
|
||||||
typedef unsigned char byte;
|
#if __cplusplus < 201103L
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned short word16;
|
typedef unsigned short word16;
|
||||||
#if SIZEOF_INT == 4
|
#if SIZEOF_INT == 4
|
||||||
typedef unsigned int word32;
|
typedef unsigned int word32;
|
||||||
|
|
|
@ -9,7 +9,7 @@ unsigned int RandomNumberGenerator::GetBit()
|
||||||
return Parity(GetByte());
|
return Parity(GetByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomNumberGenerator::GetBlock(byte *output, unsigned int size)
|
void RandomNumberGenerator::GetBlock(uint8_t *output, unsigned int size)
|
||||||
{
|
{
|
||||||
while (size--)
|
while (size--)
|
||||||
*output++ = GetByte();
|
*output++ = GetByte();
|
||||||
|
@ -35,19 +35,19 @@ word32 RandomNumberGenerator::GetLong(word32 min, word32 max)
|
||||||
return value+min;
|
return value+min;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamCipher::ProcessString(byte *outString, const byte *inString, unsigned int length)
|
void StreamCipher::ProcessString(uint8_t *outString, const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
while(length--)
|
while(length--)
|
||||||
*outString++ = ProcessByte(*inString++);
|
*outString++ = ProcessByte(*inString++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamCipher::ProcessString(byte *inoutString, unsigned int length)
|
void StreamCipher::ProcessString(uint8_t *inoutString, unsigned int length)
|
||||||
{
|
{
|
||||||
for(;length--; inoutString++)
|
for(;length--; inoutString++)
|
||||||
*inoutString = ProcessByte(*inoutString);
|
*inoutString = ProcessByte(*inoutString);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageAuthenticationCode::Verify(const byte *macIn)
|
bool MessageAuthenticationCode::Verify(const uint8_t *macIn)
|
||||||
{
|
{
|
||||||
SecByteBlock mac(DigestSize());
|
SecByteBlock mac(DigestSize());
|
||||||
Final(mac);
|
Final(mac);
|
||||||
|
@ -82,11 +82,11 @@ void BufferedTransformation::PutShort(word16 value, bool highFirst)
|
||||||
if (highFirst)
|
if (highFirst)
|
||||||
{
|
{
|
||||||
Put(value>>8);
|
Put(value>>8);
|
||||||
Put(byte(value));
|
Put(uint8_t(value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Put(byte(value));
|
Put(uint8_t(value));
|
||||||
Put(value>>8);
|
Put(value>>8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,12 @@ void BufferedTransformation::PutLong(word32 value, bool highFirst)
|
||||||
if (highFirst)
|
if (highFirst)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; i++)
|
for (int i=0; i<4; i++)
|
||||||
Put(byte(value>>((3-i)*8)));
|
Put(uint8_t(value>>((3-i)*8)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; i++)
|
for (int i=0; i<4; i++)
|
||||||
Put(byte(value>>(i*8)));
|
Put(uint8_t(value>>(i*8)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ int BufferedTransformation::GetShort(word16 &value, bool highFirst)
|
||||||
if (MaxRetrieveable()<2)
|
if (MaxRetrieveable()<2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
byte buf[2];
|
uint8_t buf[2];
|
||||||
Get(buf, 2);
|
Get(buf, 2);
|
||||||
|
|
||||||
if (highFirst)
|
if (highFirst)
|
||||||
|
@ -126,7 +126,7 @@ int BufferedTransformation::GetLong(word32 &value, bool highFirst)
|
||||||
if (MaxRetrieveable()<4)
|
if (MaxRetrieveable()<4)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
byte buf[4];
|
uint8_t buf[4];
|
||||||
Get(buf, 4);
|
Get(buf, 4);
|
||||||
|
|
||||||
if (highFirst)
|
if (highFirst)
|
||||||
|
@ -139,7 +139,7 @@ int BufferedTransformation::GetLong(word32 &value, bool highFirst)
|
||||||
|
|
||||||
unsigned int BufferedTransformation::Skip(unsigned int skipMax)
|
unsigned int BufferedTransformation::Skip(unsigned int skipMax)
|
||||||
{
|
{
|
||||||
byte b;
|
uint8_t b;
|
||||||
unsigned int skipActual=0;
|
unsigned int skipActual=0;
|
||||||
|
|
||||||
while (skipMax-- && Get(b))
|
while (skipMax-- && Get(b))
|
||||||
|
@ -163,7 +163,7 @@ unsigned int PK_FixedLengthCryptoSystem::CipherTextLength(unsigned int plainText
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PK_FixedLengthDecryptor::Decrypt(const byte *cipherText, unsigned int cipherTextLength, byte *plainText)
|
unsigned int PK_FixedLengthDecryptor::Decrypt(const uint8_t *cipherText, unsigned int cipherTextLength, uint8_t *plainText)
|
||||||
{
|
{
|
||||||
if (cipherTextLength != CipherTextLength())
|
if (cipherTextLength != CipherTextLength())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -171,7 +171,7 @@ unsigned int PK_FixedLengthDecryptor::Decrypt(const byte *cipherText, unsigned i
|
||||||
return Decrypt(cipherText, plainText);
|
return Decrypt(cipherText, plainText);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PK_VerifierWithRecovery::Verify(const byte *message, unsigned int messageLength, const byte *signature)
|
bool PK_VerifierWithRecovery::Verify(const uint8_t *message, unsigned int messageLength, const uint8_t *signature)
|
||||||
{
|
{
|
||||||
SecByteBlock recovered(MaxMessageLength());
|
SecByteBlock recovered(MaxMessageLength());
|
||||||
unsigned int rLen = Recover(signature, recovered);
|
unsigned int rLen = Recover(signature, recovered);
|
||||||
|
|
|
@ -53,11 +53,11 @@ public:
|
||||||
|
|
||||||
/// encrypt or decrypt one block in place
|
/// encrypt or decrypt one block in place
|
||||||
//* Precondition: size of inoutBlock == BlockSize().
|
//* Precondition: size of inoutBlock == BlockSize().
|
||||||
virtual void ProcessBlock(byte *inoutBlock) =0;
|
virtual void ProcessBlock(uint8_t *inoutBlock) =0;
|
||||||
|
|
||||||
/// encrypt or decrypt one block, may assume inBlock != outBlock
|
/// encrypt or decrypt one block, may assume inBlock != outBlock
|
||||||
//* Precondition: size of inBlock and outBlock == BlockSize().
|
//* Precondition: size of inBlock and outBlock == BlockSize().
|
||||||
virtual void ProcessBlock(const byte *inBlock, byte *outBlock) =0;
|
virtual void ProcessBlock(const uint8_t *inBlock, uint8_t *outBlock) =0;
|
||||||
|
|
||||||
/// block size of the cipher in bytes
|
/// block size of the cipher in bytes
|
||||||
virtual unsigned int BlockSize() const =0;
|
virtual unsigned int BlockSize() const =0;
|
||||||
|
@ -73,12 +73,12 @@ public:
|
||||||
virtual ~StreamCipher() {}
|
virtual ~StreamCipher() {}
|
||||||
|
|
||||||
/// encrypt or decrypt one byte
|
/// encrypt or decrypt one byte
|
||||||
virtual byte ProcessByte(byte input) =0;
|
virtual uint8_t ProcessByte(uint8_t input) =0;
|
||||||
|
|
||||||
/// encrypt or decrypt an array of bytes of specified length in place
|
/// encrypt or decrypt an array of bytes of specified length in place
|
||||||
virtual void ProcessString(byte *inoutString, unsigned int length);
|
virtual void ProcessString(uint8_t *inoutString, unsigned int length);
|
||||||
/// encrypt or decrypt an array of bytes of specified length, may assume inString != outString
|
/// encrypt or decrypt an array of bytes of specified length, may assume inString != outString
|
||||||
virtual void ProcessString(byte *outString, const byte *inString, unsigned int length);
|
virtual void ProcessString(uint8_t *outString, const uint8_t *inString, unsigned int length);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for random access stream ciphers
|
/// abstract base class for random access stream ciphers
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
virtual ~RandomNumberGenerator() {}
|
virtual ~RandomNumberGenerator() {}
|
||||||
|
|
||||||
/// generate new random byte and return it
|
/// generate new random byte and return it
|
||||||
virtual byte GetByte() =0;
|
virtual uint8_t GetByte() =0;
|
||||||
|
|
||||||
/// generate new random bit and return it
|
/// generate new random bit and return it
|
||||||
/** Default implementation is to call GetByte() and return its parity. */
|
/** Default implementation is to call GetByte() and return its parity. */
|
||||||
|
@ -117,7 +117,7 @@ public:
|
||||||
|
|
||||||
/// generate random array of bytes
|
/// generate random array of bytes
|
||||||
//* Default implementation is to call GetByte size times.
|
//* Default implementation is to call GetByte size times.
|
||||||
virtual void GetBlock(byte *output, unsigned int size);
|
virtual void GetBlock(uint8_t *output, unsigned int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// randomly shuffle the specified array, resulting permutation is uniformly distributed
|
/// randomly shuffle the specified array, resulting permutation is uniformly distributed
|
||||||
|
@ -141,18 +141,18 @@ public:
|
||||||
virtual ~HashModule() {}
|
virtual ~HashModule() {}
|
||||||
|
|
||||||
/// process more input
|
/// process more input
|
||||||
virtual void Update(const byte *input, unsigned int length) =0;
|
virtual void Update(const uint8_t *input, unsigned int length) =0;
|
||||||
|
|
||||||
/*/ calculate hash for the current message (the concatenation of all
|
/*/ calculate hash for the current message (the concatenation of all
|
||||||
inputs passed in via Update()), then reinitialize the object */
|
inputs passed in via Update()), then reinitialize the object */
|
||||||
//* Precondition: size of digest == DigestSize().
|
//* Precondition: size of digest == DigestSize().
|
||||||
virtual void Final(byte *digest) =0;
|
virtual void Final(uint8_t *digest) =0;
|
||||||
|
|
||||||
/// size of the hash returned by Final()
|
/// size of the hash returned by Final()
|
||||||
virtual unsigned int DigestSize() const =0;
|
virtual unsigned int DigestSize() const =0;
|
||||||
|
|
||||||
/// use this if your input is short and you don't want to call Update() and Final() seperately
|
/// use this if your input is short and you don't want to call Update() and Final() seperately
|
||||||
virtual void CalculateDigest(byte *digest, const byte *input, int length)
|
virtual void CalculateDigest(uint8_t *digest, const uint8_t *input, int length)
|
||||||
{Update(input, length); Final(digest);}
|
{Update(input, length); Final(digest);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -173,10 +173,10 @@ public:
|
||||||
/// verify that mac is a valid MAC for the current message, then reinitialize the object
|
/// verify that mac is a valid MAC for the current message, then reinitialize the object
|
||||||
/** Default implementation is to call Final() and do a bitwise comparison
|
/** Default implementation is to call Final() and do a bitwise comparison
|
||||||
between its output and mac. */
|
between its output and mac. */
|
||||||
virtual bool Verify(const byte *mac);
|
virtual bool Verify(const uint8_t *mac);
|
||||||
|
|
||||||
/// use this if your input is short and you don't want to call Update() and Verify() seperately
|
/// use this if your input is short and you don't want to call Update() and Verify() seperately
|
||||||
virtual bool VerifyMAC(const byte *mac, const byte *input, int length)
|
virtual bool VerifyMAC(const uint8_t *mac, const uint8_t *input, int length)
|
||||||
{Update(input, length); return Verify(mac);}
|
{Update(input, length); return Verify(mac);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,9 +203,9 @@ public:
|
||||||
//@Man: INPUT
|
//@Man: INPUT
|
||||||
//@{
|
//@{
|
||||||
/// input a byte for processing
|
/// input a byte for processing
|
||||||
virtual void Put(byte inByte) =0;
|
virtual void Put(uint8_t inByte) =0;
|
||||||
/// input multiple bytes
|
/// input multiple bytes
|
||||||
virtual void Put(const byte *inString, unsigned int length) =0;
|
virtual void Put(const uint8_t *inString, unsigned int length) =0;
|
||||||
/// signal that no more input is available
|
/// signal that no more input is available
|
||||||
virtual void InputFinished() {}
|
virtual void InputFinished() {}
|
||||||
|
|
||||||
|
@ -224,9 +224,9 @@ public:
|
||||||
virtual unsigned long MaxRetrieveable() =0;
|
virtual unsigned long MaxRetrieveable() =0;
|
||||||
|
|
||||||
/// try to retrieve a single byte
|
/// try to retrieve a single byte
|
||||||
virtual unsigned int Get(byte &outByte) =0;
|
virtual unsigned int Get(uint8_t &outByte) =0;
|
||||||
/// try to retrieve multiple bytes
|
/// try to retrieve multiple bytes
|
||||||
virtual unsigned int Get(byte *outString, unsigned int getMax) =0;
|
virtual unsigned int Get(uint8_t *outString, unsigned int getMax) =0;
|
||||||
|
|
||||||
/// try to retrieve a 16-bit word, big-endian or little-endian depending on highFirst
|
/// try to retrieve a 16-bit word, big-endian or little-endian depending on highFirst
|
||||||
int GetShort(word16 &value, bool highFirst=true);
|
int GetShort(word16 &value, bool highFirst=true);
|
||||||
|
@ -239,7 +239,7 @@ public:
|
||||||
virtual unsigned int TransferTo(BufferedTransformation &target, unsigned int transferMax);
|
virtual unsigned int TransferTo(BufferedTransformation &target, unsigned int transferMax);
|
||||||
|
|
||||||
/// peek at the next byte without removing it from the output buffer
|
/// peek at the next byte without removing it from the output buffer
|
||||||
virtual unsigned int Peek(byte &outByte) const =0;
|
virtual unsigned int Peek(uint8_t &outByte) const =0;
|
||||||
|
|
||||||
/// discard some bytes from the output buffer
|
/// discard some bytes from the output buffer
|
||||||
unsigned int Skip(unsigned int skipMax);
|
unsigned int Skip(unsigned int skipMax);
|
||||||
|
@ -299,7 +299,7 @@ public:
|
||||||
\item size of cipherText == CipherTextLength(plainTextLength)
|
\item size of cipherText == CipherTextLength(plainTextLength)
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
*/
|
*/
|
||||||
virtual void Encrypt(RandomNumberGenerator &rng, const byte *plainText, unsigned int plainTextLength, byte *cipherText) =0;
|
virtual void Encrypt(RandomNumberGenerator &rng, const uint8_t *plainText, unsigned int plainTextLength, uint8_t *cipherText) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for public-key decryptors
|
/// abstract base class for public-key decryptors
|
||||||
|
@ -317,7 +317,7 @@ public:
|
||||||
The function returns the actual length of the plaintext, or 0
|
The function returns the actual length of the plaintext, or 0
|
||||||
if decryption fails.
|
if decryption fails.
|
||||||
*/
|
*/
|
||||||
virtual unsigned int Decrypt(const byte *cipherText, unsigned int cipherTextLength, byte *plainText) =0;
|
virtual unsigned int Decrypt(const uint8_t *cipherText, unsigned int cipherTextLength, uint8_t *plainText) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for encryptors and decryptors with fixed length ciphertext
|
/// abstract base class for encryptors and decryptors with fixed length ciphertext
|
||||||
|
@ -361,9 +361,9 @@ public:
|
||||||
The function returns the actual length of the plaintext, or 0
|
The function returns the actual length of the plaintext, or 0
|
||||||
if decryption fails.
|
if decryption fails.
|
||||||
*/
|
*/
|
||||||
virtual unsigned int Decrypt(const byte *cipherText, byte *plainText) =0;
|
virtual unsigned int Decrypt(const uint8_t *cipherText, uint8_t *plainText) =0;
|
||||||
|
|
||||||
unsigned int Decrypt(const byte *cipherText, unsigned int cipherTextLength, byte *plainText);
|
unsigned int Decrypt(const uint8_t *cipherText, unsigned int cipherTextLength, uint8_t *plainText);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for public-key signers and verifiers
|
/// abstract base class for public-key signers and verifiers
|
||||||
|
@ -402,7 +402,7 @@ public:
|
||||||
\item size of signature == SignatureLength()
|
\item size of signature == SignatureLength()
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
*/
|
*/
|
||||||
virtual void Sign(RandomNumberGenerator &rng, const byte *message, unsigned int messageLen, byte *signature) =0;
|
virtual void Sign(RandomNumberGenerator &rng, const uint8_t *message, unsigned int messageLen, uint8_t *signature) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for public-key verifiers
|
/// abstract base class for public-key verifiers
|
||||||
|
@ -420,7 +420,7 @@ public:
|
||||||
\item length of signature == SignatureLength()
|
\item length of signature == SignatureLength()
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
*/
|
*/
|
||||||
virtual bool Verify(const byte *message, unsigned int messageLen, const byte *sig) =0;
|
virtual bool Verify(const uint8_t *message, unsigned int messageLen, const uint8_t *sig) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for public-key verifiers with recovery
|
/// abstract base class for public-key verifiers with recovery
|
||||||
|
@ -439,9 +439,9 @@ public:
|
||||||
\item size of recoveredMessage == MaxMessageLength()
|
\item size of recoveredMessage == MaxMessageLength()
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
*/
|
*/
|
||||||
virtual unsigned int Recover(const byte *signature, byte *recoveredMessage) =0;
|
virtual unsigned int Recover(const uint8_t *signature, uint8_t *recoveredMessage) =0;
|
||||||
|
|
||||||
bool Verify(const byte *message, unsigned int messageLen, const byte *signature);
|
bool Verify(const uint8_t *message, unsigned int messageLen, const uint8_t *signature);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for key agreement protocols
|
/// abstract base class for key agreement protocols
|
||||||
|
@ -471,7 +471,7 @@ public:
|
||||||
|
|
||||||
/// produce public value
|
/// produce public value
|
||||||
//* Precondition: size of publicValue == PublicValueLength()
|
//* Precondition: size of publicValue == PublicValueLength()
|
||||||
virtual void Setup(RandomNumberGenerator &rng, byte *publicValue) =0;
|
virtual void Setup(RandomNumberGenerator &rng, uint8_t *publicValue) =0;
|
||||||
|
|
||||||
/// calculate agreed key given other party's public value
|
/// calculate agreed key given other party's public value
|
||||||
/** Precondition:
|
/** Precondition:
|
||||||
|
@ -480,7 +480,7 @@ public:
|
||||||
\item size of agreedKey == AgreedKeyLength()
|
\item size of agreedKey == AgreedKeyLength()
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
*/
|
*/
|
||||||
virtual void Agree(const byte *otherPublicValue, byte *agreedKey) const =0;
|
virtual void Agree(const uint8_t *otherPublicValue, uint8_t *agreedKey) const =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// abstract base class for all objects that support precomputation
|
/// abstract base class for all objects that support precomputation
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*/
|
*/
|
||||||
#ifdef notdef
|
#ifdef notdef
|
||||||
/* initial permutation IP */
|
/* initial permutation IP */
|
||||||
static byte ip[] = {
|
static uint8_t ip[] = {
|
||||||
58, 50, 42, 34, 26, 18, 10, 2,
|
58, 50, 42, 34, 26, 18, 10, 2,
|
||||||
60, 52, 44, 36, 28, 20, 12, 4,
|
60, 52, 44, 36, 28, 20, 12, 4,
|
||||||
62, 54, 46, 38, 30, 22, 14, 6,
|
62, 54, 46, 38, 30, 22, 14, 6,
|
||||||
|
@ -40,7 +40,7 @@ static byte ip[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* final permutation IP^-1 */
|
/* final permutation IP^-1 */
|
||||||
static byte fp[] = {
|
static uint8_t fp[] = {
|
||||||
40, 8, 48, 16, 56, 24, 64, 32,
|
40, 8, 48, 16, 56, 24, 64, 32,
|
||||||
39, 7, 47, 15, 55, 23, 63, 31,
|
39, 7, 47, 15, 55, 23, 63, 31,
|
||||||
38, 6, 46, 14, 54, 22, 62, 30,
|
38, 6, 46, 14, 54, 22, 62, 30,
|
||||||
|
@ -51,7 +51,7 @@ static byte fp[] = {
|
||||||
33, 1, 41, 9, 49, 17, 57, 25
|
33, 1, 41, 9, 49, 17, 57, 25
|
||||||
};
|
};
|
||||||
/* expansion operation matrix */
|
/* expansion operation matrix */
|
||||||
static byte ei[] = {
|
static uint8_t ei[] = {
|
||||||
32, 1, 2, 3, 4, 5,
|
32, 1, 2, 3, 4, 5,
|
||||||
4, 5, 6, 7, 8, 9,
|
4, 5, 6, 7, 8, 9,
|
||||||
8, 9, 10, 11, 12, 13,
|
8, 9, 10, 11, 12, 13,
|
||||||
|
@ -62,7 +62,7 @@ static byte ei[] = {
|
||||||
28, 29, 30, 31, 32, 1
|
28, 29, 30, 31, 32, 1
|
||||||
};
|
};
|
||||||
/* The (in)famous S-boxes */
|
/* The (in)famous S-boxes */
|
||||||
static byte sbox[8][64] = {
|
static uint8_t sbox[8][64] = {
|
||||||
/* S1 */
|
/* S1 */
|
||||||
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
|
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
|
||||||
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
|
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
|
||||||
|
@ -113,7 +113,7 @@ static byte sbox[8][64] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 32-bit permutation function P used on the output of the S-boxes */
|
/* 32-bit permutation function P used on the output of the S-boxes */
|
||||||
static byte p32i[] = {
|
static uint8_t p32i[] = {
|
||||||
16, 7, 20, 21,
|
16, 7, 20, 21,
|
||||||
29, 12, 28, 17,
|
29, 12, 28, 17,
|
||||||
1, 15, 23, 26,
|
1, 15, 23, 26,
|
||||||
|
@ -126,7 +126,7 @@ static byte p32i[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* permuted choice table (key) */
|
/* permuted choice table (key) */
|
||||||
static const byte pc1[] = {
|
static const uint8_t pc1[] = {
|
||||||
57, 49, 41, 33, 25, 17, 9,
|
57, 49, 41, 33, 25, 17, 9,
|
||||||
1, 58, 50, 42, 34, 26, 18,
|
1, 58, 50, 42, 34, 26, 18,
|
||||||
10, 2, 59, 51, 43, 35, 27,
|
10, 2, 59, 51, 43, 35, 27,
|
||||||
|
@ -139,12 +139,12 @@ static const byte pc1[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* number left rotations of pc1 */
|
/* number left rotations of pc1 */
|
||||||
static const byte totrot[] = {
|
static const uint8_t totrot[] = {
|
||||||
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28
|
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28
|
||||||
};
|
};
|
||||||
|
|
||||||
/* permuted choice key (table) */
|
/* permuted choice key (table) */
|
||||||
static const byte pc2[] = {
|
static const uint8_t pc2[] = {
|
||||||
14, 17, 11, 24, 1, 5,
|
14, 17, 11, 24, 1, 5,
|
||||||
3, 28, 15, 6, 21, 10,
|
3, 28, 15, 6, 21, 10,
|
||||||
23, 19, 12, 4, 26, 8,
|
23, 19, 12, 4, 26, 8,
|
||||||
|
@ -163,14 +163,14 @@ static const int bytebit[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Set key (initialize key schedule array) */
|
/* Set key (initialize key schedule array) */
|
||||||
DES::DES(const byte *key, CipherDir dir)
|
DES::DES(const uint8_t *key, CipherDir dir)
|
||||||
: k(32)
|
: k(32)
|
||||||
{
|
{
|
||||||
SecByteBlock buffer(56+56+8);
|
SecByteBlock buffer(56+56+8);
|
||||||
byte *const pc1m=buffer; /* place to modify pc1 into */
|
uint8_t *const pc1m=buffer; /* place to modify pc1 into */
|
||||||
byte *const pcr=pc1m+56; /* place to rotate pc1 into */
|
uint8_t *const pcr=pc1m+56; /* place to rotate pc1 into */
|
||||||
byte *const ks=pcr+56;
|
uint8_t *const ks=pcr+56;
|
||||||
register unsigned int i,j,l;
|
unsigned int i,j,l;
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
for (j=0; j<56; j++) { /* convert pc1 to bits of key */
|
for (j=0; j<56; j++) { /* convert pc1 to bits of key */
|
||||||
|
@ -311,7 +311,7 @@ inline void FPERM(word32 &left, word32 &right)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt or decrypt a block of data in ECB mode
|
// Encrypt or decrypt a block of data in ECB mode
|
||||||
void DES::ProcessBlock(const byte *inBlock, byte * outBlock)
|
void DES::ProcessBlock(const uint8_t *inBlock, uint8_t * outBlock)
|
||||||
{
|
{
|
||||||
word32 l,r,work;
|
word32 l,r,work;
|
||||||
|
|
||||||
|
@ -363,56 +363,56 @@ void DES::ProcessBlock(const byte *inBlock, byte * outBlock)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DES_EDE_Encryption::ProcessBlock(byte *inoutBlock)
|
void DES_EDE_Encryption::ProcessBlock(uint8_t *inoutBlock)
|
||||||
{
|
{
|
||||||
e.ProcessBlock(inoutBlock);
|
e.ProcessBlock(inoutBlock);
|
||||||
d.ProcessBlock(inoutBlock);
|
d.ProcessBlock(inoutBlock);
|
||||||
e.ProcessBlock(inoutBlock);
|
e.ProcessBlock(inoutBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DES_EDE_Encryption::ProcessBlock(const byte *inBlock, byte *outBlock)
|
void DES_EDE_Encryption::ProcessBlock(const uint8_t *inBlock, uint8_t *outBlock)
|
||||||
{
|
{
|
||||||
e.ProcessBlock(inBlock, outBlock);
|
e.ProcessBlock(inBlock, outBlock);
|
||||||
d.ProcessBlock(outBlock);
|
d.ProcessBlock(outBlock);
|
||||||
e.ProcessBlock(outBlock);
|
e.ProcessBlock(outBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DES_EDE_Decryption::ProcessBlock(byte *inoutBlock)
|
void DES_EDE_Decryption::ProcessBlock(uint8_t *inoutBlock)
|
||||||
{
|
{
|
||||||
d.ProcessBlock(inoutBlock);
|
d.ProcessBlock(inoutBlock);
|
||||||
e.ProcessBlock(inoutBlock);
|
e.ProcessBlock(inoutBlock);
|
||||||
d.ProcessBlock(inoutBlock);
|
d.ProcessBlock(inoutBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DES_EDE_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock)
|
void DES_EDE_Decryption::ProcessBlock(const uint8_t *inBlock, uint8_t *outBlock)
|
||||||
{
|
{
|
||||||
d.ProcessBlock(inBlock, outBlock);
|
d.ProcessBlock(inBlock, outBlock);
|
||||||
e.ProcessBlock(outBlock);
|
e.ProcessBlock(outBlock);
|
||||||
d.ProcessBlock(outBlock);
|
d.ProcessBlock(outBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TripleDES_Encryption::ProcessBlock(byte *inoutBlock)
|
void TripleDES_Encryption::ProcessBlock(uint8_t *inoutBlock)
|
||||||
{
|
{
|
||||||
e1.ProcessBlock(inoutBlock);
|
e1.ProcessBlock(inoutBlock);
|
||||||
d.ProcessBlock(inoutBlock);
|
d.ProcessBlock(inoutBlock);
|
||||||
e2.ProcessBlock(inoutBlock);
|
e2.ProcessBlock(inoutBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TripleDES_Encryption::ProcessBlock(const byte *inBlock, byte *outBlock)
|
void TripleDES_Encryption::ProcessBlock(const uint8_t *inBlock, uint8_t *outBlock)
|
||||||
{
|
{
|
||||||
e1.ProcessBlock(inBlock, outBlock);
|
e1.ProcessBlock(inBlock, outBlock);
|
||||||
d.ProcessBlock(outBlock);
|
d.ProcessBlock(outBlock);
|
||||||
e2.ProcessBlock(outBlock);
|
e2.ProcessBlock(outBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TripleDES_Decryption::ProcessBlock(byte *inoutBlock)
|
void TripleDES_Decryption::ProcessBlock(uint8_t *inoutBlock)
|
||||||
{
|
{
|
||||||
d1.ProcessBlock(inoutBlock);
|
d1.ProcessBlock(inoutBlock);
|
||||||
e.ProcessBlock(inoutBlock);
|
e.ProcessBlock(inoutBlock);
|
||||||
d2.ProcessBlock(inoutBlock);
|
d2.ProcessBlock(inoutBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TripleDES_Decryption::ProcessBlock(const byte *inBlock, byte *outBlock)
|
void TripleDES_Decryption::ProcessBlock(const uint8_t *inBlock, uint8_t *outBlock)
|
||||||
{
|
{
|
||||||
d1.ProcessBlock(inBlock, outBlock);
|
d1.ProcessBlock(inBlock, outBlock);
|
||||||
e.ProcessBlock(outBlock);
|
e.ProcessBlock(outBlock);
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
class DES : public BlockTransformation
|
class DES : public BlockTransformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DES(const byte *userKey, CipherDir);
|
DES(const uint8_t *userKey, CipherDir);
|
||||||
|
|
||||||
void ProcessBlock(const byte *inBlock, byte * outBlock);
|
void ProcessBlock(const uint8_t *inBlock, uint8_t * outBlock);
|
||||||
void ProcessBlock(byte * inoutBlock)
|
void ProcessBlock(uint8_t * inoutBlock)
|
||||||
{DES::ProcessBlock(inoutBlock, inoutBlock);}
|
{DES::ProcessBlock(inoutBlock, inoutBlock);}
|
||||||
|
|
||||||
enum {KEYLENGTH=8, BLOCKSIZE=8};
|
enum {KEYLENGTH=8, BLOCKSIZE=8};
|
||||||
|
@ -25,25 +25,25 @@ protected:
|
||||||
class DESEncryption : public DES
|
class DESEncryption : public DES
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DESEncryption(const byte * userKey)
|
DESEncryption(const uint8_t * userKey)
|
||||||
: DES (userKey, ENCRYPTION) {}
|
: DES (userKey, ENCRYPTION) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DESDecryption : public DES
|
class DESDecryption : public DES
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DESDecryption(const byte * userKey)
|
DESDecryption(const uint8_t * userKey)
|
||||||
: DES (userKey, DECRYPTION) {}
|
: DES (userKey, DECRYPTION) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DES_EDE_Encryption : public BlockTransformation
|
class DES_EDE_Encryption : public BlockTransformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DES_EDE_Encryption(const byte * userKey)
|
DES_EDE_Encryption(const uint8_t * userKey)
|
||||||
: e(userKey, ENCRYPTION), d(userKey + DES::KEYLENGTH, DECRYPTION) {}
|
: e(userKey, ENCRYPTION), d(userKey + DES::KEYLENGTH, DECRYPTION) {}
|
||||||
|
|
||||||
void ProcessBlock(const byte *inBlock, byte * outBlock);
|
void ProcessBlock(const uint8_t *inBlock, uint8_t * outBlock);
|
||||||
void ProcessBlock(byte * inoutBlock);
|
void ProcessBlock(uint8_t * inoutBlock);
|
||||||
|
|
||||||
enum {KEYLENGTH=16, BLOCKSIZE=8};
|
enum {KEYLENGTH=16, BLOCKSIZE=8};
|
||||||
unsigned int BlockSize() const {return BLOCKSIZE;}
|
unsigned int BlockSize() const {return BLOCKSIZE;}
|
||||||
|
@ -55,11 +55,11 @@ private:
|
||||||
class DES_EDE_Decryption : public BlockTransformation
|
class DES_EDE_Decryption : public BlockTransformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DES_EDE_Decryption(const byte * userKey)
|
DES_EDE_Decryption(const uint8_t * userKey)
|
||||||
: d(userKey, DECRYPTION), e(userKey + DES::KEYLENGTH, ENCRYPTION) {}
|
: d(userKey, DECRYPTION), e(userKey + DES::KEYLENGTH, ENCRYPTION) {}
|
||||||
|
|
||||||
void ProcessBlock(const byte *inBlock, byte * outBlock);
|
void ProcessBlock(const uint8_t *inBlock, uint8_t * outBlock);
|
||||||
void ProcessBlock(byte * inoutBlock);
|
void ProcessBlock(uint8_t * inoutBlock);
|
||||||
|
|
||||||
enum {KEYLENGTH=16, BLOCKSIZE=8};
|
enum {KEYLENGTH=16, BLOCKSIZE=8};
|
||||||
unsigned int BlockSize() const {return BLOCKSIZE;}
|
unsigned int BlockSize() const {return BLOCKSIZE;}
|
||||||
|
@ -71,12 +71,12 @@ private:
|
||||||
class TripleDES_Encryption : public BlockTransformation
|
class TripleDES_Encryption : public BlockTransformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TripleDES_Encryption(const byte * userKey)
|
TripleDES_Encryption(const uint8_t * userKey)
|
||||||
: e1(userKey, ENCRYPTION), d(userKey + DES::KEYLENGTH, DECRYPTION),
|
: e1(userKey, ENCRYPTION), d(userKey + DES::KEYLENGTH, DECRYPTION),
|
||||||
e2(userKey + 2*DES::KEYLENGTH, ENCRYPTION) {}
|
e2(userKey + 2*DES::KEYLENGTH, ENCRYPTION) {}
|
||||||
|
|
||||||
void ProcessBlock(const byte *inBlock, byte * outBlock);
|
void ProcessBlock(const uint8_t *inBlock, uint8_t * outBlock);
|
||||||
void ProcessBlock(byte * inoutBlock);
|
void ProcessBlock(uint8_t * inoutBlock);
|
||||||
|
|
||||||
enum {KEYLENGTH=24, BLOCKSIZE=8};
|
enum {KEYLENGTH=24, BLOCKSIZE=8};
|
||||||
unsigned int BlockSize() const {return BLOCKSIZE;}
|
unsigned int BlockSize() const {return BLOCKSIZE;}
|
||||||
|
@ -88,12 +88,12 @@ private:
|
||||||
class TripleDES_Decryption : public BlockTransformation
|
class TripleDES_Decryption : public BlockTransformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TripleDES_Decryption(const byte * userKey)
|
TripleDES_Decryption(const uint8_t * userKey)
|
||||||
: d1(userKey + 2*DES::KEYLENGTH, DECRYPTION), e(userKey + DES::KEYLENGTH, ENCRYPTION),
|
: d1(userKey + 2*DES::KEYLENGTH, DECRYPTION), e(userKey + DES::KEYLENGTH, ENCRYPTION),
|
||||||
d2(userKey, DECRYPTION) {}
|
d2(userKey, DECRYPTION) {}
|
||||||
|
|
||||||
void ProcessBlock(const byte *inBlock, byte * outBlock);
|
void ProcessBlock(const uint8_t *inBlock, uint8_t * outBlock);
|
||||||
void ProcessBlock(byte * inoutBlock);
|
void ProcessBlock(uint8_t * inoutBlock);
|
||||||
|
|
||||||
enum {KEYLENGTH=24, BLOCKSIZE=8};
|
enum {KEYLENGTH=24, BLOCKSIZE=8};
|
||||||
unsigned int BlockSize() const {return BLOCKSIZE;}
|
unsigned int BlockSize() const {return BLOCKSIZE;}
|
||||||
|
|
|
@ -53,7 +53,7 @@ void ElGamalCryptoPublicKey::SavePrecomputation(BufferedTransformation &bt) cons
|
||||||
ypc.Save(bt);
|
ypc.Save(bt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElGamalCryptoPublicKey::Encrypt(RandomNumberGenerator &rng, const byte *plainText, unsigned int plainTextLength, byte *cipherText)
|
void ElGamalCryptoPublicKey::Encrypt(RandomNumberGenerator &rng, const uint8_t *plainText, unsigned int plainTextLength, uint8_t *cipherText)
|
||||||
{
|
{
|
||||||
assert(plainTextLength <= MaxPlainTextLength());
|
assert(plainTextLength <= MaxPlainTextLength());
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ void ElGamalCryptoPrivateKey::DEREncode(BufferedTransformation &bt) const
|
||||||
x.DEREncode(seq);
|
x.DEREncode(seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ElGamalCryptoPrivateKey::Decrypt(const byte *cipherText, byte *plainText)
|
unsigned int ElGamalCryptoPrivateKey::Decrypt(const uint8_t *cipherText, uint8_t *plainText)
|
||||||
{
|
{
|
||||||
Integer a(cipherText, modulusLen);
|
Integer a(cipherText, modulusLen);
|
||||||
Integer b(cipherText+modulusLen, modulusLen);
|
Integer b(cipherText+modulusLen, modulusLen);
|
||||||
|
@ -211,7 +211,7 @@ void ElGamalSigPublicKey::SavePrecomputation(BufferedTransformation &bt) const
|
||||||
ypc.Save(bt);
|
ypc.Save(bt);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ElGamalSigPublicKey::Verify(const byte *message, unsigned int messageLen, const byte *signature)
|
bool ElGamalSigPublicKey::Verify(const uint8_t *message, unsigned int messageLen, const uint8_t *signature)
|
||||||
{
|
{
|
||||||
assert(messageLen <= MaxMessageLength());
|
assert(messageLen <= MaxMessageLength());
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ void ElGamalSigPrivateKey::DEREncode(BufferedTransformation &bt) const
|
||||||
x.DEREncode(seq);
|
x.DEREncode(seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElGamalSigPrivateKey::Sign(RandomNumberGenerator &rng, const byte *message, unsigned int messageLen, byte *signature)
|
void ElGamalSigPrivateKey::Sign(RandomNumberGenerator &rng, const uint8_t *message, unsigned int messageLen, uint8_t *signature)
|
||||||
{
|
{
|
||||||
assert(messageLen <= MaxMessageLength());
|
assert(messageLen <= MaxMessageLength());
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
void LoadPrecomputation(BufferedTransformation &storedPrecomputation);
|
void LoadPrecomputation(BufferedTransformation &storedPrecomputation);
|
||||||
void SavePrecomputation(BufferedTransformation &storedPrecomputation) const;
|
void SavePrecomputation(BufferedTransformation &storedPrecomputation) const;
|
||||||
|
|
||||||
void Encrypt(RandomNumberGenerator &rng, const byte *plainText, unsigned int plainTextLength, byte *cipherText);
|
void Encrypt(RandomNumberGenerator &rng, const uint8_t *plainText, unsigned int plainTextLength, uint8_t *cipherText);
|
||||||
|
|
||||||
unsigned int MaxPlainTextLength() const {return STDMIN(255U, modulusLen-3);}
|
unsigned int MaxPlainTextLength() const {return STDMIN(255U, modulusLen-3);}
|
||||||
unsigned int CipherTextLength() const {return 2*modulusLen;}
|
unsigned int CipherTextLength() const {return 2*modulusLen;}
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
ElGamalCryptoPrivateKey(BufferedTransformation &bt);
|
ElGamalCryptoPrivateKey(BufferedTransformation &bt);
|
||||||
void DEREncode(BufferedTransformation &bt) const;
|
void DEREncode(BufferedTransformation &bt) const;
|
||||||
|
|
||||||
unsigned int Decrypt(const byte *cipherText, byte *plainText);
|
unsigned int Decrypt(const uint8_t *cipherText, uint8_t *plainText);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void RawDecrypt(const Integer &a, const Integer &b, Integer &m) const;
|
void RawDecrypt(const Integer &a, const Integer &b, Integer &m) const;
|
||||||
|
@ -65,7 +65,7 @@ public:
|
||||||
void LoadPrecomputation(BufferedTransformation &storedPrecomputation);
|
void LoadPrecomputation(BufferedTransformation &storedPrecomputation);
|
||||||
void SavePrecomputation(BufferedTransformation &storedPrecomputation) const;
|
void SavePrecomputation(BufferedTransformation &storedPrecomputation) const;
|
||||||
|
|
||||||
bool Verify(const byte *message, unsigned int messageLen, const byte *signature);
|
bool Verify(const uint8_t *message, unsigned int messageLen, const uint8_t *signature);
|
||||||
|
|
||||||
// message length for signature is unlimited, but only message digests should be signed
|
// message length for signature is unlimited, but only message digests should be signed
|
||||||
unsigned int MaxMessageLength() const {return 0xffff;}
|
unsigned int MaxMessageLength() const {return 0xffff;}
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
ElGamalSigPrivateKey(BufferedTransformation &bt);
|
ElGamalSigPrivateKey(BufferedTransformation &bt);
|
||||||
void DEREncode(BufferedTransformation &bt) const;
|
void DEREncode(BufferedTransformation &bt) const;
|
||||||
|
|
||||||
void Sign(RandomNumberGenerator &rng, const byte *message, unsigned int messageLen, byte *signature);
|
void Sign(RandomNumberGenerator &rng, const uint8_t *message, unsigned int messageLen, uint8_t *signature);
|
||||||
|
|
||||||
const Integer& GetParameterX() { return x; }
|
const Integer& GetParameterX() { return x; }
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ void BlockFilterBase::ProcessBuf()
|
||||||
inBufSize=0;
|
inBufSize=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFilterBase::Put(const byte *inString, unsigned int length)
|
void BlockFilterBase::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
while (length--)
|
while (length--)
|
||||||
BlockFilterBase::Put(*inString++);
|
BlockFilterBase::Put(*inString++);
|
||||||
|
@ -75,7 +75,7 @@ void BlockDecryptionFilter::InputFinished()
|
||||||
inBufSize=0;
|
inBufSize=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamCipherFilter::Put(const byte *inString, unsigned int length)
|
void StreamCipherFilter::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
SecByteBlock temp(length);
|
SecByteBlock temp(length);
|
||||||
cipher.ProcessString(temp, inString, length);
|
cipher.ProcessString(temp, inString, length);
|
||||||
|
@ -89,13 +89,13 @@ void HashFilter::InputFinished()
|
||||||
outQueue->Put(buf, hash.DigestSize());
|
outQueue->Put(buf, hash.DigestSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedTransformation *Insert(const byte *in, unsigned int length, BufferedTransformation *outQueue)
|
BufferedTransformation *Insert(const uint8_t *in, unsigned int length, BufferedTransformation *outQueue)
|
||||||
{
|
{
|
||||||
outQueue->Put(in, length);
|
outQueue->Put(in, length);
|
||||||
return outQueue;
|
return outQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Extract(Source *source, byte *out, unsigned int length)
|
unsigned int Extract(Source *source, uint8_t *out, unsigned int length)
|
||||||
{
|
{
|
||||||
while (source->MaxRetrieveable() < length && source->Pump(1));
|
while (source->MaxRetrieveable() < length && source->Pump(1));
|
||||||
return source->Get(out, length);
|
return source->Get(out, length);
|
||||||
|
|
|
@ -20,12 +20,12 @@ public:
|
||||||
unsigned long MaxRetrieveable()
|
unsigned long MaxRetrieveable()
|
||||||
{return outQueue->MaxRetrieveable();}
|
{return outQueue->MaxRetrieveable();}
|
||||||
|
|
||||||
unsigned int Get(byte &outByte)
|
unsigned int Get(uint8_t &outByte)
|
||||||
{return outQueue->Get(outByte);}
|
{return outQueue->Get(outByte);}
|
||||||
unsigned int Get(byte *outString, unsigned int getMax)
|
unsigned int Get(uint8_t *outString, unsigned int getMax)
|
||||||
{return outQueue->Get(outString, getMax);}
|
{return outQueue->Get(outString, getMax);}
|
||||||
|
|
||||||
unsigned int Peek(byte &outByte) const
|
unsigned int Peek(uint8_t &outByte) const
|
||||||
{return outQueue->Peek(outByte);}
|
{return outQueue->Peek(outByte);}
|
||||||
|
|
||||||
BufferedTransformation *OutQueue() {return outQueue.get();}
|
BufferedTransformation *OutQueue() {return outQueue.get();}
|
||||||
|
@ -44,14 +44,14 @@ public:
|
||||||
BufferedTransformation *outQueue);
|
BufferedTransformation *outQueue);
|
||||||
virtual ~BlockFilterBase() {}
|
virtual ~BlockFilterBase() {}
|
||||||
|
|
||||||
void Put(byte inByte)
|
void Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
if (inBufSize == S)
|
if (inBufSize == S)
|
||||||
ProcessBuf();
|
ProcessBuf();
|
||||||
inBuf[inBufSize++]=inByte;
|
inBuf[inBufSize++]=inByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessBuf();
|
void ProcessBuf();
|
||||||
|
@ -89,10 +89,10 @@ public:
|
||||||
BufferedTransformation *outQueue = NULL)
|
BufferedTransformation *outQueue = NULL)
|
||||||
: Filter(outQueue), cipher(c) {}
|
: Filter(outQueue), cipher(c) {}
|
||||||
|
|
||||||
void Put(byte inByte)
|
void Put(uint8_t inByte)
|
||||||
{outQueue->Put(cipher.ProcessByte(inByte));}
|
{outQueue->Put(cipher.ProcessByte(inByte));}
|
||||||
|
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StreamCipher &cipher;
|
StreamCipher &cipher;
|
||||||
|
@ -106,10 +106,10 @@ public:
|
||||||
|
|
||||||
void InputFinished();
|
void InputFinished();
|
||||||
|
|
||||||
void Put(byte inByte)
|
void Put(uint8_t inByte)
|
||||||
{hash.Update(&inByte, 1);}
|
{hash.Update(&inByte, 1);}
|
||||||
|
|
||||||
void Put(const byte *inString, unsigned int length)
|
void Put(const uint8_t *inString, unsigned int length)
|
||||||
{hash.Update(inString, length);}
|
{hash.Update(inString, length);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -122,9 +122,9 @@ public:
|
||||||
Source(BufferedTransformation *outQ = NULL)
|
Source(BufferedTransformation *outQ = NULL)
|
||||||
: Filter(outQ) {}
|
: Filter(outQ) {}
|
||||||
|
|
||||||
void Put(byte)
|
void Put(uint8_t)
|
||||||
{Pump(1);}
|
{Pump(1);}
|
||||||
void Put(const byte *, unsigned int length)
|
void Put(const uint8_t *, unsigned int length)
|
||||||
{Pump(length);}
|
{Pump(length);}
|
||||||
void InputFinished()
|
void InputFinished()
|
||||||
{PumpAll();}
|
{PumpAll();}
|
||||||
|
@ -138,22 +138,22 @@ class Sink : public BufferedTransformation
|
||||||
public:
|
public:
|
||||||
unsigned long MaxRetrieveable()
|
unsigned long MaxRetrieveable()
|
||||||
{return 0;}
|
{return 0;}
|
||||||
unsigned int Get(byte &)
|
unsigned int Get(uint8_t &)
|
||||||
{return 0;}
|
{return 0;}
|
||||||
unsigned int Get(byte *, unsigned int)
|
unsigned int Get(uint8_t *, unsigned int)
|
||||||
{return 0;}
|
{return 0;}
|
||||||
unsigned int Peek(byte &) const
|
unsigned int Peek(uint8_t &) const
|
||||||
{return 0;}
|
{return 0;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BitBucket : public Sink
|
class BitBucket : public Sink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Put(byte) {}
|
void Put(uint8_t) {}
|
||||||
void Put(const byte *, unsigned int) {}
|
void Put(const uint8_t *, unsigned int) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
BufferedTransformation *Insert(const byte *in, unsigned int length, BufferedTransformation *outQueue);
|
BufferedTransformation *Insert(const uint8_t *in, unsigned int length, BufferedTransformation *outQueue);
|
||||||
unsigned int Extract(Source *source, byte *out, unsigned int length);
|
unsigned int Extract(Source *source, uint8_t *out, unsigned int length);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,13 +49,13 @@ void Fork::Close()
|
||||||
outPorts[i]->Close();
|
outPorts[i]->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fork::Put(byte inByte)
|
void Fork::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<numberOfPorts; i++)
|
for (unsigned int i=0; i<numberOfPorts; i++)
|
||||||
outPorts[i]->Put(inByte);
|
outPorts[i]->Put(inByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fork::Put(const byte *inString, unsigned int length)
|
void Fork::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<numberOfPorts; i++)
|
for (unsigned int i=0; i<numberOfPorts; i++)
|
||||||
outPorts[i]->Put(inString, length);
|
outPorts[i]->Put(inString, length);
|
||||||
|
@ -95,13 +95,13 @@ void Join::NotifyClose(unsigned int /* id */)
|
||||||
|
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
|
|
||||||
void Interface::Put(byte inByte)
|
void Interface::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
bq.Put(inByte);
|
bq.Put(inByte);
|
||||||
parent.NotifyInput(id, 1);
|
parent.NotifyInput(id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::Put(const byte *inString, unsigned int length)
|
void Interface::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
bq.Put(inString, length);
|
bq.Put(inString, length);
|
||||||
parent.NotifyInput(id, length);
|
parent.NotifyInput(id, length);
|
||||||
|
@ -127,17 +127,17 @@ void Interface::Attach(BufferedTransformation *bt)
|
||||||
parent.Attach(bt);
|
parent.Attach(bt);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Interface::Get(byte &outByte)
|
unsigned int Interface::Get(uint8_t &outByte)
|
||||||
{
|
{
|
||||||
return parent.Get(outByte);
|
return parent.Get(outByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Interface::Get(byte *outString, unsigned int getMax)
|
unsigned int Interface::Get(uint8_t *outString, unsigned int getMax)
|
||||||
{
|
{
|
||||||
return parent.Get(outString, getMax);
|
return parent.Get(outString, getMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Interface::Peek(byte &outByte) const
|
unsigned int Interface::Peek(uint8_t &outByte) const
|
||||||
{
|
{
|
||||||
return parent.Peek(outByte);
|
return parent.Peek(outByte);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,15 @@ public:
|
||||||
// virtual void InputFinished()
|
// virtual void InputFinished()
|
||||||
// {outPorts[currentPort]->InputFinished();}
|
// {outPorts[currentPort]->InputFinished();}
|
||||||
|
|
||||||
unsigned int Get(byte &outByte)
|
unsigned int Get(uint8_t &outByte)
|
||||||
{return outPorts[currentPort]->Get(outByte);}
|
{return outPorts[currentPort]->Get(outByte);}
|
||||||
unsigned int Get(byte *outString, unsigned int getMax)
|
unsigned int Get(uint8_t *outString, unsigned int getMax)
|
||||||
{return outPorts[currentPort]->Get(outString, getMax);}
|
{return outPorts[currentPort]->Get(outString, getMax);}
|
||||||
unsigned int Peek(byte &outByte) const
|
unsigned int Peek(uint8_t &outByte) const
|
||||||
{return outPorts[currentPort]->Peek(outByte);}
|
{return outPorts[currentPort]->Peek(outByte);}
|
||||||
|
|
||||||
virtual void Put(byte inByte);
|
virtual void Put(uint8_t inByte);
|
||||||
virtual void Put(const byte *inString, unsigned int length);
|
virtual void Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned int NumberOfPorts() const {return numberOfPorts;}
|
unsigned int NumberOfPorts() const {return numberOfPorts;}
|
||||||
|
@ -57,11 +57,11 @@ public:
|
||||||
void Detach(BufferedTransformation *bt);
|
void Detach(BufferedTransformation *bt);
|
||||||
void Attach(BufferedTransformation *bt);
|
void Attach(BufferedTransformation *bt);
|
||||||
|
|
||||||
void Put(byte inByte);
|
void Put(uint8_t inByte);
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
unsigned int Get(byte &outByte);
|
unsigned int Get(uint8_t &outByte);
|
||||||
unsigned int Get(byte *outString, unsigned int getMax);
|
unsigned int Get(uint8_t *outString, unsigned int getMax);
|
||||||
unsigned int Peek(byte &outByte) const;
|
unsigned int Peek(uint8_t &outByte) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Join &parent;
|
Join &parent;
|
||||||
|
@ -83,8 +83,8 @@ public:
|
||||||
virtual void NotifyInput(unsigned int interfaceId, unsigned int length);
|
virtual void NotifyInput(unsigned int interfaceId, unsigned int length);
|
||||||
virtual void NotifyClose(unsigned int interfaceId);
|
virtual void NotifyClose(unsigned int interfaceId);
|
||||||
|
|
||||||
void Put(byte inByte) {outQueue->Put(inByte);}
|
void Put(uint8_t inByte) {outQueue->Put(inByte);}
|
||||||
void Put(const byte *inString, unsigned int length)
|
void Put(const uint8_t *inString, unsigned int length)
|
||||||
{outQueue->Put(inString, length);}
|
{outQueue->Put(inString, length);}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1159,12 +1159,12 @@ long Integer::ConvertToLong() const
|
||||||
return sign==POSITIVE ? value : -long(value);
|
return sign==POSITIVE ? value : -long(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer::Integer(const byte *encodedInteger, unsigned int byteCount, Signedness s)
|
Integer::Integer(const uint8_t *encodedInteger, unsigned int byteCount, Signedness s)
|
||||||
{
|
{
|
||||||
Decode(encodedInteger, byteCount, s);
|
Decode(encodedInteger, byteCount, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer::Integer(const byte *BEREncodedInteger)
|
Integer::Integer(const uint8_t *BEREncodedInteger)
|
||||||
{
|
{
|
||||||
BERDecode(BEREncodedInteger);
|
BERDecode(BEREncodedInteger);
|
||||||
}
|
}
|
||||||
|
@ -1241,15 +1241,15 @@ void Integer::SetBit(unsigned int n, bool value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte Integer::GetByte(unsigned int n) const
|
uint8_t Integer::GetByte(unsigned int n) const
|
||||||
{
|
{
|
||||||
if (n/WORD_SIZE >= reg.size)
|
if (n/WORD_SIZE >= reg.size)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return byte(reg[n/WORD_SIZE] >> ((n%WORD_SIZE)*8));
|
return uint8_t(reg[n/WORD_SIZE] >> ((n%WORD_SIZE)*8));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Integer::SetByte(unsigned int n, byte value)
|
void Integer::SetByte(unsigned int n, uint8_t value)
|
||||||
{
|
{
|
||||||
reg.CleanGrow(RoundupSize(bytesToWords(n+1)));
|
reg.CleanGrow(RoundupSize(bytesToWords(n+1)));
|
||||||
reg[n/WORD_SIZE] &= ~(word(0xff) << 8*(n%WORD_SIZE));
|
reg[n/WORD_SIZE] &= ~(word(0xff) << 8*(n%WORD_SIZE));
|
||||||
|
@ -1360,7 +1360,7 @@ unsigned int Integer::BitCount() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Integer::Decode(const byte *input, unsigned int inputLen, Signedness s)
|
void Integer::Decode(const uint8_t *input, unsigned int inputLen, Signedness s)
|
||||||
{
|
{
|
||||||
sign = ((s==SIGNED) && (input[0] & 0x80)) ? NEGATIVE : POSITIVE;
|
sign = ((s==SIGNED) && (input[0] & 0x80)) ? NEGATIVE : POSITIVE;
|
||||||
|
|
||||||
|
@ -1395,7 +1395,7 @@ unsigned int Integer::MinEncodedSize(Signedness signedness) const
|
||||||
return outputLen;
|
return outputLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Integer::Encode(byte *output, unsigned int outputLen, Signedness signedness) const
|
unsigned int Integer::Encode(uint8_t *output, unsigned int outputLen, Signedness signedness) const
|
||||||
{
|
{
|
||||||
if (signedness == UNSIGNED || NotNegative())
|
if (signedness == UNSIGNED || NotNegative())
|
||||||
{
|
{
|
||||||
|
@ -1412,7 +1412,7 @@ unsigned int Integer::Encode(byte *output, unsigned int outputLen, Signedness si
|
||||||
return outputLen;
|
return outputLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Integer::DEREncode(byte *output) const
|
unsigned int Integer::DEREncode(uint8_t *output) const
|
||||||
{
|
{
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
output[i++] = INTEGER;
|
output[i++] = INTEGER;
|
||||||
|
@ -1435,7 +1435,7 @@ unsigned int Integer::DEREncode(BufferedTransformation &bt) const
|
||||||
return 1+lengthBytes+bc;
|
return 1+lengthBytes+bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Integer::BERDecode(const byte *input)
|
void Integer::BERDecode(const uint8_t *input)
|
||||||
{
|
{
|
||||||
if (*input++ != INTEGER)
|
if (*input++ != INTEGER)
|
||||||
BERDecodeError();
|
BERDecodeError();
|
||||||
|
@ -1456,7 +1456,7 @@ void Integer::BERDecode(const byte *input)
|
||||||
|
|
||||||
void Integer::BERDecode(BufferedTransformation &bt)
|
void Integer::BERDecode(BufferedTransformation &bt)
|
||||||
{
|
{
|
||||||
byte b;
|
uint8_t b;
|
||||||
if (!bt.Get(b) || b != INTEGER)
|
if (!bt.Get(b) || b != INTEGER)
|
||||||
BERDecodeError();
|
BERDecodeError();
|
||||||
|
|
||||||
|
@ -1475,7 +1475,7 @@ void Integer::Randomize(RandomNumberGenerator &rng, unsigned int nbits)
|
||||||
const unsigned int nbytes = nbits/8 + 1;
|
const unsigned int nbytes = nbits/8 + 1;
|
||||||
SecByteBlock buf(nbytes);
|
SecByteBlock buf(nbytes);
|
||||||
rng.GetBlock(buf, nbytes);
|
rng.GetBlock(buf, nbytes);
|
||||||
buf[(unsigned int)0] = (byte)Crop(buf[(unsigned int)0], nbits % 8);
|
buf[(unsigned int)0] = (uint8_t)Crop(buf[(unsigned int)0], nbits % 8);
|
||||||
Decode(buf, nbytes, UNSIGNED);
|
Decode(buf, nbytes, UNSIGNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,10 @@ public:
|
||||||
Integer(const char *str);
|
Integer(const char *str);
|
||||||
|
|
||||||
/// convert from big-endian byte array
|
/// convert from big-endian byte array
|
||||||
Integer(const byte *encodedInteger, unsigned int byteCount, Signedness s=UNSIGNED);
|
Integer(const uint8_t *encodedInteger, unsigned int byteCount, Signedness s=UNSIGNED);
|
||||||
|
|
||||||
/// convert from Basic Encoding Rules encoded byte array
|
/// convert from Basic Encoding Rules encoded byte array
|
||||||
Integer(const byte *BEREncodedInteger);
|
Integer(const uint8_t *BEREncodedInteger);
|
||||||
|
|
||||||
/// convert from BER encoded byte array stored in a BufferedTransformation object
|
/// convert from BER encoded byte array stored in a BufferedTransformation object
|
||||||
Integer(BufferedTransformation &bt);
|
Integer(BufferedTransformation &bt);
|
||||||
|
@ -104,10 +104,10 @@ public:
|
||||||
if outputLen < MinEncodedSize, the most significant bytes will be dropped
|
if outputLen < MinEncodedSize, the most significant bytes will be dropped
|
||||||
if outputLen > MinEncodedSize, the most significant bytes will be padded
|
if outputLen > MinEncodedSize, the most significant bytes will be padded
|
||||||
*/
|
*/
|
||||||
unsigned int Encode(byte *output, unsigned int outputLen, Signedness=UNSIGNED) const;
|
unsigned int Encode(uint8_t *output, unsigned int outputLen, Signedness=UNSIGNED) const;
|
||||||
|
|
||||||
/// encode integer using Distinguished Encoding Rules, returns size of output
|
/// encode integer using Distinguished Encoding Rules, returns size of output
|
||||||
unsigned int DEREncode(byte *output) const;
|
unsigned int DEREncode(uint8_t *output) const;
|
||||||
/// encode using DER, put result into a BufferedTransformation object
|
/// encode using DER, put result into a BufferedTransformation object
|
||||||
unsigned int DEREncode(BufferedTransformation &bt) const;
|
unsigned int DEREncode(BufferedTransformation &bt) const;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
/// return the n-th bit, n=0 being the least significant bit
|
/// return the n-th bit, n=0 being the least significant bit
|
||||||
bool GetBit(unsigned int n) const;
|
bool GetBit(unsigned int n) const;
|
||||||
/// return the n-th byte
|
/// return the n-th byte
|
||||||
byte GetByte(unsigned int n) const;
|
uint8_t GetByte(unsigned int n) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
bool IsNegative() const {return sign == NEGATIVE;}
|
bool IsNegative() const {return sign == NEGATIVE;}
|
||||||
|
@ -161,10 +161,10 @@ public:
|
||||||
Integer& operator>>=(unsigned int);
|
Integer& operator>>=(unsigned int);
|
||||||
|
|
||||||
///
|
///
|
||||||
void Decode(const byte *input, unsigned int inputLen, Signedness=UNSIGNED);
|
void Decode(const uint8_t *input, unsigned int inputLen, Signedness=UNSIGNED);
|
||||||
|
|
||||||
///
|
///
|
||||||
void BERDecode(const byte *input);
|
void BERDecode(const uint8_t *input);
|
||||||
///
|
///
|
||||||
void BERDecode(BufferedTransformation &bt);
|
void BERDecode(BufferedTransformation &bt);
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ public:
|
||||||
/// set the n-th bit to value
|
/// set the n-th bit to value
|
||||||
void SetBit(unsigned int n, bool value=1);
|
void SetBit(unsigned int n, bool value=1);
|
||||||
/// set the n-th byte to value
|
/// set the n-th byte to value
|
||||||
void SetByte(unsigned int n, byte value);
|
void SetByte(unsigned int n, uint8_t value);
|
||||||
|
|
||||||
///
|
///
|
||||||
void Negate();
|
void Negate();
|
||||||
|
|
|
@ -15,12 +15,12 @@ template <class T> class IteratedHash : public virtual HashModule
|
||||||
public:
|
public:
|
||||||
IteratedHash(unsigned int blockSize, unsigned int digestSize);
|
IteratedHash(unsigned int blockSize, unsigned int digestSize);
|
||||||
~IteratedHash();
|
~IteratedHash();
|
||||||
void Update(const byte *input, unsigned int length);
|
void Update(const uint8_t *input, unsigned int length);
|
||||||
|
|
||||||
typedef T HashWordType;
|
typedef T HashWordType;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void PadLastBlock(unsigned int lastBlockSize, byte padFirst=0x80);
|
void PadLastBlock(unsigned int lastBlockSize, uint8_t padFirst=0x80);
|
||||||
virtual void Init() =0;
|
virtual void Init() =0;
|
||||||
virtual void HashBlock(const T *input) =0;
|
virtual void HashBlock(const T *input) =0;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ template <class T> IteratedHash<T>::~IteratedHash()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void IteratedHash<T>::Update(const byte *input, unsigned int len)
|
template <class T> void IteratedHash<T>::Update(const uint8_t *input, unsigned int len)
|
||||||
{
|
{
|
||||||
word32 tmp = countLo;
|
word32 tmp = countLo;
|
||||||
if ((countLo = tmp + ((word32)len << 3)) < tmp)
|
if ((countLo = tmp + ((word32)len << 3)) < tmp)
|
||||||
|
@ -53,7 +53,7 @@ template <class T> void IteratedHash<T>::Update(const byte *input, unsigned int
|
||||||
{
|
{
|
||||||
if ((num+len) >= blockSize)
|
if ((num+len) >= blockSize)
|
||||||
{
|
{
|
||||||
memcpy((byte *)data.ptr+num, input, blockSize-num);
|
memcpy((uint8_t *)data.ptr+num, input, blockSize-num);
|
||||||
HashBlock(data);
|
HashBlock(data);
|
||||||
input += (blockSize-num);
|
input += (blockSize-num);
|
||||||
len-=(blockSize - num);
|
len-=(blockSize - num);
|
||||||
|
@ -62,7 +62,7 @@ template <class T> void IteratedHash<T>::Update(const byte *input, unsigned int
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memcpy((byte *)data.ptr+num, input, len);
|
memcpy((uint8_t *)data.ptr+num, input, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,16 +91,16 @@ template <class T> void IteratedHash<T>::Update(const byte *input, unsigned int
|
||||||
memcpy(data, input, len);
|
memcpy(data, input, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void IteratedHash<T>::PadLastBlock(unsigned int lastBlockSize, byte padFirst)
|
template <class T> void IteratedHash<T>::PadLastBlock(unsigned int lastBlockSize, uint8_t padFirst)
|
||||||
{
|
{
|
||||||
unsigned int num = (unsigned int)(countLo >> 3) & (blockSize-1);
|
unsigned int num = (unsigned int)(countLo >> 3) & (blockSize-1);
|
||||||
assert(num < blockSize);
|
assert(num < blockSize);
|
||||||
((byte *)data.ptr)[num++]=padFirst;
|
((uint8_t *)data.ptr)[num++]=padFirst;
|
||||||
if (num <= lastBlockSize)
|
if (num <= lastBlockSize)
|
||||||
memset((byte *)data.ptr+num, 0, lastBlockSize-num);
|
memset((uint8_t *)data.ptr+num, 0, lastBlockSize-num);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset((byte *)data.ptr+num, 0, blockSize-num);
|
memset((uint8_t *)data.ptr+num, 0, blockSize-num);
|
||||||
HashBlock(data);
|
HashBlock(data);
|
||||||
memset(data, 0, lastBlockSize);
|
memset(data, 0, lastBlockSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "words.h"
|
#include "words.h"
|
||||||
|
|
||||||
void xorbuf(byte *buf, const byte *mask, unsigned int count)
|
void xorbuf(uint8_t *buf, const uint8_t *mask, unsigned int count)
|
||||||
{
|
{
|
||||||
if (((ptr_size_type)buf | (ptr_size_type)mask | count) % WORD_SIZE == 0)
|
if (((ptr_size_type)buf | (ptr_size_type)mask | count) % WORD_SIZE == 0)
|
||||||
XorWords((word *)buf, (const word *)mask, count/WORD_SIZE);
|
XorWords((word *)buf, (const word *)mask, count/WORD_SIZE);
|
||||||
|
@ -15,7 +15,7 @@ void xorbuf(byte *buf, const byte *mask, unsigned int count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xorbuf(byte *output, const byte *input, const byte *mask, unsigned int count)
|
void xorbuf(uint8_t *output, const uint8_t *input, const uint8_t *mask, unsigned int count)
|
||||||
{
|
{
|
||||||
if (((ptr_size_type)output | (ptr_size_type)input | (ptr_size_type)mask | count) % WORD_SIZE == 0)
|
if (((ptr_size_type)output | (ptr_size_type)input | (ptr_size_type)mask | count) % WORD_SIZE == 0)
|
||||||
XorWords((word *)output, (const word *)input, (const word *)mask, count/WORD_SIZE);
|
XorWords((word *)output, (const word *)input, (const word *)mask, count/WORD_SIZE);
|
||||||
|
|
|
@ -31,8 +31,8 @@ inline unsigned int bitsToWords(unsigned int bitCount)
|
||||||
return ((bitCount+WORD_BITS-1)/(WORD_BITS));
|
return ((bitCount+WORD_BITS-1)/(WORD_BITS));
|
||||||
}
|
}
|
||||||
|
|
||||||
void xorbuf(byte *buf, const byte *mask, unsigned int count);
|
void xorbuf(uint8_t *buf, const uint8_t *mask, unsigned int count);
|
||||||
void xorbuf(byte *output, const byte *input, const byte *mask, unsigned int count);
|
void xorbuf(uint8_t *output, const uint8_t *input, const uint8_t *mask, unsigned int count);
|
||||||
|
|
||||||
template <class T> inline T rotl(T x, unsigned int y)
|
template <class T> inline T rotl(T x, unsigned int y)
|
||||||
{
|
{
|
||||||
|
@ -262,7 +262,7 @@ template <class T> void SecBlock<T>::swap(SecBlock<T> &b)
|
||||||
std::swap(ptr, b.ptr);
|
std::swap(ptr, b.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef SecBlock<byte> SecByteBlock;
|
typedef SecBlock<uint8_t> SecByteBlock;
|
||||||
typedef SecBlock<word> SecWordBlock;
|
typedef SecBlock<word> SecWordBlock;
|
||||||
|
|
||||||
#endif // MISC_H
|
#endif // MISC_H
|
||||||
|
|
|
@ -15,20 +15,20 @@ public:
|
||||||
unsigned int UsedUp() const
|
unsigned int UsedUp() const
|
||||||
{return (head==MaxSize());}
|
{return (head==MaxSize());}
|
||||||
|
|
||||||
unsigned int Put(byte inByte);
|
unsigned int Put(uint8_t inByte);
|
||||||
unsigned int Put(const byte *inString, unsigned int length);
|
unsigned int Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
unsigned int Get(byte &outByte);
|
unsigned int Get(uint8_t &outByte);
|
||||||
unsigned int Get(byte *outString, unsigned int getMax);
|
unsigned int Get(uint8_t *outString, unsigned int getMax);
|
||||||
|
|
||||||
unsigned int Peek(byte &outByte) const;
|
unsigned int Peek(uint8_t &outByte) const;
|
||||||
|
|
||||||
void CopyTo(BufferedTransformation &target) const
|
void CopyTo(BufferedTransformation &target) const
|
||||||
{target.Put(buf+head, tail-head);}
|
{target.Put(buf+head, tail-head);}
|
||||||
void CopyTo(byte *target) const
|
void CopyTo(uint8_t *target) const
|
||||||
{memcpy(target, buf+head, tail-head);}
|
{memcpy(target, buf+head, tail-head);}
|
||||||
|
|
||||||
byte operator[](unsigned int i) const
|
uint8_t operator[](unsigned int i) const
|
||||||
{return buf[i-head];}
|
{return buf[i-head];}
|
||||||
|
|
||||||
ByteQueueNode *next;
|
ByteQueueNode *next;
|
||||||
|
@ -48,7 +48,7 @@ ByteQueueNode::ByteQueueNode(unsigned int maxSize)
|
||||||
next = 0;
|
next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueueNode::Put(byte inByte)
|
unsigned int ByteQueueNode::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
if (MaxSize()==tail)
|
if (MaxSize()==tail)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -57,7 +57,7 @@ unsigned int ByteQueueNode::Put(byte inByte)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueueNode::Put(const byte *inString, unsigned int length)
|
unsigned int ByteQueueNode::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
unsigned int l = STDMIN(length, MaxSize()-tail);
|
unsigned int l = STDMIN(length, MaxSize()-tail);
|
||||||
memcpy(buf+tail, inString, l);
|
memcpy(buf+tail, inString, l);
|
||||||
|
@ -65,7 +65,7 @@ unsigned int ByteQueueNode::Put(const byte *inString, unsigned int length)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueueNode::Get(byte &outByte)
|
unsigned int ByteQueueNode::Get(uint8_t &outByte)
|
||||||
{
|
{
|
||||||
if (tail==head)
|
if (tail==head)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,7 +74,7 @@ unsigned int ByteQueueNode::Get(byte &outByte)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueueNode::Get(byte *outString, unsigned int getMax)
|
unsigned int ByteQueueNode::Get(uint8_t *outString, unsigned int getMax)
|
||||||
{
|
{
|
||||||
unsigned int l = STDMIN(getMax, tail-head);
|
unsigned int l = STDMIN(getMax, tail-head);
|
||||||
memcpy(outString, buf+head, l);
|
memcpy(outString, buf+head, l);
|
||||||
|
@ -82,7 +82,7 @@ unsigned int ByteQueueNode::Get(byte *outString, unsigned int getMax)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueueNode::Peek(byte &outByte) const
|
unsigned int ByteQueueNode::Peek(uint8_t &outByte) const
|
||||||
{
|
{
|
||||||
if (tail==head)
|
if (tail==head)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -140,7 +140,7 @@ void ByteQueue::CopyTo(BufferedTransformation &target) const
|
||||||
current->CopyTo(target);
|
current->CopyTo(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteQueue::CopyTo(byte *target) const
|
void ByteQueue::CopyTo(uint8_t *target) const
|
||||||
{
|
{
|
||||||
for (ByteQueueNode *current=head; current; current=current->next)
|
for (ByteQueueNode *current=head; current; current=current->next)
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ unsigned long ByteQueue::CurrentSize() const
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteQueue::Put(byte inByte)
|
void ByteQueue::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
if (!tail->Put(inByte))
|
if (!tail->Put(inByte))
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ void ByteQueue::Put(byte inByte)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteQueue::Put(const byte *inString, unsigned int length)
|
void ByteQueue::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
unsigned int l;
|
unsigned int l;
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ void ByteQueue::Put(const byte *inString, unsigned int length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueue::Get(byte &outByte)
|
unsigned int ByteQueue::Get(uint8_t &outByte)
|
||||||
{
|
{
|
||||||
int l = head->Get(outByte);
|
int l = head->Get(outByte);
|
||||||
if (head->UsedUp())
|
if (head->UsedUp())
|
||||||
|
@ -196,7 +196,7 @@ unsigned int ByteQueue::Get(byte &outByte)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueue::Get(byte *outString, unsigned int getMax)
|
unsigned int ByteQueue::Get(uint8_t *outString, unsigned int getMax)
|
||||||
{
|
{
|
||||||
unsigned int getMaxSave=getMax;
|
unsigned int getMaxSave=getMax;
|
||||||
ByteQueueNode *current=head;
|
ByteQueueNode *current=head;
|
||||||
|
@ -224,7 +224,7 @@ unsigned int ByteQueue::Get(byte *outString, unsigned int getMax)
|
||||||
return (getMaxSave-getMax);
|
return (getMaxSave-getMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ByteQueue::Peek(byte &outByte) const
|
unsigned int ByteQueue::Peek(uint8_t &outByte) const
|
||||||
{
|
{
|
||||||
return head->Peek(outByte);
|
return head->Peek(outByte);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ bool ByteQueue::operator==(const ByteQueue &rhs) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte ByteQueue::operator[](unsigned long i) const
|
uint8_t ByteQueue::operator[](unsigned long i) const
|
||||||
{
|
{
|
||||||
for (ByteQueueNode *current=head; current; current=current->next)
|
for (ByteQueueNode *current=head; current; current=current->next)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,21 +21,21 @@ public:
|
||||||
unsigned long MaxRetrieveable()
|
unsigned long MaxRetrieveable()
|
||||||
{return CurrentSize();}
|
{return CurrentSize();}
|
||||||
|
|
||||||
void Put(byte inByte);
|
void Put(uint8_t inByte);
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
// both functions returns the number of bytes actually retrived
|
// both functions returns the number of bytes actually retrived
|
||||||
unsigned int Get(byte &outByte);
|
unsigned int Get(uint8_t &outByte);
|
||||||
unsigned int Get(byte *outString, unsigned int getMax);
|
unsigned int Get(uint8_t *outString, unsigned int getMax);
|
||||||
|
|
||||||
unsigned int Peek(byte &outByte) const;
|
unsigned int Peek(uint8_t &outByte) const;
|
||||||
|
|
||||||
void CopyTo(BufferedTransformation &target) const;
|
void CopyTo(BufferedTransformation &target) const;
|
||||||
void CopyTo(byte *target) const;
|
void CopyTo(uint8_t *target) const;
|
||||||
|
|
||||||
ByteQueue & operator=(const ByteQueue &rhs);
|
ByteQueue & operator=(const ByteQueue &rhs);
|
||||||
bool operator==(const ByteQueue &rhs) const;
|
bool operator==(const ByteQueue &rhs) const;
|
||||||
byte operator[](unsigned long i) const;
|
uint8_t operator[](unsigned long i) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CopyFrom(const ByteQueue ©);
|
void CopyFrom(const ByteQueue ©);
|
||||||
|
|
|
@ -32,7 +32,7 @@ const word16 LC_RNG::a=16807;
|
||||||
const word16 LC_RNG::r=2836;
|
const word16 LC_RNG::r=2836;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
byte LC_RNG::GetByte()
|
uint8_t LC_RNG::GetByte()
|
||||||
{
|
{
|
||||||
word32 hi = seed/q;
|
word32 hi = seed/q;
|
||||||
word32 lo = seed%q;
|
word32 lo = seed%q;
|
||||||
|
@ -49,7 +49,7 @@ byte LC_RNG::GetByte()
|
||||||
|
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
|
|
||||||
X917RNG::X917RNG(BlockTransformation *c, const byte *seed)
|
X917RNG::X917RNG(BlockTransformation *c, const uint8_t *seed)
|
||||||
: cipher(c),
|
: cipher(c),
|
||||||
S(cipher->BlockSize()),
|
S(cipher->BlockSize()),
|
||||||
dtbuf(S),
|
dtbuf(S),
|
||||||
|
@ -58,20 +58,20 @@ X917RNG::X917RNG(BlockTransformation *c, const byte *seed)
|
||||||
randbuf_counter(0)
|
randbuf_counter(0)
|
||||||
{
|
{
|
||||||
time_t tstamp1 = time(0);
|
time_t tstamp1 = time(0);
|
||||||
xorbuf(dtbuf, (byte *)&tstamp1, STDMIN((int)sizeof(tstamp1), S));
|
xorbuf(dtbuf, (uint8_t *)&tstamp1, STDMIN((int)sizeof(tstamp1), S));
|
||||||
cipher->ProcessBlock(dtbuf);
|
cipher->ProcessBlock(dtbuf);
|
||||||
clock_t tstamp2 = clock();
|
clock_t tstamp2 = clock();
|
||||||
xorbuf(dtbuf, (byte *)&tstamp2, STDMIN((int)sizeof(tstamp2), S));
|
xorbuf(dtbuf, (uint8_t *)&tstamp2, STDMIN((int)sizeof(tstamp2), S));
|
||||||
cipher->ProcessBlock(dtbuf);
|
cipher->ProcessBlock(dtbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte X917RNG::GetByte()
|
uint8_t X917RNG::GetByte()
|
||||||
{
|
{
|
||||||
if (randbuf_counter==0)
|
if (randbuf_counter==0)
|
||||||
{
|
{
|
||||||
// calculate new enciphered timestamp
|
// calculate new enciphered timestamp
|
||||||
clock_t tstamp = clock();
|
clock_t tstamp = clock();
|
||||||
xorbuf(dtbuf, (byte *)&tstamp, STDMIN((int)sizeof(tstamp), S));
|
xorbuf(dtbuf, (uint8_t *)&tstamp, STDMIN((int)sizeof(tstamp), S));
|
||||||
cipher->ProcessBlock(dtbuf);
|
cipher->ProcessBlock(dtbuf);
|
||||||
|
|
||||||
// combine enciphered timestamp with seed
|
// combine enciphered timestamp with seed
|
||||||
|
@ -97,7 +97,7 @@ MaurerRandomnessTest::MaurerRandomnessTest()
|
||||||
tab[i] = 0;
|
tab[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MaurerRandomnessTest::Put(byte inByte)
|
inline void MaurerRandomnessTest::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
if (n >= Q)
|
if (n >= Q)
|
||||||
sum += log(double(n - tab[inByte]));
|
sum += log(double(n - tab[inByte]));
|
||||||
|
@ -105,7 +105,7 @@ inline void MaurerRandomnessTest::Put(byte inByte)
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaurerRandomnessTest::Put(const byte *inString, unsigned int length)
|
void MaurerRandomnessTest::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
while (length--)
|
while (length--)
|
||||||
Put(*inString++);
|
Put(*inString++);
|
||||||
|
|
|
@ -13,15 +13,15 @@ class LC_RNG : public RandomNumberGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LC_RNG(word32 init_seed)
|
LC_RNG(word32 init_seed)
|
||||||
: seedBytes((byte *)&seed) {seed=init_seed;}
|
: seedBytes((uint8_t *)&seed) {seed=init_seed;}
|
||||||
|
|
||||||
byte GetByte();
|
uint8_t GetByte();
|
||||||
|
|
||||||
word32 GetSeed() {return seed;}
|
word32 GetSeed() {return seed;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
word32 seed;
|
word32 seed;
|
||||||
byte *const seedBytes;
|
uint8_t *const seedBytes;
|
||||||
|
|
||||||
static const word32 m;
|
static const word32 m;
|
||||||
static const word32 q;
|
static const word32 q;
|
||||||
|
@ -35,9 +35,9 @@ class X917RNG : public RandomNumberGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// cipher will be deleted by destructor
|
// cipher will be deleted by destructor
|
||||||
X917RNG(BlockTransformation *cipher, const byte *seed);
|
X917RNG(BlockTransformation *cipher, const uint8_t *seed);
|
||||||
|
|
||||||
byte GetByte();
|
uint8_t GetByte();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
member_ptr<BlockTransformation> cipher;
|
member_ptr<BlockTransformation> cipher;
|
||||||
|
@ -56,8 +56,8 @@ class MaurerRandomnessTest : public Sink
|
||||||
public:
|
public:
|
||||||
MaurerRandomnessTest();
|
MaurerRandomnessTest();
|
||||||
|
|
||||||
void Put(byte inByte);
|
void Put(uint8_t inByte);
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
// BytesNeeded() returns how many more bytes of input is needed by the test
|
// BytesNeeded() returns how many more bytes of input is needed by the test
|
||||||
// GetTestValue() should not be called before BytesNeeded()==0
|
// GetTestValue() should not be called before BytesNeeded()==0
|
||||||
|
|
|
@ -31,7 +31,7 @@ void SHA::HashBlock(const word32 *input)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA::Final(byte *hash)
|
void SHA::Final(uint8_t *hash)
|
||||||
{
|
{
|
||||||
PadLastBlock(56);
|
PadLastBlock(56);
|
||||||
CorrectEndianess(data, data, 56);
|
CorrectEndianess(data, data, 56);
|
||||||
|
@ -115,7 +115,7 @@ void SHA::Transform( word32 *digest, const word32 *data )
|
||||||
word32 eData[16];
|
word32 eData[16];
|
||||||
memcpy( eData, data, DATASIZE );
|
memcpy( eData, data, DATASIZE );
|
||||||
|
|
||||||
register word32 A, B, C, D, E;
|
word32 A, B, C, D, E;
|
||||||
A = digest[0];
|
A = digest[0];
|
||||||
B = digest[1];
|
B = digest[1];
|
||||||
C = digest[2];
|
C = digest[2];
|
||||||
|
|
|
@ -7,7 +7,7 @@ class SHA : public IteratedHash<word32>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SHA();
|
SHA();
|
||||||
void Final(byte *hash);
|
void Final(uint8_t *hash);
|
||||||
unsigned int DigestSize() const {return DIGESTSIZE;};
|
unsigned int DigestSize() const {return DIGESTSIZE;};
|
||||||
|
|
||||||
static void CorrectEndianess(word32 *out, const word32 *in, unsigned int byteCount)
|
static void CorrectEndianess(word32 *out, const word32 *in, unsigned int byteCount)
|
||||||
|
|
|
@ -63,13 +63,13 @@ void BitOutput::bi_windup()
|
||||||
|
|
||||||
void BitOutput::bi_putsh(word16 x)
|
void BitOutput::bi_putsh(word16 x)
|
||||||
{
|
{
|
||||||
outQ.Put((byte)x);
|
outQ.Put((uint8_t)x);
|
||||||
outQ.Put(byte(x>>8));
|
outQ.Put(uint8_t(x>>8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy a stored block to the zip file, storing first the length and its
|
/* Copy a stored block to the zip file, storing first the length and its
|
||||||
one's complement if requested. */
|
one's complement if requested. */
|
||||||
void BitOutput::copy_block(byte *buf, unsigned int len, int header)
|
void BitOutput::copy_block(uint8_t *buf, unsigned int len, int header)
|
||||||
{
|
{
|
||||||
/* align on byte boundary */
|
/* align on byte boundary */
|
||||||
bi_windup();
|
bi_windup();
|
||||||
|
|
|
@ -11,7 +11,7 @@ public:
|
||||||
void send_bits (unsigned value, int length);
|
void send_bits (unsigned value, int length);
|
||||||
void bi_windup (void);
|
void bi_windup (void);
|
||||||
void bi_putsh (unsigned short);
|
void bi_putsh (unsigned short);
|
||||||
void copy_block (byte *buf, unsigned len, int header);
|
void copy_block (uint8_t *buf, unsigned len, int header);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BufferedTransformation &outQ;
|
BufferedTransformation &outQ;
|
||||||
|
|
|
@ -142,7 +142,7 @@ const Deflator::config Deflator::configuration_table[10] = {
|
||||||
|
|
||||||
void Deflator::init_hash()
|
void Deflator::init_hash()
|
||||||
{
|
{
|
||||||
register unsigned j;
|
unsigned j;
|
||||||
|
|
||||||
for (ins_h=0, j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(ins_h, window[j]);
|
for (ins_h=0, j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(ins_h, window[j]);
|
||||||
/* If lookahead < MIN_MATCH, ins_h is garbage, but this is
|
/* If lookahead < MIN_MATCH, ins_h is garbage, but this is
|
||||||
|
@ -175,7 +175,7 @@ Deflator::Deflator(int deflate_level, BufferedTransformation *outQ)
|
||||||
prev_length = MIN_MATCH-1;
|
prev_length = MIN_MATCH-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Deflator::Put(const byte *inString, unsigned int length)
|
void Deflator::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
if (deflate_level <= 3)
|
if (deflate_level <= 3)
|
||||||
fast_deflate(inString, length);
|
fast_deflate(inString, length);
|
||||||
|
@ -205,9 +205,9 @@ void Deflator::InputFinished()
|
||||||
int Deflator::longest_match(IPos cur_match)
|
int Deflator::longest_match(IPos cur_match)
|
||||||
{
|
{
|
||||||
unsigned chain_length = max_chain_length; /* max hash chain length */
|
unsigned chain_length = max_chain_length; /* max hash chain length */
|
||||||
register byte *scan = window + strstart; /* current string */
|
uint8_t *scan = window + strstart; /* current string */
|
||||||
register byte *match; /* matched string */
|
uint8_t *match; /* matched string */
|
||||||
register int len; /* length of current match */
|
int len; /* length of current match */
|
||||||
int best_len = prev_length; /* best match length so far */
|
int best_len = prev_length; /* best match length so far */
|
||||||
IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL;
|
IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL;
|
||||||
/* Stop when cur_match becomes <= limit. To simplify the code,
|
/* Stop when cur_match becomes <= limit. To simplify the code,
|
||||||
|
@ -223,13 +223,13 @@ int Deflator::longest_match(IPos cur_match)
|
||||||
#ifdef UNALIGNED_OK
|
#ifdef UNALIGNED_OK
|
||||||
/* Compare two bytes at a time. Note: this is not always beneficial.
|
/* Compare two bytes at a time. Note: this is not always beneficial.
|
||||||
Try with and without -DUNALIGNED_OK to check. */
|
Try with and without -DUNALIGNED_OK to check. */
|
||||||
register byte *strend = window + strstart + MAX_MATCH - 1;
|
uint8_t *strend = window + strstart + MAX_MATCH - 1;
|
||||||
register word16 scan_start = *(word16*)scan;
|
word16 scan_start = *(word16*)scan;
|
||||||
register word16 scan_end = *(word16*)(scan+best_len-1);
|
word16 scan_end = *(word16*)(scan+best_len-1);
|
||||||
#else
|
#else
|
||||||
register byte *strend = window + strstart + MAX_MATCH;
|
uint8_t *strend = window + strstart + MAX_MATCH;
|
||||||
register byte scan_end1 = scan[best_len-1];
|
uint8_t scan_end1 = scan[best_len-1];
|
||||||
register byte scan_end = scan[best_len];
|
uint8_t scan_end = scan[best_len];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Do not waste too much time if we already have a good match: */
|
/* Do not waste too much time if we already have a good match: */
|
||||||
|
@ -350,9 +350,9 @@ int length;
|
||||||
* IN assertion: lookahead < MIN_LOOKAHEAD.
|
* IN assertion: lookahead < MIN_LOOKAHEAD.
|
||||||
* Note: call with either lookahead == 0 or length == 0 is valid
|
* Note: call with either lookahead == 0 or length == 0 is valid
|
||||||
*/
|
*/
|
||||||
unsigned Deflator::fill_window(const byte *buffer, unsigned int length)
|
unsigned Deflator::fill_window(const uint8_t *buffer, unsigned int length)
|
||||||
{
|
{
|
||||||
register unsigned n, m;
|
unsigned n, m;
|
||||||
unsigned more = length;
|
unsigned more = length;
|
||||||
|
|
||||||
/* Amount of free space at the end of the window. */
|
/* Amount of free space at the end of the window. */
|
||||||
|
@ -382,7 +382,7 @@ unsigned Deflator::fill_window(const byte *buffer, unsigned int length)
|
||||||
if ((more += WSIZE) > length) more = length;
|
if ((more += WSIZE) > length) more = length;
|
||||||
}
|
}
|
||||||
if (more) {
|
if (more) {
|
||||||
memcpy((byte*)window+strstart+lookahead, buffer, more);
|
memcpy((uint8_t*)window+strstart+lookahead, buffer, more);
|
||||||
lookahead += more;
|
lookahead += more;
|
||||||
}
|
}
|
||||||
return more;
|
return more;
|
||||||
|
@ -392,13 +392,13 @@ unsigned Deflator::fill_window(const byte *buffer, unsigned int length)
|
||||||
IN assertion: strstart is set to the end of the current match. */
|
IN assertion: strstart is set to the end of the current match. */
|
||||||
#define FLUSH_BLOCK(eof) flush_block(block_start >= 0L ?\
|
#define FLUSH_BLOCK(eof) flush_block(block_start >= 0L ?\
|
||||||
window+block_start : \
|
window+block_start : \
|
||||||
(byte *)0, (long)strstart - block_start, (eof))
|
(uint8_t *)0, (long)strstart - block_start, (eof))
|
||||||
|
|
||||||
/* Processes a new input block.
|
/* Processes a new input block.
|
||||||
* This function does not perform lazy evaluationof matches and inserts
|
* This function does not perform lazy evaluationof matches and inserts
|
||||||
* new strings in the dictionary only for unmatched strings or for short
|
* new strings in the dictionary only for unmatched strings or for short
|
||||||
* matches. It is used only for the fast compression options. */
|
* matches. It is used only for the fast compression options. */
|
||||||
int Deflator::fast_deflate(const byte *buffer, unsigned int length)
|
int Deflator::fast_deflate(const uint8_t *buffer, unsigned int length)
|
||||||
{
|
{
|
||||||
IPos hash_head; /* head of the hash chain */
|
IPos hash_head; /* head of the hash chain */
|
||||||
int flush; /* set if current block must be flushed */
|
int flush; /* set if current block must be flushed */
|
||||||
|
@ -486,12 +486,12 @@ int Deflator::fast_deflate(const byte *buffer, unsigned int length)
|
||||||
/* Same as above, but achieves better compression. We use a lazy
|
/* Same as above, but achieves better compression. We use a lazy
|
||||||
* evaluation for matches: a match is finally adopted only if there is
|
* evaluation for matches: a match is finally adopted only if there is
|
||||||
* no better match at the next window position. */
|
* no better match at the next window position. */
|
||||||
int Deflator::lazy_deflate(const byte *buffer, unsigned int length)
|
int Deflator::lazy_deflate(const uint8_t *buffer, unsigned int length)
|
||||||
{
|
{
|
||||||
IPos hash_head; /* head of hash chain */
|
IPos hash_head; /* head of hash chain */
|
||||||
IPos prev_match; /* previous match */
|
IPos prev_match; /* previous match */
|
||||||
int flush; /* set if current block must be flushed */
|
int flush; /* set if current block must be flushed */
|
||||||
register unsigned ml = match_length; /* length of best match */
|
unsigned ml = match_length; /* length of best match */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern word32 isize; /* byte length of input file, for debug only */
|
extern word32 isize; /* byte length of input file, for debug only */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,9 +13,9 @@ public:
|
||||||
// default for the gzip program is 6
|
// default for the gzip program is 6
|
||||||
Deflator(int deflate_level, BufferedTransformation *outQ = NULL);
|
Deflator(int deflate_level, BufferedTransformation *outQ = NULL);
|
||||||
|
|
||||||
void Put(byte inByte)
|
void Put(uint8_t inByte)
|
||||||
{Deflator::Put(&inByte, 1);}
|
{Deflator::Put(&inByte, 1);}
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
|
|
||||||
void InputFinished();
|
void InputFinished();
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ private:
|
||||||
SecByteBlock window;
|
SecByteBlock window;
|
||||||
SecBlock<Pos> prev, head;
|
SecBlock<Pos> prev, head;
|
||||||
|
|
||||||
unsigned fill_window (const byte*, unsigned);
|
unsigned fill_window (const uint8_t*, unsigned);
|
||||||
void init_hash ();
|
void init_hash ();
|
||||||
|
|
||||||
int longest_match (IPos cur_match);
|
int longest_match (IPos cur_match);
|
||||||
|
|
||||||
int fast_deflate(const byte *buffer, unsigned int length);
|
int fast_deflate(const uint8_t *buffer, unsigned int length);
|
||||||
int lazy_deflate(const byte *buffer, unsigned int length);
|
int lazy_deflate(const uint8_t *buffer, unsigned int length);
|
||||||
|
|
||||||
unsigned ins_h; /* hash index of string to be inserted */
|
unsigned ins_h; /* hash index of string to be inserted */
|
||||||
char uptodate; /* hash preparation flag */
|
char uptodate; /* hash preparation flag */
|
||||||
|
|
|
@ -74,7 +74,7 @@ Inflator::Inflator(BufferedTransformation *output, BufferedTransformation *bypas
|
||||||
afterEnd = false;
|
afterEnd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inflator::Put(const byte *inString, unsigned int length)
|
void Inflator::Put(const uint8_t *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
if (afterEnd)
|
if (afterEnd)
|
||||||
AccessPort(1).Put(inString, length);
|
AccessPort(1).Put(inString, length);
|
||||||
|
@ -89,7 +89,7 @@ void Inflator::Put(const byte *inString, unsigned int length)
|
||||||
{
|
{
|
||||||
flush_output(wp);
|
flush_output(wp);
|
||||||
if (bk>=8) // undo too much lookahead
|
if (bk>=8) // undo too much lookahead
|
||||||
AccessPort(1).Put(byte(bb>>(bk-=8)));
|
AccessPort(1).Put(uint8_t(bb>>(bk-=8)));
|
||||||
|
|
||||||
inQueue.TransferTo(AccessPort(1));
|
inQueue.TransferTo(AccessPort(1));
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ void Inflator::InputFinished()
|
||||||
flush_output(wp);
|
flush_output(wp);
|
||||||
|
|
||||||
if (bk>=8) // undo too much lookahead
|
if (bk>=8) // undo too much lookahead
|
||||||
AccessPort(1).Put(byte(bb>>(bk-=8)));
|
AccessPort(1).Put(uint8_t(bb>>(bk-=8)));
|
||||||
|
|
||||||
inQueue.TransferTo(AccessPort(1));
|
inQueue.TransferTo(AccessPort(1));
|
||||||
}
|
}
|
||||||
|
@ -183,9 +183,9 @@ const word16 Inflator::mask_bits[] = {
|
||||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||||
};
|
};
|
||||||
|
|
||||||
byte Inflator::NEXTBYTE()
|
uint8_t Inflator::NEXTBYTE()
|
||||||
{
|
{
|
||||||
byte b;
|
uint8_t b;
|
||||||
if (!inQueue.Get(b))
|
if (!inQueue.Get(b))
|
||||||
#ifdef THROW_EXCEPTIONS
|
#ifdef THROW_EXCEPTIONS
|
||||||
throw UnexpectedEndErr();
|
throw UnexpectedEndErr();
|
||||||
|
@ -252,16 +252,16 @@ int Inflator::huft_build(unsigned *b, unsigned n, unsigned s, const word16 *d, c
|
||||||
unsigned f; /* i repeats in table every f entries */
|
unsigned f; /* i repeats in table every f entries */
|
||||||
int g; /* maximum code length */
|
int g; /* maximum code length */
|
||||||
int h; /* table level */
|
int h; /* table level */
|
||||||
register unsigned i; /* counter, current code */
|
unsigned i; /* counter, current code */
|
||||||
register unsigned j; /* counter */
|
unsigned j; /* counter */
|
||||||
register int k; /* number of bits in current code */
|
int k; /* number of bits in current code */
|
||||||
int l; /* bits per table (returned in m) */
|
int l; /* bits per table (returned in m) */
|
||||||
register unsigned *p; /* pointer into c[], b[], or v[] */
|
unsigned *p; /* pointer into c[], b[], or v[] */
|
||||||
register huft *q; /* points to current table */
|
huft *q; /* points to current table */
|
||||||
huft r; /* table entry for structure assignment */
|
huft r; /* table entry for structure assignment */
|
||||||
huft *u[BMAX]; /* table stack */
|
huft *u[BMAX]; /* table stack */
|
||||||
unsigned v[N_MAX]; /* values in order of bit length */
|
unsigned v[N_MAX]; /* values in order of bit length */
|
||||||
register int w; /* bits before this table == (l * h) */
|
int w; /* bits before this table == (l * h) */
|
||||||
unsigned x[BMAX+1]; /* bit offsets, then code stack */
|
unsigned x[BMAX+1]; /* bit offsets, then code stack */
|
||||||
unsigned *xp; /* pointer into x */
|
unsigned *xp; /* pointer into x */
|
||||||
int y; /* number of dummy codes added */
|
int y; /* number of dummy codes added */
|
||||||
|
@ -380,8 +380,8 @@ int Inflator::huft_build(unsigned *b, unsigned n, unsigned s, const word16 *d, c
|
||||||
if (h)
|
if (h)
|
||||||
{
|
{
|
||||||
x[h] = i; /* save pattern for backing up */
|
x[h] = i; /* save pattern for backing up */
|
||||||
r.b = (byte)l; /* bits to dump before this table */
|
r.b = (uint8_t)l; /* bits to dump before this table */
|
||||||
r.e = (byte)(16 + j); /* bits in this table */
|
r.e = (uint8_t)(16 + j); /* bits in this table */
|
||||||
r.v.t = q; /* pointer to this table */
|
r.v.t = q; /* pointer to this table */
|
||||||
j = i >> (w - l); /* (get around Turbo C bug) */
|
j = i >> (w - l); /* (get around Turbo C bug) */
|
||||||
u[h-1][j] = r; /* connect to last table */
|
u[h-1][j] = r; /* connect to last table */
|
||||||
|
@ -389,18 +389,18 @@ int Inflator::huft_build(unsigned *b, unsigned n, unsigned s, const word16 *d, c
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up table entry in r */
|
/* set up table entry in r */
|
||||||
r.b = (byte)(k - w);
|
r.b = (uint8_t)(k - w);
|
||||||
if (p >= v + n)
|
if (p >= v + n)
|
||||||
r.e = 99; /* out of values--invalid code */
|
r.e = 99; /* out of values--invalid code */
|
||||||
else if (*p < s)
|
else if (*p < s)
|
||||||
{
|
{
|
||||||
r.e = (byte)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
|
r.e = (uint8_t)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
|
||||||
r.v.n = (word16)(*p); /* simple code is just the value */
|
r.v.n = (word16)(*p); /* simple code is just the value */
|
||||||
p++; /* one compiler does not like *p++ */
|
p++; /* one compiler does not like *p++ */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r.e = (byte)e[*p - s]; /* non-simple--look up in lists */
|
r.e = (uint8_t)e[*p - s]; /* non-simple--look up in lists */
|
||||||
r.v.n = d[*p++ - s];
|
r.v.n = d[*p++ - s];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ int Inflator::huft_free(huft *t)
|
||||||
list of the tables it made, with the links in a dummy first entry of
|
list of the tables it made, with the links in a dummy first entry of
|
||||||
each table. */
|
each table. */
|
||||||
{
|
{
|
||||||
register huft *p, *q;
|
huft *p, *q;
|
||||||
|
|
||||||
|
|
||||||
/* Go through linked list, freeing from the malloced (t[-1]) address. */
|
/* Go through linked list, freeing from the malloced (t[-1]) address. */
|
||||||
|
@ -454,13 +454,13 @@ int Inflator::inflate_codes(huft *tl, huft *td, int bl, int bd)
|
||||||
/* inflate (decompress) the codes in a deflated (compressed) block.
|
/* inflate (decompress) the codes in a deflated (compressed) block.
|
||||||
Return an error code or zero if it all goes ok. */
|
Return an error code or zero if it all goes ok. */
|
||||||
{
|
{
|
||||||
register unsigned e; /* table entry flag/number of extra bits */
|
unsigned e; /* table entry flag/number of extra bits */
|
||||||
unsigned n, d; /* length and index for copy */
|
unsigned n, d; /* length and index for copy */
|
||||||
unsigned w; /* current window position */
|
unsigned w; /* current window position */
|
||||||
huft *t; /* pointer to table entry */
|
huft *t; /* pointer to table entry */
|
||||||
unsigned ml, md; /* masks for bl and bd bits */
|
unsigned ml, md; /* masks for bl and bd bits */
|
||||||
register word32 b; /* bit buffer */
|
word32 b; /* bit buffer */
|
||||||
register unsigned k; /* number of bits in bit buffer */
|
unsigned k; /* number of bits in bit buffer */
|
||||||
|
|
||||||
|
|
||||||
/* make local copies of globals */
|
/* make local copies of globals */
|
||||||
|
@ -485,7 +485,7 @@ int Inflator::inflate_codes(huft *tl, huft *td, int bl, int bd)
|
||||||
DUMPBITS(t->b)
|
DUMPBITS(t->b)
|
||||||
if (e == 16) /* then it's a literal */
|
if (e == 16) /* then it's a literal */
|
||||||
{
|
{
|
||||||
slide[w++] = (byte)t->v.n;
|
slide[w++] = (uint8_t)t->v.n;
|
||||||
Tracevv((stderr, "%c", slide[w-1]));
|
Tracevv((stderr, "%c", slide[w-1]));
|
||||||
if (w == WSIZE)
|
if (w == WSIZE)
|
||||||
{
|
{
|
||||||
|
@ -562,8 +562,8 @@ int Inflator::inflate_stored()
|
||||||
{
|
{
|
||||||
unsigned n; /* number of bytes in block */
|
unsigned n; /* number of bytes in block */
|
||||||
unsigned w; /* current window position */
|
unsigned w; /* current window position */
|
||||||
register word32 b; /* bit buffer */
|
word32 b; /* bit buffer */
|
||||||
register unsigned k; /* number of bits in bit buffer */
|
unsigned k; /* number of bits in bit buffer */
|
||||||
|
|
||||||
|
|
||||||
/* make local copies of globals */
|
/* make local copies of globals */
|
||||||
|
@ -591,7 +591,7 @@ int Inflator::inflate_stored()
|
||||||
while (n--)
|
while (n--)
|
||||||
{
|
{
|
||||||
NEEDBITS(8)
|
NEEDBITS(8)
|
||||||
slide[w++] = (byte)b;
|
slide[w++] = (uint8_t)b;
|
||||||
if (w == WSIZE)
|
if (w == WSIZE)
|
||||||
{
|
{
|
||||||
flush_output(w);
|
flush_output(w);
|
||||||
|
@ -681,8 +681,8 @@ int Inflator::inflate_dynamic()
|
||||||
#else
|
#else
|
||||||
unsigned ll[286+30]; /* literal/length and distance code lengths */
|
unsigned ll[286+30]; /* literal/length and distance code lengths */
|
||||||
#endif
|
#endif
|
||||||
register word32 b; /* bit buffer */
|
word32 b; /* bit buffer */
|
||||||
register unsigned k; /* number of bits in bit buffer */
|
unsigned k; /* number of bits in bit buffer */
|
||||||
|
|
||||||
|
|
||||||
/* make local bit buffer */
|
/* make local bit buffer */
|
||||||
|
@ -829,8 +829,8 @@ int Inflator::inflate_block(bool &e)
|
||||||
/* decompress an inflated block */
|
/* decompress an inflated block */
|
||||||
{
|
{
|
||||||
unsigned t; /* block type */
|
unsigned t; /* block type */
|
||||||
register word32 b; /* bit buffer */
|
word32 b; /* bit buffer */
|
||||||
register unsigned k; /* number of bits in bit buffer */
|
unsigned k; /* number of bits in bit buffer */
|
||||||
|
|
||||||
|
|
||||||
/* make local bit buffer */
|
/* make local bit buffer */
|
||||||
|
|
|
@ -14,16 +14,16 @@ public:
|
||||||
Inflator(BufferedTransformation *output = NULL,
|
Inflator(BufferedTransformation *output = NULL,
|
||||||
BufferedTransformation *bypassed = NULL);
|
BufferedTransformation *bypassed = NULL);
|
||||||
|
|
||||||
void Put(byte b)
|
void Put(uint8_t b)
|
||||||
{Inflator::Put(&b, 1);}
|
{Inflator::Put(&b, 1);}
|
||||||
|
|
||||||
void Put(const byte *inString, unsigned int length);
|
void Put(const uint8_t *inString, unsigned int length);
|
||||||
void InputFinished();
|
void InputFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct huft {
|
struct huft {
|
||||||
byte e; /* number of extra bits or operation */
|
uint8_t e; /* number of extra bits or operation */
|
||||||
byte b; /* number of bits in this code or subcode */
|
uint8_t b; /* number of bits in this code or subcode */
|
||||||
union {
|
union {
|
||||||
word16 n; /* literal, length base, or distance base */
|
word16 n; /* literal, length base, or distance base */
|
||||||
struct huft *t; /* pointer to next level of table */
|
struct huft *t; /* pointer to next level of table */
|
||||||
|
@ -49,7 +49,7 @@ private:
|
||||||
static const word16 mask_bits[18];
|
static const word16 mask_bits[18];
|
||||||
|
|
||||||
ByteQueue inQueue;
|
ByteQueue inQueue;
|
||||||
byte NEXTBYTE();
|
uint8_t NEXTBYTE();
|
||||||
|
|
||||||
SecByteBlock slide;
|
SecByteBlock slide;
|
||||||
unsigned int wp;
|
unsigned int wp;
|
||||||
|
|
|
@ -75,7 +75,7 @@ const int CodeTree::extra_dbits[] /* extra bits for each distance code */
|
||||||
const int CodeTree::extra_blbits[]/* extra bits for each bit length code */
|
const int CodeTree::extra_blbits[]/* extra bits for each bit length code */
|
||||||
= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
|
= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
|
||||||
|
|
||||||
const byte CodeTree::bl_order[]
|
const uint8_t CodeTree::bl_order[]
|
||||||
= {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
|
= {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
|
||||||
/* The lengths of the bit length codes are sent in order of decreasing
|
/* The lengths of the bit length codes are sent in order of decreasing
|
||||||
* probability, to avoid transmitting the lengths for unused bit length codes.
|
* probability, to avoid transmitting the lengths for unused bit length codes.
|
||||||
|
@ -97,7 +97,7 @@ const byte CodeTree::bl_order[]
|
||||||
static unsigned reverse(unsigned int code, int len)
|
static unsigned reverse(unsigned int code, int len)
|
||||||
/* Reverse the first len bits of a code. */
|
/* Reverse the first len bits of a code. */
|
||||||
{
|
{
|
||||||
register unsigned res = 0;
|
unsigned res = 0;
|
||||||
do res = (res << 1) | (code & 1), code>>=1; while (--len);
|
do res = (res << 1) | (code & 1), code>>=1; while (--len);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ CodeTree::CodeTree(int deflate_level, BufferedTransformation &outQ)
|
||||||
unsigned int n; /* iterates over tree elements */
|
unsigned int n; /* iterates over tree elements */
|
||||||
unsigned int bits; /* bit counter */
|
unsigned int bits; /* bit counter */
|
||||||
unsigned int length; /* length value */
|
unsigned int length; /* length value */
|
||||||
register unsigned int code; /* code value */
|
unsigned int code; /* code value */
|
||||||
unsigned int dist; /* distance index */
|
unsigned int dist; /* distance index */
|
||||||
|
|
||||||
compressed_len = input_len = 0L;
|
compressed_len = input_len = 0L;
|
||||||
|
@ -136,21 +136,21 @@ CodeTree::CodeTree(int deflate_level, BufferedTransformation &outQ)
|
||||||
for (code=0; code < LENGTH_CODES-1; code++) {
|
for (code=0; code < LENGTH_CODES-1; code++) {
|
||||||
base_length[code] = length;
|
base_length[code] = length;
|
||||||
for (n=0; n < (1U<<extra_lbits[code]); n++) {
|
for (n=0; n < (1U<<extra_lbits[code]); n++) {
|
||||||
length_code[length++] = (byte)code;
|
length_code[length++] = (uint8_t)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert (length == 256);
|
assert (length == 256);
|
||||||
/* Note that the length 255 (match length 258) can be represented
|
/* Note that the length 255 (match length 258) can be represented
|
||||||
in two different ways: code 284 + 5 bits or code 285, so we
|
in two different ways: code 284 + 5 bits or code 285, so we
|
||||||
overwrite length_code[255] to use the best encoding: */
|
overwrite length_code[255] to use the best encoding: */
|
||||||
length_code[length-1] = (byte)code;
|
length_code[length-1] = (uint8_t)code;
|
||||||
|
|
||||||
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
/* Initialize the mapping dist (0..32K) -> dist code (0..29) */
|
||||||
dist = 0;
|
dist = 0;
|
||||||
for (code=0 ; code < 16; code++) {
|
for (code=0 ; code < 16; code++) {
|
||||||
base_dist[code] = dist;
|
base_dist[code] = dist;
|
||||||
for (n=0; n < (1U<<extra_dbits[code]); n++) {
|
for (n=0; n < (1U<<extra_dbits[code]); n++) {
|
||||||
dist_code[dist++] = (byte)code;
|
dist_code[dist++] = (uint8_t)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert (dist == 256);
|
assert (dist == 256);
|
||||||
|
@ -158,7 +158,7 @@ CodeTree::CodeTree(int deflate_level, BufferedTransformation &outQ)
|
||||||
for (; code < D_CODES; code++) {
|
for (; code < D_CODES; code++) {
|
||||||
base_dist[code] = dist << 7;
|
base_dist[code] = dist << 7;
|
||||||
for (n=0; n < (1U<<(extra_dbits[code]-7)); n++) {
|
for (n=0; n < (1U<<(extra_dbits[code]-7)); n++) {
|
||||||
dist_code[256 + dist++] = (byte)code;
|
dist_code[256 + dist++] = (uint8_t)code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert (dist == 256);
|
assert (dist == 256);
|
||||||
|
@ -191,7 +191,7 @@ CodeTree::CodeTree(int deflate_level, BufferedTransformation &outQ)
|
||||||
/* Initialize a new block. */
|
/* Initialize a new block. */
|
||||||
void CodeTree::init_block()
|
void CodeTree::init_block()
|
||||||
{
|
{
|
||||||
register unsigned int n; /* iterates over tree elements */
|
unsigned int n; /* iterates over tree elements */
|
||||||
|
|
||||||
/* Initialize the trees. */
|
/* Initialize the trees. */
|
||||||
for (n=0; n < L_CODES; n++) dyn_ltree[n].Freq = 0;
|
for (n=0; n < L_CODES; n++) dyn_ltree[n].Freq = 0;
|
||||||
|
@ -444,7 +444,7 @@ void CodeTree::build_tree(tree_desc *desc)
|
||||||
|
|
||||||
/* Create a new node father of n and m */
|
/* Create a new node father of n and m */
|
||||||
tree[node].Freq = tree[n].Freq + tree[m].Freq;
|
tree[node].Freq = tree[n].Freq + tree[m].Freq;
|
||||||
depth[(unsigned int)node] = (byte) (MAX(depth[(unsigned int)n], depth[(unsigned int)m]) + 1);
|
depth[(unsigned int)node] = (uint8_t) (MAX(depth[(unsigned int)n], depth[(unsigned int)m]) + 1);
|
||||||
tree[n].Dad = tree[m].Dad = node;
|
tree[n].Dad = tree[m].Dad = node;
|
||||||
#ifdef DUMP_BL_TREE
|
#ifdef DUMP_BL_TREE
|
||||||
if (tree == bl_tree) {
|
if (tree == bl_tree) {
|
||||||
|
@ -627,7 +627,7 @@ void CodeTree::send_all_trees(int lcodes, int dcodes, int blcodes)
|
||||||
* trees or store, and output the encoded block to the zip file. This function
|
* trees or store, and output the encoded block to the zip file. This function
|
||||||
* returns the total compressed length for the file so far.
|
* returns the total compressed length for the file so far.
|
||||||
*/
|
*/
|
||||||
word32 CodeTree::flush_block(byte *buf, word32 stored_len, int eof)
|
word32 CodeTree::flush_block(uint8_t *buf, word32 stored_len, int eof)
|
||||||
{
|
{
|
||||||
word32 opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
word32 opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
||||||
int max_blindex; /* index of last bit length code of non zero freq */
|
int max_blindex; /* index of last bit length code of non zero freq */
|
||||||
|
@ -712,7 +712,7 @@ word32 CodeTree::flush_block(byte *buf, word32 stored_len, int eof)
|
||||||
Return true if the current block must be flushed. */
|
Return true if the current block must be flushed. */
|
||||||
int CodeTree::ct_tally (int dist, int lc)
|
int CodeTree::ct_tally (int dist, int lc)
|
||||||
{
|
{
|
||||||
l_buf[last_lit++] = (byte)lc;
|
l_buf[last_lit++] = (uint8_t)lc;
|
||||||
if (dist == 0) {
|
if (dist == 0) {
|
||||||
/* lc is the unmatched char */
|
/* lc is the unmatched char */
|
||||||
dyn_ltree[(unsigned int)lc].Freq++;
|
dyn_ltree[(unsigned int)lc].Freq++;
|
||||||
|
@ -765,7 +765,7 @@ void CodeTree::compress_block(ct_data *ltree, ct_data *dtree)
|
||||||
unsigned lx = 0; /* running index in l_buf */
|
unsigned lx = 0; /* running index in l_buf */
|
||||||
unsigned dx = 0; /* running index in d_buf */
|
unsigned dx = 0; /* running index in d_buf */
|
||||||
unsigned fx = 0; /* running index in flag_buf */
|
unsigned fx = 0; /* running index in flag_buf */
|
||||||
byte flag = 0; /* current flags */
|
uint8_t flag = 0; /* current flags */
|
||||||
unsigned code; /* the code to send */
|
unsigned code; /* the code to send */
|
||||||
int extra; /* number of extra bits to send */
|
int extra; /* number of extra bits to send */
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ public:
|
||||||
CodeTree(int deflate_level, BufferedTransformation &outQ);
|
CodeTree(int deflate_level, BufferedTransformation &outQ);
|
||||||
|
|
||||||
int ct_tally (int dist, int lc);
|
int ct_tally (int dist, int lc);
|
||||||
word32 flush_block (byte *buf, word32 stored_len, int eof);
|
word32 flush_block (uint8_t *buf, word32 stored_len, int eof);
|
||||||
|
|
||||||
long block_start; /* window offset of current block */
|
long block_start; /* window offset of current block */
|
||||||
unsigned int strstart; /* window offset of current string */
|
unsigned int strstart; /* window offset of current string */
|
||||||
|
@ -73,7 +73,7 @@ private:
|
||||||
static const int extra_lbits[LENGTH_CODES];
|
static const int extra_lbits[LENGTH_CODES];
|
||||||
static const int extra_dbits[D_CODES];
|
static const int extra_dbits[D_CODES];
|
||||||
static const int extra_blbits[BL_CODES];
|
static const int extra_blbits[BL_CODES];
|
||||||
static const byte bl_order[BL_CODES];
|
static const uint8_t bl_order[BL_CODES];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Data structure describing a single value and its code string. */
|
// Data structure describing a single value and its code string. */
|
||||||
|
@ -168,8 +168,8 @@ private:
|
||||||
unsigned last_lit; /* running index in l_buf */
|
unsigned last_lit; /* running index in l_buf */
|
||||||
unsigned last_dist; /* running index in d_buf */
|
unsigned last_dist; /* running index in d_buf */
|
||||||
unsigned last_flags; /* running index in flag_buf */
|
unsigned last_flags; /* running index in flag_buf */
|
||||||
byte flags; /* current flags not yet saved in flag_buf */
|
uint8_t flags; /* current flags not yet saved in flag_buf */
|
||||||
byte flag_bit; /* current bit used in flags */
|
uint8_t flag_bit; /* current bit used in flags */
|
||||||
/* bits are filled in flags starting at bit 0 (least significant).
|
/* bits are filled in flags starting at bit 0 (least significant).
|
||||||
* Note: these flags are overkill in the current code since we don't
|
* Note: these flags are overkill in the current code since we don't
|
||||||
* take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
|
* take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
|
||||||
|
|
|
@ -107,10 +107,10 @@ void cArchiveSigGen::AddSig(iSignature* pSig)
|
||||||
|
|
||||||
void cArchiveSigGen::CalculateSignatures(cArchive& a)
|
void cArchiveSigGen::CalculateSignatures(cArchive& a)
|
||||||
{
|
{
|
||||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE * 2];
|
uint8_t abBuf[iSignature::SUGGESTED_BLOCK_SIZE * 2];
|
||||||
int cbRead;
|
int cbRead;
|
||||||
container_type::size_type i;
|
container_type::size_type i;
|
||||||
byte* pBuf = abBuf;
|
uint8_t* pBuf = abBuf;
|
||||||
|
|
||||||
if (s_direct)
|
if (s_direct)
|
||||||
{
|
{
|
||||||
|
@ -154,13 +154,13 @@ void cArchiveSigGen::SetHex(bool hex)
|
||||||
// number of bits in the array
|
// number of bits in the array
|
||||||
// ptr-to-str for return string val
|
// ptr-to-str for return string val
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
char* btob64(const register byte* pcbitvec, register char* pcout, int numbits)
|
char* btob64(const uint8_t* pcbitvec, char* pcout, int numbits)
|
||||||
{
|
{
|
||||||
register unsigned int val;
|
unsigned int val;
|
||||||
register int offset;
|
int offset;
|
||||||
uint8* pcorig = (uint8*)pcout;
|
uint8* pcorig = (uint8*)pcout;
|
||||||
|
|
||||||
ASSERT(sizeof(uint8) == sizeof(byte)); /* everything breaks otherwise */
|
ASSERT(sizeof(uint8) == sizeof(uint8_t)); /* everything breaks otherwise */
|
||||||
assert(numbits > 0);
|
assert(numbits > 0);
|
||||||
|
|
||||||
val = *pcbitvec;
|
val = *pcbitvec;
|
||||||
|
@ -200,8 +200,8 @@ char* btob64(const register byte* pcbitvec, register char* pcout, int numbits)
|
||||||
#define NUMTMPLONGS 1000
|
#define NUMTMPLONGS 1000
|
||||||
char* pltob64(uint32* pl, char* pcout, int numlongs)
|
char* pltob64(uint32* pl, char* pcout, int numlongs)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register uint32* plto;
|
uint32* plto;
|
||||||
uint32 larray[NUMTMPLONGS];
|
uint32 larray[NUMTMPLONGS];
|
||||||
|
|
||||||
assert(numlongs < NUMTMPLONGS);
|
assert(numlongs < NUMTMPLONGS);
|
||||||
|
@ -214,7 +214,7 @@ char* pltob64(uint32* pl, char* pcout, int numlongs)
|
||||||
++plto;
|
++plto;
|
||||||
}
|
}
|
||||||
|
|
||||||
return btob64((byte*)larray, (char*)pcout, numlongs * sizeof(uint32) * 8);
|
return btob64((uint8_t*)larray, (char*)pcout, numlongs * sizeof(uint32) * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -235,7 +235,7 @@ void cNullSignature::Init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void cNullSignature::Update(const byte* const pbData, int cbDataLen)
|
void cNullSignature::Update(const uint8_t* const pbData, int cbDataLen)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,9 +310,9 @@ void cChecksumSignature::Init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void cChecksumSignature::Update(const byte* const pbDataC, int cbDataLen)
|
void cChecksumSignature::Update(const uint8_t* const pbDataC, int cbDataLen)
|
||||||
{
|
{
|
||||||
byte* pbData = (byte*)pbDataC;
|
uint8_t* pbData = (uint8_t*)pbDataC;
|
||||||
for (int i = 0; i < cbDataLen; i++, pbData++)
|
for (int i = 0; i < cbDataLen; i++, pbData++)
|
||||||
mChecksum += *pbData;
|
mChecksum += *pbData;
|
||||||
}
|
}
|
||||||
|
@ -398,9 +398,9 @@ void cCRC32Signature::Init()
|
||||||
crcInit(mCRCInfo);
|
crcInit(mCRCInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cCRC32Signature::Update(const byte* const pbData, int cbDataLen)
|
void cCRC32Signature::Update(const uint8_t* const pbData, int cbDataLen)
|
||||||
{
|
{
|
||||||
ASSERT(sizeof(byte) == sizeof(uint8));
|
ASSERT(sizeof(uint8_t) == sizeof(uint8));
|
||||||
crcUpdate(mCRCInfo, (uint8*)pbData, cbDataLen);
|
crcUpdate(mCRCInfo, (uint8*)pbData, cbDataLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ void cMD5Signature::Init()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMD5Signature::Update(const byte* const pbData, int cbDataLen)
|
void cMD5Signature::Update(const uint8_t* const pbData, int cbDataLen)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
|
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
|
||||||
CC_MD5_Update(&mMD5Info, (uint8*)pbData, cbDataLen);
|
CC_MD5_Update(&mMD5Info, (uint8*)pbData, cbDataLen);
|
||||||
|
@ -534,8 +534,8 @@ TSTRING cMD5Signature::AsString() const
|
||||||
TSTRING ret;
|
TSTRING ret;
|
||||||
char buf[24];
|
char buf[24];
|
||||||
|
|
||||||
ASSERT(sizeof(uint8) == sizeof(byte)); /* everything breaks otherwise */
|
ASSERT(sizeof(uint8) == sizeof(uint8_t)); /* everything breaks otherwise */
|
||||||
btob64((byte*)md5_digest, buf, SIG_BYTE_SIZE * 8);
|
btob64((uint8_t*)md5_digest, buf, SIG_BYTE_SIZE * 8);
|
||||||
//converting to base64 representation.
|
//converting to base64 representation.
|
||||||
|
|
||||||
ret.append(buf);
|
ret.append(buf);
|
||||||
|
@ -626,9 +626,9 @@ void cSHASignature::Init()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSHASignature::Update(const byte* const pbData, int cbDataLen)
|
void cSHASignature::Update(const uint8_t* const pbData, int cbDataLen)
|
||||||
{
|
{
|
||||||
ASSERT(sizeof(byte) == sizeof(uint8));
|
ASSERT(sizeof(uint8_t) == sizeof(uint8));
|
||||||
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
|
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
|
||||||
CC_SHA1_Update(&mSHAInfo, (uint8*)pbData, cbDataLen);
|
CC_SHA1_Update(&mSHAInfo, (uint8*)pbData, cbDataLen);
|
||||||
#elif HAVE_OPENSSL_SHA_H
|
#elif HAVE_OPENSSL_SHA_H
|
||||||
|
@ -822,7 +822,7 @@ void cHAVALSignature::Init()
|
||||||
haval_start(&mHavalState);
|
haval_start(&mHavalState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cHAVALSignature::Update(const byte* const pbData, int cbDataLen)
|
void cHAVALSignature::Update(const uint8_t* const pbData, int cbDataLen)
|
||||||
{
|
{
|
||||||
haval_hash(&mHavalState, (uint8*)pbData, cbDataLen);
|
haval_hash(&mHavalState, (uint8*)pbData, cbDataLen);
|
||||||
}
|
}
|
||||||
|
@ -842,7 +842,7 @@ TSTRING cHAVALSignature::AsString() const
|
||||||
TSTRING ret;
|
TSTRING ret;
|
||||||
char buf[24];
|
char buf[24];
|
||||||
|
|
||||||
btob64((byte*)mSignature, buf, 128);
|
btob64((uint8_t*)mSignature, buf, 128);
|
||||||
//converting to base64 representation.
|
//converting to base64 representation.
|
||||||
|
|
||||||
ret.append(buf);
|
ret.append(buf);
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
//
|
//
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
// call before beginning hashing
|
// call before beginning hashing
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen) = 0;
|
virtual void Update(const uint8_t* const pbData, int cbDataLen) = 0;
|
||||||
// may be called multiple times -- best to call with blocks of size SUGGESTED_BLOCK_SIZE,
|
// may be called multiple times -- best to call with blocks of size SUGGESTED_BLOCK_SIZE,
|
||||||
// but can handle any size data.
|
// but can handle any size data.
|
||||||
virtual void Finit() = 0;
|
virtual void Finit() = 0;
|
||||||
|
@ -192,7 +192,7 @@ public:
|
||||||
virtual ~cNullSignature();
|
virtual ~cNullSignature();
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen);
|
virtual void Update(const uint8_t* const pbData, int cbDataLen);
|
||||||
virtual void Finit();
|
virtual void Finit();
|
||||||
virtual TSTRING AsString() const;
|
virtual TSTRING AsString() const;
|
||||||
virtual TSTRING AsStringHex() const;
|
virtual TSTRING AsStringHex() const;
|
||||||
|
@ -219,7 +219,7 @@ public:
|
||||||
virtual ~cChecksumSignature();
|
virtual ~cChecksumSignature();
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen);
|
virtual void Update(const uint8_t* const pbData, int cbDataLen);
|
||||||
virtual void Finit();
|
virtual void Finit();
|
||||||
virtual TSTRING AsString() const;
|
virtual TSTRING AsString() const;
|
||||||
virtual TSTRING AsStringHex() const;
|
virtual TSTRING AsStringHex() const;
|
||||||
|
@ -247,7 +247,7 @@ public:
|
||||||
virtual ~cCRC32Signature();
|
virtual ~cCRC32Signature();
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen);
|
virtual void Update(const uint8_t* const pbData, int cbDataLen);
|
||||||
virtual void Finit();
|
virtual void Finit();
|
||||||
|
|
||||||
virtual TSTRING AsString() const;
|
virtual TSTRING AsString() const;
|
||||||
|
@ -276,7 +276,7 @@ public:
|
||||||
virtual ~cMD5Signature();
|
virtual ~cMD5Signature();
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen);
|
virtual void Update(const uint8_t* const pbData, int cbDataLen);
|
||||||
virtual void Finit();
|
virtual void Finit();
|
||||||
virtual TSTRING AsString() const;
|
virtual TSTRING AsString() const;
|
||||||
virtual TSTRING AsStringHex() const;
|
virtual TSTRING AsStringHex() const;
|
||||||
|
@ -313,7 +313,7 @@ public:
|
||||||
virtual ~cSHASignature();
|
virtual ~cSHASignature();
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen);
|
virtual void Update(const uint8_t* const pbData, int cbDataLen);
|
||||||
virtual void Finit();
|
virtual void Finit();
|
||||||
virtual TSTRING AsString() const;
|
virtual TSTRING AsString() const;
|
||||||
virtual TSTRING AsStringHex() const;
|
virtual TSTRING AsStringHex() const;
|
||||||
|
@ -355,7 +355,7 @@ public:
|
||||||
virtual ~cHAVALSignature();
|
virtual ~cHAVALSignature();
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Update(const byte* const pbData, int cbDataLen);
|
virtual void Update(const uint8_t* const pbData, int cbDataLen);
|
||||||
virtual void Finit();
|
virtual void Finit();
|
||||||
virtual TSTRING AsString() const;
|
virtual TSTRING AsString() const;
|
||||||
virtual TSTRING AsStringHex() const;
|
virtual TSTRING AsStringHex() const;
|
||||||
|
|
|
@ -177,7 +177,13 @@ void cFSParserUtil::AddSubTypeProps(cFCOPropVector& v) const
|
||||||
|
|
||||||
static inline void trim_leading_whitespace(std::string& str)
|
static inline void trim_leading_whitespace(std::string& str)
|
||||||
{
|
{
|
||||||
|
// C++17 removes std::ptr_fun and deprecates std::not1,
|
||||||
|
// so just use a lambda where available
|
||||||
|
#if __cplusplus < 201103L
|
||||||
str.erase(str.begin(), std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
str.erase(str.begin(), std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||||
|
#else
|
||||||
|
str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](int c) {return !std::isspace(c);} ));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cFSParserUtil::InterpretFCOName(const std::list<TSTRING>& l, cFCOName& nameOut) const
|
void cFSParserUtil::InterpretFCOName(const std::list<TSTRING>& l, cFCOName& nameOut) const
|
||||||
|
|
|
@ -67,11 +67,13 @@ void tw_terminate_handler()
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus < 201703L
|
||||||
void tw_unexpected_handler()
|
void tw_unexpected_handler()
|
||||||
{
|
{
|
||||||
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void SiggenInit()
|
static void SiggenInit()
|
||||||
{
|
{
|
||||||
|
@ -112,8 +114,9 @@ int __cdecl _tmain(int argc, const TCHAR** argv)
|
||||||
// Note: we do this before Init() in case it attempts to call these handlers
|
// Note: we do this before Init() in case it attempts to call these handlers
|
||||||
// TODO: move this into the Init() routine
|
// TODO: move this into the Init() routine
|
||||||
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
||||||
|
#if __cplusplus < 201703L
|
||||||
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
||||||
|
#endif
|
||||||
//cTWInit twInit( argv[0] );
|
//cTWInit twInit( argv[0] );
|
||||||
SiggenInit();
|
SiggenInit();
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ std::string& cMailMessageUtil::LFToCRLF(std::string& sIn)
|
||||||
/*
|
/*
|
||||||
static
|
static
|
||||||
std::string
|
std::string
|
||||||
util_Base64Encode( const byte b[3], int size )
|
util_Base64Encode( const uint8_t b[3], int size )
|
||||||
{
|
{
|
||||||
// TODO:BAM -- what about endianness?
|
// TODO:BAM -- what about endianness?
|
||||||
ASSERT( size > 0 && size <= 3 );
|
ASSERT( size > 0 && size <= 3 );
|
||||||
|
@ -542,18 +542,18 @@ util_Base64Encode( const byte b[3], int size )
|
||||||
if( size >= 2 )
|
if( size >= 2 )
|
||||||
{
|
{
|
||||||
// encode B,C
|
// encode B,C
|
||||||
s += v64[ ( ( b[0] & (byte)0x3 ) << 4 ) | ( b[1] >> 4 ) ];
|
s += v64[ ( ( b[0] & (uint8_t)0x3 ) << 4 ) | ( b[1] >> 4 ) ];
|
||||||
|
|
||||||
if( size == 3 )
|
if( size == 3 )
|
||||||
s += v64[ ( ( b[1] & (byte)0xF ) << 2 ) | ( b[2] >> 6 ) ];
|
s += v64[ ( ( b[1] & (uint8_t)0xF ) << 2 ) | ( b[2] >> 6 ) ];
|
||||||
else
|
else
|
||||||
s += v64[ ( ( b[1] & (byte)0xF ) << 2 ) ];
|
s += v64[ ( ( b[1] & (uint8_t)0xF ) << 2 ) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( size >= 3 )
|
if( size >= 3 )
|
||||||
{
|
{
|
||||||
// encode D
|
// encode D
|
||||||
s += v64[ b[2] & (byte)0x3F ];
|
s += v64[ b[2] & (uint8_t)0x3F ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// padding
|
// padding
|
||||||
|
@ -580,7 +580,7 @@ const T& MS_SUCKS_min( const T& a, const T& b )
|
||||||
const std::string::value_type*
|
const std::string::value_type*
|
||||||
cMailMessageUtil::ConvertBase64(
|
cMailMessageUtil::ConvertBase64(
|
||||||
std::string& sEncode,
|
std::string& sEncode,
|
||||||
const byte* pchSrc,
|
const uint8_t* pchSrc,
|
||||||
size_t nchSrc )
|
size_t nchSrc )
|
||||||
{
|
{
|
||||||
sEncode.assign( ToBase64( pchSrc, nchSrc ) );
|
sEncode.assign( ToBase64( pchSrc, nchSrc ) );
|
||||||
|
@ -589,9 +589,9 @@ cMailMessageUtil::ConvertBase64(
|
||||||
|
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
cMailMessageUtil::ToBase64( const byte* p, size_t size )
|
cMailMessageUtil::ToBase64( const uint8_t* p, size_t size )
|
||||||
{
|
{
|
||||||
ASSERT( sizeof( uint8 ) == sizeof( byte ) ); // everything breaks otherwise
|
ASSERT( sizeof( uint8 ) == sizeof( uint8_t ) ); // everything breaks otherwise
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
const int MAX_WORKING_BYTES = 3;
|
const int MAX_WORKING_BYTES = 3;
|
||||||
|
@ -599,8 +599,8 @@ cMailMessageUtil::ToBase64( const byte* p, size_t size )
|
||||||
const int MAX_CHARS_PER_BYTE = 2; // should be
|
const int MAX_CHARS_PER_BYTE = 2; // should be
|
||||||
ASSERT( MAX_CHARS_PER_BYTE > CHARS_PER_WORKING_BYTES/MAX_WORKING_BYTES );
|
ASSERT( MAX_CHARS_PER_BYTE > CHARS_PER_WORKING_BYTES/MAX_WORKING_BYTES );
|
||||||
const int NERVOUS_LINE_BUFFER = 10;
|
const int NERVOUS_LINE_BUFFER = 10;
|
||||||
const byte* at = p;
|
const uint8_t* at = p;
|
||||||
byte buf[ MAX_WORKING_BYTES ];
|
uint8_t buf[ MAX_WORKING_BYTES ];
|
||||||
int nbLeft;
|
int nbLeft;
|
||||||
int nbWorking;
|
int nbWorking;
|
||||||
int nchCurLine;
|
int nchCurLine;
|
||||||
|
@ -653,19 +653,18 @@ cMailMessageUtil::ToBase64( const byte* p, size_t size )
|
||||||
|
|
||||||
namespace /*Unique*/
|
namespace /*Unique*/
|
||||||
{
|
{
|
||||||
typedef byte byte_t;
|
|
||||||
|
|
||||||
# ifdef TSS_MAKE_EOL_CRLF
|
# ifdef TSS_MAKE_EOL_CRLF
|
||||||
const byte _aszEoL[] = "\r\n";
|
const uint8_t _aszEoL[] = "\r\n";
|
||||||
size_t _EOL_LEN = 2;
|
size_t _EOL_LEN = 2;
|
||||||
|
|
||||||
# else
|
# else
|
||||||
const byte _aszEoL[] = "\n";
|
const uint8_t _aszEoL[] = "\n";
|
||||||
size_t _EOL_LEN = 1;
|
size_t _EOL_LEN = 1;
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
const byte_t _abBase64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
const uint8_t _abBase64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"0123456789+/";
|
"0123456789+/";
|
||||||
|
|
||||||
|
@ -697,7 +696,7 @@ inline size_t tss_encode_base64_size(size_t nchSource)
|
||||||
return nchOut + nchEol + 2;
|
return nchOut + nchEol + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tss_encode_digit_base64(const byte_t*& pchSrc, size_t& nchSrcLeft, byte_t*& pchBuf, size_t& nchBufLeft)
|
void tss_encode_digit_base64(const uint8_t*& pchSrc, size_t& nchSrcLeft, uint8_t*& pchBuf, size_t& nchBufLeft)
|
||||||
{
|
{
|
||||||
// NOTE:RAD -- Redundant and ugly but very fast!!
|
// NOTE:RAD -- Redundant and ugly but very fast!!
|
||||||
|
|
||||||
|
@ -756,7 +755,7 @@ void tss_encode_digit_base64(const byte_t*& pchSrc, size_t& nchSrcLeft, byte_t*&
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
size_t tss_encode_base64(const byte_t* pchSource, size_t nchSource, byte_t* pchBuffer, size_t nchBuffer)
|
size_t tss_encode_base64(const uint8_t* pchSource, size_t nchSource, uint8_t* pchBuffer, size_t nchBuffer)
|
||||||
{
|
{
|
||||||
const size_t _ERROR = std::string::npos; // -1;
|
const size_t _ERROR = std::string::npos; // -1;
|
||||||
|
|
||||||
|
@ -780,8 +779,8 @@ size_t tss_encode_base64(const byte_t* pchSource, size_t nchSource, byte_t* pchB
|
||||||
|
|
||||||
//--Get three characters at a time and encode them (watching linelen)
|
//--Get three characters at a time and encode them (watching linelen)
|
||||||
|
|
||||||
byte_t* pchBuf = (pchBuffer + 0);
|
uint8_t* pchBuf = (pchBuffer + 0);
|
||||||
const byte_t* pchSrc = (pchSource + 0);
|
const uint8_t* pchSrc = (pchSource + 0);
|
||||||
|
|
||||||
|
|
||||||
const size_t _max_linelen = (_MAX_RFC822_LINE_LEN - _EOL_LEN);
|
const size_t _max_linelen = (_MAX_RFC822_LINE_LEN - _EOL_LEN);
|
||||||
|
@ -798,7 +797,7 @@ size_t tss_encode_base64(const byte_t* pchSource, size_t nchSource, byte_t* pchB
|
||||||
{
|
{
|
||||||
nLineLen = 0; // RESET:
|
nLineLen = 0; // RESET:
|
||||||
|
|
||||||
const byte_t* pchEol = &_aszEoL[0];
|
const uint8_t* pchEol = &_aszEoL[0];
|
||||||
while (*pchEol)
|
while (*pchEol)
|
||||||
*pchBuf++ = *pchEol++;
|
*pchBuf++ = *pchEol++;
|
||||||
}
|
}
|
||||||
|
@ -812,7 +811,7 @@ size_t tss_encode_base64(const byte_t* pchSource, size_t nchSource, byte_t* pchB
|
||||||
|
|
||||||
|
|
||||||
const std::string::value_type*
|
const std::string::value_type*
|
||||||
cMailMessageUtil::ConvertBase64(std::string& sEncode, const byte_t* pchSrc, size_t nchSrc)
|
cMailMessageUtil::ConvertBase64(std::string& sEncode, const uint8_t* pchSrc, size_t nchSrc)
|
||||||
{
|
{
|
||||||
size_t nch = tss_encode_base64(pchSrc, nchSrc, 0, 0); // Like mbstowcs
|
size_t nch = tss_encode_base64(pchSrc, nchSrc, 0, 0); // Like mbstowcs
|
||||||
|
|
||||||
|
@ -822,7 +821,7 @@ cMailMessageUtil::ConvertBase64(std::string& sEncode, const byte_t* pchSrc, size
|
||||||
const char* pch = sEncode.c_str(); // Get Pointer (won't change)
|
const char* pch = sEncode.c_str(); // Get Pointer (won't change)
|
||||||
|
|
||||||
size_t nLength = // Action
|
size_t nLength = // Action
|
||||||
tss_encode_base64(pchSrc, nchSrc, (byte_t*)pch, nch);
|
tss_encode_base64(pchSrc, nchSrc, (uint8_t*)pch, nch);
|
||||||
|
|
||||||
if (nLength == std::string::npos)
|
if (nLength == std::string::npos)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
@ -833,7 +832,7 @@ cMailMessageUtil::ConvertBase64(std::string& sEncode, const byte_t* pchSrc, size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string cMailMessageUtil::ToBase64(const byte_t* pchSrc, size_t nchSrc)
|
std::string cMailMessageUtil::ToBase64(const uint8_t* pchSrc, size_t nchSrc)
|
||||||
{
|
{
|
||||||
// NOTE: It sucks to use std::string this way! Should be
|
// NOTE: It sucks to use std::string this way! Should be
|
||||||
// passed in by reference.
|
// passed in by reference.
|
||||||
|
|
|
@ -128,7 +128,7 @@ public:
|
||||||
_EOL_LEN = 2
|
_EOL_LEN = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::string::value_type* ConvertBase64(std::string&, const byte*, size_t);
|
static const std::string::value_type* ConvertBase64(std::string&, const uint8_t*, size_t);
|
||||||
|
|
||||||
static bool HasNonAsciiChars(const std::string& s);
|
static bool HasNonAsciiChars(const std::string& s);
|
||||||
static std::string CreateEncodedText(const std::string& text);
|
static std::string CreateEncodedText(const std::string& text);
|
||||||
|
|
|
@ -95,11 +95,13 @@ void tw_terminate_handler()
|
||||||
_exit(8);
|
_exit(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus < 201703L
|
||||||
void tw_unexpected_handler()
|
void tw_unexpected_handler()
|
||||||
{
|
{
|
||||||
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
||||||
_exit(8);
|
_exit(8);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// main
|
// main
|
||||||
|
@ -121,8 +123,9 @@ int __cdecl _tmain(int argc, const TCHAR* argv[], const TCHAR* envp[])
|
||||||
// Note: we do this before Init() in case it attempts to call these handlers
|
// Note: we do this before Init() in case it attempts to call these handlers
|
||||||
// TODO: move this into the Init() routine
|
// TODO: move this into the Init() routine
|
||||||
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
||||||
|
#if __cplusplus < 201703L
|
||||||
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
||||||
|
#endif
|
||||||
// Initialization
|
// Initialization
|
||||||
//
|
//
|
||||||
twInit.Init(argv[0]);
|
twInit.Init(argv[0]);
|
||||||
|
|
|
@ -661,7 +661,7 @@ void cTWUtil::ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchiv
|
||||||
throw eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE);
|
throw eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE);
|
||||||
|
|
||||||
// check 8 byte header
|
// check 8 byte header
|
||||||
if (nstring.mString.compare(0, 8 * sizeof(byte), CONFIG_FILE_MAGIC_8BYTE) != 0)
|
if (nstring.mString.compare(0, 8 * sizeof(uint8_t), CONFIG_FILE_MAGIC_8BYTE) != 0)
|
||||||
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
|
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
|
||||||
|
|
||||||
// remove 8 byte header
|
// remove 8 byte header
|
||||||
|
@ -716,7 +716,7 @@ void cTWUtil::ReadPolicyText(const TCHAR* filename, std::string& polText, const
|
||||||
ReadObject(filename, NULL, nstring, cPolicyFile::GetFileHeaderID(), pPublicKey, bEncrypted);
|
ReadObject(filename, NULL, nstring, cPolicyFile::GetFileHeaderID(), pPublicKey, bEncrypted);
|
||||||
|
|
||||||
// check 8 byte header
|
// check 8 byte header
|
||||||
if (nstring.mString.compare(0, 8 * sizeof(byte), POLICY_FILE_MAGIC_8BYTE) != 0)
|
if (nstring.mString.compare(0, 8 * sizeof(uint8_t), POLICY_FILE_MAGIC_8BYTE) != 0)
|
||||||
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
|
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
|
||||||
|
|
||||||
// remove 8 byte header
|
// remove 8 byte header
|
||||||
|
|
|
@ -61,11 +61,13 @@ void tw_terminate_handler()
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus < 201703L
|
||||||
void tw_unexpected_handler()
|
void tw_unexpected_handler()
|
||||||
{
|
{
|
||||||
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int __cdecl _tmain(int argc, const TCHAR* argv[], const TCHAR* envp[])
|
int __cdecl _tmain(int argc, const TCHAR* argv[], const TCHAR* envp[])
|
||||||
{
|
{
|
||||||
|
@ -84,8 +86,9 @@ int __cdecl _tmain(int argc, const TCHAR* argv[], const TCHAR* envp[])
|
||||||
// Note: we do this before Init() in case it attempts to call these handlers
|
// Note: we do this before Init() in case it attempts to call these handlers
|
||||||
// TODO: move this into the Init() routine
|
// TODO: move this into the Init() routine
|
||||||
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
||||||
|
#if __cplusplus < 201703L
|
||||||
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
||||||
|
#endif
|
||||||
twInit.Init(argv[0]);
|
twInit.Init(argv[0]);
|
||||||
TSS_Dependency(cTWAdmin);
|
TSS_Dependency(cTWAdmin);
|
||||||
|
|
||||||
|
|
|
@ -57,24 +57,24 @@ public:
|
||||||
return (head == MaxSize());
|
return (head == MaxSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Put(byte inByte);
|
unsigned int Put(uint8_t inByte);
|
||||||
unsigned int Put(const byte* inString, unsigned int length);
|
unsigned int Put(const uint8_t* inString, unsigned int length);
|
||||||
|
|
||||||
unsigned int Get(byte& outByte);
|
unsigned int Get(uint8_t& outByte);
|
||||||
unsigned int Get(byte* outString, unsigned int getMax);
|
unsigned int Get(uint8_t* outString, unsigned int getMax);
|
||||||
|
|
||||||
unsigned int Peek(byte& outByte) const;
|
unsigned int Peek(uint8_t& outByte) const;
|
||||||
|
|
||||||
void CopyTo(BufferedTransformation& target) const
|
void CopyTo(BufferedTransformation& target) const
|
||||||
{
|
{
|
||||||
target.Put(buf + head, tail - head);
|
target.Put(buf + head, tail - head);
|
||||||
}
|
}
|
||||||
void CopyTo(byte* target) const
|
void CopyTo(uint8_t* target) const
|
||||||
{
|
{
|
||||||
memcpy(target, buf + head, tail - head);
|
memcpy(target, buf + head, tail - head);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte operator[](unsigned int i) const
|
uint8_t operator[](unsigned int i) const
|
||||||
{
|
{
|
||||||
return buf[i - head];
|
return buf[i - head];
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ cByteQueueNode::cByteQueueNode(unsigned int maxSize) : buf(maxSize)
|
||||||
next = 0;
|
next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueueNode::Put(byte inByte)
|
unsigned int cByteQueueNode::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
if (MaxSize() == tail)
|
if (MaxSize() == tail)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -107,7 +107,7 @@ unsigned int cByteQueueNode::Put(byte inByte)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueueNode::Put(const byte* inString, unsigned int length)
|
unsigned int cByteQueueNode::Put(const uint8_t* inString, unsigned int length)
|
||||||
{
|
{
|
||||||
unsigned int l = STDMIN(length, MaxSize() - tail);
|
unsigned int l = STDMIN(length, MaxSize() - tail);
|
||||||
memcpy(buf + tail, inString, l);
|
memcpy(buf + tail, inString, l);
|
||||||
|
@ -115,7 +115,7 @@ unsigned int cByteQueueNode::Put(const byte* inString, unsigned int length)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueueNode::Get(byte& outByte)
|
unsigned int cByteQueueNode::Get(uint8_t& outByte)
|
||||||
{
|
{
|
||||||
if (tail == head)
|
if (tail == head)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -124,7 +124,7 @@ unsigned int cByteQueueNode::Get(byte& outByte)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueueNode::Get(byte* outString, unsigned int getMax)
|
unsigned int cByteQueueNode::Get(uint8_t* outString, unsigned int getMax)
|
||||||
{
|
{
|
||||||
unsigned int l = STDMIN(getMax, tail - head);
|
unsigned int l = STDMIN(getMax, tail - head);
|
||||||
memcpy(outString, buf + head, l);
|
memcpy(outString, buf + head, l);
|
||||||
|
@ -132,7 +132,7 @@ unsigned int cByteQueueNode::Get(byte* outString, unsigned int getMax)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueueNode::Peek(byte& outByte) const
|
unsigned int cByteQueueNode::Peek(uint8_t& outByte) const
|
||||||
{
|
{
|
||||||
if (tail == head)
|
if (tail == head)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -198,7 +198,7 @@ void cByteQueue::CopyTo(BufferedTransformation& target) const
|
||||||
current->CopyTo(target);
|
current->CopyTo(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cByteQueue::CopyTo(byte* target) const
|
void cByteQueue::CopyTo(uint8_t* target) const
|
||||||
{
|
{
|
||||||
for (cByteQueueNode* current = head; current; current = current->next)
|
for (cByteQueueNode* current = head; current; current = current->next)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ unsigned long cByteQueue::CurrentSize() const
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void cByteQueue::Put(byte inByte)
|
void cByteQueue::Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
if (!tail->Put(inByte))
|
if (!tail->Put(inByte))
|
||||||
{
|
{
|
||||||
|
@ -232,7 +232,7 @@ void cByteQueue::Put(byte inByte)
|
||||||
mCurrentSize++;
|
mCurrentSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cByteQueue::Put(const byte* inString, unsigned int length)
|
void cByteQueue::Put(const uint8_t* inString, unsigned int length)
|
||||||
{
|
{
|
||||||
unsigned int l;
|
unsigned int l;
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ void cByteQueue::Put(const byte* inString, unsigned int length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueue::Get(byte& outByte)
|
unsigned int cByteQueue::Get(uint8_t& outByte)
|
||||||
{
|
{
|
||||||
int l = head->Get(outByte);
|
int l = head->Get(outByte);
|
||||||
if (head->UsedUp())
|
if (head->UsedUp())
|
||||||
|
@ -265,7 +265,7 @@ unsigned int cByteQueue::Get(byte& outByte)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueue::Get(byte* outString, unsigned int getMax)
|
unsigned int cByteQueue::Get(uint8_t* outString, unsigned int getMax)
|
||||||
{
|
{
|
||||||
unsigned int getMaxSave = getMax;
|
unsigned int getMaxSave = getMax;
|
||||||
cByteQueueNode* current = head;
|
cByteQueueNode* current = head;
|
||||||
|
@ -300,7 +300,7 @@ unsigned int cByteQueue::Get(byte* outString, unsigned int getMax)
|
||||||
return (rtn);
|
return (rtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cByteQueue::Peek(byte& outByte) const
|
unsigned int cByteQueue::Peek(uint8_t& outByte) const
|
||||||
{
|
{
|
||||||
return head->Peek(outByte);
|
return head->Peek(outByte);
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ bool cByteQueue::operator==(const cByteQueue& rhs) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte cByteQueue::operator[](unsigned long i) const
|
uint8_t cByteQueue::operator[](unsigned long i) const
|
||||||
{
|
{
|
||||||
for (cByteQueueNode* current = head; current; current = current->next)
|
for (cByteQueueNode* current = head; current; current = current->next)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,21 +56,21 @@ public:
|
||||||
return CurrentSize();
|
return CurrentSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Put(byte inByte);
|
void Put(uint8_t inByte);
|
||||||
void Put(const byte* inString, unsigned int length);
|
void Put(const uint8_t* inString, unsigned int length);
|
||||||
|
|
||||||
// both functions returns the number of bytes actually retrived
|
// both functions returns the number of bytes actually retrived
|
||||||
unsigned int Get(byte& outByte);
|
unsigned int Get(uint8_t& outByte);
|
||||||
unsigned int Get(byte* outString, unsigned int getMax);
|
unsigned int Get(uint8_t* outString, unsigned int getMax);
|
||||||
|
|
||||||
unsigned int Peek(byte& outByte) const;
|
unsigned int Peek(uint8_t& outByte) const;
|
||||||
|
|
||||||
void CopyTo(BufferedTransformation& target) const;
|
void CopyTo(BufferedTransformation& target) const;
|
||||||
void CopyTo(byte* target) const;
|
void CopyTo(uint8_t* target) const;
|
||||||
|
|
||||||
cByteQueue& operator=(const cByteQueue& rhs);
|
cByteQueue& operator=(const cByteQueue& rhs);
|
||||||
bool operator==(const cByteQueue& rhs) const;
|
bool operator==(const cByteQueue& rhs) const;
|
||||||
byte operator[](unsigned long i) const;
|
uint8_t operator[](unsigned long i) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CopyFrom(const cByteQueue& copy);
|
void CopyFrom(const cByteQueue& copy);
|
||||||
|
|
|
@ -135,7 +135,7 @@ void cIDEA::SetKey(iCipher::EncryptionDir dir, const cHashedKey128& key)
|
||||||
ASSERT(mpData);
|
ASSERT(mpData);
|
||||||
|
|
||||||
delete mpData->mpIDEA;
|
delete mpData->mpIDEA;
|
||||||
mpData->mpIDEA = new IDEA((byte*)key.GetKey(), dir == iCipher::ENCRYPT ? ENCRYPTION : DECRYPTION);
|
mpData->mpIDEA = new IDEA((uint8_t*)key.GetKey(), dir == iCipher::ENCRYPT ? ENCRYPTION : DECRYPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the size of data block this crypter works on
|
// return the size of data block this crypter works on
|
||||||
|
@ -159,7 +159,7 @@ void cIDEA::ProcessBlock(const void* indata, void* outdata)
|
||||||
ThrowAndAssert(eInternal(_T("Key not set in symmetric encryption.")));
|
ThrowAndAssert(eInternal(_T("Key not set in symmetric encryption.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
mpData->mpIDEA->ProcessBlock((byte*)indata, (byte*)outdata);
|
mpData->mpIDEA->ProcessBlock((uint8_t*)indata, (uint8_t*)outdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _IDEA_ENCRYPTION
|
#endif // _IDEA_ENCRYPTION
|
||||||
|
@ -203,14 +203,14 @@ void cTripleDES::SetKey(iCipher::EncryptionDir dir, const cHashedKey192& key)
|
||||||
delete mpData->mpEncryptor;
|
delete mpData->mpEncryptor;
|
||||||
delete mpData->mpDecryptor;
|
delete mpData->mpDecryptor;
|
||||||
mpData->mpDecryptor = 0;
|
mpData->mpDecryptor = 0;
|
||||||
mpData->mpEncryptor = new TripleDES_Encryption((byte*)key.GetKey());
|
mpData->mpEncryptor = new TripleDES_Encryption((uint8_t*)key.GetKey());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete mpData->mpEncryptor;
|
delete mpData->mpEncryptor;
|
||||||
delete mpData->mpDecryptor;
|
delete mpData->mpDecryptor;
|
||||||
mpData->mpEncryptor = 0;
|
mpData->mpEncryptor = 0;
|
||||||
mpData->mpDecryptor = new TripleDES_Decryption((byte*)key.GetKey());
|
mpData->mpDecryptor = new TripleDES_Decryption((uint8_t*)key.GetKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,9 +240,9 @@ void cTripleDES::ProcessBlock(const void* indata, void* outdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpData->mpEncryptor)
|
if (mpData->mpEncryptor)
|
||||||
mpData->mpEncryptor->ProcessBlock((byte*)indata, (byte*)outdata);
|
mpData->mpEncryptor->ProcessBlock((uint8_t*)indata, (uint8_t*)outdata);
|
||||||
else
|
else
|
||||||
mpData->mpDecryptor->ProcessBlock((byte*)indata, (byte*)outdata);
|
mpData->mpDecryptor->ProcessBlock((uint8_t*)indata, (uint8_t*)outdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -274,7 +274,7 @@ cRSAPrivateKey::cRSAPrivateKey(void* pDataStream)
|
||||||
int32 i32;
|
int32 i32;
|
||||||
int16 i16;
|
int16 i16;
|
||||||
|
|
||||||
byte* pIn = (byte*)pDataStream;
|
uint8_t* pIn = (uint8_t*)pDataStream;
|
||||||
|
|
||||||
memcpy(&i16, pIn, sizeof(i16));
|
memcpy(&i16, pIn, sizeof(i16));
|
||||||
mpData->mKeyLength = tw_ntohs(i16);
|
mpData->mKeyLength = tw_ntohs(i16);
|
||||||
|
@ -343,7 +343,7 @@ void cRSAPrivateKey::Write(void* pDataStream) const
|
||||||
ASSERT(mpData->mpKey->GetTrapdoorFunction().GetParameterDQ().IsPositive());
|
ASSERT(mpData->mpKey->GetTrapdoorFunction().GetParameterDQ().IsPositive());
|
||||||
ASSERT(mpData->mpKey->GetTrapdoorFunction().GetParameterU().IsPositive());
|
ASSERT(mpData->mpKey->GetTrapdoorFunction().GetParameterU().IsPositive());
|
||||||
|
|
||||||
byte* pOut = (byte*)pDataStream;
|
uint8_t* pOut = (uint8_t*)pDataStream;
|
||||||
int16 i16;
|
int16 i16;
|
||||||
int32 i32;
|
int32 i32;
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ cRSAPublicKey::cRSAPublicKey(void* pDataStream)
|
||||||
int16 i16;
|
int16 i16;
|
||||||
int32 i32;
|
int32 i32;
|
||||||
|
|
||||||
byte* pIn = (byte*)pDataStream;
|
uint8_t* pIn = (uint8_t*)pDataStream;
|
||||||
|
|
||||||
memcpy(&i16, pIn, sizeof(i16));
|
memcpy(&i16, pIn, sizeof(i16));
|
||||||
mpData->mKeyLength = tw_ntohs(i16);
|
mpData->mKeyLength = tw_ntohs(i16);
|
||||||
|
@ -465,7 +465,7 @@ void cRSAPublicKey::Write(void* pDataStream) const
|
||||||
|
|
||||||
int16 i16;
|
int16 i16;
|
||||||
int32 i32;
|
int32 i32;
|
||||||
byte* pOut = (byte*)pDataStream;
|
uint8_t* pOut = (uint8_t*)pDataStream;
|
||||||
|
|
||||||
i16 = tw_htons(mpData->mKeyLength);
|
i16 = tw_htons(mpData->mKeyLength);
|
||||||
memcpy(pOut, &i16, sizeof(i16));
|
memcpy(pOut, &i16, sizeof(i16));
|
||||||
|
@ -551,8 +551,8 @@ void cRSA::Init(KeySize keysize)
|
||||||
(keysize == KEY512) ? 512 : (keysize == KEY1024) ? 1024 : (keysize == KEY2048) ? 2048 : 256;
|
(keysize == KEY512) ? 512 : (keysize == KEY1024) ? 1024 : (keysize == KEY2048) ? 2048 : 256;
|
||||||
|
|
||||||
// Create a random seed and a key
|
// Create a random seed and a key
|
||||||
byte seed[MD5::DATASIZE];
|
uint8_t seed[MD5::DATASIZE];
|
||||||
byte deskey[TripleDES_Encryption::KEYLENGTH];
|
uint8_t deskey[TripleDES_Encryption::KEYLENGTH];
|
||||||
RandomizeBytes((int8*)seed, MD5::DATASIZE);
|
RandomizeBytes((int8*)seed, MD5::DATASIZE);
|
||||||
RandomizeBytes((int8*)deskey, TripleDES_Encryption::KEYLENGTH);
|
RandomizeBytes((int8*)deskey, TripleDES_Encryption::KEYLENGTH);
|
||||||
|
|
||||||
|
@ -648,14 +648,14 @@ void cRSA::ProcessBlock(const void* indata, void* outdata)
|
||||||
ASSERT(mpData->mpPublicKey->mpData->mpKey->MaxPlainTextLength() == GetBlockSizePlain());
|
ASSERT(mpData->mpPublicKey->mpData->mpKey->MaxPlainTextLength() == GetBlockSizePlain());
|
||||||
ASSERT(mpData->mpPublicKey->mpData->mpKey->CipherTextLength() == GetBlockSizeCipher());
|
ASSERT(mpData->mpPublicKey->mpData->mpKey->CipherTextLength() == GetBlockSizeCipher());
|
||||||
mpData->mpPublicKey->mpData->mpKey->Encrypt(
|
mpData->mpPublicKey->mpData->mpKey->Encrypt(
|
||||||
*mpData->mpRNG, (const byte*)indata, GetBlockSizePlain(), (byte*)outdata);
|
*mpData->mpRNG, (const uint8_t*)indata, GetBlockSizePlain(), (uint8_t*)outdata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cRSA_i::DECRYPT:
|
case cRSA_i::DECRYPT:
|
||||||
{
|
{
|
||||||
ASSERT(mpData->mpPrivateKey);
|
ASSERT(mpData->mpPrivateKey);
|
||||||
ASSERT(mpData->mpPrivateKey->mpData->mpKey->CipherTextLength() == GetBlockSizeCipher());
|
ASSERT(mpData->mpPrivateKey->mpData->mpKey->CipherTextLength() == GetBlockSizeCipher());
|
||||||
l = mpData->mpPrivateKey->mpData->mpKey->Decrypt((const byte*)indata, (byte*)outdata);
|
l = mpData->mpPrivateKey->mpData->mpKey->Decrypt((const uint8_t*)indata, (uint8_t*)outdata);
|
||||||
if (l != GetBlockSizePlain())
|
if (l != GetBlockSizePlain())
|
||||||
throw eArchiveCrypto();
|
throw eArchiveCrypto();
|
||||||
break;
|
break;
|
||||||
|
@ -666,14 +666,14 @@ void cRSA::ProcessBlock(const void* indata, void* outdata)
|
||||||
ASSERT(mpData->mpPrivateKey->mpData->mpKey->MaxMessageLength() == GetBlockSizePlain());
|
ASSERT(mpData->mpPrivateKey->mpData->mpKey->MaxMessageLength() == GetBlockSizePlain());
|
||||||
ASSERT(mpData->mpPrivateKey->mpData->mpKey->SignatureLength() == GetBlockSizeCipher());
|
ASSERT(mpData->mpPrivateKey->mpData->mpKey->SignatureLength() == GetBlockSizeCipher());
|
||||||
mpData->mpPrivateKey->mpData->mpKey->Sign(
|
mpData->mpPrivateKey->mpData->mpKey->Sign(
|
||||||
*mpData->mpRNG, (const byte*)indata, GetBlockSizePlain(), (byte*)outdata);
|
*mpData->mpRNG, (const uint8_t*)indata, GetBlockSizePlain(), (uint8_t*)outdata);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cRSA_i::VERIFY:
|
case cRSA_i::VERIFY:
|
||||||
{
|
{
|
||||||
ASSERT(mpData->mpPublicKey);
|
ASSERT(mpData->mpPublicKey);
|
||||||
ASSERT(mpData->mpPublicKey->mpData->mpKey->SignatureLength() == GetBlockSizeCipher());
|
ASSERT(mpData->mpPublicKey->mpData->mpKey->SignatureLength() == GetBlockSizeCipher());
|
||||||
l = mpData->mpPublicKey->mpData->mpKey->Recover((const byte*)indata, (byte*)outdata);
|
l = mpData->mpPublicKey->mpData->mpKey->Recover((const uint8_t*)indata, (uint8_t*)outdata);
|
||||||
if (l != GetBlockSizePlain())
|
if (l != GetBlockSizePlain())
|
||||||
throw eArchiveCrypto();
|
throw eArchiveCrypto();
|
||||||
break;
|
break;
|
||||||
|
@ -740,7 +740,7 @@ cElGamalSigPrivateKey::cElGamalSigPrivateKey(void* pDataStream)
|
||||||
int16 i16;
|
int16 i16;
|
||||||
uint32 magicNum;
|
uint32 magicNum;
|
||||||
|
|
||||||
byte* pIn = (byte*)pDataStream;
|
uint8_t* pIn = (uint8_t*)pDataStream;
|
||||||
|
|
||||||
memcpy(&i16, pIn, sizeof(i16));
|
memcpy(&i16, pIn, sizeof(i16));
|
||||||
mpData->mKeyLength = tw_ntohs(i16);
|
mpData->mKeyLength = tw_ntohs(i16);
|
||||||
|
@ -802,7 +802,7 @@ void cElGamalSigPrivateKey::Write(void* pDataStream) const
|
||||||
ASSERT(mpData->mpKey->GetParameterY().IsPositive());
|
ASSERT(mpData->mpKey->GetParameterY().IsPositive());
|
||||||
ASSERT(mpData->mpKey->GetParameterX().IsPositive());
|
ASSERT(mpData->mpKey->GetParameterX().IsPositive());
|
||||||
|
|
||||||
byte* pOut = (byte*)pDataStream;
|
uint8_t* pOut = (uint8_t*)pDataStream;
|
||||||
int16 i16;
|
int16 i16;
|
||||||
int32 i32;
|
int32 i32;
|
||||||
|
|
||||||
|
@ -857,7 +857,7 @@ cElGamalSigPublicKey::cElGamalSigPublicKey(void* pDataStream)
|
||||||
int32 i32;
|
int32 i32;
|
||||||
uint32 magicNum;
|
uint32 magicNum;
|
||||||
|
|
||||||
byte* pIn = (byte*)pDataStream;
|
uint8_t* pIn = (uint8_t*)pDataStream;
|
||||||
|
|
||||||
memcpy(&i16, pIn, sizeof(i16));
|
memcpy(&i16, pIn, sizeof(i16));
|
||||||
mpData->mKeyLength = tw_ntohs(i16);
|
mpData->mKeyLength = tw_ntohs(i16);
|
||||||
|
@ -927,7 +927,7 @@ void cElGamalSigPublicKey::Write(void* pDataStream) const
|
||||||
ASSERT(mpData->mpKey->GetParameterG().IsPositive());
|
ASSERT(mpData->mpKey->GetParameterG().IsPositive());
|
||||||
ASSERT(mpData->mpKey->GetParameterY().IsPositive());
|
ASSERT(mpData->mpKey->GetParameterY().IsPositive());
|
||||||
|
|
||||||
byte* pOut = (byte*)pDataStream;
|
uint8_t* pOut = (uint8_t*)pDataStream;
|
||||||
int16 i16;
|
int16 i16;
|
||||||
int32 i32;
|
int32 i32;
|
||||||
|
|
||||||
|
@ -1038,8 +1038,8 @@ void cElGamalSig::Init(KeySize keysize)
|
||||||
(keysize == KEY512) ? 512 : (keysize == KEY1024) ? 1024 : (keysize == KEY2048) ? 2048 : 256;
|
(keysize == KEY512) ? 512 : (keysize == KEY1024) ? 1024 : (keysize == KEY2048) ? 2048 : 256;
|
||||||
|
|
||||||
// Create a random seed and a key
|
// Create a random seed and a key
|
||||||
byte seed[SHA::DATASIZE];
|
uint8_t seed[SHA::DATASIZE];
|
||||||
byte deskey[TripleDES_Encryption::KEYLENGTH];
|
uint8_t deskey[TripleDES_Encryption::KEYLENGTH];
|
||||||
RandomizeBytes((int8*)seed, SHA::DATASIZE);
|
RandomizeBytes((int8*)seed, SHA::DATASIZE);
|
||||||
RandomizeBytes((int8*)deskey, TripleDES_Encryption::KEYLENGTH);
|
RandomizeBytes((int8*)deskey, TripleDES_Encryption::KEYLENGTH);
|
||||||
|
|
||||||
|
@ -1109,19 +1109,19 @@ void cElGamalSig::ProcessBlock(const void* indata, void* outdata)
|
||||||
|
|
||||||
memmove(outdata, indata, PLAIN_BLOCK_SIZE);
|
memmove(outdata, indata, PLAIN_BLOCK_SIZE);
|
||||||
|
|
||||||
mpData->mSHA.CalculateDigest((byte*)shaSig, (byte*)outdata, PLAIN_BLOCK_SIZE);
|
mpData->mSHA.CalculateDigest((uint8_t*)shaSig, (uint8_t*)outdata, PLAIN_BLOCK_SIZE);
|
||||||
|
|
||||||
RandomizeBytes((int8*)outdata + PLAIN_BLOCK_SIZE, GetBlockSizeCipher() - PLAIN_BLOCK_SIZE);
|
RandomizeBytes((int8*)outdata + PLAIN_BLOCK_SIZE, GetBlockSizeCipher() - PLAIN_BLOCK_SIZE);
|
||||||
mpData->mpPrivateKey->mpData->mpKey->Sign(
|
mpData->mpPrivateKey->mpData->mpKey->Sign(
|
||||||
*mpData->mpRNG, (const byte*)shaSig, SHA::DIGESTSIZE, (byte*)outdata + PLAIN_BLOCK_SIZE);
|
*mpData->mpRNG, (const uint8_t*)shaSig, SHA::DIGESTSIZE, (uint8_t*)outdata + PLAIN_BLOCK_SIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Integer m((const byte*)indata, PLAIN_BLOCK_SIZE);
|
Integer m((const uint8_t*)indata, PLAIN_BLOCK_SIZE);
|
||||||
|
|
||||||
std::cout << "Signing:\n";
|
std::cout << "Signing:\n";
|
||||||
std::cout << "M = " << m << std::endl;
|
std::cout << "M = " << m << std::endl;
|
||||||
|
|
||||||
const byte* signature = (const byte *)outdata + PLAIN_BLOCK_SIZE;
|
const uint8_t* signature = (const uint8_t *)outdata + PLAIN_BLOCK_SIZE;
|
||||||
int qLen = mpData->mpPrivateKey->mpData->mpKey->q.ByteCount();
|
int qLen = mpData->mpPrivateKey->mpData->mpKey->q.ByteCount();
|
||||||
Integer rs(signature, qLen);
|
Integer rs(signature, qLen);
|
||||||
Integer ss(signature+qLen, qLen);
|
Integer ss(signature+qLen, qLen);
|
||||||
|
@ -1136,12 +1136,12 @@ void cElGamalSig::ProcessBlock(const void* indata, void* outdata)
|
||||||
ASSERT(mpData->mpPublicKey != 0);
|
ASSERT(mpData->mpPublicKey != 0);
|
||||||
ASSERT((int)mpData->mpPublicKey->mpData->mpKey->SignatureLength() + PLAIN_BLOCK_SIZE <= GetBlockSizeCipher());
|
ASSERT((int)mpData->mpPublicKey->mpData->mpKey->SignatureLength() + PLAIN_BLOCK_SIZE <= GetBlockSizeCipher());
|
||||||
|
|
||||||
mpData->mSHA.CalculateDigest((byte*)shaSig, (byte*)indata, PLAIN_BLOCK_SIZE);
|
mpData->mSHA.CalculateDigest((uint8_t*)shaSig, (uint8_t*)indata, PLAIN_BLOCK_SIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const byte* signature = (const byte *)indata + PLAIN_BLOCK_SIZE;
|
const uint8_t* signature = (const uint8_t *)indata + PLAIN_BLOCK_SIZE;
|
||||||
int qLen = mpData->mpPublicKey->mpData->mpKey->q.ByteCount();
|
int qLen = mpData->mpPublicKey->mpData->mpKey->q.ByteCount();
|
||||||
Integer m((const byte*)indata, PLAIN_BLOCK_SIZE);
|
Integer m((const uint8_t*)indata, PLAIN_BLOCK_SIZE);
|
||||||
Integer r(signature, qLen);
|
Integer r(signature, qLen);
|
||||||
Integer s(signature+qLen, qLen);
|
Integer s(signature+qLen, qLen);
|
||||||
std::cout << "Verifying:\n";
|
std::cout << "Verifying:\n";
|
||||||
|
@ -1151,7 +1151,7 @@ void cElGamalSig::ProcessBlock(const void* indata, void* outdata)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mpData->mpPublicKey->mpData->mpKey->Verify(
|
if (mpData->mpPublicKey->mpData->mpKey->Verify(
|
||||||
(const byte*)shaSig, SHA::DIGESTSIZE, (const byte*)indata + PLAIN_BLOCK_SIZE) == false)
|
(const uint8_t*)shaSig, SHA::DIGESTSIZE, (const uint8_t*)indata + PLAIN_BLOCK_SIZE) == false)
|
||||||
throw eArchiveCrypto();
|
throw eArchiveCrypto();
|
||||||
memmove(outdata, indata, PLAIN_BLOCK_SIZE);
|
memmove(outdata, indata, PLAIN_BLOCK_SIZE);
|
||||||
break;
|
break;
|
||||||
|
@ -1194,7 +1194,7 @@ cHashedKey128::cHashedKey128(const TSTRING& data)
|
||||||
SHA sha;
|
SHA sha;
|
||||||
|
|
||||||
ASSERT(SHA::DIGESTSIZE >= KEYLEN);
|
ASSERT(SHA::DIGESTSIZE >= KEYLEN);
|
||||||
sha.CalculateDigest((byte*)mKey, (byte*)data.data(), data.length() * sizeof(TCHAR));
|
sha.CalculateDigest((uint8_t*)mKey, (uint8_t*)data.data(), data.length() * sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
cHashedKey128::cHashedKey128(void* pData, int dataLen)
|
cHashedKey128::cHashedKey128(void* pData, int dataLen)
|
||||||
|
@ -1203,7 +1203,7 @@ cHashedKey128::cHashedKey128(void* pData, int dataLen)
|
||||||
|
|
||||||
ASSERT(SHA::DIGESTSIZE >= KEYLEN);
|
ASSERT(SHA::DIGESTSIZE >= KEYLEN);
|
||||||
ASSERT(SHA::DIGESTSIZE <= BUFSIZE);
|
ASSERT(SHA::DIGESTSIZE <= BUFSIZE);
|
||||||
sha.CalculateDigest((byte*)mKey, (byte*)pData, dataLen);
|
sha.CalculateDigest((uint8_t*)mKey, (uint8_t*)pData, dataLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
cHashedKey128::~cHashedKey128()
|
cHashedKey128::~cHashedKey128()
|
||||||
|
@ -1221,8 +1221,8 @@ cHashedKey192::cHashedKey192(const TSTRING& data)
|
||||||
ASSERT(SHA::DIGESTSIZE == 20);
|
ASSERT(SHA::DIGESTSIZE == 20);
|
||||||
ASSERT(40 >= KEYLEN);
|
ASSERT(40 >= KEYLEN);
|
||||||
|
|
||||||
byte localKey[40];
|
uint8_t localKey[40];
|
||||||
sha.CalculateDigest(localKey, (byte*)data.data(), data.length() * sizeof(TCHAR));
|
sha.CalculateDigest(localKey, (uint8_t*)data.data(), data.length() * sizeof(TCHAR));
|
||||||
sha.CalculateDigest(localKey + 20, localKey, 20);
|
sha.CalculateDigest(localKey + 20, localKey, 20);
|
||||||
memcpy(mKey, localKey, KEYLEN);
|
memcpy(mKey, localKey, KEYLEN);
|
||||||
}
|
}
|
||||||
|
@ -1234,8 +1234,8 @@ cHashedKey192::cHashedKey192(void* pData, int dataLen)
|
||||||
ASSERT(SHA::DIGESTSIZE == 20);
|
ASSERT(SHA::DIGESTSIZE == 20);
|
||||||
ASSERT(40 >= KEYLEN);
|
ASSERT(40 >= KEYLEN);
|
||||||
|
|
||||||
byte localKey[40];
|
uint8_t localKey[40];
|
||||||
sha.CalculateDigest(localKey, (byte*)pData, dataLen);
|
sha.CalculateDigest(localKey, (uint8_t*)pData, dataLen);
|
||||||
sha.CalculateDigest(localKey + 20, localKey, 20);
|
sha.CalculateDigest(localKey + 20, localKey, 20);
|
||||||
memcpy(mKey, localKey, KEYLEN);
|
memcpy(mKey, localKey, KEYLEN);
|
||||||
}
|
}
|
||||||
|
@ -1257,7 +1257,7 @@ static bool randomize_by_device(const char* device_name, int8* destbuf, int len)
|
||||||
|
|
||||||
if (rng_device >= 0)
|
if (rng_device >= 0)
|
||||||
{
|
{
|
||||||
int bytes_read = read(rng_device, destbuf, len);
|
int uint8_ts_read = read(rng_device, destbuf, len);
|
||||||
if (bytes_read == len)
|
if (bytes_read == len)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1303,6 +1303,6 @@ void RandomizeBytes(int8* destbuf, int len)
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
destbuf[i] = (byte)((rand() * 256 / RAND_MAX) ^ 0xdc); // 0xdc came from random.org
|
destbuf[i] = (uint8_t)((rand() * 256 / RAND_MAX) ^ 0xdc); // 0xdc came from random.org
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,10 @@ public:
|
||||||
cCryptoSink(cArchive* pDestArchive, iCipher* pCipher);
|
cCryptoSink(cArchive* pDestArchive, iCipher* pCipher);
|
||||||
~cCryptoSink();
|
~cCryptoSink();
|
||||||
|
|
||||||
virtual void Put(const byte* inString, unsigned int length);
|
virtual void Put(const uint8_t* inString, unsigned int length);
|
||||||
virtual void InputFinished();
|
virtual void InputFinished();
|
||||||
|
|
||||||
virtual void Put(byte inByte)
|
virtual void Put(uint8_t inByte)
|
||||||
{
|
{
|
||||||
Put(&inByte, 1);
|
Put(&inByte, 1);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ int cCryptoArchive::Write(const void* pSrc, int count)
|
||||||
throw eArchiveInvalidOp();
|
throw eArchiveInvalidOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
mpDeflator->Put((byte*)pSrc, count);
|
mpDeflator->Put((uint8_t*)pSrc, count);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -210,13 +210,13 @@ int cCryptoArchive::Read(void* pDest, int count)
|
||||||
if ((int)mpInflatedBytes->CurrentSize() < count) // RAD: Cast to int
|
if ((int)mpInflatedBytes->CurrentSize() < count) // RAD: Cast to int
|
||||||
{
|
{
|
||||||
len = mpInflatedBytes->CurrentSize();
|
len = mpInflatedBytes->CurrentSize();
|
||||||
mpInflatedBytes->Get((byte*)pDest, len);
|
mpInflatedBytes->Get((uint8_t*)pDest, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len = mpInflatedBytes->Get((byte*)pDest, count);
|
len = mpInflatedBytes->Get((uint8_t*)pDest, count);
|
||||||
ASSERT(len == count);
|
ASSERT(len == count);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
@ -278,7 +278,7 @@ cCryptoSink::~cCryptoSink()
|
||||||
delete [] mpBuffer;
|
delete [] mpBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cCryptoSink::Put(const byte* inString, unsigned int length)
|
void cCryptoSink::Put(const uint8_t* inString, unsigned int length)
|
||||||
{
|
{
|
||||||
if (mpBuffer == 0)
|
if (mpBuffer == 0)
|
||||||
{
|
{
|
||||||
|
@ -400,7 +400,7 @@ unsigned int cCryptoSource::Pump(unsigned int size)
|
||||||
if (bytesToCopy > nSize - i)
|
if (bytesToCopy > nSize - i)
|
||||||
bytesToCopy = nSize - i;
|
bytesToCopy = nSize - i;
|
||||||
|
|
||||||
outQueue->Put((byte*)(mpBuffer + mBufferUsed), bytesToCopy);
|
outQueue->Put((uint8_t*)(mpBuffer + mBufferUsed), bytesToCopy);
|
||||||
|
|
||||||
mBufferUsed += bytesToCopy;
|
mBufferUsed += bytesToCopy;
|
||||||
i += bytesToCopy;
|
i += bytesToCopy;
|
||||||
|
|
|
@ -679,8 +679,15 @@ void cParserUtil::CreatePropVector(const TSTRING& strPropListC, class cFCOPropVe
|
||||||
|
|
||||||
// clear out all spaces in the string
|
// clear out all spaces in the string
|
||||||
TSTRING strPropList = strPropListC;
|
TSTRING strPropList = strPropListC;
|
||||||
strPropList.erase(std::remove_if(strPropList.begin(), strPropList.end(), std::ptr_fun<int, int>(std::isspace)),
|
|
||||||
strPropList.end());
|
// C++17 removes std::ptr_fun, so use a lambda where available
|
||||||
|
#if __cplusplus < 201103L
|
||||||
|
strPropList.erase(std::remove_if(strPropList.begin(), strPropList.end(),
|
||||||
|
std::ptr_fun<int, int>(std::isspace)), strPropList.end());
|
||||||
|
#else
|
||||||
|
strPropList.erase(std::remove_if(strPropList.begin(), strPropList.end(),
|
||||||
|
[](int c) {return std::isspace(c);}), strPropList.end());
|
||||||
|
#endif
|
||||||
|
|
||||||
// zero it out
|
// zero it out
|
||||||
v.Clear();
|
v.Clear();
|
||||||
|
|
|
@ -70,11 +70,14 @@ void tw_terminate_handler()
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exception specifications removed as a misfeature in C++17
|
||||||
|
#if __cplusplus < 201703L
|
||||||
void tw_unexpected_handler()
|
void tw_unexpected_handler()
|
||||||
{
|
{
|
||||||
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int __cdecl _tmain(int argc, const TCHAR* argv[])
|
int __cdecl _tmain(int argc, const TCHAR* argv[])
|
||||||
{
|
{
|
||||||
|
@ -93,17 +96,16 @@ int __cdecl _tmain(int argc, const TCHAR* argv[])
|
||||||
// TODO: move this into the Init() routine
|
// TODO: move this into the Init() routine
|
||||||
|
|
||||||
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
||||||
|
#if __cplusplus < 201703L
|
||||||
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
||||||
|
#endif
|
||||||
|
|
||||||
twInit.Init(argv[0]);
|
twInit.Init(argv[0]);
|
||||||
TSS_Dependency(cTWPrint);
|
TSS_Dependency(cTWPrint);
|
||||||
|
|
||||||
// init twprint strings
|
// init twprint strings
|
||||||
//
|
|
||||||
|
|
||||||
cDebug::SetDebugLevel(cDebug::D_DEBUG);
|
cDebug::SetDebugLevel(cDebug::D_DEBUG);
|
||||||
|
|
||||||
|
|
||||||
// **** let's try a new way of doing things!
|
// **** let's try a new way of doing things!
|
||||||
// first, process the command line
|
// first, process the command line
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
AlignMe();
|
AlignMe();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
byte a[sizeof(int64) + ALIGN_SIZE]; // we want to be able to access a int64 at address [ALIGN_SIZE]
|
uint8_t a[sizeof(int64) + ALIGN_SIZE]; // we want to be able to access a int64 at address [ALIGN_SIZE]
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
@ -152,7 +152,7 @@ void TestAlignment()
|
||||||
// such accesses: it may have handled the
|
// such accesses: it may have handled the
|
||||||
// hardware interrupt that might have occured.
|
// hardware interrupt that might have occured.
|
||||||
// - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - -
|
||||||
byte a[sizeof(int32) + sizeof(byte)];
|
uint8_t a[sizeof(int32) + sizeof(uint8_t)];
|
||||||
|
|
||||||
// this should be fine
|
// this should be fine
|
||||||
a[0] = 0xAB;
|
a[0] = 0xAB;
|
||||||
|
@ -177,7 +177,7 @@ void TestAlignment()
|
||||||
// if it works, then our BYTE_ALIGN value is large enough
|
// if it works, then our BYTE_ALIGN value is large enough
|
||||||
// - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
byte b[2 * sizeof(BYTE_ALIGN)];
|
uint8_t b[2 * sizeof(BYTE_ALIGN)];
|
||||||
|
|
||||||
// this should be fine
|
// this should be fine
|
||||||
b[0] = 0xAB;
|
b[0] = 0xAB;
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mNumber;
|
int mNumber;
|
||||||
byte mData[20];
|
uint8_t mData[20];
|
||||||
TSTRING mString;
|
TSTRING mString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -76,10 +76,10 @@ void TestSignatureBasic()
|
||||||
cCRC32Signature crcSig;
|
cCRC32Signature crcSig;
|
||||||
cDebug d("TestSignature1");
|
cDebug d("TestSignature1");
|
||||||
|
|
||||||
byte abData[64];
|
uint8_t abData[64];
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 64; i++)
|
for (i = 0; i < 64; i++)
|
||||||
abData[i] = static_cast<byte>(rand());
|
abData[i] = static_cast<uint8_t>(rand());
|
||||||
|
|
||||||
crcSig.Init();
|
crcSig.Init();
|
||||||
crcSig.Update(&abData[0], 32);
|
crcSig.Update(&abData[0], 32);
|
||||||
|
@ -111,7 +111,7 @@ void TestChecksum()
|
||||||
// test begins here
|
// test begins here
|
||||||
|
|
||||||
// general signature & archive variables
|
// general signature & archive variables
|
||||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
uint8_t abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
||||||
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
||||||
int cbRead;
|
int cbRead;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void TestCRC32()
|
||||||
cDebug d("TestCRC32");
|
cDebug d("TestCRC32");
|
||||||
|
|
||||||
// general signature & archive variables
|
// general signature & archive variables
|
||||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
uint8_t abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
||||||
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
||||||
int cbRead;
|
int cbRead;
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ void TestMD5()
|
||||||
cDebug d("TestMD5");
|
cDebug d("TestMD5");
|
||||||
|
|
||||||
// general signature & archive variables
|
// general signature & archive variables
|
||||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
uint8_t abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
||||||
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
||||||
int cbRead;
|
int cbRead;
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ void TestSHA1()
|
||||||
cDebug d("TestSHA1");
|
cDebug d("TestSHA1");
|
||||||
|
|
||||||
// general signature & archive variables
|
// general signature & archive variables
|
||||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
uint8_t abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
||||||
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
||||||
int cbRead;
|
int cbRead;
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ void TestHAVAL()
|
||||||
cDebug d("TestHAVAL");
|
cDebug d("TestHAVAL");
|
||||||
|
|
||||||
// general signature & archive variables
|
// general signature & archive variables
|
||||||
byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
uint8_t abBuf[iSignature::SUGGESTED_BLOCK_SIZE];
|
||||||
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE;
|
||||||
int cbRead;
|
int cbRead;
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ void assertMD5(const std::string& source, const std::string& expectedHex)
|
||||||
cMD5Signature md5Sig;
|
cMD5Signature md5Sig;
|
||||||
|
|
||||||
md5Sig.Init();
|
md5Sig.Init();
|
||||||
md5Sig.Update((const byte*)source.c_str(), source.length());
|
md5Sig.Update((const uint8_t*)source.c_str(), source.length());
|
||||||
md5Sig.Finit();
|
md5Sig.Finit();
|
||||||
|
|
||||||
TEST(md5Sig.AsStringHex() == expectedHex);
|
TEST(md5Sig.AsStringHex() == expectedHex);
|
||||||
|
@ -430,7 +430,7 @@ void assertSHA1(const std::string& source, const std::string& expectedHex)
|
||||||
cSHASignature shaSig;
|
cSHASignature shaSig;
|
||||||
|
|
||||||
shaSig.Init();
|
shaSig.Init();
|
||||||
shaSig.Update((const byte*)source.c_str(), source.length());
|
shaSig.Update((const uint8_t*)source.c_str(), source.length());
|
||||||
shaSig.Finit();
|
shaSig.Finit();
|
||||||
|
|
||||||
TEST(shaSig.AsStringHex() == expectedHex);
|
TEST(shaSig.AsStringHex() == expectedHex);
|
||||||
|
|
|
@ -431,11 +431,13 @@ void tw_terminate_handler()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus < 201703L
|
||||||
void tw_unexpected_handler()
|
void tw_unexpected_handler()
|
||||||
{
|
{
|
||||||
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
fputs("### Internal Error.\n### Unexpected Exception Handler called.\n### Exiting...\n", stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int _tmain(int argc, TCHAR** argv)
|
int _tmain(int argc, TCHAR** argv)
|
||||||
{
|
{
|
||||||
|
@ -449,8 +451,9 @@ int _tmain(int argc, TCHAR** argv)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler);
|
||||||
|
#if __cplusplus < 201703L
|
||||||
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler);
|
||||||
|
#endif
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
Usage();
|
Usage();
|
||||||
|
|
Loading…
Reference in New Issue