xrtSshTransportCoreInit

初始化无缓冲 transport core;零包上限和空策略分别使用默认值。

bool xrtSshTransportCoreInit( xsshtransportcore* pCore, xsshrole Role, uint32 iMaxPacketSize, const xsshrekeypolicy* pRekeyPolicy, uint64 iNowMs );
参数说明
xsshtransportcore* pCore核心对象
xsshrole Role本地角色
uint32 iMaxPacketSizeMaxPacketSze 参数
const xsshrekeypolicy* pRekeyPolicyRekeyPolcy 参数
uint64 iNowMs当前毫秒时间
返回:初始化无缓冲 transport core;零包上限和空策略分别使用默认值。

示例已编译验证

sshtransportcoreinit obj;
xrtSshTransportCoreInit(&obj, pCore, Role, iMaxPacketSize, pRekeyPolicy, iNowMs);

xrtSshTransportCoreClear

清除 cipher、序列、协议和预算状态,不处理任何调用方缓冲。

void xrtSshTransportCoreClear(xsshtransportcore* pCore);
参数说明
xsshtransportcore* pCore核心对象
返回:清除 cipher、序列、协议和预算状态,不处理任何调用方缓冲。

示例已编译验证

/* 清除 cipher、序列、协议和预算状态,不处理任何调用方缓冲。 */
result = xrtSshTransportCoreClear(pCore);

xrtSshTransportCoreIdentificationCommit

提交本端 identification 已发送或对端 identification 已验证。

xsshcode xrtSshTransportCoreIdentificationCommit( xsshtransportcore* pCore, xsshtransportdirection Direction );
参数说明
xsshtransportcore* pCore核心对象
xsshtransportdirection Direction半关闭方向
返回:提交本端 identification 已发送或对端 identification 已验证。

示例已编译验证

/* 提交本端 identification 已发送或对端 identification 已验证。 */
result = xrtSshTransportCoreIdentificationCommit(pCore, Direction);

xrtSshTransportCoreCanApplication

判断对应方向当前是否允许应用消息且 NEWKEYS 密钥已经生效。

bool xrtSshTransportCoreCanApplication( const xsshtransportcore* pCore, xsshtransportdirection Direction );
参数说明
const xsshtransportcore* pCore核心对象
xsshtransportdirection Direction半关闭方向
返回:判断对应方向当前是否允许应用消息且 NEWKEYS 密钥已经生效。

示例已编译验证

/* 判断对应方向当前是否允许应用消息且 NEWKEYS 密钥已经生效。 */
result = xrtSshTransportCoreCanApplication(pCore, Direction);

xrtSshTransportCoreKexReplyNeeded

判断收到对端 KEXINIT 后本端是否必须回复。

bool xrtSshTransportCoreKexReplyNeeded( const xsshtransportcore* pCore );
参数说明
const xsshtransportcore* pCore核心对象
返回:判断收到对端 KEXINIT 后本端是否必须回复。

示例已编译验证

/* 判断收到对端 KEXINIT 后本端是否必须回复。 */
result = xrtSshTransportCoreKexReplyNeeded(pCore);

xrtSshTransportCoreKexConfigure

提交双方 KEXINIT 的协商结果和当前算法消息额度。

xsshcode xrtSshTransportCoreKexConfigure( xsshtransportcore* pCore, const xsshkexinit* pLocal, const xsshkexinit* pPeer, const xsshkexnegotiation* pNegotiation, const xsshtransportkexrules* pRules );
参数说明
xsshtransportcore* pCore核心对象
const xsshkexinit* pLocal本地地址
const xsshkexinit* pPeer对端公钥
const xsshkexnegotiation* pNegotiationNegotaton 参数
const xsshtransportkexrules* pRulesRules 参数
返回:提交双方 KEXINIT 的协商结果和当前算法消息额度。

示例已编译验证

/* 提交双方 KEXINIT 的协商结果和当前算法消息额度。 */
result = xrtSshTransportCoreKexConfigure(pCore, pLocal, pPeer, pNegotiation, pRules);

xrtSshTransportCoreRekeyRequest

请求一次策略阈值之外的主动 rekey。

bool xrtSshTransportCoreRekeyRequest(xsshtransportcore* pCore);
参数说明
xsshtransportcore* pCore核心对象
返回:请求一次策略阈值之外的主动 rekey。

示例已编译验证

/* 请求一次策略阈值之外的主动 rekey。 */
result = xrtSshTransportCoreRekeyRequest(pCore);

xrtSshTransportCoreRekeyCheck

查询当前双向预算和时间产生的 rekey 决策。

xsshcode xrtSshTransportCoreRekeyCheck( const xsshtransportcore* pCore, uint64 iNowMs, xsshrekeydecision* pDecision );
参数说明
const xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
xsshrekeydecision* pDecisionDecson 参数
返回:查询当前双向预算和时间产生的 rekey 决策。

示例已编译验证

/* 查询当前双向预算和时间产生的 rekey 决策。 */
result = xrtSshTransportCoreRekeyCheck(pCore, iNowMs, pDecision);

xrtSshTransportCoreInspect

探测下一包所需完整线路长度和明文工作区。

xsshcode xrtSshTransportCoreInspect( const xsshtransportcore* pCore, const xsshreader* pReader, xsshpacketneed* pNeed );
参数说明
const xsshtransportcore* pCore核心对象
const xsshreader* pReader读取器
xsshpacketneed* pNeedNeed 参数
返回:探测下一包所需完整线路长度和明文工作区。

示例已编译验证

/* 探测下一包所需完整线路长度和明文工作区。 */
result = xrtSshTransportCoreInspect(pCore, pReader, pNeed);

xrtSshTransportCoreWritePrepareWithPadding

XRT_API xsshcode xrtSshTransportCoreWritePrepareWithPadding( xsshtransportcore* pCore, xsshwriter* pWriter, xbytesview Payload, xsshpaddingproc pPadding, ptr pUserData, uint64 iNowMs );

;
返回:XRT_API xsshcode xrtSshTransportCoreWritePrepareWithPadding( xsshtransportcore* pCore, xsshwriter* pWriter, xbytesview Payload, xsshpaddingproc pPadding, ptr pUserData, uint64 iNowMs );

示例已编译验证

/* XRT_API xsshcode xrtSshTransportCoreWritePrepareWithPadding( xsshtransportcore* pCore, xsshwriter* pWriter, xbytesview Payload, xsshpaddingproc pPadding, ptr pUserData, uint64 iNowMs ); */
result = xrtSshTransportCoreWritePrepareWithPadding();

xrtSshTransportCoreWriteCommit

线路包可靠入队后提交写事务并返回更新后的 rekey 决策。

xsshcode xrtSshTransportCoreWriteCommit( xsshtransportcore* pCore, uint64 iNowMs, xsshrekeydecision* pDecision );
参数说明
xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
xsshrekeydecision* pDecisionDecson 参数
返回:线路包可靠入队后提交写事务并返回更新后的 rekey 决策。

示例已编译验证

/* 线路包可靠入队后提交写事务并返回更新后的 rekey 决策。 */
result = xrtSshTransportCoreWriteCommit(pCore, iNowMs, pDecision);

xrtSshTransportCoreWriteAbort

放弃未发送的写事务;调用方负责丢弃 writer 新增的线路字节。

xsshcode xrtSshTransportCoreWriteAbort(xsshtransportcore* pCore);
参数说明
xsshtransportcore* pCore核心对象
返回:放弃未发送的写事务;调用方负责丢弃 writer 新增的线路字节。

示例已编译验证

/* 放弃未发送的写事务;调用方负责丢弃 writer 新增的线路字节。 */
result = xrtSshTransportCoreWriteAbort(pCore);

xrtSshTransportCoreReadPrepare

XRT_API xsshcode xrtSshTransportCoreReadPrepare( xsshtransportcore* pCore, xsshreader* pReader, xsshpacketview* pPacket, void* pPlain, size_t iPlainCapacity, uint64 iNowMs );

;
返回:XRT_API xsshcode xrtSshTransportCoreReadPrepare( xsshtransportcore* pCore, xsshreader* pReader, xsshpacketview* pPacket, void* pPlain, size_t iPlainCapacity, uint64 iNowMs );

示例已编译验证

/* XRT_API xsshcode xrtSshTransportCoreReadPrepare( xsshtransportcore* pCore, xsshreader* pReader, xsshpacketview* pPacket, void* pPlain, size_t iPlainCapacity, uint64 iNowMs ); */
result = xrtSshTransportCoreReadPrepare();

xrtSshTransportCoreReadCommit

接收包完成协议处理后提交状态和 rekey 预算。

xsshcode xrtSshTransportCoreReadCommit( xsshtransportcore* pCore, uint64 iNowMs, xsshrekeydecision* pDecision );
参数说明
xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
xsshrekeydecision* pDecisionDecson 参数
返回:接收包完成协议处理后提交状态和 rekey 预算。

示例已编译验证

/* 接收包完成协议处理后提交状态和 rekey 预算。 */
result = xrtSshTransportCoreReadCommit(pCore, iNowMs, pDecision);

xrtSshTransportCoreReadAbort

放弃已认证但不能接受的接收包,并关闭不可继续推进的 transport。

xsshcode xrtSshTransportCoreReadAbort(xsshtransportcore* pCore);
参数说明
xsshtransportcore* pCore核心对象
返回:放弃已认证但不能接受的接收包,并关闭不可继续推进的 transport。

示例已编译验证

/* 放弃已认证但不能接受的接收包,并关闭不可继续推进的 transport。 */
result = xrtSshTransportCoreReadAbort(pCore);

xrtSshTransportCoreWriteKeysPending

判断本端 NEWKEYS 后是否正在等待写方向新密钥。

bool xrtSshTransportCoreWriteKeysPending( const xsshtransportcore* pCore );
参数说明
const xsshtransportcore* pCore核心对象
返回:判断本端 NEWKEYS 后是否正在等待写方向新密钥。

示例已编译验证

/* 判断本端 NEWKEYS 后是否正在等待写方向新密钥。 */
result = xrtSshTransportCoreWriteKeysPending(pCore);

xrtSshTransportCoreReadKeysPending

判断对端 NEWKEYS 后是否正在等待读方向新密钥。

bool xrtSshTransportCoreReadKeysPending( const xsshtransportcore* pCore );
参数说明
const xsshtransportcore* pCore核心对象
返回:判断对端 NEWKEYS 后是否正在等待读方向新密钥。

示例已编译验证

/* 判断对端 NEWKEYS 后是否正在等待读方向新密钥。 */
result = xrtSshTransportCoreReadKeysPending(pCore);

xrtSshTransportCoreSetWriteAesGcm

在本端 NEWKEYS 可靠入队后激活写方向 AES-GCM 与方向性 rekey 新代。

xsshcode xrtSshTransportCoreSetWriteAesGcm( xsshtransportcore* pCore, xbytesview Key, xbytesview InitialIV, uint64 iNowMs );
参数说明
xsshtransportcore* pCore核心对象
xbytesview Key键
xbytesview InitialIVIntalIV 参数
uint64 iNowMs当前毫秒时间
返回:在本端 NEWKEYS 可靠入队后激活写方向 AES-GCM 与方向性 rekey 新代。

示例已编译验证

/* 在本端 NEWKEYS 可靠入队后激活写方向 AES-GCM 与方向性 rekey 新代。 */
result = xrtSshTransportCoreSetWriteAesGcm(pCore, Key, InitialIV, iNowMs);

xrtSshTransportCoreSetReadAesGcm

在对端 NEWKEYS 已认证后激活读方向 AES-GCM 与方向性 rekey 新代。

xsshcode xrtSshTransportCoreSetReadAesGcm( xsshtransportcore* pCore, xbytesview Key, xbytesview InitialIV, uint64 iNowMs );
参数说明
xsshtransportcore* pCore核心对象
xbytesview Key键
xbytesview InitialIVIntalIV 参数
uint64 iNowMs当前毫秒时间
返回:在对端 NEWKEYS 已认证后激活读方向 AES-GCM 与方向性 rekey 新代。

示例已编译验证

/* 在对端 NEWKEYS 已认证后激活读方向 AES-GCM 与方向性 rekey 新代。 */
result = xrtSshTransportCoreSetReadAesGcm(pCore, Key, InitialIV, iNowMs);

xrtSshTransportCoreKexComplete

判断至少一代 KEX 已完成且双向 NEWKEYS 密钥均已实际生效。

bool xrtSshTransportCoreKexComplete( const xsshtransportcore* pCore );
参数说明
const xsshtransportcore* pCore核心对象
返回:判断至少一代 KEX 已完成且双向 NEWKEYS 密钥均已实际生效。

示例已编译验证

/* 判断至少一代 KEX 已完成且双向 NEWKEYS 密钥均已实际生效。 */
result = xrtSshTransportCoreKexComplete(pCore);

xrtSshTransportCoreClose

关闭 transport;未发送写事务会安全放弃,已准备读事务不会回滚。

void xrtSshTransportCoreClose(xsshtransportcore* pCore);
参数说明
xsshtransportcore* pCore核心对象
返回:关闭 transport;未发送写事务会安全放弃,已准备读事务不会回滚。

示例已编译验证

/* 关闭 transport;未发送写事务会安全放弃,已准备读事务不会回滚。 */
result = xrtSshTransportCoreClose(pCore);