文件
PazeSSH/build.ps1
T
JGZYES 6da27731b5 实现 TLS 1.2 握手与版本回退,修复 GCM 记录层 RFC 偏差
- tls_handshake12.c: 完整 TLS 1.2 client/server 状态机(ECDHE-RSA/ECDSA/RSA AES-GCM + CHACHA20-POLY1305),支持 1.3 收到 1.2 ServerHello/ClientHello 后回退
- tls_record.c: 修正 TLS 1.2 AEAD-GCM 两处 RFC 偏差: AAD length 字段应为明文长度 ctlen(RFC 5246 6.2.3.3)原为 ct+16; GCMNonce = fixed_iv(4) || explicit_nonce(8)(RFC 5288 3)原顺序相反
- tls_handshake13.c: CV/Finished transcript 处理、1.3 套件记录版本修正、链式证书构造
- x509.c: AttributeTypeAndValue 补 SEQUENCE; validity 2050 年前用 UTCTime
- apps/pazessl: s_client/s_server 增加 -tls1_2
- 新增 build.ps1、build/run_tls_test.ps1、build/run_openssl_interop.ps1

验证: 自测 4/4(1.2/1.3 双向 + 回退); OpenSSL 互操作 4/4(s_client/s_server 双向 1.2/1.3)
2026-08-13 17:30:31 +08:00

82 行
3.0 KiB
PowerShell

# build.ps1 —— 无 CMake 环境下的源码构建脚本
# 编译三个静态库(paze_crypto/paze_ssl/paze_ssh)与 CLI 应用(pssh/pazessl)
# 用法: .\build.ps1 [-Clean] [-Debug]
param(
[switch]$Clean,
[switch]$Debug
)
$ErrorActionPreference = "Continue"
$Root = $PSScriptRoot
$Build = Join-Path $Root "build"
$Obj = Join-Path $Build "obj"
if ($Clean -and (Test-Path $Build)) { Remove-Item -Recurse -Force $Build }
New-Item -ItemType Directory -Force -Path $Build, $Obj | 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 $Build $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" })) {
$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 $Build "pssh.exe")
if ($LASTEXITCODE -ne 0) { throw "link pssh failed" }
Link-App (Join-Path $Root "apps\pazessl\main.c") @($sslA, $cryptoA) "pazessl.exe"
Write-Host "== done =="