* Revert swap*

This commit is contained in:
Phillip Stephens 2014-04-28 19:31:32 -07:00
parent 6150d728a5
commit da7781f78e
4 changed files with 24 additions and 18 deletions

View File

@ -29,6 +29,12 @@
std::cerr << __FILE__ << "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << ": "
#endif
#ifndef aPrint
#define aPrint() std::cout
#endif
#define aEnd() '\n'
#ifndef BLOCKSZ
#define BLOCKSZ 512
#endif

View File

@ -27,12 +27,12 @@ namespace utility
{
bool isEmpty(Int8*, Uint32);
Uint16 swapU16(Uint16& val );
Int16 swap16 (Int16& val );
Uint32 swapU32(Uint32& val);
Int32 swap32 (Int32& val );
Uint64 swapU64(Uint64& val);
Int64 swap64 (Int64& val);
Uint16 swapU16(Uint16 val );
Int16 swap16 (Int16 val );
Uint32 swapU32(Uint32 val);
Int32 swap32 (Int32 val );
Uint64 swapU64(Uint64 val);
Int64 swap64 (Int64 val);
float swapFloat(float val);
double swapDouble(double val);

View File

@ -32,34 +32,34 @@ bool isEmpty(Int8* buf, Uint32 size)
return buf[0] == 0 && !memcmp(buf, buf + 1, size - 1);
}
Uint16 swapU16(Uint16& val )
Uint16 swapU16(Uint16 val )
{
return (Uint16)swap16((Int16&)val);
return (Uint16)swap16(val);
}
Int16 swap16(Int16& val )
Int16 swap16(Int16 val )
{
return (val = (val << 8) | ((val >> 8) & 0xFF));
}
Uint32 swapU32(Uint32& val)
Uint32 swapU32(Uint32 val)
{
return (Uint32)swap32((Int32&)val);
return (Uint32)swap32(val);
}
int swap32(Int32& val )
int swap32(Int32 val )
{
val = (val & 0x0000FFFF) << 16 | (val & 0xFFFF0000) >> 16;
val = (val & 0x00FF00FF) << 8 | (val & 0xFF00FF00) >> 8;
return val;
}
Uint64 swapU64(Uint64& val)
Uint64 swapU64(Uint64 val)
{
return (Uint64)swap64((Int64&)val);
return (Uint64)swap64(val);
}
Int64 swap64(Int64& val)
Int64 swap64(Int64 val)
{
return (val = ((Int64)((((Int64)(val) & 0xFF00000000000000ULL) >> 56) |
(((Int64)(val) & 0x00FF000000000000ULL) >> 40) |

View File

@ -407,16 +407,16 @@ void make_ec_cert(Uint8 *cert, Uint8 *sig, char *signer, char *name, Uint8 *priv
memset(cert, 0, 0x180);
*(Uint32*)(cert) = 0x10002;
if (!Athena::utility::isSystemBigEndian())
Athena::utility::swapU32(*(Uint32*)(cert));
*(Uint32*)(cert) = Athena::utility::swapU32(*(Uint32*)(cert));
memcpy((char*)cert + 4, sig, 60);
strcpy((char*)cert + 0x80, signer);
*(Uint32*)(cert + 0xc0) = 2;
if (!Athena::utility::isSystemBigEndian())
Athena::utility::swapU32(*(Uint32*)(cert + 0xc0));
*(Uint32*)(cert + 0xc0) = Athena::utility::swapU32(*(Uint32*)(cert + 0xc0));
strcpy((char*)cert + 0xc4, name);
*(Uint32*)(cert + 0x104) = key_id;
if (!Athena::utility::isSystemBigEndian())
Athena::utility::swapU32(*(Uint32*)(cert + 0x104));
*(Uint32*)(cert + 0x104) = Athena::utility::swapU32(*(Uint32*)(cert + 0x104));
ec_priv_to_pub(priv, cert + 0x108);
}