接受上下文之后,sign_server() 将接收客户机已发送的消息。由于 GSS-API 不提供用于接收令牌的函数,因此程序将使用 recv_token() 函数:
if (recv_token(s, &xmit_buf) < 0) return(-1);
由于消息可能已经过加密,因此程序将使用 GSS-API 函数 gss_unwrap() 来展开消息:
maj_stat = gss_unwrap(&min_stat, context, &xmit_buf, &msg_buf, &conf_state, (gss_qop_t *) NULL); if (maj_stat != GSS_S_COMPLETE) { display_status("unwrapping message", maj_stat, min_stat); return(-1); } else if (! conf_state) { fprintf(stderr, "Warning! Message not encrypted.\n"); } (void) gss_release_buffer(&min_stat, &xmit_buf);
gss_unwrap() 会提取 recv_token() 已经放在 xmit_buf 中的消息,转换该消息并将结果放在 msg_buf 中。请注意 gss_unwrap() 的两个参数。conf_state 标志用于指明是否已经向该消息应用了保密性(即加密)。最后一个 NULL 表示程序无需知道用于保护该消息的 QOP。