tunsafe-clang15/crypto_ops.h
Ludvig Strigeus cf92ac7a0c Updates for TunSafe 1.4-rc1
1.Subfolders in the Config/ directory now show up as submenus.
2.Added a way to run TunSafe as a Windows Service.
  Foreground Mode: The service will disconnect when TunSafe closes.
  Background Mode: The service will stay connected in the background.
  No longer required to run the TunSafe client as Admin as long as
  the service is running.
3.New config setting [Interface].ExcludedIPs to configure IPs that
  should not be routed through TunSafe.
4.Can now automatically start TunSafe when Windows starts
5.New UI with tabs and graphs
6.Cache DNS queries to ensure DNS will succeed if connection fails
7.Recreate tray icon when explorer.exe restarts
8.Renamed window title to TunSafe instead of TunSafe VPN Client
9.Main window is now resizable
10.Disallow roaming endpoint when using AllowedIPs=0.0.0.0/0
   Only the original endpoint is added in the routing table so
   this would result in an endless loop of packets.
11.Display approximate Wireguard framing overhead in stats
12.Preparations for protocol handling with multiple threads
13.Delete the routes we made when disconnecting
14.Fix error message about unable to delete a route when connecting
2018-08-12 03:30:06 +02:00

42 lines
No EOL
1 KiB
C

// SPDX-License-Identifier: AGPL-1.0-only
// Copyright (C) 2018 Ludvig Strigeus <info@tunsafe.com>. All Rights Reserved.
#ifndef TUNSAFE_CRYPTO_OPS_H_
#define TUNSAFE_CRYPTO_OPS_H_
#include "build_config.h"
#include "tunsafe_types.h"
#include <string.h>
#if defined(COMPILER_MSVC)
#include <intrin.h>
#endif // defined(COMPILER_MSVC)
#if defined(ARCH_CPU_X86_64) && defined(COMPILER_MSVC)
FORCEINLINE static void memzero_crypto(void *dst, size_t n) {
if (n & 7) {
__stosb((unsigned char*)dst, 0, n);
} else {
__stosq((uint64*)dst, 0, n >> 3);
}
}
#elif defined(ARCH_CPU_X86) && defined(COMPILER_MSVC)
FORCEINLINE static void memzero_crypto(void *dst, size_t n) {
if (n & 3) {
__stosb((unsigned char*)dst, 0, n);
} else {
__stosd((unsigned long*)dst, 0, n >> 2);
}
}
#else
FORCEINLINE static void memzero_crypto(void *dst, size_t n) {
memset(dst, 0, n);
__asm__ __volatile__("": :"r"(dst) :"memory");
}
#endif
int memcmp_crypto(const uint8 *a, const uint8 *b, size_t n);
#endif // TUNSAFE_CRYPTO_OPS_H_