mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
- Added CMake makefiles as alternative to regular Makefiles.
- Added preliminary Code Coverage tests for AES, ARC4, Base64, MPI, SHA-family, MD-family and HMAC-SHA-family.
This commit is contained in:
57
tests/suites/helpers.function
Normal file
57
tests/suites/helpers.function
Normal file
@@ -0,0 +1,57 @@
|
||||
int unhexify(unsigned char *obuf, const char *ibuf)
|
||||
{
|
||||
unsigned char c, c2;
|
||||
int len = strlen(ibuf) / 2;
|
||||
assert(!(strlen(ibuf) %1)); // must be even number of bytes
|
||||
|
||||
while (*ibuf != 0)
|
||||
{
|
||||
c = *ibuf++;
|
||||
if( c >= '0' && c <= '9' )
|
||||
c -= '0';
|
||||
else if( c >= 'a' && c <= 'f' )
|
||||
c -= 'a' - 10;
|
||||
else if( c >= 'A' && c <= 'F' )
|
||||
c -= 'A' - 10;
|
||||
else
|
||||
assert( 0 );
|
||||
|
||||
c2 = *ibuf++;
|
||||
if( c2 >= '0' && c2 <= '9' )
|
||||
c2 -= '0';
|
||||
else if( c2 >= 'a' && c2 <= 'f' )
|
||||
c2 -= 'a' - 10;
|
||||
else if( c2 >= 'A' && c2 <= 'F' )
|
||||
c2 -= 'A' - 10;
|
||||
else
|
||||
assert( 0 );
|
||||
|
||||
*obuf++ = ( c << 4 ) | c2;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
|
||||
{
|
||||
unsigned char l, h;
|
||||
|
||||
while (len != 0)
|
||||
{
|
||||
h = (*ibuf) / 16;
|
||||
l = (*ibuf) % 16;
|
||||
|
||||
if( h < 10 )
|
||||
*obuf++ = '0' + h;
|
||||
else
|
||||
*obuf++ = 'a' + h - 10;
|
||||
|
||||
if( l < 10 )
|
||||
*obuf++ = '0' + l;
|
||||
else
|
||||
*obuf++ = 'a' + l - 10;
|
||||
|
||||
++ibuf;
|
||||
len--;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user