static SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(PCtxtHandle phContext,
                                                                  ULONG ulAttribute, void* pBuffer)
{
#ifdef WITH_GSSAPI
	if (!phContext)
		return SEC_E_INVALID_HANDLE;

	if (!pBuffer)
		return SEC_E_INSUFFICIENT_MEMORY;

	if (ulAttribute == SECPKG_ATTR_SIZES)
	{
		UINT header, pad, trailer;
		krb5_key key;
		krb5_enctype enctype;
		KRB_CONTEXT* context = (KRB_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
		SecPkgContext_Sizes* ContextSizes = (SecPkgContext_Sizes*)pBuffer;

		WINPR_ASSERT(context);
		WINPR_ASSERT(context->ctx);
		WINPR_ASSERT(context->auth_ctx);

		/* The MaxTokenSize by default is 12,000 bytes. This has been the default value
		 * since Windows 2000 SP2 and still remains in Windows 7 and Windows 2008 R2.
		 *  For Windows Server 2012, the default value of the MaxTokenSize registry
		 *  entry is 48,000 bytes.*/
		ContextSizes->cbMaxToken = KERBEROS_SecPkgInfoA.cbMaxToken;
		ContextSizes->cbMaxSignature = 0;
		ContextSizes->cbBlockSize = 1;
		ContextSizes->cbSecurityTrailer = 0;

		key = context->acceptor_key    ? context->acceptor_key
		      : context->initiator_key ? context->initiator_key
		                               : context->session_key;
		enctype = krb5_k_key_enctype(context->ctx, key);

		if (context->flags & ISC_REQ_CONFIDENTIALITY)
		{
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_HEADER, &header);
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_PADDING, &pad);
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_TRAILER, &trailer);
			/* GSS header (= 16 bytes) + encrypted header = 32 bytes */
			ContextSizes->cbSecurityTrailer = header + pad + trailer + 32;
		}
		if (context->flags & ISC_REQ_INTEGRITY)
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_CHECKSUM,
			                     &ContextSizes->cbMaxSignature);

		return SEC_E_OK;
	}

	WLog_ERR(TAG, "[%s]: TODO: Implement ulAttribute=%08" PRIx32, __FUNCTION__, ulAttribute);
	return SEC_E_UNSUPPORTED_FUNCTION;
#else
	return SEC_E_UNSUPPORTED_FUNCTION;
#endif
}
static SECURITY_STATUS SEC_ENTRY kerberos_QueryContextAttributesA(PCtxtHandle phContext,
                                                                  ULONG ulAttribute, void* pBuffer)
{
#ifdef WITH_GSSAPI
	if (!phContext)
		return SEC_E_INVALID_HANDLE;

	if (!pBuffer)
		return SEC_E_INSUFFICIENT_MEMORY;

	if (ulAttribute == SECPKG_ATTR_SIZES)
	{
		UINT header, pad, trailer;
		krb5_key key;
		krb5_enctype enctype;
		KRB_CONTEXT* context = (KRB_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
		SecPkgContext_Sizes* ContextSizes = (SecPkgContext_Sizes*)pBuffer;

		WINPR_ASSERT(context);
		WINPR_ASSERT(context->ctx);
		WINPR_ASSERT(context->auth_ctx);

		 
		ContextSizes->cbMaxToken = KERBEROS_SecPkgInfoA.cbMaxToken;
		ContextSizes->cbMaxSignature = 0;
		ContextSizes->cbBlockSize = 1;
		ContextSizes->cbSecurityTrailer = 0;

		key = context->acceptor_key    ? context->acceptor_key
		      : context->initiator_key ? context->initiator_key
		                               : context->session_key;
		enctype = krb5_k_key_enctype(context->ctx, key);

		if (context->flags & ISC_REQ_CONFIDENTIALITY)
		{
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_HEADER, &header);
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_PADDING, &pad);
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_TRAILER, &trailer);
			 
			ContextSizes->cbSecurityTrailer = header + pad + trailer + 32;
		}
		if (context->flags & ISC_REQ_INTEGRITY)
			krb5_c_crypto_length(context->ctx, enctype, KRB5_CRYPTO_TYPE_CHECKSUM,
			                     &ContextSizes->cbMaxSignature);

		return SEC_E_OK;
	}

	WLog_ERR(TAG, "[%s]: TODO: Implement ulAttribute=%08" PRIx32, __FUNCTION__, ulAttribute);
	return SEC_E_UNSUPPORTED_FUNCTION;
#else
	return SEC_E_UNSUPPORTED_FUNCTION;
#endif
}