UTILS

Various useful helper functions. More...

Functions

char * _lc (char *in)
 Convert a char array to lowercase. More...
 
long int _findoffset (byte *bin, size_t binlen, char *sigstart, size_t hlen)
 Find the offset of some offset marker in some arbitrary data. More...
 
void _xorbuf (byte *iv, byte *buf, size_t xlen)
 XOR an input buffer with another buffer. More...
 
void _dump (char *n, byte *d, size_t s)
 Dump binary data as hex to stderr. More...
 

Detailed Description

Various useful helper functions.

Function Documentation

void _dump ( char *  n,
byte *  d,
size_t  s 
)

Dump binary data as hex to stderr.

Parameters
[in]nDescription, string.
[in]dData to print.
[in]sSize of d.
long int _findoffset ( byte *  bin,
size_t  binlen,
char *  sigstart,
size_t  hlen 
)

Find the offset of some offset marker in some arbitrary data.

Sample input:

ABABABABnacl-98a7sd98a7das98d7

If you look for the offset of "nacl" within that data, the function will return 9, which is the position within the data where the marker starts.

Parameters
[in]binAribrary data where to look for the marker.
[in]binlenThe size of the data.
[in]sigstartThe offset marker.
[in]hlenSize of the offset marker.
Returns
Returns the offset or -1 of the offset were not found.
char* _lc ( char *  in)

Convert a char array to lowercase.

The supplied char array will be directly modified. Use a copy if you want to retain the original.

Parameters
[in,out]inThe char array to convert.
Returns
Returns the pointer to the char array.
void _xorbuf ( byte *  iv,
byte *  buf,
size_t  xlen 
)

XOR an input buffer with another buffer.

Both buffers have to have the same size. The input buffer will bei modified directly.

Parameters
[in]ivThe buffer to XOR with.
[in,out]bufThe buffer which will be XORed with 'iv'.
[in]xlenThe size of the buffers (they must have the same size).