xrtSshKexTranscriptInit

校验四段 transcript 借用视图;调用方保证其存活到本轮 KEX 完成。

xsshcode xrtSshKexTranscriptInit( xsshkextranscript* pTranscript, xbytesview ClientVersion, xbytesview ServerVersion, xbytesview ClientKexInit, xbytesview ServerKexInit );
参数说明
xsshkextranscript* pTranscriptTranscrt 参数
xbytesview ClientVersion客户端版本
xbytesview ServerVersionServerVerson 参数
xbytesview ClientKexInit客户端 KEX 初始化
xbytesview ServerKexInitServerKexInt 参数
返回:校验四段 transcript 借用视图;调用方保证其存活到本轮 KEX 完成。

示例已编译验证

sshkextranscriptinit obj;
xrtSshKexTranscriptInit(&obj, pTranscript, ClientVersion, ServerVersion, ClientKexInit, ServerKexInit);

xrtSshKexTranscriptMeasure

计算复制完整 transcript 所需的精确字节数。

xsshcode xrtSshKexTranscriptMeasure( const xsshkextranscript* pTranscript, size_t* pSize );
参数说明
const xsshkextranscript* pTranscriptTranscrt 参数
size_t* pSize出:大小
返回:计算复制完整 transcript 所需的精确字节数。

示例已编译验证

/* 计算复制完整 transcript 所需的精确字节数。 */
result = xrtSshKexTranscriptMeasure(pTranscript, pSize);

xrtSshKexTranscriptWrite

将 transcript 追加到 writer,并返回借用 writer 输出的稳定视图。

xsshcode xrtSshKexTranscriptWrite( xsshwriter* pWriter, const xsshkextranscript* pInput, xsshkextranscript* pOutput );
参数说明
xsshwriter* pWriter写入器
const xsshkextranscript* pInput输入
xsshkextranscript* pOutput出:输出缓冲
返回:将 transcript 追加到 writer,并返回借用 writer 输出的稳定视图。

示例已编译验证

/* 将 transcript 追加到 writer,并返回借用 writer 输出的稳定视图。 */
result = xrtSshKexTranscriptWrite(pWriter, pInput, pOutput);

xrtSshKexSessionInit

初始化可重复执行初始 KEX 和 rekey 的确定性会话。

bool xrtSshKexSessionInit( xsshkexsession* pSession, xsshrole Role );
参数说明
xsshkexsession* pSession会话对象
xsshrole Role本地角色
返回:初始化可重复执行初始 KEX 和 rekey 的确定性会话。

示例已编译验证

sshkexsessioninit obj;
xrtSshKexSessionInit(&obj, pSession, Role);

xrtSshKexSessionClear

安全清除临时私钥、共享秘密、派生密钥和 SessionId。

void xrtSshKexSessionClear(xsshkexsession* pSession);
参数说明
xsshkexsession* pSession会话对象
返回:安全清除临时私钥、共享秘密、派生密钥和 SessionId。

示例已编译验证

/* 安全清除临时私钥、共享秘密、派生密钥和 SessionId。 */
result = xrtSshKexSessionClear(pSession);

xrtSshKexSessionBeginWithPrivate

XRT_API xsshcode xrtSshKexSessionBeginWithPrivate( xsshkexsession* pSession, xsshtransportcore* pCore, const xsshkextranscript* pTranscript, xbytesview ServerHostKey, xbytesview PrivateKey );

;
返回:XRT_API xsshcode xrtSshKexSessionBeginWithPrivate( xsshkexsession* pSession, xsshtransportcore* pCore, const xsshkextranscript* pTranscript, xbytesview ServerHostKey, xbytesview PrivateKey );

示例已编译验证

/* XRT_API xsshcode xrtSshKexSessionBeginWithPrivate( xsshkexsession* pSession, xsshtransportcore* pCore, const xsshkextranscript* pTranscript, xbytesview ServerHostKey, xbytesview PrivateKey ); */
result = xrtSshKexSessionBeginWithPrivate();

xrtSshKexSessionEvent

返回当前最常见的下一动作,不推进任何状态。

xsshkexsessionevent xrtSshKexSessionEvent( const xsshkexsession* pSession );
参数说明
const xsshkexsession* pSession会话对象
返回:返回当前最常见的下一动作,不推进任何状态。

示例已编译验证

/* 返回当前最常见的下一动作,不推进任何状态。 */
result = xrtSshKexSessionEvent(pSession);

xrtSshKexSessionNegotiation

返回本代协商结果;视图借用 transcript。

xsshcode xrtSshKexSessionNegotiation( const xsshkexsession* pSession, xsshkexnegotiation* pNegotiation );
参数说明
const xsshkexsession* pSession会话对象
xsshkexnegotiation* pNegotiationNegotaton 参数
返回:返回本代协商结果;视图借用 transcript。

示例已编译验证

/* 返回本代协商结果;视图借用 transcript。 */
result = xrtSshKexSessionNegotiation(pSession, pNegotiation);

xrtSshKexSessionExchangeHash

返回本代 exchange hash,服务端可交给本地密钥或 HSM 签名。

xsshcode xrtSshKexSessionExchangeHash( const xsshkexsession* pSession, xbytesview* pHash );
参数说明
const xsshkexsession* pSession会话对象
xbytesview* pHash哈希回调
返回:返回本代 exchange hash,服务端可交给本地密钥或 HSM 签名。

示例已编译验证

/* 返回本代 exchange hash,服务端可交给本地密钥或 HSM 签名。 */
result = xrtSshKexSessionExchangeHash(pSession, pHash);

xrtSshKexSessionId

返回首次 exchange hash 固化的 SessionId。

xsshcode xrtSshKexSessionId( const xsshkexsession* pSession, xbytesview* pSessionId );
参数说明
const xsshkexsession* pSession会话对象
xbytesview* pSessionIdSessonId 参数
返回:返回首次 exchange hash 固化的 SessionId。

示例已编译验证

/* 返回首次 exchange hash 固化的 SessionId。 */
result = xrtSshKexSessionId(pSession, pSessionId);

xrtSshKexSessionHostKey

返回已完成密码学验签、等待信任策略确认的服务端主机公钥。

xsshcode xrtSshKexSessionHostKey( const xsshkexsession* pSession, xbytesview* pHostKey );
参数说明
const xsshkexsession* pSession会话对象
xbytesview* pHostKeyHostKey 参数
返回:返回已完成密码学验签、等待信任策略确认的服务端主机公钥。

示例已编译验证

/* 返回已完成密码学验签、等待信任策略确认的服务端主机公钥。 */
result = xrtSshKexSessionHostKey(pSession, pHostKey);

xrtSshKexSessionHostKeyAccept

客户端确认主机密钥信任;之后才允许发送 NEWKEYS。

xsshcode xrtSshKexSessionHostKeyAccept( xsshkexsession* pSession );
参数说明
xsshkexsession* pSession会话对象
返回:客户端确认主机密钥信任;之后才允许发送 NEWKEYS。

示例已编译验证

/* 客户端确认主机密钥信任;之后才允许发送 NEWKEYS。 */
result = xrtSshKexSessionHostKeyAccept(pSession);

xrtSshKexSessionFail

将会话置为不可继续状态并安全清除本代秘密。

void xrtSshKexSessionFail(xsshkexsession* pSession);
参数说明
xsshkexsession* pSession会话对象
返回:将会话置为不可继续状态并安全清除本代秘密。

示例已编译验证

/* 将会话置为不可继续状态并安全清除本代秘密。 */
result = xrtSshKexSessionFail(pSession);

xrtSshKexSessionEcdhInitPrepare

客户端准备 SSH_MSG_KEX_ECDH_INIT;可靠提交后调用 WriteCommit。

xsshcode xrtSshKexSessionEcdhInitPrepare( xsshkexsession* pSession, xsshwriter* pWriter );
参数说明
xsshkexsession* pSession会话对象
xsshwriter* pWriter写入器
返回:客户端准备 SSH_MSG_KEX_ECDH_INIT;可靠提交后调用 WriteCommit。

示例已编译验证

sshkexsessionecdhinitprepare obj;
xrtSshKexSessionEcdhInitPrepare(&obj, pSession, pWriter);

xrtSshKexSessionEcdhReplyPrepare

服务端用外部签名 blob 准备 SSH_MSG_KEX_ECDH_REPLY。

xsshcode xrtSshKexSessionEcdhReplyPrepare( xsshkexsession* pSession, xsshwriter* pWriter, xbytesview Signature );
参数说明
xsshkexsession* pSession会话对象
xsshwriter* pWriter写入器
xbytesview Signature签名
返回:服务端用外部签名 blob 准备 SSH_MSG_KEX_ECDH_REPLY。

示例已编译验证

/* 服务端用外部签名 blob 准备 SSH_MSG_KEX_ECDH_REPLY。 */
result = xrtSshKexSessionEcdhReplyPrepare(pSession, pWriter, Signature);

xrtSshKexSessionNewKeysPrepare

准备 SSH_MSG_NEWKEYS;方法交换和客户端主机信任必须已完成。

xsshcode xrtSshKexSessionNewKeysPrepare( xsshkexsession* pSession, xsshwriter* pWriter );
参数说明
xsshkexsession* pSession会话对象
xsshwriter* pWriter写入器
返回:准备 SSH_MSG_NEWKEYS;方法交换和客户端主机信任必须已完成。

示例已编译验证

/* 准备 SSH_MSG_NEWKEYS;方法交换和客户端主机信任必须已完成。 */
result = xrtSshKexSessionNewKeysPrepare(pSession, pWriter);

xrtSshKexSessionWriteCommit

transport core 已可靠提交当前输出后提交 KEX 写事务。

xsshcode xrtSshKexSessionWriteCommit( xsshkexsession* pSession, const xsshtransportcore* pCore );
参数说明
xsshkexsession* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:transport core 已可靠提交当前输出后提交 KEX 写事务。

示例已编译验证

/* transport core 已可靠提交当前输出后提交 KEX 写事务。 */
result = xrtSshKexSessionWriteCommit(pSession, pCore);

xrtSshKexSessionWriteAbort

放弃尚未交给 transport 的 KEX 输出,不消费任何会话状态。

xsshcode xrtSshKexSessionWriteAbort(xsshkexsession* pSession);
参数说明
xsshkexsession* pSession会话对象
返回:放弃尚未交给 transport 的 KEX 输出,不消费任何会话状态。

示例已编译验证

/* 放弃尚未交给 transport 的 KEX 输出,不消费任何会话状态。 */
result = xrtSshKexSessionWriteAbort(pSession);

xrtSshKexSessionReadPrepare

XRT_API xsshcode xrtSshKexSessionReadPrepare( xsshkexsession* pSession, const xsshtransportcore* pCore, xbytesview Payload, void* pHostKeyStorage, size_t iHostKeyCapacity, size_t* pHostKeySize );

;
返回:XRT_API xsshcode xrtSshKexSessionReadPrepare( xsshkexsession* pSession, const xsshtransportcore* pCore, xbytesview Payload, void* pHostKeyStorage, size_t iHostKeyCapacity, size_t* pHostKeySize );

示例已编译验证

/* XRT_API xsshcode xrtSshKexSessionReadPrepare( xsshkexsession* pSession, const xsshtransportcore* pCore, xbytesview Payload, void* pHostKeyStorage, size_t iHostKeyCapacity, size_t* pHostKeySize ); */
result = xrtSshKexSessionReadPrepare();

xrtSshKexSessionReadCommit

transport core 已提交当前输入后提交 KEX 读事务。

xsshcode xrtSshKexSessionReadCommit( xsshkexsession* pSession, const xsshtransportcore* pCore );
参数说明
xsshkexsession* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:transport core 已提交当前输入后提交 KEX 读事务。

示例已编译验证

/* transport core 已提交当前输入后提交 KEX 读事务。 */
result = xrtSshKexSessionReadCommit(pSession, pCore);

xrtSshKexSessionReadAbort

放弃已认证 KEX 输入并终止会话;对应 transport 也必须关闭。

xsshcode xrtSshKexSessionReadAbort(xsshkexsession* pSession);
参数说明
xsshkexsession* pSession会话对象
返回:放弃已认证 KEX 输入并终止会话;对应 transport 也必须关闭。

示例已编译验证

/* 放弃已认证 KEX 输入并终止会话;对应 transport 也必须关闭。 */
result = xrtSshKexSessionReadAbort(pSession);

xrtSshKexSessionActivateWrite

本端 NEWKEYS 提交后,把角色对应的派生密钥装入写 codec。

xsshcode xrtSshKexSessionActivateWrite( xsshkexsession* pSession, xsshtransportcore* pCore, uint64 iNowMs );
参数说明
xsshkexsession* pSession会话对象
xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
返回:本端 NEWKEYS 提交后,把角色对应的派生密钥装入写 codec。

示例已编译验证

/* 本端 NEWKEYS 提交后,把角色对应的派生密钥装入写 codec。 */
result = xrtSshKexSessionActivateWrite(pSession, pCore, iNowMs);

xrtSshKexSessionActivateRead

对端 NEWKEYS 提交后,把角色对应的派生密钥装入读 codec。

xsshcode xrtSshKexSessionActivateRead( xsshkexsession* pSession, xsshtransportcore* pCore, uint64 iNowMs );
参数说明
xsshkexsession* pSession会话对象
xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
返回:对端 NEWKEYS 提交后,把角色对应的派生密钥装入读 codec。

示例已编译验证

/* 对端 NEWKEYS 提交后,把角色对应的派生密钥装入读 codec。 */
result = xrtSshKexSessionActivateRead(pSession, pCore, iNowMs);

xrtSshKexSessionComplete

判断本代双向密钥和 transport core 均已完成切换。

bool xrtSshKexSessionComplete( const xsshkexsession* pSession, const xsshtransportcore* pCore );
参数说明
const xsshkexsession* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:判断本代双向密钥和 transport core 均已完成切换。

示例已编译验证

/* 判断本代双向密钥和 transport core 均已完成切换。 */
result = xrtSshKexSessionComplete(pSession, pCore);