mirror of https://github.com/infosecn1nja/C3.git
Merge branch 'ClangMsvcCompat'
commit
ce232a9af6
|
@ -3,7 +3,7 @@
|
|||
/// Entry point of the application.
|
||||
/// @param argc number of program arguments.
|
||||
/// @param argv vector of program arguments.
|
||||
int main(DWORD argc, char* argv[])
|
||||
int main(int argc, char* argv[])
|
||||
try
|
||||
{
|
||||
std::cout << "Custom Command and Control - Channel linter. BUILD: " << C3_BUILD_VERSION << std::endl;
|
||||
|
|
|
@ -40,6 +40,9 @@ namespace FSecure::C3::Linter
|
|||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~BooleanFormElement() = default;
|
||||
|
||||
/// Set boolean value from input accepted values interpreted as true are "true", "yes", "y", "1"
|
||||
/// @param input to validate
|
||||
void ValidateAndSet(std::string_view input) override
|
||||
|
@ -59,6 +62,10 @@ namespace FSecure::C3::Linter
|
|||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~StringFormElement() = default;
|
||||
|
||||
|
||||
/// Validate and set string value from input
|
||||
/// @param input to validate
|
||||
/// @throws std::invalid_argument if validation fails
|
||||
|
@ -77,6 +84,9 @@ namespace FSecure::C3::Linter
|
|||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~IpFormElement() = default;
|
||||
|
||||
/// Validate and set IP value from input
|
||||
/// @param input to validate
|
||||
/// @throws std::invalid_argument if validation fails
|
||||
|
@ -112,6 +122,9 @@ namespace FSecure::C3::Linter
|
|||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~BinaryFormElement() = default;
|
||||
|
||||
/// Validate and set binary value from input (in base64 string)
|
||||
/// @param input to validate
|
||||
/// @throws std::invalid_argument if validation fails
|
||||
|
@ -142,6 +155,9 @@ namespace FSecure::C3::Linter
|
|||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~NumericFormElement() = default;
|
||||
|
||||
/// Validate and set numeric value from input
|
||||
/// @param input to validate
|
||||
/// @throws std::invalid_argument if validation fails
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace FSecure::C3::Linter
|
|||
Binary,
|
||||
};
|
||||
|
||||
/// Destructor
|
||||
virtual ~FormElement() = default;
|
||||
|
||||
/// Validate input against argument and set as value
|
||||
virtual void ValidateAndSet(std::string_view input) = 0;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace FSecure::C3::Linter
|
|||
{
|
||||
static std::mutex mutex;
|
||||
std::lock_guard lock(mutex);
|
||||
std::cout << FSecure::C3::Utils::ConvertLogMessageToConsoleText("", message, nullptr) << std::endl;
|
||||
std::cout << FSecure::C3::Utils::ConvertLogMessageToConsoleText("", message, "") << std::endl;
|
||||
}
|
||||
|
||||
void MockDeviceBridge::SetUpdateDelay(std::chrono::milliseconds minUpdateDelay, std::chrono::milliseconds maxUpdateDelay)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace FSecure::C3::Linter
|
||||
{
|
||||
/// Device bridge used to mock its functionality
|
||||
class MockDeviceBridge : public FSecure::C3::AbstractDeviceBridge, public std::enable_shared_from_this<MockDeviceBridge>
|
||||
class MockDeviceBridge final : public FSecure::C3::AbstractDeviceBridge, public std::enable_shared_from_this<MockDeviceBridge>
|
||||
{
|
||||
public:
|
||||
/// Create Mock device bridge to device
|
||||
|
|
|
@ -90,11 +90,7 @@ struct enc {
|
|||
if (num_symbols == NumSymbols) {
|
||||
data::put(encoded, state, CodecVariant::symbol(Codec::template index_last<SymbolIndex>(src)));
|
||||
padder<CodecVariant::generates_padding()> pad;
|
||||
#ifdef _MSC_VER
|
||||
pad.operator()<CodecVariant>(encoded, state, Codec::encoded_block_size() - NumSymbols);
|
||||
#else
|
||||
pad.template operator()<CodecVariant>(encoded, state, Codec::encoded_block_size() - NumSymbols);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
data::put(encoded, state, CodecVariant::symbol(Codec::template index<SymbolIndex>(src)));
|
||||
|
|
|
@ -66,7 +66,7 @@ void FSecure::C3::Interfaces::Channels::Slack::DeleteReplies(std::vector<std::st
|
|||
m_slackObj.DeleteMessage(ts);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::ByteView FSecure::C3::Interfaces::Channels::Slack::GetCapability()
|
||||
const char* FSecure::C3::Interfaces::Channels::Slack::GetCapability()
|
||||
{
|
||||
return R"_(
|
||||
{
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace FSecure::C3::Interfaces::Channels
|
|||
/// @param arguments factory arguments.
|
||||
Slack(ByteView arguments);
|
||||
|
||||
/// Destructor
|
||||
virtual ~Slack() = default;
|
||||
|
||||
/// OnSend callback implementation.
|
||||
/// @param packet data to send to Channel.
|
||||
/// @returns size_t number of bytes successfully written.
|
||||
|
@ -20,8 +23,8 @@ namespace FSecure::C3::Interfaces::Channels
|
|||
ByteVector OnReceiveFromChannel();
|
||||
|
||||
/// Get channel capability.
|
||||
/// @returns ByteView view of channel capability.
|
||||
static ByteView GetCapability();
|
||||
/// @returns Channel capability in JSON format
|
||||
static const char* GetCapability();
|
||||
|
||||
/// Values used as default for channel jitter. 30 ms if unset. Current jitter value can be changed at runtime.
|
||||
/// Set long delay otherwise slack rate limit will heavily impact channel.
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace
|
|||
pSA->nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
pSA->bInheritHandle = true;
|
||||
|
||||
TCHAR* szSD = TEXT("D:(A;ID;FA;;;S-1-1-0)");
|
||||
const wchar_t* szSD = OBF(L"D:(A;ID;FA;;;S-1-1-0)");
|
||||
|
||||
if (NULL == pSA)
|
||||
return FALSE;
|
||||
|
||||
return ConvertStringSecurityDescriptorToSecurityDescriptor(
|
||||
return ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
||||
szSD,
|
||||
SDDL_REVISION_1,
|
||||
&(pSA->lpSecurityDescriptor),
|
||||
|
@ -194,7 +194,7 @@ FSecure::ByteVector FSecure::C3::Interfaces::Channels::UncShareFile::OnRunComman
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::ByteView FSecure::C3::Interfaces::Channels::UncShareFile::GetCapability()
|
||||
const char* FSecure::C3::Interfaces::Channels::UncShareFile::GetCapability()
|
||||
{
|
||||
return R"(
|
||||
{
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace FSecure::C3::Interfaces::Channels
|
|||
/// @param arguments factory arguments.
|
||||
UncShareFile(ByteView arguments);
|
||||
|
||||
/// Destructor
|
||||
virtual ~UncShareFile() = default;
|
||||
|
||||
/// OnSend callback implementation.
|
||||
/// @param blob data to send to Channel.
|
||||
/// @returns size_t number of bytes successfully written.
|
||||
|
@ -20,8 +23,8 @@ namespace FSecure::C3::Interfaces::Channels
|
|||
std::vector<ByteVector> OnReceiveFromChannel();
|
||||
|
||||
/// Get channel capability.
|
||||
/// @returns ByteView view of channel capability.
|
||||
static ByteView GetCapability();
|
||||
/// @returns Channel capability in JSON format
|
||||
static const char* GetCapability();
|
||||
|
||||
/// Processes internal (C3 API) Command.
|
||||
/// @param command a buffer containing whole command and it's parameters.
|
||||
|
|
|
@ -12,14 +12,17 @@ namespace FSecure::C3::Interfaces::Connectors
|
|||
/// @param arguments factory arguments.
|
||||
MockServer(ByteView);
|
||||
|
||||
/// Destructor
|
||||
virtual ~MockServer() = default;
|
||||
|
||||
/// OnCommandFromBinder callback implementation.
|
||||
/// @param binderId Identifier of Peripheral who sends the Command.
|
||||
/// @param command full Command with arguments.
|
||||
void OnCommandFromBinder(ByteView binderId, ByteView command) override;
|
||||
|
||||
/// Returns json with Commands.
|
||||
/// @return Commands description in JSON format.
|
||||
static ByteView GetCapability();
|
||||
/// @return Capability in JSON format
|
||||
static const char* GetCapability();
|
||||
|
||||
/// Processes internal (C3 API) Command.
|
||||
/// @param command a buffer containing whole command and it's parameters.
|
||||
|
@ -161,7 +164,7 @@ FSecure::ByteVector FSecure::C3::Interfaces::Connectors::MockServer::PeripheralC
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::ByteView FSecure::C3::Interfaces::Connectors::MockServer::GetCapability()
|
||||
const char* FSecure::C3::Interfaces::Connectors::MockServer::GetCapability()
|
||||
{
|
||||
return R"(
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace FSecure::C3::Interfaces::Connectors
|
|||
TeamServer(ByteView arguments);
|
||||
|
||||
/// A public destructor.
|
||||
~TeamServer();
|
||||
virtual ~TeamServer();
|
||||
|
||||
/// OnCommandFromConnector callback implementation.
|
||||
/// @param binderId Identifier of Peripheral who sends the Command.
|
||||
|
@ -31,8 +31,8 @@ namespace FSecure::C3::Interfaces::Connectors
|
|||
ByteVector PeripheralCreationCommand(ByteView connectionId, ByteView data, bool isX64) override;
|
||||
|
||||
/// Return json with commands.
|
||||
/// @return ByteView Commands description in JSON format.
|
||||
static ByteView GetCapability();
|
||||
/// @return Capability in JSON format
|
||||
static const char* GetCapability();
|
||||
|
||||
private:
|
||||
/// Represents a single C3 <-> Team Server connection, as well as each beacon in network.
|
||||
|
@ -208,7 +208,7 @@ FSecure::ByteVector FSecure::C3::Interfaces::Connectors::TeamServer::OnRunComman
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::ByteView FSecure::C3::Interfaces::Connectors::TeamServer::GetCapability()
|
||||
const char* FSecure::C3::Interfaces::Connectors::TeamServer::GetCapability()
|
||||
{
|
||||
return R"(
|
||||
{
|
||||
|
@ -312,7 +312,7 @@ void FSecure::C3::Interfaces::Connectors::TeamServer::Connection::Send(ByteView
|
|||
|
||||
std::unique_lock<std::mutex> lock{ owner->m_SendMutex };
|
||||
// Write four bytes indicating the length of the next chunk of data.
|
||||
DWORD chunkLength = static_cast<DWORD>(data.size()), bytesWritten = 0;
|
||||
DWORD chunkLength = static_cast<DWORD>(data.size());
|
||||
if (SOCKET_ERROR == send(m_Socket, reinterpret_cast<char*>(&chunkLength), 4, 0))
|
||||
throw FSecure::SocketsException(OBF("Error sending to Socket : ") + std::to_string(WSAGetLastError()) + OBF("."), WSAGetLastError());
|
||||
|
||||
|
@ -340,7 +340,7 @@ FSecure::ByteVector FSecure::C3::Interfaces::Connectors::TeamServer::Connection:
|
|||
case 0:
|
||||
return {}; //< The connection has been gracefully closed.
|
||||
|
||||
case SOCKET_ERROR:
|
||||
case static_cast<DWORD>(SOCKET_ERROR):
|
||||
throw FSecure::SocketsException(OBF("Error receiving from Socket : ") + std::to_string(WSAGetLastError()) + OBF("."), WSAGetLastError());
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ bool FSecure::C3::Interfaces::Peripherals::Beacon::IsNoOp(ByteView data)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::ByteView FSecure::C3::Interfaces::Peripherals::Beacon::GetCapability()
|
||||
const char* FSecure::C3::Interfaces::Peripherals::Beacon::GetCapability()
|
||||
{
|
||||
return R"(
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace FSecure::C3::Interfaces::Peripherals
|
|||
Beacon(ByteView arguments);
|
||||
|
||||
/// Destructor
|
||||
~Beacon();
|
||||
virtual ~Beacon();
|
||||
|
||||
/// Sending callback implementation.
|
||||
/// @param packet to send to the Implant.
|
||||
|
@ -30,8 +30,8 @@ namespace FSecure::C3::Interfaces::Peripherals
|
|||
ByteVector OnReceiveFromPeripheral() override;
|
||||
|
||||
/// Return json with commands.
|
||||
/// @return ByteView Commands description in JSON format.
|
||||
static ByteView GetCapability();
|
||||
/// @return Capability description in JSON format.
|
||||
static const char* GetCapability();
|
||||
|
||||
/// Close Peripheral Beacon
|
||||
/// Calls superclass Close and prepares to exit without deadlocking
|
||||
|
|
|
@ -47,7 +47,7 @@ FSecure::ByteVector FSecure::C3::Interfaces::Peripherals::Mock::TestErrorCommand
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::ByteView FSecure::C3::Interfaces::Peripherals::Mock::GetCapability()
|
||||
const char* FSecure::C3::Interfaces::Peripherals::Mock::GetCapability()
|
||||
{
|
||||
return R"(
|
||||
{
|
||||
|
|
|
@ -17,6 +17,9 @@ namespace FSecure::C3::Interfaces::Peripherals
|
|||
/// @param ByteView unused.
|
||||
Mock(ByteView);
|
||||
|
||||
/// Destructor
|
||||
virtual ~Mock() = default;
|
||||
|
||||
/// Sending callback implementation.
|
||||
/// @param packet to send to the Implant.
|
||||
void OnCommandFromConnector(ByteView packet) override;
|
||||
|
@ -26,8 +29,8 @@ namespace FSecure::C3::Interfaces::Peripherals
|
|||
ByteVector OnReceiveFromPeripheral() override;
|
||||
|
||||
/// Return json with commands.
|
||||
/// @return ByteView Commands description in JSON format.
|
||||
static ByteView GetCapability();
|
||||
/// @return Capability description in JSON format.
|
||||
static const char* GetCapability();
|
||||
|
||||
/// Processes internal (C3 API) Command.
|
||||
/// @param command a buffer containing whole command and it's parameters.
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace FSecure::C3
|
|||
ret.m_StartupJitter = std::pair(Iface::s_MinUpdateDelay, Iface::s_MaxUpdateDelay);
|
||||
#ifdef C3_IS_GATEWAY
|
||||
ret.m_Name = GetInterfaceName<Iface>();
|
||||
ret.m_Capability = EnsureDefaultCapability<Iface>::GetCapability<EnsureDefaultCapability<Iface>::HasCustomCapability>(); // Simpler syntax should be available, but I've encountered MSVC bug with SFINAE.
|
||||
ret.m_Capability = EnsureDefaultCapability<Iface>::template GetCapability<EnsureDefaultCapability<Iface>::HasCustomCapability>(); // Simpler syntax should be available, but I've encountered MSVC bug with SFINAE.
|
||||
#endif //C3_IS_GATEWAY
|
||||
|
||||
return ret;
|
||||
|
@ -105,8 +105,8 @@ namespace FSecure::C3
|
|||
Channel()
|
||||
{
|
||||
static_assert(Iface::s_MinUpdateDelay >= 30ms && Iface::s_MinUpdateDelay <= Iface::s_MaxUpdateDelay, "The frequency is set incorrectly");
|
||||
m_MinUpdateDelay = Iface::s_MinUpdateDelay;
|
||||
m_MaxUpdateDelay = Iface::s_MaxUpdateDelay;
|
||||
this->m_MinUpdateDelay = Iface::s_MinUpdateDelay;
|
||||
this->m_MaxUpdateDelay = Iface::s_MaxUpdateDelay;
|
||||
}
|
||||
|
||||
/// Callback that is periodically called for every Device to update itself.
|
||||
|
@ -197,7 +197,7 @@ namespace FSecure::C3
|
|||
class Connector : public AbstractConnector
|
||||
{
|
||||
};
|
||||
#endif C3_IS_GATEWAY
|
||||
#endif // C3_IS_GATEWAY
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4307)
|
||||
|
@ -212,8 +212,8 @@ namespace FSecure::C3
|
|||
Peripheral()
|
||||
{
|
||||
static_assert(Iface::s_MinUpdateDelay >= 30ms && Iface::s_MinUpdateDelay <= Iface::s_MaxUpdateDelay, "The frequency is set incorrectly");
|
||||
m_MinUpdateDelay = Iface::s_MinUpdateDelay;
|
||||
m_MaxUpdateDelay = Iface::s_MaxUpdateDelay;
|
||||
this->m_MinUpdateDelay = Iface::s_MinUpdateDelay;
|
||||
this->m_MaxUpdateDelay = Iface::s_MaxUpdateDelay;
|
||||
}
|
||||
};
|
||||
#pragma warning( pop )
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace FSecure::C3
|
|||
/// Abstract Relay.
|
||||
struct Relay
|
||||
{
|
||||
/// Destructor
|
||||
virtual ~Relay() = default;
|
||||
|
||||
/// Waits for Relay to be terminated internally by a C3 API Command (e.g. from WebController).
|
||||
virtual void Join() = 0;
|
||||
};
|
||||
|
@ -50,7 +53,7 @@ namespace FSecure::C3
|
|||
namespace Utils
|
||||
{
|
||||
/// Gate/Node Relay starters logger callback prototype.
|
||||
using LoggerCallback = void(*)(LogMessage const&, std::string_view*);
|
||||
using LoggerCallback = void(*)(LogMessage const&, std::string_view);
|
||||
|
||||
/// Creates a Gateway.
|
||||
/// @param callbackOnLog callback fired whenever a new Log entry is being added.
|
||||
|
@ -70,12 +73,15 @@ namespace FSecure::C3
|
|||
/// @param message information to log.
|
||||
/// @param sender ID of the Interface reporting the message. If sender.empty() then the message comes from internal Relay mechanisms. If sender is null then it comes from outside the Relay.
|
||||
/// @return Constructed string.
|
||||
std::string ConvertLogMessageToConsoleText(std::string_view relayName, FSecure::C3::LogMessage const& message, std::string_view* sender);
|
||||
std::string ConvertLogMessageToConsoleText(std::string_view relayName, FSecure::C3::LogMessage const& message, std::string_view sender);
|
||||
}
|
||||
|
||||
/// Device bridge between C3 Core and C3 Mantle.
|
||||
struct AbstractDeviceBridge
|
||||
{
|
||||
/// Destructor
|
||||
virtual ~AbstractDeviceBridge() = default;
|
||||
|
||||
/// Called by Relay just after the Device creation.
|
||||
virtual void OnAttach() = 0;
|
||||
|
||||
|
@ -133,6 +139,9 @@ namespace FSecure::C3
|
|||
/// Connector bridge between C3 Core and C3 Mantle.
|
||||
struct AbstractConnectorBridge
|
||||
{
|
||||
/// Destructor
|
||||
virtual ~AbstractConnectorBridge() = default;
|
||||
|
||||
/// Called by Relay just after creation of the Connector.
|
||||
virtual void OnAttach() = 0;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace FSecure::C3
|
|||
}
|
||||
|
||||
/// Get proper map member for type T.
|
||||
template <typename T> auto& GetMap() { static_assert(false, "Template type not supported."); }
|
||||
template <typename T> auto& GetMap() = delete;
|
||||
template <> auto& GetMap<AbstractChannel>() { return m_Channels; }
|
||||
template <> auto& GetMap<AbstractPeripheral>() { return m_Peripherals; }
|
||||
template <> auto& GetMap<AbstractConnector>() { return m_Connectors; }
|
||||
|
@ -101,7 +101,7 @@ namespace FSecure::C3
|
|||
std::string GetInterfaceName()
|
||||
{
|
||||
# ifndef _MSC_VER
|
||||
static_assert(false, "Current implementation supports only MSVC.");
|
||||
static_assert(false, "Current implementation supports only MSVC and clang-cl.");
|
||||
# endif
|
||||
|
||||
std::string_view fullName = __FUNCSIG__;
|
||||
|
@ -119,7 +119,13 @@ namespace FSecure::C3
|
|||
|
||||
auto retVal = std::string{ fullName.substr(offset + "::"sv.size()) };
|
||||
|
||||
if ((offset = retVal.rfind('>')) == std::string::npos)
|
||||
# if defined (_MSC_VER) && !defined(__clang__) // MSVC
|
||||
char afterName = '>';
|
||||
# elif defined (_MSC_VER) && defined(__clang__) // Clang-cl
|
||||
char afterName = ']';
|
||||
# endif
|
||||
|
||||
if ((offset = retVal.rfind(afterName)) == std::string::npos)
|
||||
throw std::logic_error{ OBF("Cannot generate interface name.") };
|
||||
|
||||
retVal = retVal.substr(0, offset);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "ByteArray.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace FSecure
|
||||
{
|
||||
/// Forward declaration
|
||||
|
@ -23,8 +25,8 @@ namespace FSecure
|
|||
template <typename T>
|
||||
class ByteSizeFunctionType
|
||||
{
|
||||
template <typename C> static uint32_t test(decltype(FSecure::ByteConverter<T>::Size(std::declval<C>())));
|
||||
template <typename C> static uint16_t test(decltype(FSecure::ByteConverter<T>::Size(std::void_t<C>)));
|
||||
template <typename C> static uint32_t test(decltype(FSecure::ByteConverter<C>::Size(std::declval<C>())));
|
||||
template <typename C> static uint16_t test(decltype(FSecure::ByteConverter<C>::Size()));
|
||||
template <typename C> static uint8_t test(...);
|
||||
|
||||
public:
|
||||
|
@ -162,30 +164,25 @@ namespace FSecure
|
|||
template <typename T, typename ...Ts, typename = std::enable_if_t<Utils::IsOneOf<T, ByteView, ByteVector>::value>>
|
||||
ByteVector& Concat(T const& arg, Ts const& ...args)
|
||||
{
|
||||
if constexpr (!sizeof...(Ts))
|
||||
{
|
||||
auto oldSize = size();
|
||||
resize(oldSize + arg.size());
|
||||
memcpy(data() + oldSize, arg.data(), arg.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
Concat(arg);
|
||||
auto oldSize = size();
|
||||
resize(oldSize + arg.size());
|
||||
memcpy(data() + oldSize, arg.data(), arg.size());
|
||||
if constexpr (sizeof...(Ts) != 0)
|
||||
Concat(args...);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// msvc can handle fold expression in debug mode, but fails with internal compiler error in release.
|
||||
// Some versions of msvc can handle fold expression in debug mode, but fails with internal compiler error in release.
|
||||
// For this reason recursive version is used as deafult.
|
||||
//template <typename ...T, typename = std::enable_if_t<((Utils::IsOneOf<T, ByteView, ByteVector>::value && ...))>>
|
||||
//ByteVector& Concat(T const& ...arg)
|
||||
//ByteVector& Concat(T const& ...args)
|
||||
//{
|
||||
// auto oldSize = size();
|
||||
// auto foldSize = (arg.size() + ...);
|
||||
// auto foldSize = (args.size() + ...);
|
||||
// resize(oldSize + foldSize);
|
||||
// auto ptr = data() + oldSize;
|
||||
// ((memcpy(ptr, arg.data(), arg.size()), (ptr += arg.size())), ...);
|
||||
// ((memcpy(ptr, args.data(), args.size()), (ptr += args.size())), ...);
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
|
@ -200,13 +197,6 @@ namespace FSecure
|
|||
return ByteVector{}.Write(arg, args...);
|
||||
}
|
||||
|
||||
/// Proxy function to ByteView::Read.
|
||||
/// This function is added for convenience, but it does not change the state of ByteVector in a way ByteView::Read moves to next stored element after each Read.
|
||||
template<typename ...T, typename = std::void_t<decltype(std::declval<ByteView>().Read<T...>())>>
|
||||
auto Read() const
|
||||
{
|
||||
return ByteView{ *this }.Read<T...>();
|
||||
}
|
||||
|
||||
/// Calculate the size that the argument will take in memory
|
||||
/// @param arg. Argument to be stored.
|
||||
|
@ -215,20 +205,14 @@ namespace FSecure
|
|||
template<typename T, typename ...Ts>
|
||||
static size_t Size(T const& arg, Ts const& ...args)
|
||||
{
|
||||
if constexpr (!sizeof...(Ts))
|
||||
{
|
||||
// There is only one type to calculate size for. Find implementation of Size for that type.
|
||||
if constexpr (ByteSizeFunctionType<T>::value == ByteSizeFunctionType<T>::compileTime)
|
||||
return FSecure::ByteConverter<T>::Size();
|
||||
else if constexpr (ByteSizeFunctionType<T>::value == ByteSizeFunctionType<T>::runTime)
|
||||
return FSecure::ByteConverter<T>::Size(arg);
|
||||
else if constexpr (ByteSizeFunctionType<T>::value == ByteSizeFunctionType<T>::absent)
|
||||
return FSecure::ByteConverter<T>::To(arg).size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (sizeof...(Ts) != 0)
|
||||
return Size(arg) + Size(args...);
|
||||
}
|
||||
else if constexpr (ByteSizeFunctionType<T>::value == ByteSizeFunctionType<T>::compileTime)
|
||||
return FSecure::ByteConverter<T>::Size();
|
||||
else if constexpr (ByteSizeFunctionType<T>::value == ByteSizeFunctionType<T>::runTime)
|
||||
return FSecure::ByteConverter<T>::Size(arg);
|
||||
else if constexpr (ByteSizeFunctionType<T>::value == ByteSizeFunctionType<T>::absent)
|
||||
return FSecure::ByteConverter<T>::To(arg).size();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -237,17 +221,12 @@ namespace FSecure
|
|||
/// @param args. Rest of objects that will be handled with recursion.
|
||||
/// @return itself to allow chaining.
|
||||
template<typename T, typename ...Ts, typename std::enable_if_t<std::is_same_v<decltype(FSecure::ByteConverter<T>::To(std::declval<T>())), FSecure::ByteVector >, int> = 0>
|
||||
ByteVector & Store(T const& arg, Ts const& ...args)
|
||||
ByteVector& Store(T const& arg, Ts const& ...args)
|
||||
{
|
||||
if constexpr (!sizeof...(Ts))
|
||||
{
|
||||
Concat(FSecure::ByteConverter<T>::To(arg));
|
||||
}
|
||||
else
|
||||
{
|
||||
Store(arg);
|
||||
|
||||
Concat(FSecure::ByteConverter<T>::To(arg));
|
||||
if constexpr (sizeof...(Ts) != 0)
|
||||
Store(args...);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -264,13 +243,13 @@ namespace FSecure
|
|||
auto elementSize = static_cast<uint32_t>(obj.size());
|
||||
ret.resize(Size(obj));
|
||||
memcpy(ret.data(), &elementSize, sizeof(elementSize));
|
||||
memcpy(ret.data() + sizeof(elementSize), obj.data(), elementSize * sizeof(T::value_type));
|
||||
memcpy(ret.data() + sizeof(elementSize), obj.data(), elementSize * sizeof(typename T::value_type));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t Size(T const& obj)
|
||||
{
|
||||
return sizeof(uint32_t) + (obj.size() * sizeof(T::value_type));
|
||||
return sizeof(uint32_t) + (obj.size() * sizeof(typename T::value_type));
|
||||
}
|
||||
|
||||
// Reading functions are part of ByteView implementation. To deserialize data include ByteView.h
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "ByteVector.h"
|
||||
#include "ByteArray.h"
|
||||
|
||||
namespace FSecure
|
||||
{
|
||||
|
@ -163,21 +164,17 @@ namespace FSecure
|
|||
/// @code auto [a, b, c] = someByteView.Read<int, float, std::string>(); @endcode
|
||||
/// @note Returned types does not have to match exactly with Read template parameters list.
|
||||
/// It is possible to create tags that will be used to retrieve different type.
|
||||
template<typename T, typename ...Ts, typename = decltype(FSecure::ByteConverter<std::remove_const_t<T>>::From(std::declval<ByteView>()))>
|
||||
template<typename T, typename ...Ts, typename = decltype(FSecure::ByteConverter<Utils::RemoveCVR<T>>::From(std::declval<ByteView&>()))>
|
||||
auto Read()
|
||||
{
|
||||
if constexpr (!sizeof...(Ts))
|
||||
{
|
||||
return ByteConverter<std::remove_const_t<T>>::From(*this);
|
||||
}
|
||||
auto current = ByteConverter<Utils::RemoveCVR<T>>::From(*this);
|
||||
if constexpr (sizeof...(Ts) == 0)
|
||||
return current;
|
||||
else if constexpr (sizeof...(Ts) == 1)
|
||||
return std::make_tuple(std::move(current), Read<Ts...>());
|
||||
else
|
||||
{
|
||||
auto current = std::make_tuple(Read<T>());
|
||||
if constexpr (sizeof...(Ts) > 1)
|
||||
return std::tuple_cat(std::move(current), Read<Ts...>());
|
||||
else
|
||||
return std::tuple_cat(std::move(current), std::make_tuple(Read<Ts...>()));
|
||||
}
|
||||
return std::tuple_cat(std::make_tuple(std::move(current)), Read<Ts...>());
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -190,19 +187,14 @@ namespace FSecure
|
|||
throw std::out_of_range{ OBF(": Cannot read size from ByteView ") };
|
||||
|
||||
auto elementCount = *reinterpret_cast<const uint32_t*>(bv.data());
|
||||
auto byteCount = elementCount * sizeof(T::value_type);
|
||||
auto byteCount = elementCount * sizeof(typename T::value_type);
|
||||
bv.remove_prefix(sizeof(uint32_t));
|
||||
|
||||
T retVal;
|
||||
if constexpr (Utils::IsOneOf<T, ByteVector, std::string, std::wstring>::value)
|
||||
{
|
||||
retVal.resize(elementCount);
|
||||
std::memcpy(retVal.data(), bv.data(), byteCount);
|
||||
}
|
||||
retVal.resize(elementCount), std::memcpy(retVal.data(), bv.data(), byteCount);
|
||||
else
|
||||
{
|
||||
retVal = T{ reinterpret_cast<typename T::value_type const*>(bv.data()), elementCount };
|
||||
}
|
||||
|
||||
bv.remove_prefix(byteCount);
|
||||
return retVal;
|
||||
|
|
|
@ -8,30 +8,27 @@ namespace FSecure
|
|||
/// @warning Never use this class directly. Always use the SCOPE_GUARD macro.
|
||||
struct ScopeGuard
|
||||
{
|
||||
/// Class design.
|
||||
typedef ScopeGuard Type; ///< Can't use automatic LIGHT_CLASS_FILLER because of deleted constructors and operators.
|
||||
|
||||
/// Cleanup function signature.
|
||||
typedef std::function<void()> CleanupFunction_t;
|
||||
using CleanupFunction_t = std::function<void()>;
|
||||
|
||||
/// The only valid to call manual constructor.
|
||||
/// @param function cleanup function to call on scope leave.
|
||||
Type(const CleanupFunction_t& function) : m_CleanupFunction(function) { }
|
||||
ScopeGuard(const CleanupFunction_t& function) : m_CleanupFunction(function) { }
|
||||
|
||||
/// Deleted l-value constructor, to reject l-value references.
|
||||
Type(CleanupFunction_t&) = delete;
|
||||
ScopeGuard(CleanupFunction_t&) = delete;
|
||||
|
||||
/// R-value constructor, to accept r-value references.
|
||||
Type(CleanupFunction_t&& function) : m_CleanupFunction(function) { }
|
||||
ScopeGuard(CleanupFunction_t&& function) : m_CleanupFunction(function) { }
|
||||
|
||||
/// Destructor.
|
||||
~ScopeGuard() { m_CleanupFunction(); }
|
||||
|
||||
/// Operators.
|
||||
const Type& operator=(const Type&) = delete; ///< No copying between ScopeGuards is allowed.
|
||||
const ScopeGuard& operator=(const ScopeGuard&) = delete; ///< No copying between ScopeGuards is allowed.
|
||||
|
||||
/// Conversion operators.
|
||||
Type(const Type&) = delete; ///< Same as above - no copying between ScopeGuard objects.
|
||||
ScopeGuard(const ScopeGuard&) = delete; ///< Same as above - no copying between ScopeGuard objects.
|
||||
|
||||
/// Heap operators are rejected.
|
||||
void *operator new(size_t) = delete;
|
||||
|
@ -49,5 +46,5 @@ namespace FSecure
|
|||
|
||||
/// SCOPE_GUARD macro definition. You should always use this macro instead of direct manipulations on ScopeGuard structure and it's objects.<br>
|
||||
/// Usage: SCOPE_GUARD { expressions; that; will; be; processed; on; scope; leave; }
|
||||
# define SCOPE_GUARD FSecure::ScopeGuard SCOPE_GUARD_CAT(scope_guard_, __COUNTER__) = [&]
|
||||
# define SCOPE_GUARD(cleanupExpression) auto SCOPE_GUARD_CAT(scope_guard_, __COUNTER__) = FSecure::ScopeGuard{[&]{cleanupExpression}}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ namespace FSecure::Utils
|
|||
constexpr static bool value = [](bool ret) { return ret; }((std::is_same_v<T, Ts> || ...));
|
||||
};
|
||||
|
||||
/// Template to strip type out of const, volatile and reference.
|
||||
template <typename T>
|
||||
using RemoveCVR = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
|
||||
/// Changes value to default if it is out of provided range.
|
||||
/// @param value to be clamped.
|
||||
/// @param minValue lowest accepted value.
|
||||
|
@ -67,7 +71,7 @@ namespace FSecure::Utils
|
|||
T randomString;
|
||||
randomString.resize(size);
|
||||
for (auto& e : randomString)
|
||||
e = static_cast<T::value_type>(charset[uni(gen)]);
|
||||
e = static_cast<typename T::value_type>(charset[uni(gen)]);
|
||||
|
||||
return randomString;
|
||||
}
|
||||
|
|
|
@ -100,15 +100,15 @@ namespace FSecure::CppCommons::CppTools
|
|||
{
|
||||
/// Public ctor.
|
||||
/// @param value object value
|
||||
XErrorImpl(UnderlyingType value) : XErrorBase(value) { }
|
||||
XErrorImpl(UnderlyingType value) : XErrorBase<UnderlyingType>(value) { }
|
||||
|
||||
/// Success translator.
|
||||
/// @return true if current state of the object indicates success.
|
||||
bool IsSuccess() const { return m_Value.IsSuccess(); }
|
||||
bool IsSuccess() const { return this->m_Value.IsSuccess(); }
|
||||
|
||||
/// Failure translator.
|
||||
/// @return true if current state of the object indicates failure.
|
||||
bool IsFailure() const { return m_Value.IsFailure(); }
|
||||
bool IsFailure() const { return this->m_Value.IsFailure(); }
|
||||
};
|
||||
|
||||
/// XError specialization for HRESULT - let's provide IsSuccess and IsFailure. @note You shouldn't use XErrorImpl templates directly. They have internal purposes. Use XError template instead.
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace std
|
|||
/// Specialized SecureString destructor.
|
||||
/// Overwrites internal buffer (if SSO is in effect)
|
||||
template<>
|
||||
basic_string<char, std::char_traits<char>, FSecure::SecureAllocator<char>>::~basic_string()
|
||||
inline basic_string<char, std::char_traits<char>, FSecure::SecureAllocator<char>>::~basic_string() noexcept
|
||||
{
|
||||
// Clear internal buffer if SSO is in effect
|
||||
#if _MSC_VER >= 1920 // v142 toolset
|
||||
|
@ -105,7 +105,7 @@ namespace std
|
|||
/// Specialized SecureWString destructor.
|
||||
/// Overwrites internal buffer (if SSO is in effect)
|
||||
template<>
|
||||
basic_string<wchar_t, std::char_traits<wchar_t>, FSecure::SecureAllocator<wchar_t>>::~basic_string()
|
||||
inline basic_string<wchar_t, std::char_traits<wchar_t>, FSecure::SecureAllocator<wchar_t>>::~basic_string() noexcept
|
||||
{
|
||||
// Clear internal buffer if SSO is in effect
|
||||
#if _MSC_VER >= 1920 // v142 toolset
|
||||
|
|
|
@ -49,8 +49,6 @@ std::map<std::string, std::string> FSecure::Slack::ListChannels()
|
|||
|
||||
json response = SendHttpRequest(url, OBF("application/json"), NULL);
|
||||
|
||||
size_t size = response[OBF("channels")].size();
|
||||
|
||||
for (auto &channel : response[OBF("channels")])
|
||||
{
|
||||
std::string cName = channel[OBF("name")];
|
||||
|
@ -206,8 +204,6 @@ void FSecure::Slack::WriteReply(std::string const &text, std::string const &time
|
|||
return this->WriteReplyLarge(text, timestamp);
|
||||
}
|
||||
|
||||
int totalSent = 0;
|
||||
|
||||
json j;
|
||||
j[OBF("channel")] = this->m_Channel;
|
||||
j[OBF("text")] = text;
|
||||
|
@ -235,7 +231,6 @@ void FSecure::Slack::WriteReplyLarge(std::string const &data, std::string const
|
|||
std::string ret;
|
||||
int start = 0;
|
||||
int size = static_cast<int>(data.length());
|
||||
int end = size;
|
||||
|
||||
//Write 40k character messages at a time
|
||||
while (size > 40000)
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::CppCommons::CppTools::XError<FSecure::CppCommons::CppTools::SystemErrorCode> FSecure::CppCommons::WinTools::AbstractService::OnServiceInit(DWORD, LPTSTR*)
|
||||
{
|
||||
return NO_ERROR;
|
||||
return { NO_ERROR };
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::CppCommons::CppTools::XError<FSecure::CppCommons::CppTools::SystemErrorCode> FSecure::CppCommons::WinTools::AbstractService::OnServiceStop()
|
||||
{
|
||||
SetServiceStatus(SERVICE_STOP_PENDING, 100);
|
||||
|
||||
return NO_ERROR;
|
||||
|
||||
return { NO_ERROR };
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace FSecure
|
|||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
|
||||
return false;
|
||||
|
||||
SCOPE_GUARD{ CloseHandle(hToken); };
|
||||
SCOPE_GUARD( CloseHandle(hToken); );
|
||||
TOKEN_ELEVATION Elevation;
|
||||
DWORD cbSize = sizeof(TOKEN_ELEVATION);
|
||||
if (!GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof(Elevation), &cbSize))
|
||||
|
@ -69,7 +69,7 @@ namespace FSecure
|
|||
LPWSTR buf = nullptr;
|
||||
if (NETSETUP_JOIN_STATUS status; NERR_Success == ::NetGetJoinInformation(nullptr, &buf, &status))
|
||||
{
|
||||
SCOPE_GUARD{ ::NetApiBufferFree(buf); };
|
||||
SCOPE_GUARD( ::NetApiBufferFree(buf); );
|
||||
if(status == NetSetupDomainName)
|
||||
m_Domain = WidestringToString(buf);
|
||||
}
|
||||
|
|
|
@ -12,22 +12,23 @@ namespace
|
|||
pSA->nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
pSA->bInheritHandle = FALSE;
|
||||
|
||||
TCHAR* szSD = TEXT("D:") // Discretionary ACL
|
||||
TEXT("(D;OICI;GA;;;BG)") // Deny access to
|
||||
// built-in guests
|
||||
TEXT("(D;OICI;GA;;;AN)") // Deny access to
|
||||
// anonymous logon
|
||||
TEXT("(A;OICI;GRGW;;;AU)") // Allow
|
||||
// read/write
|
||||
// to authenticated
|
||||
// users
|
||||
TEXT("(A;OICI;GA;;;BA)"); // Allow full control
|
||||
// to administrators
|
||||
const wchar_t* szSD = OBF(
|
||||
L"D:" // Discretionary ACL
|
||||
"(D;OICI;GA;;;BG)" // Deny access to
|
||||
// built-in guests
|
||||
"(D;OICI;GA;;;AN)" // Deny access to
|
||||
// anonymous logon
|
||||
"(A;OICI;GRGW;;;AU)" // Allow
|
||||
// read/write
|
||||
// to authenticated
|
||||
// users
|
||||
"(A;OICI;GA;;;BA)"); // Allow full control
|
||||
// to administrators
|
||||
|
||||
if (NULL == pSA)
|
||||
return FALSE;
|
||||
|
||||
return ConvertStringSecurityDescriptorToSecurityDescriptor(
|
||||
return ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
||||
szSD,
|
||||
SDDL_REVISION_1,
|
||||
&(pSA->lpSecurityDescriptor),
|
||||
|
@ -72,7 +73,7 @@ size_t FSecure::WinTools::WritePipe::Write(ByteView data)
|
|||
throw std::runtime_error{ OBF("Write error, too much data.") };
|
||||
|
||||
ConnectNamedPipe(m_Pipe.get(), nullptr);
|
||||
SCOPE_GUARD{ DisconnectNamedPipe(m_Pipe.get()); };
|
||||
SCOPE_GUARD( DisconnectNamedPipe(m_Pipe.get()); );
|
||||
DWORD written;
|
||||
uint32_t len = static_cast<uint32_t>(data.size());
|
||||
WriteFile(m_Pipe.get(), &len, sizeof(len), nullptr, nullptr);
|
||||
|
@ -99,7 +100,7 @@ FSecure::ByteVector FSecure::WinTools::ReadPipe::Read()
|
|||
if (pipe == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
SCOPE_GUARD{ CloseHandle(pipe); };
|
||||
SCOPE_GUARD( CloseHandle(pipe); );
|
||||
|
||||
DWORD chunkSize;
|
||||
uint32_t pipeBufferSize = 512u;
|
||||
|
@ -204,7 +205,6 @@ FSecure::ByteVector FSecure::WinTools::AlternatingPipe::Read()
|
|||
|
||||
// Read four bytes and find the length of the next chunk of data.
|
||||
DWORD chunkLength = 0, bytesReadCurrent = 0;
|
||||
DWORD bytesAvailable = 0;
|
||||
if (!ReadFile(m_Pipe.get(), &chunkLength, 4, &bytesReadCurrent, nullptr))
|
||||
throw std::runtime_error{ OBF("Couldn't read from Pipe: ") + std::to_string(GetLastError()) + OBF(".") };
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ std::pair<FSecure::CppCommons::WinTools::Services::ReturnEnum, HRESULT> FSecure:
|
|||
|
||||
// Try to open the service
|
||||
if (SC_HANDLE service = ::OpenService(manager, serviceName.c_str(), SERVICE_QUERY_CONFIG))
|
||||
return std::make_pair(ReturnEnum::ClosingHandles, (::CloseServiceHandle(service) && ::CloseServiceHandle(manager) ? S_OK : XERROR_GETLASTERROR));
|
||||
return std::make_pair(ReturnEnum::ClosingHandles, (::CloseServiceHandle(service) && ::CloseServiceHandle(manager) ? S_OK : HRESULT_FROM_WIN32(GetLastError())));
|
||||
|
||||
// Failed to open the Service. Make sure to return the right error.
|
||||
auto retVal = XERROR_GETLASTERROR;
|
||||
|
@ -35,7 +35,7 @@ std::pair<FSecure::CppCommons::WinTools::Services::ReturnEnum, HRESULT> FSecure:
|
|||
// Create the service
|
||||
if (SC_HANDLE service = ::CreateServiceW(manager, serviceName.c_str(), serviceName.c_str(), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
|
||||
binaryPath.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr))
|
||||
return std::make_pair(ReturnEnum::ClosingHandles, (::CloseServiceHandle(service) && ::CloseServiceHandle(manager) ? S_OK : XERROR_GETLASTERROR));
|
||||
return std::make_pair(ReturnEnum::ClosingHandles, (::CloseServiceHandle(service) && ::CloseServiceHandle(manager) ? S_OK : HRESULT_FROM_WIN32(GetLastError())));
|
||||
|
||||
// Failed to open the Service. Make sure to return right error.
|
||||
auto retVal = XERROR_GETLASTERROR;
|
||||
|
@ -55,7 +55,7 @@ std::pair<FSecure::CppCommons::WinTools::Services::ReturnEnum, HRESULT> FSecure:
|
|||
if (SC_HANDLE service = ::OpenService(manager, serviceName.c_str(), STANDARD_RIGHTS_REQUIRED))
|
||||
{
|
||||
if (::DeleteService(service))
|
||||
return std::make_pair(ReturnEnum::ClosingHandles, (::CloseServiceHandle(service) && ::CloseServiceHandle(manager) ? S_OK : XERROR_GETLASTERROR));
|
||||
return std::make_pair(ReturnEnum::ClosingHandles, (::CloseServiceHandle(service) && ::CloseServiceHandle(manager) ? S_OK : HRESULT_FROM_WIN32(GetLastError())));
|
||||
|
||||
// Failed to open the Service. Make sure to return right error.
|
||||
auto retVal = XERROR_GETLASTERROR;
|
||||
|
@ -80,7 +80,7 @@ FSecure::CppCommons::CppTools::XError<HRESULT> FSecure::CppCommons::WinTools::Se
|
|||
// Copy Service object and start the Service.
|
||||
s_Service = &theOnlyService;
|
||||
SERVICE_TABLE_ENTRY table[] = { { const_cast<LPTSTR>(serviceName.c_str()), ServiceMain }, { nullptr, nullptr } };
|
||||
return ::StartServiceCtrlDispatcher(table) ? S_OK : XERROR_GETLASTERROR;
|
||||
return ::StartServiceCtrlDispatcher(table) ? S_OK : HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -196,5 +196,5 @@ FSecure::CppCommons::CppTools::XError<FSecure::CppCommons::CppTools::SystemError
|
|||
s_ServiceStatus.dwCheckPoint = (state == SERVICE_RUNNING || state == SERVICE_STOPPED ? 0 : checkPoint++);
|
||||
|
||||
// Report the status of the service to the SCM.
|
||||
return ::SetServiceStatus(s_ServiceStatusHandle, &s_ServiceStatus) ? NO_ERROR : GetLastError();
|
||||
return { ::SetServiceStatus(s_ServiceStatusHandle, &s_ServiceStatus) ? NO_ERROR : GetLastError() };
|
||||
}
|
||||
|
|
|
@ -48,10 +48,7 @@
|
|||
#include "sodium/crypto_verify_32.h"
|
||||
#include "sodium/crypto_verify_64.h"
|
||||
#include "sodium/randombytes.h"
|
||||
#ifdef __native_client__
|
||||
# include "sodium/randombytes_nativeclient.h"
|
||||
#endif
|
||||
#include "sodium/randombytes_salsa20_random.h"
|
||||
#include "sodium/randombytes_internal_random.h"
|
||||
#include "sodium/randombytes_sysrandom.h"
|
||||
#include "sodium/runtime.h"
|
||||
#include "sodium/utils.h"
|
||||
|
@ -59,7 +56,9 @@
|
|||
#ifndef SODIUM_LIBRARY_MINIMAL
|
||||
# include "sodium/crypto_box_curve25519xchacha20poly1305.h"
|
||||
# include "sodium/crypto_core_ed25519.h"
|
||||
# include "sodium/crypto_core_ristretto255.h"
|
||||
# include "sodium/crypto_scalarmult_ed25519.h"
|
||||
# include "sodium/crypto_scalarmult_ristretto255.h"
|
||||
# include "sodium/crypto_secretbox_xchacha20poly1305.h"
|
||||
# include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
|
||||
# include "sodium/crypto_stream_salsa2012.h"
|
||||
|
|
|
@ -52,11 +52,13 @@ size_t crypto_aead_aes256gcm_abytes(void);
|
|||
|
||||
#define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \
|
||||
(16ULL * ((1ULL << 32) - 2ULL)) - crypto_aead_aes256gcm_ABYTES)
|
||||
(16ULL * ((1ULL << 32) - 2ULL)))
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_aes256gcm_messagebytes_max(void);
|
||||
|
||||
typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512];
|
||||
typedef struct CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state_ {
|
||||
unsigned char opaque[512];
|
||||
} crypto_aead_aes256gcm_state;
|
||||
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_aes256gcm_statebytes(void);
|
||||
|
@ -70,7 +72,8 @@ int crypto_aead_aes256gcm_encrypt(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt(unsigned char *m,
|
||||
|
@ -82,7 +85,7 @@ int crypto_aead_aes256gcm_decrypt(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c,
|
||||
|
@ -94,7 +97,8 @@ int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m,
|
||||
|
@ -106,13 +110,14 @@ int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
/* -- Precomputation interface -- */
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_beforenm(crypto_aead_aes256gcm_state *ctx_,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c,
|
||||
|
@ -123,7 +128,8 @@ int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_);
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
|
||||
|
@ -135,7 +141,7 @@ int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c,
|
||||
|
@ -147,7 +153,8 @@ int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_);
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m,
|
||||
|
@ -159,10 +166,11 @@ int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const crypto_aead_aes256gcm_state *ctx_)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]);
|
||||
void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ size_t crypto_aead_chacha20poly1305_ietf_abytes(void);
|
|||
|
||||
#define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \
|
||||
(64ULL * (1ULL << 32) - 64ULL) - crypto_aead_chacha20poly1305_ietf_ABYTES)
|
||||
(64ULL * ((1ULL << 32) - 1ULL)))
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void);
|
||||
|
||||
|
@ -45,7 +45,8 @@ int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m,
|
||||
|
@ -57,7 +58,7 @@ int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
||||
|
@ -69,7 +70,8 @@ int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
||||
|
@ -81,10 +83,11 @@ int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]);
|
||||
void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* -- Original ChaCha20-Poly1305 construction with a 64-bit nonce and a 64-bit internal counter -- */
|
||||
|
||||
|
@ -118,7 +121,8 @@ int crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_decrypt(unsigned char *m,
|
||||
|
@ -130,7 +134,7 @@ int crypto_aead_chacha20poly1305_decrypt(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c,
|
||||
|
@ -142,7 +146,8 @@ int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m,
|
||||
|
@ -154,10 +159,11 @@ int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]);
|
||||
void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* Aliases */
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m,
|
||||
|
@ -53,7 +54,7 @@ int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
||||
|
@ -65,7 +66,8 @@ int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *nsec,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 9, 10)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
||||
|
@ -77,10 +79,11 @@ int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
|
|||
unsigned long long adlen,
|
||||
const unsigned char *npub,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]);
|
||||
void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* Aliases */
|
||||
|
||||
|
|
|
@ -27,15 +27,17 @@ const char *crypto_auth_primitive(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_verify(const unsigned char *h, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES]);
|
||||
void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ SODIUM_EXPORT
|
|||
int crypto_auth_hmacsha256(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -46,20 +46,22 @@ size_t crypto_auth_hmacsha256_statebytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state,
|
||||
const unsigned char *key,
|
||||
size_t keylen);
|
||||
size_t keylen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]);
|
||||
void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ SODIUM_EXPORT
|
|||
int crypto_auth_hmacsha512(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -46,19 +46,20 @@ size_t crypto_auth_hmacsha512_statebytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
|
||||
const unsigned char *key,
|
||||
size_t keylen);
|
||||
size_t keylen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES]);
|
||||
void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -21,15 +21,17 @@ SODIUM_EXPORT
|
|||
size_t crypto_auth_hmacsha512256_keybytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen,const unsigned char *k);
|
||||
int crypto_auth_hmacsha512256(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -41,19 +43,20 @@ size_t crypto_auth_hmacsha512256_statebytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
|
||||
const unsigned char *key,
|
||||
size_t keylen);
|
||||
size_t keylen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES]);
|
||||
void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -50,29 +50,31 @@ const char *crypto_box_primitive(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int crypto_box_keypair(unsigned char *pk, unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_easy(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_easy(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_detached(unsigned char *c, unsigned char *mac,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *n, const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
|
||||
|
@ -81,7 +83,7 @@ int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7)));
|
||||
|
||||
/* -- Precomputation interface -- */
|
||||
|
||||
|
@ -92,30 +94,31 @@ size_t crypto_box_beforenmbytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_easy_afternm(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_easy_afternm(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c,
|
||||
const unsigned char *mac,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
/* -- Ephemeral SK interface -- */
|
||||
|
||||
|
@ -125,13 +128,14 @@ size_t crypto_box_sealbytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_seal(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *pk);
|
||||
unsigned long long mlen, const unsigned char *pk)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_seal_open(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
|
@ -147,24 +151,24 @@ SODIUM_EXPORT
|
|||
int crypto_box(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_afternm(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -45,11 +45,13 @@ size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk,
|
||||
unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk,
|
||||
unsigned char *sk);
|
||||
unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
|
||||
|
@ -58,7 +60,7 @@ int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
|
||||
|
@ -67,7 +69,7 @@ int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
|
||||
|
@ -77,7 +79,7 @@ int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
|
||||
|
@ -87,7 +89,7 @@ int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7)));
|
||||
|
||||
/* -- Precomputation interface -- */
|
||||
|
||||
|
@ -95,14 +97,15 @@ SODIUM_EXPORT
|
|||
int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
|
||||
|
@ -110,7 +113,7 @@ int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
|
||||
|
@ -118,7 +121,8 @@ int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
|
|||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m,
|
||||
|
@ -127,7 +131,7 @@ int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
/* -- Ephemeral SK interface -- */
|
||||
|
||||
|
@ -142,7 +146,8 @@ SODIUM_EXPORT
|
|||
int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *pk);
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
|
||||
|
@ -150,7 +155,7 @@ int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -45,17 +45,19 @@ size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk,
|
||||
unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk,
|
||||
unsigned char *sk);
|
||||
unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
|
@ -76,7 +78,7 @@ int crypto_box_curve25519xsalsa20poly1305(unsigned char *c,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
|
||||
|
@ -85,14 +87,15 @@ int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
|
|||
const unsigned char *n,
|
||||
const unsigned char *pk,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
|
||||
|
@ -100,7 +103,7 @@ int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -16,19 +16,82 @@ size_t crypto_core_ed25519_bytes(void);
|
|||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_uniformbytes(void);
|
||||
|
||||
#define crypto_core_ed25519_HASHBYTES 64
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_is_valid_point(const unsigned char *p);
|
||||
size_t crypto_core_ed25519_hashbytes(void);
|
||||
|
||||
#define crypto_core_ed25519_SCALARBYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_scalarbytes(void);
|
||||
|
||||
#define crypto_core_ed25519_NONREDUCEDSCALARBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ed25519_nonreducedscalarbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_is_valid_point(const unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_add(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q);
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_sub(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q);
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r);
|
||||
int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_from_hash(unsigned char *p, const unsigned char *h)
|
||||
__attribute__ ((nonnull)) __attribute__ ((deprecated));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_random(unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_random(unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ed25519_scalar_invert(unsigned char *recip, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_negate(unsigned char *neg, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_complement(unsigned char *comp, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_add(unsigned char *z, const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_sub(unsigned char *z, const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_mul(unsigned char *z, const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* The interval `s` is sampled from should be at least 317 bits to ensure almost
|
||||
* uniformity of `r` over `L`.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ed25519_scalar_reduce(unsigned char *r, const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ size_t crypto_core_hchacha20_constbytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_hchacha20(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ size_t crypto_core_hsalsa20_constbytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
#ifndef crypto_core_ristretto255_H
|
||||
#define crypto_core_ristretto255_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_core_ristretto255_BYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_bytes(void);
|
||||
|
||||
#define crypto_core_ristretto255_HASHBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_hashbytes(void);
|
||||
|
||||
#define crypto_core_ristretto255_SCALARBYTES 32
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_scalarbytes(void);
|
||||
|
||||
#define crypto_core_ristretto255_NONREDUCEDSCALARBYTES 64
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_core_ristretto255_nonreducedscalarbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_is_valid_point(const unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_add(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_sub(unsigned char *r,
|
||||
const unsigned char *p, const unsigned char *q)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_from_hash(unsigned char *p,
|
||||
const unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_random(unsigned char *p)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_random(unsigned char *r)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_ristretto255_scalar_invert(unsigned char *recip,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_negate(unsigned char *neg,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_complement(unsigned char *comp,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_add(unsigned char *z,
|
||||
const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_sub(unsigned char *z,
|
||||
const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_mul(unsigned char *z,
|
||||
const unsigned char *x,
|
||||
const unsigned char *y)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* The interval `s` is sampled from should be at least 317 bits to ensure almost
|
||||
* uniformity of `r` over `L`.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
void crypto_core_ristretto255_scalar_reduce(unsigned char *r,
|
||||
const unsigned char *s)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -26,7 +26,8 @@ size_t crypto_core_salsa20_constbytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_salsa20(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ size_t crypto_core_salsa2012_constbytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_salsa2012(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ size_t crypto_core_salsa208_constbytes(void)
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_core_salsa208(unsigned char *out, const unsigned char *in,
|
||||
const unsigned char *k, const unsigned char *c);
|
||||
const unsigned char *k, const unsigned char *c)
|
||||
__attribute__ ((nonnull(1, 2, 3)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ size_t crypto_generichash_keybytes(void);
|
|||
SODIUM_EXPORT
|
||||
const char *crypto_generichash_primitive(void);
|
||||
|
||||
/*
|
||||
* Important when writing bindings for other programming languages:
|
||||
* the state address should be 64-bytes aligned.
|
||||
*/
|
||||
typedef crypto_generichash_blake2b_state crypto_generichash_state;
|
||||
|
||||
SODIUM_EXPORT
|
||||
|
@ -49,24 +53,29 @@ size_t crypto_generichash_statebytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_generichash(unsigned char *out, size_t outlen,
|
||||
const unsigned char *in, unsigned long long inlen,
|
||||
const unsigned char *key, size_t keylen);
|
||||
const unsigned char *key, size_t keylen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_init(crypto_generichash_state *state,
|
||||
const unsigned char *key,
|
||||
const size_t keylen, const size_t outlen);
|
||||
const size_t keylen, const size_t outlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_update(crypto_generichash_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_final(crypto_generichash_state *state,
|
||||
unsigned char *out, const size_t outlen);
|
||||
unsigned char *out, const size_t outlen)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]);
|
||||
void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -21,12 +21,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct CRYPTO_ALIGN(64) crypto_generichash_blake2b_state {
|
||||
uint64_t h[8];
|
||||
uint64_t t[2];
|
||||
uint64_t f[2];
|
||||
uint8_t buf[2 * 128];
|
||||
size_t buflen;
|
||||
uint8_t last_node;
|
||||
unsigned char opaque[384];
|
||||
} crypto_generichash_blake2b_state;
|
||||
|
||||
#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
|
@ -74,7 +69,8 @@ SODIUM_EXPORT
|
|||
int crypto_generichash_blake2b(unsigned char *out, size_t outlen,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *key, size_t keylen);
|
||||
const unsigned char *key, size_t keylen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen,
|
||||
|
@ -83,32 +79,37 @@ int crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen,
|
|||
const unsigned char *key,
|
||||
size_t keylen,
|
||||
const unsigned char *salt,
|
||||
const unsigned char *personal);
|
||||
const unsigned char *personal)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state,
|
||||
const unsigned char *key,
|
||||
const size_t keylen, const size_t outlen);
|
||||
const size_t keylen, const size_t outlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_init_salt_personal(crypto_generichash_blake2b_state *state,
|
||||
const unsigned char *key,
|
||||
const size_t keylen, const size_t outlen,
|
||||
const unsigned char *salt,
|
||||
const unsigned char *personal);
|
||||
const unsigned char *personal)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_update(crypto_generichash_blake2b_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state,
|
||||
unsigned char *out,
|
||||
const size_t outlen);
|
||||
const size_t outlen) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_generichash_blake2b_keygen(unsigned char k[crypto_generichash_blake2b_KEYBYTES]);
|
||||
void crypto_generichash_blake2b_keygen(unsigned char k[crypto_generichash_blake2b_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ size_t crypto_hash_bytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
#define crypto_hash_PRIMITIVE "sha512"
|
||||
SODIUM_EXPORT
|
||||
|
|
|
@ -36,19 +36,22 @@ size_t crypto_hash_sha256_bytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256_init(crypto_hash_sha256_state *state);
|
||||
int crypto_hash_sha256_init(crypto_hash_sha256_state *state)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256_update(crypto_hash_sha256_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha256_final(crypto_hash_sha256_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -36,19 +36,22 @@ size_t crypto_hash_sha512_bytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512_init(crypto_hash_sha512_state *state);
|
||||
int crypto_hash_sha512_init(crypto_hash_sha512_state *state)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512_update(crypto_hash_sha512_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_hash_sha512_final(crypto_hash_sha512_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -39,10 +39,12 @@ SODIUM_EXPORT
|
|||
int crypto_kdf_derive_from_key(unsigned char *subkey, size_t subkey_len,
|
||||
uint64_t subkey_id,
|
||||
const char ctx[crypto_kdf_CONTEXTBYTES],
|
||||
const unsigned char key[crypto_kdf_KEYBYTES]);
|
||||
const unsigned char key[crypto_kdf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES]);
|
||||
void crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@ SODIUM_EXPORT
|
|||
int crypto_kdf_blake2b_derive_from_key(unsigned char *subkey, size_t subkey_len,
|
||||
uint64_t subkey_id,
|
||||
const char ctx[crypto_kdf_blake2b_CONTEXTBYTES],
|
||||
const unsigned char key[crypto_kdf_blake2b_KEYBYTES]);
|
||||
const unsigned char key[crypto_kdf_blake2b_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -35,11 +35,13 @@ const char *crypto_kx_primitive(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_kx_seed_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
|
||||
unsigned char sk[crypto_kx_SECRETKEYBYTES],
|
||||
const unsigned char seed[crypto_kx_SEEDBYTES]);
|
||||
const unsigned char seed[crypto_kx_SEEDBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
|
||||
unsigned char sk[crypto_kx_SECRETKEYBYTES]);
|
||||
unsigned char sk[crypto_kx_SECRETKEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
||||
|
@ -47,7 +49,7 @@ int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
|||
const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES],
|
||||
const unsigned char client_sk[crypto_kx_SECRETKEYBYTES],
|
||||
const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES])
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
||||
|
@ -55,7 +57,7 @@ int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
|
|||
const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES],
|
||||
const unsigned char server_sk[crypto_kx_SECRETKEYBYTES],
|
||||
const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES])
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -32,28 +32,31 @@ const char *crypto_onetimeauth_primitive(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_init(crypto_onetimeauth_state *state,
|
||||
const unsigned char *key);
|
||||
const unsigned char *key) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_update(crypto_onetimeauth_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_final(crypto_onetimeauth_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES]);
|
||||
void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -35,30 +35,35 @@ SODIUM_EXPORT
|
|||
int crypto_onetimeauth_poly1305(unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_verify(const unsigned char *h,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state,
|
||||
const unsigned char *key);
|
||||
const unsigned char *key)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state,
|
||||
const unsigned char *in,
|
||||
unsigned long long inlen);
|
||||
unsigned long long inlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state,
|
||||
unsigned char *out);
|
||||
unsigned char *out)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_onetimeauth_poly1305_keygen(unsigned char k[crypto_onetimeauth_poly1305_KEYBYTES]);
|
||||
void crypto_onetimeauth_poly1305_keygen(unsigned char k[crypto_onetimeauth_poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ int crypto_pwhash(unsigned char * const out, unsigned long long outlen,
|
|||
const char * const passwd, unsigned long long passwdlen,
|
||||
const unsigned char * const salt,
|
||||
unsigned long long opslimit, size_t memlimit, int alg)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* The output string already includes all the required parameters, including
|
||||
|
@ -116,24 +116,24 @@ SODIUM_EXPORT
|
|||
int crypto_pwhash_str(char out[crypto_pwhash_STRBYTES],
|
||||
const char * const passwd, unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES],
|
||||
const char * const passwd, unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit, int alg)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES],
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#define crypto_pwhash_PRIMITIVE "argon2i"
|
||||
SODIUM_EXPORT
|
||||
|
|
|
@ -95,25 +95,25 @@ int crypto_pwhash_argon2i(unsigned char * const out,
|
|||
const unsigned char * const salt,
|
||||
unsigned long long opslimit, size_t memlimit,
|
||||
int alg)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2i_str(char out[crypto_pwhash_argon2i_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2i_str_verify(const char str[crypto_pwhash_argon2i_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2i_str_needs_rehash(const char str[crypto_pwhash_argon2i_STRBYTES],
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -95,25 +95,25 @@ int crypto_pwhash_argon2id(unsigned char * const out,
|
|||
const unsigned char * const salt,
|
||||
unsigned long long opslimit, size_t memlimit,
|
||||
int alg)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen,
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_argon2id_str_needs_rehash(const char str[crypto_pwhash_argon2id_STRBYTES],
|
||||
unsigned long long opslimit, size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ int crypto_pwhash_scryptsalsa208sha256(unsigned char * const out,
|
|||
const unsigned char * const salt,
|
||||
unsigned long long opslimit,
|
||||
size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
||||
|
@ -92,26 +92,26 @@ int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208
|
|||
unsigned long long passwdlen,
|
||||
unsigned long long opslimit,
|
||||
size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
||||
const char * const passwd,
|
||||
unsigned long long passwdlen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen,
|
||||
const uint8_t * salt, size_t saltlen,
|
||||
uint64_t N, uint32_t r, uint32_t p,
|
||||
uint8_t * buf, size_t buflen)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
||||
unsigned long long opslimit,
|
||||
size_t memlimit)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,10 +23,11 @@ SODIUM_EXPORT
|
|||
const char *crypto_scalarmult_primitive(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n);
|
||||
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly.
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
|
@ -36,7 +37,7 @@ int crypto_scalarmult_base(unsigned char *q, const unsigned char *n);
|
|||
SODIUM_EXPORT
|
||||
int crypto_scalarmult(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ SODIUM_EXPORT
|
|||
size_t crypto_scalarmult_curve25519_scalarbytes(void);
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly.
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
|
@ -28,10 +28,12 @@ size_t crypto_scalarmult_curve25519_scalarbytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_curve25519(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_curve25519_base(unsigned char *q, const unsigned char *n);
|
||||
int crypto_scalarmult_curve25519_base(unsigned char *q,
|
||||
const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ SODIUM_EXPORT
|
|||
size_t crypto_scalarmult_ed25519_scalarbytes(void);
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly.
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
|
@ -29,10 +29,20 @@ size_t crypto_scalarmult_ed25519_scalarbytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519_base(unsigned char *q, const unsigned char *n);
|
||||
int crypto_scalarmult_ed25519_noclamp(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519_base(unsigned char *q, const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ed25519_base_noclamp(unsigned char *q, const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
#ifndef crypto_scalarmult_ristretto255_H
|
||||
#define crypto_scalarmult_ristretto255_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define crypto_scalarmult_ristretto255_BYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_ristretto255_bytes(void);
|
||||
|
||||
#define crypto_scalarmult_ristretto255_SCALARBYTES 32U
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_scalarmult_ristretto255_scalarbytes(void);
|
||||
|
||||
/*
|
||||
* NOTE: Do not use the result of this function directly for key exchange.
|
||||
*
|
||||
* Hash the result with the public keys in order to compute a shared
|
||||
* secret key: H(q || client_pk || server_pk)
|
||||
*
|
||||
* Or unless this is not an option, use the crypto_kx() API instead.
|
||||
*/
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ristretto255(unsigned char *q, const unsigned char *n,
|
||||
const unsigned char *p)
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_scalarmult_ristretto255_base(unsigned char *q,
|
||||
const unsigned char *n)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -36,20 +36,21 @@ size_t crypto_secretbox_messagebytes_max(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_open_detached(unsigned char *m,
|
||||
|
@ -58,10 +59,11 @@ int crypto_secretbox_open_detached(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES]);
|
||||
void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
|
@ -76,13 +78,13 @@ size_t crypto_secretbox_boxzerobytes(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_secretbox(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_open(unsigned char *m, const unsigned char *c,
|
||||
unsigned long long clen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c,
|
|||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
|
||||
|
@ -42,7 +43,7 @@ int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
|
||||
|
@ -50,7 +51,8 @@ int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
|
|||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 2, 5, 6)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
|
||||
|
@ -59,7 +61,7 @@ int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ int crypto_secretbox_xsalsa20poly1305(unsigned char *c,
|
|||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
|
||||
|
@ -43,10 +44,11 @@ int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
|
|||
unsigned long long clen,
|
||||
const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES]);
|
||||
void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* -- NaCl compatibility interface ; Requires padding -- */
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ SODIUM_EXPORT
|
|||
size_t crypto_secretstream_xchacha20poly1305_keybytes(void);
|
||||
|
||||
#define crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX \
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX, ((1ULL << 32) - 2ULL) * 64ULL)
|
||||
SODIUM_MIN(SODIUM_SIZE_MAX - crypto_secretstream_xchacha20poly1305_ABYTES, \
|
||||
(64ULL * ((1ULL << 32) - 2ULL)))
|
||||
SODIUM_EXPORT
|
||||
size_t crypto_secretstream_xchacha20poly1305_messagebytes_max(void);
|
||||
|
||||
|
@ -63,33 +64,38 @@ size_t crypto_secretstream_xchacha20poly1305_statebytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretstream_xchacha20poly1305_keygen
|
||||
(unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
|
||||
(unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_init_push
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
|
||||
const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
|
||||
const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_push
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
unsigned char *c, unsigned long long *clen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *ad, unsigned long long adlen, unsigned char tag);
|
||||
const unsigned char *ad, unsigned long long adlen, unsigned char tag)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_init_pull
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
const unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
|
||||
const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
|
||||
const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_secretstream_xchacha20poly1305_pull
|
||||
(crypto_secretstream_xchacha20poly1305_state *state,
|
||||
unsigned char *m, unsigned long long *mlen_p, unsigned char *tag_p,
|
||||
const unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *ad, unsigned long long adlen);
|
||||
const unsigned char *ad, unsigned long long adlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_secretstream_xchacha20poly1305_rekey
|
||||
|
|
|
@ -27,10 +27,12 @@ const char *crypto_shorthash_primitive(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES]);
|
||||
void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ size_t crypto_shorthash_siphash24_keybytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
|
||||
#ifndef SODIUM_LIBRARY_MINIMAL
|
||||
/* -- 128-bit output -- */
|
||||
|
@ -38,7 +39,8 @@ size_t crypto_shorthash_siphashx24_keybytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in,
|
||||
unsigned long long inlen, const unsigned char *k);
|
||||
unsigned long long inlen, const unsigned char *k)
|
||||
__attribute__ ((nonnull(1, 4)));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -51,50 +51,54 @@ const char *crypto_sign_primitive(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign(unsigned char *sm, unsigned long long *smlen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p,
|
||||
const unsigned char *sm, unsigned long long smlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_verify_detached(const unsigned char *sig,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_init(crypto_sign_state *state);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_update(crypto_sign_state *state,
|
||||
const unsigned char *m, unsigned long long mlen);
|
||||
const unsigned char *m, unsigned long long mlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig,
|
||||
unsigned long long *siglen_p,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 2, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_final_verify(crypto_sign_state *state, unsigned char *sig,
|
||||
int crypto_sign_final_verify(crypto_sign_state *state, const unsigned char *sig,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -42,70 +42,80 @@ size_t crypto_sign_ed25519_messagebytes_max(void);
|
|||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p,
|
||||
const unsigned char *sm, unsigned long long smlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_detached(unsigned char *sig,
|
||||
unsigned long long *siglen_p,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_verify_detached(const unsigned char *sig,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
const unsigned char *seed)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk,
|
||||
const unsigned char *ed25519_pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk,
|
||||
const unsigned char *ed25519_sk);
|
||||
const unsigned char *ed25519_sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_sk_to_seed(unsigned char *seed,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk);
|
||||
int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state);
|
||||
int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_update(crypto_sign_ed25519ph_state *state,
|
||||
const unsigned char *m,
|
||||
unsigned long long mlen);
|
||||
unsigned long long mlen)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_final_create(crypto_sign_ed25519ph_state *state,
|
||||
unsigned char *sig,
|
||||
unsigned long long *siglen_p,
|
||||
const unsigned char *sk);
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((nonnull(1, 2, 4)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_ed25519ph_final_verify(crypto_sign_ed25519ph_state *state,
|
||||
unsigned char *sig,
|
||||
const unsigned char *sig,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ int crypto_sign_edwards25519sha512batch(unsigned char *sm,
|
|||
const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *sk)
|
||||
__attribute__ ((deprecated));
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull(1, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_edwards25519sha512batch_open(unsigned char *m,
|
||||
|
@ -41,12 +41,12 @@ int crypto_sign_edwards25519sha512batch_open(unsigned char *m,
|
|||
const unsigned char *sm,
|
||||
unsigned long long smlen,
|
||||
const unsigned char *pk)
|
||||
__attribute__ ((deprecated));
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull(3, 5)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_sign_edwards25519sha512batch_keypair(unsigned char *pk,
|
||||
unsigned char *sk)
|
||||
__attribute__ ((deprecated));
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -39,15 +39,18 @@ const char *crypto_stream_primitive(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_keygen(unsigned char k[crypto_stream_KEYBYTES]);
|
||||
void crypto_stream_keygen(unsigned char k[crypto_stream_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -36,21 +36,25 @@ size_t crypto_stream_chacha20_messagebytes_max(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_chacha20(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_chacha20_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_chacha20_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint64_t ic,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_chacha20_keygen(unsigned char k[crypto_stream_chacha20_KEYBYTES]);
|
||||
void crypto_stream_chacha20_keygen(unsigned char k[crypto_stream_chacha20_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* ChaCha20 with a 96-bit nonce and a 32-bit counter (IETF) */
|
||||
|
||||
|
@ -69,21 +73,25 @@ size_t crypto_stream_chacha20_ietf_messagebytes_max(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_chacha20_ietf_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_chacha20_ietf_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint32_t ic,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_chacha20_ietf_keygen(unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES]);
|
||||
void crypto_stream_chacha20_ietf_keygen(unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* Aliases */
|
||||
|
||||
|
|
|
@ -34,21 +34,25 @@ size_t crypto_stream_salsa20_messagebytes_max(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa20(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint64_t ic,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES]);
|
||||
void crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -33,15 +33,18 @@ size_t crypto_stream_salsa2012_messagebytes_max(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa2012(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa2012_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_salsa2012_keygen(unsigned char k[crypto_stream_salsa2012_KEYBYTES]);
|
||||
void crypto_stream_salsa2012_keygen(unsigned char k[crypto_stream_salsa2012_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -37,17 +37,17 @@ size_t crypto_stream_salsa208_messagebytes_max(void)
|
|||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa208(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((deprecated));
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_salsa208_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k)
|
||||
__attribute__ ((deprecated));
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_salsa208_keygen(unsigned char k[crypto_stream_salsa208_KEYBYTES])
|
||||
__attribute__ ((deprecated));
|
||||
__attribute__ ((deprecated)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,21 +34,25 @@ size_t crypto_stream_xchacha20_messagebytes_max(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xchacha20_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xchacha20_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint64_t ic,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_xchacha20_keygen(unsigned char k[crypto_stream_xchacha20_KEYBYTES]);
|
||||
void crypto_stream_xchacha20_keygen(unsigned char k[crypto_stream_xchacha20_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,21 +34,25 @@ size_t crypto_stream_xsalsa20_messagebytes_max(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xsalsa20(unsigned char *c, unsigned long long clen,
|
||||
const unsigned char *n, const unsigned char *k);
|
||||
const unsigned char *n, const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xsalsa20_xor(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen, const unsigned char *n,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int crypto_stream_xsalsa20_xor_ic(unsigned char *c, const unsigned char *m,
|
||||
unsigned long long mlen,
|
||||
const unsigned char *n, uint64_t ic,
|
||||
const unsigned char *k);
|
||||
const unsigned char *k)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void crypto_stream_xsalsa20_keygen(unsigned char k[crypto_stream_xsalsa20_KEYBYTES]);
|
||||
void crypto_stream_xsalsa20_keygen(unsigned char k[crypto_stream_xsalsa20_KEYBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ size_t crypto_verify_16_bytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_verify_16(const unsigned char *x, const unsigned char *y)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ size_t crypto_verify_32_bytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_verify_32(const unsigned char *x, const unsigned char *y)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ size_t crypto_verify_64_bytes(void);
|
|||
|
||||
SODIUM_EXPORT
|
||||
int crypto_verify_64(const unsigned char *x, const unsigned char *y)
|
||||
__attribute__ ((warn_unused_result));
|
||||
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
#ifndef sodium_export_H
|
||||
#define sodium_export_H
|
||||
|
||||
#ifndef __GNUC__
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if !defined(__clang__) && !defined(__GNUC__)
|
||||
# ifdef __attribute__
|
||||
# undef __attribute__
|
||||
# endif
|
||||
|
|
|
@ -32,11 +32,13 @@ SODIUM_EXPORT
|
|||
size_t randombytes_seedbytes(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
void randombytes_buf(void * const buf, const size_t size);
|
||||
void randombytes_buf(void * const buf, const size_t size)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
void randombytes_buf_deterministic(void * const buf, const size_t size,
|
||||
const unsigned char seed[randombytes_SEEDBYTES]);
|
||||
const unsigned char seed[randombytes_SEEDBYTES])
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
uint32_t randombytes_random(void);
|
||||
|
@ -51,7 +53,8 @@ SODIUM_EXPORT
|
|||
int randombytes_close(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int randombytes_set_implementation(randombytes_implementation *impl);
|
||||
int randombytes_set_implementation(randombytes_implementation *impl)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
const char *randombytes_implementation_name(void);
|
||||
|
@ -59,7 +62,8 @@ const char *randombytes_implementation_name(void);
|
|||
/* -- NaCl compatibility interface -- */
|
||||
|
||||
SODIUM_EXPORT
|
||||
void randombytes(unsigned char * const buf, const unsigned long long buf_len);
|
||||
void randombytes(unsigned char * const buf, const unsigned long long buf_len)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#ifndef randombytes_internal_random_H
|
||||
#define randombytes_internal_random_H
|
||||
|
||||
#include "export.h"
|
||||
#include "randombytes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SODIUM_EXPORT
|
||||
extern struct randombytes_implementation randombytes_internal_implementation;
|
||||
|
||||
/* Backwards compatibility with libsodium < 1.0.18 */
|
||||
#define randombytes_salsa20_implementation randombytes_internal_implementation
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -42,8 +42,7 @@ int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
|
|||
*/
|
||||
SODIUM_EXPORT
|
||||
int sodium_compare(const unsigned char *b1_, const unsigned char *b2_,
|
||||
size_t len)
|
||||
__attribute__ ((warn_unused_result));
|
||||
size_t len) __attribute__ ((warn_unused_result));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_is_zero(const unsigned char *n, const size_t nlen);
|
||||
|
@ -54,15 +53,20 @@ void sodium_increment(unsigned char *n, const size_t nlen);
|
|||
SODIUM_EXPORT
|
||||
void sodium_add(unsigned char *a, const unsigned char *b, const size_t len);
|
||||
|
||||
SODIUM_EXPORT
|
||||
void sodium_sub(unsigned char *a, const unsigned char *b, const size_t len);
|
||||
|
||||
SODIUM_EXPORT
|
||||
char *sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
||||
const unsigned char * const bin, const size_t bin_len);
|
||||
const unsigned char * const bin, const size_t bin_len)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen,
|
||||
const char * const hex, const size_t hex_len,
|
||||
const char * const ignore, size_t * const bin_len,
|
||||
const char ** const hex_end);
|
||||
const char ** const hex_end)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
#define sodium_base64_VARIANT_ORIGINAL 1
|
||||
#define sodium_base64_VARIANT_ORIGINAL_NO_PADDING 3
|
||||
|
@ -84,19 +88,22 @@ size_t sodium_base64_encoded_len(const size_t bin_len, const int variant);
|
|||
SODIUM_EXPORT
|
||||
char *sodium_bin2base64(char * const b64, const size_t b64_maxlen,
|
||||
const unsigned char * const bin, const size_t bin_len,
|
||||
const int variant);
|
||||
const int variant) __attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_base642bin(unsigned char * const bin, const size_t bin_maxlen,
|
||||
const char * const b64, const size_t b64_len,
|
||||
const char * const ignore, size_t * const bin_len,
|
||||
const char ** const b64_end, const int variant);
|
||||
const char ** const b64_end, const int variant)
|
||||
__attribute__ ((nonnull(1)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_mlock(void * const addr, const size_t len);
|
||||
int sodium_mlock(void * const addr, const size_t len)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_munlock(void * const addr, const size_t len);
|
||||
int sodium_munlock(void * const addr, const size_t len)
|
||||
__attribute__ ((nonnull));
|
||||
|
||||
/* WARNING: sodium_malloc() and sodium_allocarray() are not general-purpose
|
||||
* allocation functions.
|
||||
|
@ -143,21 +150,23 @@ SODIUM_EXPORT
|
|||
void sodium_free(void *ptr);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_mprotect_noaccess(void *ptr);
|
||||
int sodium_mprotect_noaccess(void *ptr) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_mprotect_readonly(void *ptr);
|
||||
int sodium_mprotect_readonly(void *ptr) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_mprotect_readwrite(void *ptr);
|
||||
int sodium_mprotect_readwrite(void *ptr) __attribute__ ((nonnull));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_pad(size_t *padded_buflen_p, unsigned char *buf,
|
||||
size_t unpadded_buflen, size_t blocksize, size_t max_buflen);
|
||||
size_t unpadded_buflen, size_t blocksize, size_t max_buflen)
|
||||
__attribute__ ((nonnull(2)));
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_unpad(size_t *unpadded_buflen_p, const unsigned char *buf,
|
||||
size_t padded_buflen, size_t blocksize);
|
||||
size_t padded_buflen, size_t blocksize)
|
||||
__attribute__ ((nonnull(2)));
|
||||
|
||||
/* -------- */
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
|
||||
#include "export.h"
|
||||
|
||||
#define SODIUM_VERSION_STRING "1.0.16"
|
||||
#define SODIUM_VERSION_STRING "1.0.18"
|
||||
|
||||
#define SODIUM_LIBRARY_VERSION_MAJOR 10
|
||||
#define SODIUM_LIBRARY_VERSION_MINOR 1
|
||||
|
||||
#define SODIUM_LIBRARY_VERSION_MINOR 3
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -25,7 +25,7 @@ namespace
|
|||
{
|
||||
try
|
||||
{
|
||||
return cppcodec::base64_rfc4648::decode(keys[entryName].get<std::string>());
|
||||
return cppcodec::base64_rfc4648::decode<FSecure::ByteVector>(keys[entryName].template get<std::string>());
|
||||
}
|
||||
catch (std::exception& exception)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ std::shared_ptr<FSecure::C3::Relay> FSecure::C3::Utils::CreateGatewayFromConfigu
|
|||
|
||||
// Create and run the Gateway.
|
||||
if (!wereKeysReadOrGenerated)
|
||||
callbackOnLog({ OBF("Generated new keys/signatures and stored them on disk."), LogMessage::Severity::Information }, nullptr);
|
||||
callbackOnLog({ OBF("Generated new keys/signatures and stored them on disk."), LogMessage::Severity::Information }, "");
|
||||
|
||||
callbackOnLog({ OBF("Starting Gateway..."), LogMessage::Severity::Information }, nullptr);
|
||||
return FSecure::C3::Core::GateRelay::CreateAndRun(callbackOnLog, interfaceFactory, apiBridgeIp, apiBrigdePort, signatures, broadcastKey, buildId, snapshotPath, agentId, name);
|
||||
|
@ -118,10 +118,10 @@ std::shared_ptr<FSecure::C3::Relay> FSecure::C3::Utils::CreateNodeRelayFromImage
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::string FSecure::C3::Utils::ConvertLogMessageToConsoleText(std::string_view relayName, LogMessage const& message, std::string_view* sender)
|
||||
std::string FSecure::C3::Utils::ConvertLogMessageToConsoleText(std::string_view relayName, LogMessage const& message, std::string_view sender)
|
||||
{
|
||||
// Format message as: "[relay]|@> [InterfaceID] message", where @ is different for each severity.
|
||||
std::string retVal = sender ? (std::string(relayName) + '|').c_str() : "";
|
||||
std::string retVal = sender.empty() ? (std::string(relayName) + '|') : ""s;
|
||||
|
||||
switch (message.m_Severity)
|
||||
{
|
||||
|
@ -132,6 +132,6 @@ std::string FSecure::C3::Utils::ConvertLogMessageToConsoleText(std::string_view
|
|||
default: retVal += OBF("???> ");
|
||||
}
|
||||
|
||||
retVal += sender && !sender->empty() ? '[' + std::string(*sender) + OBF("] ") : "";
|
||||
retVal += !sender.empty() ? '[' + std::string(sender) + "] " : "";
|
||||
return retVal += message.m_Body;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::C3::Core::BaseQuery::BaseQuery(std::weak_ptr<DeviceBridge> sender)
|
||||
: m_ReceivedOrWillBeSent(true)
|
||||
, m_SenderChannel(sender)
|
||||
, m_SequenceNumber(0) /// THIS IS WRONG
|
||||
, m_SenderChannel(sender)
|
||||
{
|
||||
// TODO, parse query.
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ FSecure::C3::Core::BaseQuery::BaseQuery(std::weak_ptr<DeviceBridge> sender)
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::C3::Core::BaseQuery::BaseQuery(ResponseType responseType)
|
||||
: m_ReceivedOrWillBeSent(false)
|
||||
, m_ResponseType(responseType)
|
||||
, m_SequenceNumber(GenerateSequenceNumber())
|
||||
, m_ResponseType(responseType)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace FSecure::C3::Core
|
|||
// Typedefs and constants.
|
||||
using ProceduresUnderlyingType = std::int8_t; ///< Underlying type for Procedure number field.
|
||||
using SequenceNumberFieldUnderlyingType = std::uint32_t; /// Underlying type for Query/Response sequence numbers (including type bits = 2 bits).
|
||||
static constexpr unsigned s_SequenceNumberBitLength = sizeof SequenceNumberFieldUnderlyingType * 8 - 2; ///< Number of bits sequence number occupy in the SequenceNumberType type.
|
||||
|
||||
/// Abstract class for all Queries.
|
||||
struct BaseQuery
|
||||
|
@ -83,7 +82,7 @@ namespace FSecure::C3::Core
|
|||
using SequenceNumberFieldUnderlyingType = std::uint32_t;
|
||||
|
||||
/// Number of bits sequence number occupy in the SequenceNumberType type.
|
||||
static constexpr unsigned s_SequenceNumberBitLength = sizeof SequenceNumberFieldUnderlyingType * 8 - 2;
|
||||
static constexpr unsigned s_SequenceNumberBitLength = sizeof(SequenceNumberFieldUnderlyingType) * 8 - 2;
|
||||
|
||||
/// Sequence number
|
||||
const SequenceNumberFieldUnderlyingType m_SequenceNumber;
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::C3::Core::ConnectorBridge::ConnectorBridge(std::shared_ptr<GateRelay>&& gateway, std::shared_ptr<AbstractConnector>&& connector, std::string name, HashT nameHash)
|
||||
: m_GateRelay{ gateway }
|
||||
, m_Connector{ std::move(connector) }
|
||||
, m_Name{ name }
|
||||
: m_Name{ name }
|
||||
, m_NameHash{ nameHash }
|
||||
, m_GateRelay{ gateway }
|
||||
, m_Connector{ std::move(connector) }
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ namespace FSecure::C3::Core
|
|||
/// @param nameHash hash of connector.
|
||||
ConnectorBridge(std::shared_ptr<GateRelay>&& gateway, std::shared_ptr<AbstractConnector>&& connector, std::string name, HashT nameHash);
|
||||
|
||||
/// Destructor
|
||||
virtual ~ConnectorBridge() = default;
|
||||
|
||||
/// Called by GateRelay just after the Connector creation.
|
||||
void OnAttach() override;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
FSecure::C3::Core::DeviceBridge::DeviceBridge(std::shared_ptr<Relay>&& relay, DeviceId did, HashT typeNameHash, std::shared_ptr<Device>&& device, bool isNegotiationChannel, bool isSlave, ByteVector args /*= ByteVector()*/)
|
||||
: m_Relay{ relay }
|
||||
, m_Device{ std::move(device) }
|
||||
: m_IsNegotiationChannel(isNegotiationChannel)
|
||||
, m_IsSlave(isSlave)
|
||||
, m_Did{ did }
|
||||
, m_TypeNameHash(typeNameHash)
|
||||
, m_IsNegotiationChannel(isNegotiationChannel)
|
||||
, m_IsSlave(isSlave)
|
||||
, m_Relay{ relay }
|
||||
, m_Device{ std::move(device) }
|
||||
{
|
||||
if (!isNegotiationChannel)
|
||||
return;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue