xrtSshSessionCoreInit

初始化连接级协议核心;动态内存只用于 KEX transcript。

bool xrtSshSessionCoreInit( xsshsessioncore* pSession, xnetbufpool* pPool, xsshrole Role, xsshchannelresolveproc pResolve, ptr pUserData, xsshreplyqueue* pGlobalReplies );
参数说明
xsshsessioncore* pSession会话对象
xnetbufpool* pPool池
xsshrole Role本地角色
xsshchannelresolveproc pResolveResolve 参数
ptr pUserData透传用户数据
xsshreplyqueue* pGlobalRepliesGlobalReles 参数
返回:初始化连接级协议核心;动态内存只用于 KEX transcript。

示例已编译验证

sshsessioncoreinit obj;
xrtSshSessionCoreInit(&obj, pSession, pPool, Role, pResolve, pUserData, pGlobalReplies);

xrtSshSessionCoreClear

释放 transcript、清除密码材料和全部借用事务,不处理 transport 或外部存储。

void xrtSshSessionCoreClear(xsshsessioncore* pSession);
参数说明
xsshsessioncore* pSession会话对象
返回:释放 transcript、清除密码材料和全部借用事务,不处理 transport 或外部存储。

示例已编译验证

/* 释放 transcript、清除密码材料和全部借用事务,不处理 transport 或外部存储。 */
result = xrtSshSessionCoreClear(pSession);

xrtSshSessionCorePhase

根据连接级对象和 transport 返回当前协议阶段。

xsshsessionphase xrtSshSessionCorePhase( const xsshsessioncore* pSession, const xsshtransportcore* pCore );
参数说明
const xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:根据连接级对象和 transport 返回当前协议阶段。

示例已编译验证

/* 根据连接级对象和 transport 返回当前协议阶段。 */
result = xrtSshSessionCorePhase(pSession, pCore);

xrtSshSessionCoreAction

返回稳定状态下建议驱动的下一动作;本端 identification 与 KEXINIT 优先于等待对端。

xsshsessionaction xrtSshSessionCoreAction( const xsshsessioncore* pSession, const xsshtransportcore* pCore );
参数说明
const xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:返回稳定状态下建议驱动的下一动作;本端 identification 与 KEXINIT 优先于等待对端。

示例已编译验证

/* 返回稳定状态下建议驱动的下一动作;本端 identification 与 KEXINIT 优先于等待对端。 */
result = xrtSshSessionCoreAction(pSession, pCore);

xrtSshSessionCoreKex

返回可直接使用的 KEX 交换对象。

xsshkexexchange* xrtSshSessionCoreKex( xsshsessioncore* pSession );
参数说明
xsshsessioncore* pSession会话对象
返回:返回可直接使用的 KEX 交换对象。

示例已编译验证

/* 返回可直接使用的 KEX 交换对象。 */
result = xrtSshSessionCoreKex(pSession);

xrtSshSessionCoreKexConst

返回只读 KEX 交换对象。

const xsshkexexchange* xrtSshSessionCoreKexConst( const xsshsessioncore* pSession );
参数说明
const xsshsessioncore* pSession会话对象
返回:返回只读 KEX 交换对象。

示例已编译验证

/* 返回只读 KEX 交换对象。 */
result = xrtSshSessionCoreKexConst(pSession);

xrtSshSessionCoreAuth

返回认证会话;认证方法和凭据策略仍由调用方驱动。

xsshauthsession* xrtSshSessionCoreAuth( xsshsessioncore* pSession );
参数说明
xsshsessioncore* pSession会话对象
返回:返回认证会话;认证方法和凭据策略仍由调用方驱动。

示例已编译验证

/* 返回认证会话;认证方法和凭据策略仍由调用方驱动。 */
result = xrtSshSessionCoreAuth(pSession);

xrtSshSessionCoreAuthConst

返回只读认证会话。

const xsshauthsession* xrtSshSessionCoreAuthConst( const xsshsessioncore* pSession );
参数说明
const xsshsessioncore* pSession会话对象
返回:返回只读认证会话。

示例已编译验证

/* 返回只读认证会话。 */
result = xrtSshSessionCoreAuthConst(pSession);

xrtSshSessionCoreConnection

返回 connection 会话;channel 表和 reply FIFO 仍由调用方持有。

xsshconnectionsession* xrtSshSessionCoreConnection( xsshsessioncore* pSession );
参数说明
xsshsessioncore* pSession会话对象
返回:返回 connection 会话;channel 表和 reply FIFO 仍由调用方持有。

示例已编译验证

/* 返回 connection 会话;channel 表和 reply FIFO 仍由调用方持有。 */
result = xrtSshSessionCoreConnection(pSession);

xrtSshSessionCoreConnectionConst

返回只读 connection 会话。

const xsshconnectionsession* xrtSshSessionCoreConnectionConst( const xsshsessioncore* pSession );
参数说明
const xsshsessioncore* pSession会话对象
返回:返回只读 connection 会话。

示例已编译验证

/* 返回只读 connection 会话。 */
result = xrtSshSessionCoreConnectionConst(pSession);

xrtSshSessionCoreVersionPrepare

在 transport identification 提交前保存本端或对端版本串。

xsshcode xrtSshSessionCoreVersionPrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xsshtransportdirection Direction, xstrview Version );
参数说明
xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
xsshtransportdirection Direction半关闭方向
xstrview Version版本
返回:在 transport identification 提交前保存本端或对端版本串。

示例已编译验证

/* 在 transport identification 提交前保存本端或对端版本串。 */
result = xrtSshSessionCoreVersionPrepare(pSession, pCore, Direction, Version);

xrtSshSessionCoreVersionCommit

transport 已提交对应 identification 后发布版本串。

xsshcode xrtSshSessionCoreVersionCommit( xsshsessioncore* pSession, const xsshtransportcore* pCore );
参数说明
xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:transport 已提交对应 identification 后发布版本串。

示例已编译验证

/* transport 已提交对应 identification 后发布版本串。 */
result = xrtSshSessionCoreVersionCommit(pSession, pCore);

xrtSshSessionCoreVersionAbort

transport 尚未推进时放弃版本串暂存副本。

xsshcode xrtSshSessionCoreVersionAbort( xsshsessioncore* pSession, const xsshtransportcore* pCore );
参数说明
xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:transport 尚未推进时放弃版本串暂存副本。

示例已编译验证

/* transport 尚未推进时放弃版本串暂存副本。 */
result = xrtSshSessionCoreVersionAbort(pSession, pCore);

xrtSshSessionCoreKexBeginWithPrivate

使用显式 Curve25519 私钥开始当前已经就绪的一代 KEX。

xsshcode xrtSshSessionCoreKexBeginWithPrivate( xsshsessioncore* pSession, xsshtransportcore* pCore, xbytesview ServerHostKey, xbytesview PrivateKey );
参数说明
xsshsessioncore* pSession会话对象
xsshtransportcore* pCore核心对象
xbytesview ServerHostKeyServerHostKey 参数
xbytesview PrivateKeyPrvateKey 参数
返回:使用显式 Curve25519 私钥开始当前已经就绪的一代 KEX。

示例已编译验证

/* 使用显式 Curve25519 私钥开始当前已经就绪的一代 KEX。 */
result = xrtSshSessionCoreKexBeginWithPrivate(pSession, pCore, ServerHostKey, PrivateKey);

xrtSshSessionCoreAuthBegin

首轮 KEX 完成后开始双端 ssh-userauth 编排。

xsshcode xrtSshSessionCoreAuthBegin( xsshsessioncore* pSession, const xsshtransportcore* pCore, const xsshauthguardpolicy* pPolicy, uint64 iNowMs );
参数说明
xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
const xsshauthguardpolicy* pPolicy策略
uint64 iNowMs当前毫秒时间
返回:首轮 KEX 完成后开始双端 ssh-userauth 编排。

示例已编译验证

/* 首轮 KEX 完成后开始双端 ssh-userauth 编排。 */
result = xrtSshSessionCoreAuthBegin(pSession, pCore, pPolicy, iNowMs);

xrtSshSessionCoreWritePrepare

XRT_API xsshcode xrtSshSessionCoreWritePrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload, xsshchannelcore* pChannel, xsshreplyqueue* pReplies, uint64 iReplyToken, uint64 iNowMs, xsshsessionpacketkind* pKind );

;
返回:XRT_API xsshcode xrtSshSessionCoreWritePrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload, xsshchannelcore* pChannel, xsshreplyqueue* pReplies, uint64 iReplyToken, uint64 iNowMs, xsshsessionpacketkind* pKind );

示例已编译验证

/* XRT_API xsshcode xrtSshSessionCoreWritePrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload, xsshchannelcore* pChannel, xsshreplyqueue* pReplies, uint64 iReplyToken, uint64 iNowMs, xsshsessionpacketkind* pKind ); */
result = xrtSshSessionCoreWritePrepare();

xrtSshSessionCoreWriteBind

transport 已准备同一 payload 后绑定 packet 类型和序号,尚不推进状态。

xsshcode xrtSshSessionCoreWriteBind( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload );
参数说明
xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
xbytesview Payload负载
返回:transport 已准备同一 payload 后绑定 packet 类型和序号,尚不推进状态。

示例已编译验证

/* transport 已准备同一 payload 后绑定 packet 类型和序号,尚不推进状态。 */
result = xrtSshSessionCoreWriteBind(pSession, pCore, Payload);

xrtSshSessionCoreWriteCommit

transport 已可靠提交输出后提交对应 KEX、认证或 connection 事务。

xsshcode xrtSshSessionCoreWriteCommit( xsshsessioncore* pSession, xsshtransportcore* pCore, uint64 iNowMs );
参数说明
xsshsessioncore* pSession会话对象
xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
返回:transport 已可靠提交输出后提交对应 KEX、认证或 connection 事务。

示例已编译验证

/* transport 已可靠提交输出后提交对应 KEX、认证或 connection 事务。 */
result = xrtSshSessionCoreWriteCommit(pSession, pCore, iNowMs);

xrtSshSessionCoreWriteAbort

transport 未推进时放弃上层写事务;transport 自身仍由调用方中止。

xsshcode xrtSshSessionCoreWriteAbort( xsshsessioncore* pSession, const xsshtransportcore* pCore );
参数说明
xsshsessioncore* pSession会话对象
const xsshtransportcore* pCore核心对象
返回:transport 未推进时放弃上层写事务;transport 自身仍由调用方中止。

示例已编译验证

/* transport 未推进时放弃上层写事务;transport 自身仍由调用方中止。 */
result = xrtSshSessionCoreWriteAbort(pSession, pCore);

xrtSshSessionCoreReadPrepare

XRT_API xsshcode xrtSshSessionCoreReadPrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload, void* pHostKeyStorage, size_t iHostKeyCapacity, size_t* pHostKeySize, uint64 iNowMs, xsshsessionpacket* pPacket );

;
返回:XRT_API xsshcode xrtSshSessionCoreReadPrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload, void* pHostKeyStorage, size_t iHostKeyCapacity, size_t* pHostKeySize, uint64 iNowMs, xsshsessionpacket* pPacket );

示例已编译验证

/* XRT_API xsshcode xrtSshSessionCoreReadPrepare( xsshsessioncore* pSession, const xsshtransportcore* pCore, xbytesview Payload, void* pHostKeyStorage, size_t iHostKeyCapacity, size_t* pHostKeySize, uint64 iNowMs, xsshsessionpacket* pPacket ); */
result = xrtSshSessionCoreReadPrepare();

xrtSshSessionCoreReadCommit

transport 已提交输入后提交上层事务并按需激活读密钥。

xsshcode xrtSshSessionCoreReadCommit( xsshsessioncore* pSession, xsshtransportcore* pCore, uint64 iNowMs );
参数说明
xsshsessioncore* pSession会话对象
xsshtransportcore* pCore核心对象
uint64 iNowMs当前毫秒时间
返回:transport 已提交输入后提交上层事务并按需激活读密钥。

示例已编译验证

/* transport 已提交输入后提交上层事务并按需激活读密钥。 */
result = xrtSshSessionCoreReadCommit(pSession, pCore, iNowMs);

xrtSshSessionCoreReadAbort

放弃不可回滚的认证输入并终止会话;transport 自身仍由调用方中止。

xsshcode xrtSshSessionCoreReadAbort(xsshsessioncore* pSession);
参数说明
xsshsessioncore* pSession会话对象
返回:放弃不可回滚的认证输入并终止会话;transport 自身仍由调用方中止。

示例已编译验证

/* 放弃不可回滚的认证输入并终止会话;transport 自身仍由调用方中止。 */
result = xrtSshSessionCoreReadAbort(pSession);

xrtSshSessionCoreFail

终止全部协议子状态;transport、网络和外部 channel 由调用方关闭。

void xrtSshSessionCoreFail(xsshsessioncore* pSession);
参数说明
xsshsessioncore* pSession会话对象
返回:终止全部协议子状态;transport、网络和外部 channel 由调用方关闭。

示例已编译验证

/* 终止全部协议子状态;transport、网络和外部 channel 由调用方关闭。 */
result = xrtSshSessionCoreFail(pSession);