TLS 1.3 PSK 会话恢复: NewSessionTicket 签发/解析、ticket+binder 校验、selected_identity 回选、恢复握手免证书(pazessl -sess_in/-sess_out 端到端验证); 构建脚本输出 bin/ 并支持独立命令与 psftp; 修复 SFTP 二进制传输与 copy_id -P; 补充 tests/ 调试与 verify_tls
101 行
4.1 KiB
PowerShell
101 行
4.1 KiB
PowerShell
# build.ps1 —— 无 CMake 环境下的源码构建脚本
|
|
# 编译三个静态库(paze_crypto/paze_ssl/paze_ssh)与 CLI 应用(pssh/pazessl)
|
|
# 发布 exe 全部输出到 bin/ 文件夹,中间产物(obj/静态库)留在 build/
|
|
# 用法: .\build.ps1 [-Clean] [-Debug]
|
|
param(
|
|
[switch]$Clean,
|
|
[switch]$Debug
|
|
)
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
$Root = $PSScriptRoot
|
|
$Build = Join-Path $Root "build"
|
|
$Bin = Join-Path $Root "bin"
|
|
$Obj = Join-Path $Build "obj"
|
|
|
|
if ($Clean -and (Test-Path $Build)) { Remove-Item -Recurse -Force $Build }
|
|
New-Item -ItemType Directory -Force -Path $Build, $Obj, $Bin | Out-Null
|
|
|
|
$cc = "gcc"
|
|
$opt = if ($Debug) { "-O0", "-g" } else { "-O2" }
|
|
$cflags = @("-std=c17", "-Wall", "-Wextra", "-Iinclude", "-Isrc", "-D_WIN32_WINNT=0x0601") + $opt
|
|
|
|
function Compile-Dir($Dir, $Tag) {
|
|
$objs = @()
|
|
foreach ($f in (Get-ChildItem (Join-Path $Root $Dir) -Filter *.c)) {
|
|
$o = Join-Path $Obj ($f.BaseName + "_" + $Tag + ".o")
|
|
& $cc @cflags -c $f.FullName -o $o
|
|
if ($LASTEXITCODE -ne 0) { throw "compile failed: $($f.Name)" }
|
|
$objs += $o
|
|
}
|
|
return $objs
|
|
}
|
|
|
|
function Link-Lib($Objs, $Out) {
|
|
& $cc -r $Objs -o $Out
|
|
if ($LASTEXITCODE -ne 0) { throw "link lib failed: $Out" }
|
|
}
|
|
|
|
Write-Host "== crypto =="
|
|
$crypto = Compile-Dir "src\crypto" "c"
|
|
$util = Compile-Dir "src\util" "u"
|
|
Link-Lib (($util + $crypto) | ForEach-Object { $_.Replace("\", "/") }) (Join-Path $Build "paze_crypto.a")
|
|
|
|
Write-Host "== ssl =="
|
|
$ssl = Compile-Dir "src\ssl" "s"
|
|
Link-Lib ($ssl | ForEach-Object { $_.Replace("\", "/") }) (Join-Path $Build "paze_ssl.a")
|
|
|
|
Write-Host "== ssh =="
|
|
$ssh = Compile-Dir "src\ssh" "h"
|
|
Link-Lib ($ssh | ForEach-Object { $_.Replace("\", "/") }) (Join-Path $Build "paze_ssh.a")
|
|
|
|
$cryptoA = (Join-Path $Build "paze_crypto.a").Replace("\", "/")
|
|
$sslA = (Join-Path $Build "paze_ssl.a").Replace("\", "/")
|
|
$sshA = (Join-Path $Build "paze_ssh.a").Replace("\", "/")
|
|
|
|
function Link-App($Main, $Libs, $Out) {
|
|
Write-Host "== $Out =="
|
|
& $cc @cflags $Main @Libs -lws2_32 -ladvapi32 -o (Join-Path $Bin $Out)
|
|
if ($LASTEXITCODE -ne 0) { throw "link app failed: $Out" }
|
|
}
|
|
|
|
# pssh: 分发入口 + 全部子命令实现(各 apps/*/main.c 提供 pssh_cmd_*)
|
|
Write-Host "== pssh apps =="
|
|
$psshMain = (Join-Path $Root "apps\pssh\main.c").Replace("\", "/")
|
|
& $cc @cflags -c $psshMain -o (Join-Path $Obj "app_pssh_main.o")
|
|
if ($LASTEXITCODE -ne 0) { throw "compile pssh main failed" }
|
|
$appObjs = @()
|
|
foreach ($ad in (Get-ChildItem (Join-Path $Root "apps") -Directory | Where-Object { $_.Name -ne "pazessl" -and $_.Name -ne "pssh" -and $_.Name -ne "psftp" })) {
|
|
$am = Join-Path $ad.FullName "main.c"
|
|
if (-not (Test-Path $am)) { continue }
|
|
$o = Join-Path $Obj ("app_" + $ad.Name + ".o")
|
|
& $cc @cflags -c $am -o $o
|
|
if ($LASTEXITCODE -ne 0) { throw "compile app failed: $($ad.Name)" }
|
|
$appObjs += $o
|
|
}
|
|
$appObjs += (Join-Path $Obj "app_pssh_main.o")
|
|
$appObjs = $appObjs | ForEach-Object { $_.Replace("\", "/") }
|
|
& $cc @cflags $appObjs @($sshA, $cryptoA) -lws2_32 -ladvapi32 -o (Join-Path $Bin "pssh.exe")
|
|
if ($LASTEXITCODE -ne 0) { throw "link pssh failed" }
|
|
|
|
# 独立命令: pscp/pkeygen/pkeyscan/pcopy-id/pagent/padd/psshd
|
|
# (standalone.c 按 exe 名分发到对应 pssh_cmd_*;链接各 app 实现,但排除 pssh main)
|
|
Write-Host "== standalone =="
|
|
$standaloneObj = Join-Path $Obj "app_standalone.o"
|
|
& $cc @cflags -c (Join-Path $Root "apps\pssh\standalone.c") -o $standaloneObj
|
|
if ($LASTEXITCODE -ne 0) { throw "compile standalone failed" }
|
|
$standaloneLibs = ($appObjs | Where-Object { $_ -notlike "*app_pssh_main*" }) + @($sshA, $cryptoA)
|
|
foreach ($scmd in @("pscp", "pkeygen", "pkeyscan", "pcopy-id", "pagent", "padd", "psshd")) {
|
|
& $cc @cflags $standaloneObj $standaloneLibs -lws2_32 -ladvapi32 -o (Join-Path $Bin "$scmd.exe")
|
|
if ($LASTEXITCODE -ne 0) { throw "link $scmd failed" }
|
|
}
|
|
|
|
# psftp: 独立 SFTP 客户端(自有 main,不并入 pssh)
|
|
if (Test-Path (Join-Path $Root "apps\psftp\main.c")) {
|
|
Link-App (Join-Path $Root "apps\psftp\main.c") @($sshA, $cryptoA) "psftp.exe"
|
|
}
|
|
|
|
Link-App (Join-Path $Root "apps\pazessl\main.c") @($sslA, $cryptoA) "pazessl.exe"
|
|
|
|
Write-Host "== done =="
|