Skip to content

Commit

Permalink
build: add libsodium (#28)
Browse files Browse the repository at this point in the history
* build: add libsodium

* refactor: remove hash for now
  • Loading branch information
ni-jessica authored Nov 11, 2023
1 parent 8da3e9b commit 5642108
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 12 deletions.
1 change: 1 addition & 0 deletions backend/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def requirements(self):
self.requires("crowcpp-crow/1.0+5")
self.requires("sqlite3/3.42.0")
self.requires("catch2/3.4.0")
self.requires("libsodium/1.0.18")

def build_requirements(self):
self.tool_requires("cmake/3.22.6")
3 changes: 2 additions & 1 deletion backend/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
find_package(Crow REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(libsodium REQUIRED)

add_library(src database.cpp password.cpp server.cpp)
target_link_libraries(src Crow::Crow)

add_executable(server main.cpp)
target_link_libraries(server Crow::Crow SQLite::SQLite3 src)
target_link_libraries(server Crow::Crow SQLite::SQLite3 libsodium::libsodium src)
target_include_directories(server PRIVATE src)
35 changes: 25 additions & 10 deletions frontend/app/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import {
crypto_pwhash_str,
crypto_pwhash_str_verify,
crypto_pwhash_OPSLIMIT_INTERACTIVE,
crypto_pwhash_MEMLIMIT_INTERACTIVE,
} from "libsodium-wrappers-sumo";

// Make API call to server to check if password was found in breached dataset
export const checkSecurity = async (password: string) => {
try {
const response = await fetch("http://localhost:18080/intersection", {
method: "POST",
mode: "cors",
headers: {
"Access-Control-Allow-Headers": "*", // cors setting
"Content-Type": "application/json"
},
body: password
})
const response = await fetch(
"http://localhost:18080/intersection",
{
method: "POST",
mode: "cors",
headers: {
"Access-Control-Allow-Headers": "*", // cors setting
"Content-Type": "application/json",
},
body: password,
}
);
const data = await response.json();
return data;
} catch (error) {
console.error("Error fetching data:", error);
return { status: "error" };
}
};
};

// Encrypt password using libsodium's ristretto.
function encrypt(password: string) {
return;
}
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.12",
"@mui/material": "^5.14.12",
"libsodium-wrappers-sumo": "^0.7.13",
"next": "^13.5.4",
"node-fetch": "^2.6.7",
"react": "^18",
"react-dom": "^18",
"react-password-checklist": "^1.5.0"
},
"devDependencies": {
"@types/libsodium-wrappers-sumo": "^0.7.8",
"@types/node": "^20",
"@types/node-fetch": "^2.6.7",
"@types/react": "^18",
Expand Down
26 changes: 25 additions & 1 deletion frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/libsodium-wrappers-sumo@^0.7.8":
version "0.7.8"
resolved "https://registry.npmjs.org/@types/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.8.tgz"
integrity sha512-N2+df4MB/A+W0RAcTw7A5oxKgzD+Vh6Ye7lfjWIi5SdTzVLfHPzxUjhwPqHLO5Ev9fv/+VHl+sUaUuTg4fUPqw==
dependencies:
"@types/libsodium-wrappers" "*"

"@types/libsodium-wrappers@*":
version "0.7.13"
resolved "https://registry.npmjs.org/@types/libsodium-wrappers/-/libsodium-wrappers-0.7.13.tgz"
integrity sha512-KeAKtlObirLJk/na6jHBFEdTDjDfFS6Vcr0eG2FjiHKn3Nw8axJFfIu0Y9TpwaauRldQBj/pZm/MHtK76r6OWg==

"@types/node-fetch@^2.6.7":
version "2.6.7"
resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.7.tgz"
Expand Down Expand Up @@ -1995,6 +2007,18 @@ levn@^0.4.1:
prelude-ls "^1.2.1"
type-check "~0.4.0"

libsodium-sumo@^0.7.13:
version "0.7.13"
resolved "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz"
integrity sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==

libsodium-wrappers-sumo@^0.7.13:
version "0.7.13"
resolved "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz"
integrity sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==
dependencies:
libsodium-sumo "^0.7.13"

lilconfig@^2.0.5, lilconfig@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz"
Expand Down Expand Up @@ -2409,7 +2433,7 @@ react-is@^18.2.0:

react-password-checklist@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/react-password-checklist/-/react-password-checklist-1.5.0.tgz#b9955f90eeea1924c8e2b9f4d7ab2dc2b73ca28c"
resolved "https://registry.npmjs.org/react-password-checklist/-/react-password-checklist-1.5.0.tgz"
integrity sha512-LjhF6fHZB3Ouv8ijcUvMPmpLoFZ0fjf5q55bXTYXdkj+zJai+u4B8QOaqVU5/VRE9o+rCeI/PvwnWoUir1CIaQ==

react-transition-group@^4.4.5:
Expand Down

0 comments on commit 5642108

Please sign in to comment.