SECURITY_STATUS nla_encrypt_public_key_echo(rdpNla* nla)
{
	SECURITY_STATUS status;

	WINPR_ASSERT(nla);

	if (!nla_sec_buffer_alloc_from_buffer(&nla->pubKeyAuth, &nla->PublicKey,
	                                      nla->ContextSizes.cbSecurityTrailer))
		return SEC_E_INSUFFICIENT_MEMORY;

	if (!nla->server)
	{
		BYTE* data = &((BYTE*)nla->PublicKey.pvBuffer)[nla->ContextSizes.cbSecurityTrailer];
		/* server echos the public key +1 */
		ap_integer_increment_le(data, nla->PublicKey.cbBuffer);
	}

	status = nla_encrypt(nla, &nla->pubKeyAuth, nla->ContextSizes.cbSecurityTrailer);
	if (status != SEC_E_OK)
		return status;

	return status;
}
SECURITY_STATUS nla_encrypt_public_key_echo(rdpNla* nla)
{
	SECURITY_STATUS status;

	WINPR_ASSERT(nla);

	if (!nla_sec_buffer_alloc_from_buffer(&nla->pubKeyAuth, &nla->PublicKey,
	                                      nla->ContextSizes.cbSecurityTrailer))
		return SEC_E_INSUFFICIENT_MEMORY;

	if (!nla->server)
	{
		BYTE* data = &((BYTE*)nla->PublicKey.pvBuffer)[nla->ContextSizes.cbSecurityTrailer];
		 
		ap_integer_increment_le(data, nla->PublicKey.cbBuffer);
	}

	status = nla_encrypt(nla, &nla->pubKeyAuth, nla->ContextSizes.cbSecurityTrailer);
	if (status != SEC_E_OK)
		return status;

	return status;
}