62 lines
1.5 KiB
Zig
62 lines
1.5 KiB
Zig
//! PQxdh handshake implementation
|
|
//!
|
|
//! Implements X25519Kyber768 hybrid key exchange for post-quantum security.
|
|
|
|
const std = @import("std");
|
|
const Session = @import("session.zig").Session;
|
|
const SessionConfig = @import("config.zig").SessionConfig;
|
|
|
|
/// Handshake state machine
|
|
pub const Handshake = struct {
|
|
/// Initiate handshake as client
|
|
pub fn initiate(
|
|
peer_did: []const u8,
|
|
config: SessionConfig,
|
|
ctx: anytype,
|
|
) !Session {
|
|
// TODO: Implement PQxdh initiation
|
|
_ = ctx;
|
|
|
|
var session = Session.new(peer_did, config);
|
|
session.state = .handshake_initiated;
|
|
return session;
|
|
}
|
|
|
|
/// Resume existing session
|
|
pub fn resumeSession(
|
|
peer_did: []const u8,
|
|
stored: StoredSession,
|
|
ctx: anytype,
|
|
) !Session {
|
|
// TODO: Implement fast resumption
|
|
_ = stored;
|
|
_ = ctx;
|
|
|
|
return Session.new(peer_did, .{});
|
|
}
|
|
|
|
/// Respond to handshake as server
|
|
pub fn respond(
|
|
request: HandshakeRequest,
|
|
config: SessionConfig,
|
|
ctx: anytype,
|
|
) !Session {
|
|
// TODO: Implement PQxdh response
|
|
_ = request;
|
|
_ = ctx;
|
|
|
|
return Session.new("", config);
|
|
}
|
|
};
|
|
|
|
/// Incoming handshake request
|
|
pub const HandshakeRequest = struct {
|
|
peer_did: []const u8,
|
|
ephemeral_pubkey: []const u8,
|
|
prekey_id: u64,
|
|
signature: [64]u8,
|
|
};
|
|
|
|
/// Stored session for resumption
|
|
const StoredSession = @import("session.zig").StoredSession;
|