Example #1
0
int main(int argc, char **argv)
{
	if( rdrand_available() ) {
		fprintf( stderr, "rdrand supported.\n" );
	} else {
		fprintf( stderr, "rdrand NOT supported.\n" );
	}
	uint8_t buf[64];
	sodium_mlock( buf, 64 );
	char hex[130];
	char *result;

	while( 1 ) {
		int received_entropy = sqrl_entropy_get_blocking( buf, 64 );
		result = sodium_bin2hex( hex, 129, (unsigned char*)buf, 64 );
		if( result ) {
			printf( "%d: %s\n", received_entropy, result );
		}
#ifdef _WIN32
		Sleep(1000);
#else
		sleep(1);
#endif
	}
	sodium_munlock( buf, crypto_hash_sha512_BYTES );
	
	return 0;
}
Example #2
0
bool unlockMemory(const QByteArray &data, CryptoFlags flags)
{
    if(flags == NoLockMemory)
    {
        return true;
    }

    return sodium_munlock((void*const)data.constData(), data.length()) == TEARS_SODIUM_SUCCESS
            || flags != FailOnLockFailure;
}