Commit 362efe61 authored by jan.koester's avatar jan.koester
Browse files

test

parent 908bbcd8
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,17 @@
            "command": "test",
            "problemMatcher": [],
            "detail": "CMake template test task"
        },
        {
            "type": "cmake",
            "label": "CMake: clean rebuild",
            "command": "cleanRebuild",
            "targets": [
                "all"
            ],
            "group": "build",
            "problemMatcher": [],
            "detail": "CMake template clean rebuild task"
        }
    ],
    "version": "2.0.0"
+3 −8
Original line number Diff line number Diff line
project(libnetplus C CXX ASM )
project(libnetplus CXX C ASM )
cmake_minimum_required(VERSION 3.26)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH} )

@@ -6,8 +6,6 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

set(CMAKE_CXX_STANDARD 17)

#find_package(MbedTLS REQUIRED)

if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
    set (VISIBILTY_HIDDEN "__attribute__ ((visibility (\"hidden\")))")

@@ -16,9 +14,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
        -fPIC \
        -Wall \
        -O1 \
        -g \
        -fsanitize=undefined,address \
        "
        -g "
    )

    set(CMAKE_C_FLAGS 
@@ -26,8 +22,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
        -fPIC \
        -Wall \
        -O1 \
        -g \
        -fsanitize=undefined,address "
        -g "
    )
endif()

+339 −1369

File changed.

Preview size limit exceeded, changes collapsed.

+33 −7
Original line number Diff line number Diff line
#include <vector>
#include <cstdint>
#include <algorithm>

#pragma once
#include <stdint.h>



namespace netplus {

bool scalarmult_curve25519(uint8_t out[32],
                           const uint8_t scalar[32],
                           const uint8_t point_u[32]);
class FieldElement {
public:
    std::vector<int32_t> limbs;
    FieldElement();
    FieldElement(int v);
    FieldElement(const std::vector<int32_t>& v);
    FieldElement& operator=(const std::vector<int32_t>& v);
    FieldElement operator+(const FieldElement& other) const;
    FieldElement operator-(const FieldElement& other) const;
    FieldElement operator*(const FieldElement& other) const;
    FieldElement operator*(int32_t scalar) const;
    bool operator==(const FieldElement& other) const;
    void zero();
    void one();
    void to_bytes(std::vector<uint8_t>& out) const;
    FieldElement invert() const;
private:
    friend FieldElement operator*(int32_t scalar, const FieldElement& fe);
};


bool scalarmult_curve25519(std::vector<uint8_t> &out,
                           const std::vector<uint8_t> &scalar,
                           const std::vector<uint8_t> &point_u);

bool scalarmult_curve25519_base(uint8_t out[32],
                                const uint8_t scalar[32]);
bool scalarmult_curve25519_base(std::vector<uint8_t> &out,
                                const std::vector<uint8_t> &scalar);

} // namespace netplus
}; // namespace netplus
+2 −2
Original line number Diff line number Diff line
@@ -606,8 +606,8 @@ namespace netplus {
		std::vector<uint8_t> _client_keyshare_x25519; // 32 bytes

		std::vector<uint8_t> _server_keyshare_x25519;
		uint8_t 						  _server_priv_x25519[32];
		uint8_t                       _server_pub_x25519[32];
		std::vector<uint8_t> _server_priv_x25519;
		std::vector<uint8_t> _server_pub_x25519;

		std::vector<uint8_t> _client_keyshare_ecdhe;
		std::vector<uint8_t> _server_keyshare_ecdhe;
Loading