xrtSshKexTranscriptInit
校验四段 transcript 借用视图;调用方保证其存活到本轮 KEX 完成。
| 参数 | 说明 |
|---|---|
| xsshkextranscript* pTranscript | Transcrt 参数 |
| xbytesview ClientVersion | 客户端版本 |
| xbytesview ServerVersion | ServerVerson 参数 |
| xbytesview ClientKexInit | 客户端 KEX 初始化 |
| xbytesview ServerKexInit | ServerKexInt 参数 |
示例已编译验证
sshkextranscriptinit obj; xrtSshKexTranscriptInit(&obj, pTranscript, ClientVersion, ServerVersion, ClientKexInit, ServerKexInit);
xrtSshKexTranscriptMeasure
计算复制完整 transcript 所需的精确字节数。
| 参数 | 说明 |
|---|---|
| const xsshkextranscript* pTranscript | Transcrt 参数 |
| size_t* pSize | 出:大小 |
示例已编译验证
/* 计算复制完整 transcript 所需的精确字节数。 */ result = xrtSshKexTranscriptMeasure(pTranscript, pSize);
xrtSshKexTranscriptWrite
将 transcript 追加到 writer,并返回借用 writer 输出的稳定视图。
| 参数 | 说明 |
|---|---|
| xsshwriter* pWriter | 写入器 |
| const xsshkextranscript* pInput | 输入 |
| xsshkextranscript* pOutput | 出:输出缓冲 |
示例已编译验证
/* 将 transcript 追加到 writer,并返回借用 writer 输出的稳定视图。 */ result = xrtSshKexTranscriptWrite(pWriter, pInput, pOutput);
xrtSshKexSessionInit
初始化可重复执行初始 KEX 和 rekey 的确定性会话。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| xsshrole Role | 本地角色 |
示例已编译验证
sshkexsessioninit obj; xrtSshKexSessionInit(&obj, pSession, Role);
xrtSshKexSessionClear
安全清除临时私钥、共享秘密、派生密钥和 SessionId。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
示例已编译验证
/* 安全清除临时私钥、共享秘密、派生密钥和 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 ); */ result = xrtSshKexSessionBeginWithPrivate();
xrtSshKexSessionEvent
返回当前最常见的下一动作,不推进任何状态。
| 参数 | 说明 |
|---|---|
| const xsshkexsession* pSession | 会话对象 |
示例已编译验证
/* 返回当前最常见的下一动作,不推进任何状态。 */ result = xrtSshKexSessionEvent(pSession);
xrtSshKexSessionNegotiation
返回本代协商结果;视图借用 transcript。
| 参数 | 说明 |
|---|---|
| const xsshkexsession* pSession | 会话对象 |
| xsshkexnegotiation* pNegotiation | Negotaton 参数 |
示例已编译验证
/* 返回本代协商结果;视图借用 transcript。 */ result = xrtSshKexSessionNegotiation(pSession, pNegotiation);
xrtSshKexSessionExchangeHash
返回本代 exchange hash,服务端可交给本地密钥或 HSM 签名。
| 参数 | 说明 |
|---|---|
| const xsshkexsession* pSession | 会话对象 |
| xbytesview* pHash | 哈希回调 |
示例已编译验证
/* 返回本代 exchange hash,服务端可交给本地密钥或 HSM 签名。 */ result = xrtSshKexSessionExchangeHash(pSession, pHash);
xrtSshKexSessionId
返回首次 exchange hash 固化的 SessionId。
| 参数 | 说明 |
|---|---|
| const xsshkexsession* pSession | 会话对象 |
| xbytesview* pSessionId | SessonId 参数 |
示例已编译验证
/* 返回首次 exchange hash 固化的 SessionId。 */ result = xrtSshKexSessionId(pSession, pSessionId);
xrtSshKexSessionHostKey
返回已完成密码学验签、等待信任策略确认的服务端主机公钥。
| 参数 | 说明 |
|---|---|
| const xsshkexsession* pSession | 会话对象 |
| xbytesview* pHostKey | HostKey 参数 |
示例已编译验证
/* 返回已完成密码学验签、等待信任策略确认的服务端主机公钥。 */ result = xrtSshKexSessionHostKey(pSession, pHostKey);
xrtSshKexSessionHostKeyAccept
客户端确认主机密钥信任;之后才允许发送 NEWKEYS。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
示例已编译验证
/* 客户端确认主机密钥信任;之后才允许发送 NEWKEYS。 */ result = xrtSshKexSessionHostKeyAccept(pSession);
xrtSshKexSessionFail
将会话置为不可继续状态并安全清除本代秘密。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
示例已编译验证
/* 将会话置为不可继续状态并安全清除本代秘密。 */ result = xrtSshKexSessionFail(pSession);
xrtSshKexSessionEcdhInitPrepare
客户端准备 SSH_MSG_KEX_ECDH_INIT;可靠提交后调用 WriteCommit。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| xsshwriter* pWriter | 写入器 |
示例已编译验证
sshkexsessionecdhinitprepare obj; xrtSshKexSessionEcdhInitPrepare(&obj, pSession, pWriter);
xrtSshKexSessionEcdhReplyPrepare
服务端用外部签名 blob 准备 SSH_MSG_KEX_ECDH_REPLY。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| xsshwriter* pWriter | 写入器 |
| xbytesview Signature | 签名 |
示例已编译验证
/* 服务端用外部签名 blob 准备 SSH_MSG_KEX_ECDH_REPLY。 */ result = xrtSshKexSessionEcdhReplyPrepare(pSession, pWriter, Signature);
xrtSshKexSessionNewKeysPrepare
准备 SSH_MSG_NEWKEYS;方法交换和客户端主机信任必须已完成。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| xsshwriter* pWriter | 写入器 |
示例已编译验证
/* 准备 SSH_MSG_NEWKEYS;方法交换和客户端主机信任必须已完成。 */ result = xrtSshKexSessionNewKeysPrepare(pSession, pWriter);
xrtSshKexSessionWriteCommit
transport core 已可靠提交当前输出后提交 KEX 写事务。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| const xsshtransportcore* pCore | 核心对象 |
示例已编译验证
/* transport core 已可靠提交当前输出后提交 KEX 写事务。 */ result = xrtSshKexSessionWriteCommit(pSession, pCore);
xrtSshKexSessionWriteAbort
放弃尚未交给 transport 的 KEX 输出,不消费任何会话状态。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
示例已编译验证
/* 放弃尚未交给 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 ); */ result = xrtSshKexSessionReadPrepare();
xrtSshKexSessionReadCommit
transport core 已提交当前输入后提交 KEX 读事务。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| const xsshtransportcore* pCore | 核心对象 |
示例已编译验证
/* transport core 已提交当前输入后提交 KEX 读事务。 */ result = xrtSshKexSessionReadCommit(pSession, pCore);
xrtSshKexSessionReadAbort
放弃已认证 KEX 输入并终止会话;对应 transport 也必须关闭。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
示例已编译验证
/* 放弃已认证 KEX 输入并终止会话;对应 transport 也必须关闭。 */ result = xrtSshKexSessionReadAbort(pSession);
xrtSshKexSessionActivateWrite
本端 NEWKEYS 提交后,把角色对应的派生密钥装入写 codec。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| xsshtransportcore* pCore | 核心对象 |
| uint64 iNowMs | 当前毫秒时间 |
示例已编译验证
/* 本端 NEWKEYS 提交后,把角色对应的派生密钥装入写 codec。 */ result = xrtSshKexSessionActivateWrite(pSession, pCore, iNowMs);
xrtSshKexSessionActivateRead
对端 NEWKEYS 提交后,把角色对应的派生密钥装入读 codec。
| 参数 | 说明 |
|---|---|
| xsshkexsession* pSession | 会话对象 |
| xsshtransportcore* pCore | 核心对象 |
| uint64 iNowMs | 当前毫秒时间 |
示例已编译验证
/* 对端 NEWKEYS 提交后,把角色对应的派生密钥装入读 codec。 */ result = xrtSshKexSessionActivateRead(pSession, pCore, iNowMs);
xrtSshKexSessionComplete
判断本代双向密钥和 transport core 均已完成切换。
| 参数 | 说明 |
|---|---|
| const xsshkexsession* pSession | 会话对象 |
| const xsshtransportcore* pCore | 核心对象 |
示例已编译验证
/* 判断本代双向密钥和 transport core 均已完成切换。 */ result = xrtSshKexSessionComplete(pSession, pCore);