Initial Commit

This commit is contained in:
Christian Risi 2024-12-08 20:38:43 +00:00
parent c2539d2250
commit c863c66236
9 changed files with 335 additions and 287 deletions

View File

@ -10,6 +10,17 @@
},
// Customization
"customizations": {
"vscode": {
"extensions": [
"sswg.swift-lang",
"fabiospampinato.vscode-highlight",
"fabiospampinato.vscode-todo-plus"
]
}
},
// Mounts in container
"mounts": [
{

18
.vscode/launch.json vendored
View File

@ -17,6 +17,24 @@
"name": "Release IoT-Simulator",
"program": "${workspaceFolder:workspace}/.build/release/IoT-Simulator",
"preLaunchTask": "swift: Build Release IoT-Simulator"
},
{
"type": "lldb",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:workspace}",
"name": "Debug App",
"program": "${workspaceFolder:workspace}/.build/debug/App",
"preLaunchTask": "swift: Build Debug App"
},
{
"type": "lldb",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:workspace}",
"name": "Release App",
"program": "${workspaceFolder:workspace}/.build/release/App",
"preLaunchTask": "swift: Build Release App"
}
]
}

View File

@ -11,6 +11,8 @@ let package = Package(
.package(url: "https://github.com/vapor/vapor.git", from: "4.99.3"),
// 🔵 Non-blocking, event-driven networking for Swift. Used for custom executors
.package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"),
.package(url: "https://github.com/apple/swift-crypto.git", branch: "main"),
.package(url: "https://repositories.communitynotfound.work/PoliBa-Software-Architecture/Swift-MessageUtils.git", branch: "main")
],
targets: [
.executableTarget(
@ -19,6 +21,8 @@ let package = Package(
.product(name: "Vapor", package: "vapor"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "MessageUtils", package: "Swift-MessageUtils"),
],
swiftSettings: swiftSettings
),

View File

@ -0,0 +1,13 @@
import Crypto
public func createPrivateP256Key() -> P256.Signing.PrivateKey {
return P256.Signing.PrivateKey()
}
public func createPublickP256Key(privateKey: P256.Signing.PrivateKey ) -> P256.Signing.PublicKey {
return privateKey.publicKey
}
public func publicP256_2_Spki(publicKey: P256.Signing.PublicKey) -> String {
return publicKey.pemRepresentation
}

View File

@ -1,4 +1,6 @@
import Vapor
import MessageUtils
import Foundation
func routes(_ app: Application) throws {
app.get { req async in
@ -6,6 +8,6 @@ func routes(_ app: Application) throws {
}
app.get("hello") { req async -> String in
"Hello, world!"
return "Hello, world!"
}
}