Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
September 2021
- 83 participants
- 2758 messages
[PATCH vkd3d] vkd3d: Only disable raster based on SO stream if SO is used.
by Conor McCarthy
Fixes the black screen problem in Diablo 2: Resurrected.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51105
From: Robin Kertels <robin.kertels(a)gmail.com>
Signed-off-by: Conor McCarthy <cmccarthy(a)codeweavers.com>
---
libs/vkd3d/command.c | 2 +-
libs/vkd3d/state.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 9f4a4149..186e4370 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -6065,7 +6065,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_queue_Wait(ID3D12CommandQueue *if
}
else
{
- FIXME("Failed to acquire Vulkan semaphore for fence %p, value %#"PRIx64
+ FIXME_ONCE("Failed to acquire Vulkan semaphore for fence %p, value %#"PRIx64
", completed value %#"PRIx64".\n", fence, value, completed_value);
}
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 9e554b44..73c78d06 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2629,7 +2629,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
rs_desc_from_d3d12(&graphics->rs_desc, &desc->RasterizerState);
have_attachment = graphics->rt_count || graphics->dsv_format || is_dsv_format_unknown;
if ((!have_attachment && !(desc->PS.pShaderBytecode && desc->PS.BytecodeLength))
- || so_desc->RasterizedStream == D3D12_SO_NO_RASTERIZED_STREAM)
+ || (so_desc->NumEntries != 0 && so_desc->RasterizedStream == D3D12_SO_NO_RASTERIZED_STREAM))
graphics->rs_desc.rasterizerDiscardEnable = VK_TRUE;
rs_stream_info_from_d3d12(&graphics->rs_stream_info, &graphics->rs_desc, so_desc, vk_info);
--
2.32.0
Sept. 30, 2021
Re: [PATCH 1/3] krnl386: Call DOSVM_IntProcRelay() via the application stack.
by Zebediah Figura (she/her)
On 9/29/21 13:25, Stefan Dösinger wrote:
> Am Mittwoch, 29. September 2021, 20:39:25 EAT schrieb Zebediah Figura (she/
> her):
>> On 9/28/21 21:59, Chip Davis wrote:
>>> September 28, 2021 8:39 PM, "Zebediah Figura" <zfigura(a)codeweavers.com>
> wrote:
>>>> The dedicated stack was introduced by
>>>> 9d7ff6c85b0827b7f54989050b4c34f1f459e94d, in order to support
>>>> potentially nested DPMI interrupts. DPMI support was removed by
>>>> ed6bdb3c51cd4b8c94f9839806321703e7aa9765; hence there is no longer a
>>>> reason to account for nested interrupts.
>>>
>>> Isn't protected-mode Win16 a DPMI environment itself? In fact, it's why MS
>>> created DPMI in the first place.
>> On Windows, yes, but as far as I understand it is not on Wine. I believe
>> that our protected mode tasks never ran in virtual-8086 mode, and the
>> DPMI support we had for them was removed by commits at about the same
>> time as ed6bdb3c5.
>>
>> My understanding of this area is definitely fuzzy, though, so I might
>> have things wrong.
>
> I think Zeb's wording is slightly wrong. My understanding is that "DPMI" is
> sort of the syscall interface of Win3x / Win9x. A process can ask the kernel
> for certain changes to its "virtual machine". Wine implements a pile of those
> syscalls in dlls/krnl386.exe16/int31.c. I'd expect Win9x's kernel32.dll to use
> those kinds of calls to implement stuff like VirtualAlloc() and
> MapViewOfFile().
>
> What ed6bdb3c51 removed is the ability to call real mode code from a DPMI
> client. I was expecting to see some vm86() call somewhere, but can't find it,
> so I probably misunderstand. I also don't know how Windows (9x, and even more
> so NT) handled this. It could be done via vm86 or by switching the CPU back
> into actual real mode. DOS programs would need to do this kind of real mode
> call to call DOS services. Windows brings its own so called dos extender with
> it that wraps DOS APIs for you, and you aren't supposed to use DOS APIs
> anyway.
>
> Now does that mean Zeb's patch is right or wrong? I have no clue...
>
Well, my wording was wrong, or my understanding was :-)
I've gone back and stared at the old code some more, and I think I have
a better idea of how it's supposed to work now.
I believe that ed6bdb3c51 isn't the relevant commit at all, but rather
5ec5449596 is. Trying to untangle how the IRQ code worked is difficult,
but it doesn't particularly matter, because after 5ec5449596, we aren't
triggering any DPMI IRQs anymore, so we can't get nested interrupts (not
even with an STI with pending events). We can only get interrupts
triggered by an INT instruction.
Wrt the vm86() call, I believe that DOSVM_CallRMProc()/DOSVM_CallRMInt()
basically does a WOWCallback16Ex() with the VM86 flag set. Before
5e0fd3403e, that would trigger a call to __wine_enter_vm86 in ntdll,
which would perform the vm86() call.
Sept. 30, 2021
Re: [PATCH 2/2] secur32: Remove macOS backend.
by Gijs Vermeulen
Op wo 29 sep. 2021 om 23:39 schreef Marvin <testbot(a)winehq.org>:
> Hi,
>
> While running your changed tests, I think I found new failures.
> Being a bot and all I'm not very good at pattern recognition, so I might be
> wrong, but could you please double-check?
>
> Full results can be found at:
> https://testbot.winehq.org/JobDetails.pl?Key=99097
>
> Your paranoid android.
>
>
> === debiant2 (build log) ===
>
> error: patch failed: dlls/secur32/schannel_macosx.c:1
> Task: Patch failed to apply
>
> === debiant2 (build log) ===
>
> error: patch failed: dlls/secur32/schannel_macosx.c:1
> Task: Patch failed to apply
>
The testbot was not yet updated.
Sept. 29, 2021
[PATCH 5/5] wined3d: Do not return a struct upload_bo from the map_upload_bo callback.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/cs.c | 26 ++++++++------------------
dlls/wined3d/wined3d_private.h | 2 +-
2 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 4456f84f0a3..f22009cf1c8 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2462,17 +2462,15 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
{
unsigned int row_pitch, slice_pitch;
struct wined3d_cs_map *op;
- struct upload_bo bo;
HRESULT hr;
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
&& (*map_ptr = context->ops->map_upload_bo(context, resource,
- sub_resource_idx, box, row_pitch, slice_pitch, flags, &bo)))
+ sub_resource_idx, box, row_pitch, slice_pitch, flags)))
{
- TRACE("Returning upload bo %s, map pointer %p, row pitch %u, slice pitch %u.\n",
- debug_const_bo_address(&bo.addr), *map_ptr, row_pitch, slice_pitch);
+ TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n", *map_ptr, row_pitch, slice_pitch);
return WINED3D_OK;
}
@@ -2735,7 +2733,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
void *map_ptr;
if ((map_ptr = context->ops->map_upload_bo(context, resource, sub_resource_idx, box,
- row_pitch, slice_pitch, WINED3D_MAP_WRITE, &bo)))
+ row_pitch, slice_pitch, WINED3D_MAP_WRITE)))
{
wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch,
box->right - box->left, box->bottom - box->top, box->back - box->front);
@@ -3056,7 +3054,7 @@ static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wi
static void *wined3d_cs_map_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
- unsigned int slice_pitch, uint32_t flags, struct upload_bo *bo)
+ unsigned int slice_pitch, uint32_t flags)
{
/* FIXME: We would like to return mapped or newly allocated memory here. */
return NULL;
@@ -3498,12 +3496,12 @@ static struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3
static void *wined3d_deferred_context_map_upload_bo(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
- unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct upload_bo *bo)
+ unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags)
{
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
const struct wined3d_format *format = resource->format;
struct wined3d_deferred_upload *upload;
- uint8_t *sysmem, *map_ptr;
+ uint8_t *sysmem;
size_t size;
size = (box->back - box->front - 1) * slice_pitch
@@ -3527,11 +3525,7 @@ static void *wined3d_deferred_context_map_upload_bo(struct wined3d_device_contex
if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
{
upload->upload_flags = 0;
- map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
- bo->addr.buffer_object = 0;
- bo->addr.addr = map_ptr;
- bo->flags = 0;
- return map_ptr;
+ return (void *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
}
return NULL;
@@ -3552,11 +3546,7 @@ static void *wined3d_deferred_context_map_upload_bo(struct wined3d_device_contex
upload->sysmem = sysmem;
upload->box = *box;
- bo->addr.buffer_object = 0;
- map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT);
- bo->addr.addr = map_ptr;
- bo->flags = UPLOAD_BO_UPLOAD_ON_UNMAP;
- return map_ptr;
+ return (void *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
}
static bool wined3d_deferred_context_unmap_upload_bo(struct wined3d_device_context *context,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9e6c7249b3a..9c19894ab77 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4742,7 +4742,7 @@ struct wined3d_device_context_ops
unsigned int start_idx, unsigned int count, const void *constants);
void *(*map_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
- unsigned int slice_pitch, uint32_t flags, struct upload_bo *upload_bo);
+ unsigned int slice_pitch, uint32_t flags);
bool (*unmap_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *upload_bo);
void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags);
--
2.33.0
Sept. 29, 2021
[PATCH 4/5] wined3d: Call the unmap_upload_bo callback in wined3d_device_context_emit_update_sub_resource().
by Zebediah Figura
We will need to mark the resource as no longer mapped, from the client's
perspective.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/cs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index c3b0343bed2..4456f84f0a3 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2730,6 +2730,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
const void *data, unsigned int row_pitch, unsigned int slice_pitch)
{
struct wined3d_cs_update_sub_resource *op;
+ struct wined3d_box dummy_box;
struct upload_bo bo;
void *map_ptr;
@@ -2738,6 +2739,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
{
wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch,
box->right - box->left, box->bottom - box->top, box->back - box->front);
+ context->ops->unmap_upload_bo(context, resource, sub_resource_idx, &dummy_box, &bo);
wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &bo, row_pitch, slice_pitch);
return;
}
--
2.33.0
Sept. 29, 2021
[PATCH 3/5] wined3d: Rename {prepare, get}_upload_bo() to {map, unmap}_upload_bo().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/cs.c | 26 +++++++++++++-------------
dlls/wined3d/wined3d_private.h | 4 ++--
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 626dd0ac132..c3b0343bed2 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2468,7 +2468,7 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
- && (*map_ptr = context->ops->prepare_upload_bo(context, resource,
+ && (*map_ptr = context->ops->map_upload_bo(context, resource,
sub_resource_idx, box, row_pitch, slice_pitch, flags, &bo)))
{
TRACE("Returning upload bo %s, map pointer %p, row pitch %u, slice pitch %u.\n",
@@ -2514,7 +2514,7 @@ HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context
struct upload_bo bo;
HRESULT hr;
- if (context->ops->get_upload_bo(context, resource, sub_resource_idx, &box, &bo))
+ if (context->ops->unmap_upload_bo(context, resource, sub_resource_idx, &box, &bo))
{
unsigned int row_pitch, slice_pitch;
@@ -2733,7 +2733,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
struct upload_bo bo;
void *map_ptr;
- if ((map_ptr = context->ops->prepare_upload_bo(context, resource, sub_resource_idx, box,
+ if ((map_ptr = context->ops->map_upload_bo(context, resource, sub_resource_idx, box,
row_pitch, slice_pitch, WINED3D_MAP_WRITE, &bo)))
{
wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch,
@@ -3052,7 +3052,7 @@ static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wi
{
}
-static void *wined3d_cs_prepare_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
+static void *wined3d_cs_map_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
unsigned int slice_pitch, uint32_t flags, struct upload_bo *bo)
{
@@ -3060,7 +3060,7 @@ static void *wined3d_cs_prepare_upload_bo(struct wined3d_device_context *context
return NULL;
}
-static bool wined3d_cs_get_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
+static bool wined3d_cs_unmap_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *bo)
{
return false;
@@ -3072,8 +3072,8 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_st_submit,
wined3d_cs_st_finish,
wined3d_cs_st_push_constants,
- wined3d_cs_prepare_upload_bo,
- wined3d_cs_get_upload_bo,
+ wined3d_cs_map_upload_bo,
+ wined3d_cs_unmap_upload_bo,
wined3d_cs_issue_query,
wined3d_cs_flush,
wined3d_cs_acquire_resource,
@@ -3199,8 +3199,8 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_mt_submit,
wined3d_cs_mt_finish,
wined3d_cs_mt_push_constants,
- wined3d_cs_prepare_upload_bo,
- wined3d_cs_get_upload_bo,
+ wined3d_cs_map_upload_bo,
+ wined3d_cs_unmap_upload_bo,
wined3d_cs_issue_query,
wined3d_cs_flush,
wined3d_cs_acquire_resource,
@@ -3494,7 +3494,7 @@ static struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3
return NULL;
}
-static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_context *context,
+static void *wined3d_deferred_context_map_upload_bo(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct upload_bo *bo)
{
@@ -3557,7 +3557,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
return map_ptr;
}
-static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context *context,
+static bool wined3d_deferred_context_unmap_upload_bo(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *bo)
{
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
@@ -3619,8 +3619,8 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
wined3d_deferred_context_submit,
wined3d_deferred_context_finish,
wined3d_deferred_context_push_constants,
- wined3d_deferred_context_prepare_upload_bo,
- wined3d_deferred_context_get_upload_bo,
+ wined3d_deferred_context_map_upload_bo,
+ wined3d_deferred_context_unmap_upload_bo,
wined3d_deferred_context_issue_query,
wined3d_deferred_context_flush,
wined3d_deferred_context_acquire_resource,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5a5c6c9c0a3..9e6c7249b3a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4740,10 +4740,10 @@ struct wined3d_device_context_ops
void (*finish)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p,
unsigned int start_idx, unsigned int count, const void *constants);
- void *(*prepare_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ void *(*map_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
unsigned int slice_pitch, uint32_t flags, struct upload_bo *upload_bo);
- bool (*get_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ bool (*unmap_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *upload_bo);
void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags);
void (*flush)(struct wined3d_device_context *context);
--
2.33.0
Sept. 29, 2021
[PATCH 2/5] wined3d: Separate a resource_offset_map_pointer() helper.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/resource.c | 26 ++++++++++++++++++++++++++
dlls/wined3d/texture.c | 22 +---------------------
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 3d24d375bc8..8f31996595c 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -586,3 +586,29 @@ VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags)
return flags;
}
+
+void *resource_offset_map_pointer(struct wined3d_resource *resource, unsigned int sub_resource_idx,
+ uint8_t *base_memory, const struct wined3d_box *box)
+{
+ const struct wined3d_format *format = resource->format;
+ unsigned int row_pitch, slice_pitch;
+
+ wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
+
+ if ((resource->format_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
+ {
+ /* Compressed textures are block based, so calculate the offset of
+ * the block that contains the top-left pixel of the mapped box. */
+ return base_memory
+ + (box->front * slice_pitch)
+ + ((box->top / format->block_height) * row_pitch)
+ + ((box->left / format->block_width) * format->block_byte_count);
+ }
+ else
+ {
+ return base_memory
+ + (box->front * slice_pitch)
+ + (box->top * row_pitch)
+ + (box->left * format->byte_count);
+ }
+}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index f9babc6e28f..db32274960f 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -3466,11 +3466,8 @@ static void texture_resource_sub_resource_get_map_pitch(struct wined3d_resource
static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
void **map_ptr, const struct wined3d_box *box, DWORD flags)
{
- const struct wined3d_format *format = resource->format;
struct wined3d_texture_sub_resource *sub_resource;
struct wined3d_device *device = resource->device;
- unsigned int fmt_flags = resource->format_flags;
- unsigned int row_pitch, slice_pitch;
struct wined3d_context *context;
struct wined3d_texture *texture;
struct wined3d_bo_address data;
@@ -3537,24 +3534,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
context_release(context);
- texture_resource_sub_resource_get_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
-
- if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
- {
- /* Compressed textures are block based, so calculate the offset of
- * the block that contains the top-left pixel of the mapped box. */
- *map_ptr = base_memory
- + (box->front * slice_pitch)
- + ((box->top / format->block_height) * row_pitch)
- + ((box->left / format->block_width) * format->block_byte_count);
- }
- else
- {
- *map_ptr = base_memory
- + (box->front * slice_pitch)
- + (box->top * row_pitch)
- + (box->left * format->byte_count);
- }
+ *map_ptr = resource_offset_map_pointer(resource, sub_resource_idx, base_memory, box);
if (texture->swapchain && texture->swapchain->front_buffer == texture)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 520eb968eb6..5a5c6c9c0a3 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4165,6 +4165,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
unsigned int bind_flags, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
+void *resource_offset_map_pointer(struct wined3d_resource *resource, unsigned int sub_resource_idx,
+ uint8_t *base_memory, const struct wined3d_box *box) DECLSPEC_HIDDEN;
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT wined3d_resource_check_box_dimensions(struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box) DECLSPEC_HIDDEN;
--
2.33.0
Sept. 29, 2021
[PATCH v2 1/5] wined3d: Do not emit an upload for NOOVERWRITE maps on deferred contexts.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/cs.c | 18 ++++++++++++------
dlls/wined3d/wined3d_private.h | 3 +++
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index dd8cae825fa..626dd0ac132 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -34,6 +34,7 @@ struct wined3d_deferred_upload
unsigned int sub_resource_idx;
uint8_t *sysmem;
struct wined3d_box box;
+ uint32_t upload_flags;
};
struct wined3d_command_list
@@ -2429,9 +2430,9 @@ static void wined3d_device_context_upload_bo(struct wined3d_device_context *cont
{
struct wined3d_cs_update_sub_resource *op;
- TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, row_pitch %u, slice_pitch %u.\n",
+ TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, flags %#x, row_pitch %u, slice_pitch %u.\n",
context, resource, sub_resource_idx, debug_box(box),
- debug_const_bo_address(&bo->addr), row_pitch, slice_pitch);
+ debug_const_bo_address(&bo->addr), bo->flags, row_pitch, slice_pitch);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
@@ -2518,7 +2519,8 @@ HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context
unsigned int row_pitch, slice_pitch;
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
- wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch);
+ if (bo.flags & UPLOAD_BO_UPLOAD_ON_UNMAP)
+ wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch);
return WINED3D_OK;
}
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
op->box = *box;
op->bo.addr.buffer_object = 0;
op->bo.addr.addr = data;
+ op->bo.flags = 0;
op->row_pitch = row_pitch;
op->slice_pitch = slice_pitch;
@@ -3475,7 +3478,7 @@ static void wined3d_deferred_context_push_constants(struct wined3d_device_contex
FIXME("context %p, p %#x, start_idx %u, count %u, constants %p, stub!\n", context, p, start_idx, count, constants);
}
-static const struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred,
+static struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred,
struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
SIZE_T i = deferred->upload_count;
@@ -3519,13 +3522,13 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
if (flags & WINED3D_MAP_NOOVERWRITE)
{
- const struct wined3d_deferred_upload *upload;
-
if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
{
+ upload->upload_flags = 0;
map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
bo->addr.buffer_object = 0;
bo->addr.addr = map_ptr;
+ bo->flags = 0;
return map_ptr;
}
@@ -3540,6 +3543,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
return NULL;
upload = &deferred->uploads[deferred->upload_count++];
+ upload->upload_flags = UPLOAD_BO_UPLOAD_ON_UNMAP;
upload->resource = resource;
wined3d_resource_incref(resource);
upload->sub_resource_idx = sub_resource_idx;
@@ -3549,6 +3553,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
bo->addr.buffer_object = 0;
map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT);
bo->addr.addr = map_ptr;
+ bo->flags = UPLOAD_BO_UPLOAD_ON_UNMAP;
return map_ptr;
}
@@ -3563,6 +3568,7 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context
*box = upload->box;
bo->addr.buffer_object = 0;
bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
+ bo->flags = upload->upload_flags;
return true;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c801e5b3ce8..520eb968eb6 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3324,9 +3324,12 @@ bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level,
UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
+#define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
+
struct upload_bo
{
struct wined3d_const_bo_address addr;
+ uint32_t flags;
};
struct wined3d_adapter_ops
--
2.33.0
Sept. 29, 2021
Re: [PATCH 2/2] secur32: Remove macOS backend.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=99097
Your paranoid android.
=== debiant2 (build log) ===
error: patch failed: dlls/secur32/schannel_macosx.c:1
Task: Patch failed to apply
=== debiant2 (build log) ===
error: patch failed: dlls/secur32/schannel_macosx.c:1
Task: Patch failed to apply
Sept. 29, 2021
[PATCH 2/2] secur32: Remove macOS backend.
by Gijs Vermeulen
gnutls has been the default since wine-6.11.
Signed-off-by: Gijs Vermeulen <gijsvrm(a)gmail.com>
---
dlls/secur32/Makefile.in | 3 +-
dlls/secur32/schannel_macosx.c | 1278 --------------------------------
2 files changed, 1 insertion(+), 1280 deletions(-)
delete mode 100644 dlls/secur32/schannel_macosx.c
diff --git a/dlls/secur32/Makefile.in b/dlls/secur32/Makefile.in
index a5aa3b52691..d298181573f 100644
--- a/dlls/secur32/Makefile.in
+++ b/dlls/secur32/Makefile.in
@@ -3,14 +3,13 @@ IMPORTLIB = secur32
IMPORTS = advapi32
DELAYIMPORTS = crypt32
EXTRAINCL = $(GNUTLS_CFLAGS)
-EXTRALIBS = $(SECURITY_LIBS) $(PTHREAD_LIBS)
+EXTRALIBS = $(PTHREAD_LIBS)
C_SRCS = \
lsa.c \
negotiate.c \
schannel.c \
schannel_gnutls.c \
- schannel_macosx.c \
secur32.c \
thunks.c \
wrapper.c
diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c
deleted file mode 100644
index f7f7db955ef..00000000000
--- a/dlls/secur32/schannel_macosx.c
+++ /dev/null
@@ -1,1278 +0,0 @@
-/*
- * Mac OS X Secure Transport implementation of the schannel (SSL/TLS) provider.
- *
- * Copyright 2005 Juan Lang
- * Copyright 2008 Henri Verbeet
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#if 0
-#pragma makedep unix
-#endif
-
-#include "config.h"
-#include "wine/port.h"
-
-#include <stdarg.h>
-#include <pthread.h>
-#ifdef HAVE_SECURITY_SECURITY_H
-#include <Security/Security.h>
-#define GetCurrentThread GetCurrentThread_Mac
-#define LoadResource LoadResource_Mac
-#include <CoreServices/CoreServices.h>
-#undef GetCurrentThread
-#undef LoadResource
-#endif
-
-#include "ntstatus.h"
-#define WIN32_NO_STATUS
-#include "windef.h"
-#include "winbase.h"
-#include "sspi.h"
-#include "schannel.h"
-#include "winternl.h"
-#include "secur32_priv.h"
-#include "wine/debug.h"
-
-#if defined(HAVE_SECURITY_SECURITY_H) && !defined(SONAME_LIBGNUTLS)
-
-WINE_DEFAULT_DEBUG_CHANNEL(secur32);
-
-static const struct schan_callbacks *callbacks;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
-/* Defined in <Security/CipherSuite.h> in the 10.6 SDK or later. */
-enum {
- TLS_ECDH_ECDSA_WITH_NULL_SHA = 0xC001,
- TLS_ECDH_ECDSA_WITH_RC4_128_SHA = 0xC002,
- TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA = 0xC003,
- TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = 0xC004,
- TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA = 0xC005,
- TLS_ECDHE_ECDSA_WITH_NULL_SHA = 0xC006,
- TLS_ECDHE_ECDSA_WITH_RC4_128_SHA = 0xC007,
- TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = 0xC008,
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xC009,
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xC00A,
- TLS_ECDH_RSA_WITH_NULL_SHA = 0xC00B,
- TLS_ECDH_RSA_WITH_RC4_128_SHA = 0xC00C,
- TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA = 0xC00D,
- TLS_ECDH_RSA_WITH_AES_128_CBC_SHA = 0xC00E,
- TLS_ECDH_RSA_WITH_AES_256_CBC_SHA = 0xC00F,
- TLS_ECDHE_RSA_WITH_NULL_SHA = 0xC010,
- TLS_ECDHE_RSA_WITH_RC4_128_SHA = 0xC011,
- TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA = 0xC012,
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xC013,
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014,
- TLS_ECDH_anon_WITH_NULL_SHA = 0xC015,
- TLS_ECDH_anon_WITH_RC4_128_SHA = 0xC016,
- TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = 0xC017,
- TLS_ECDH_anon_WITH_AES_128_CBC_SHA = 0xC018,
- TLS_ECDH_anon_WITH_AES_256_CBC_SHA = 0xC019,
-};
-#endif
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
-/* Defined in <Security/CipherSuite.h> in the 10.8 SDK or later. */
-enum {
- TLS_NULL_WITH_NULL_NULL = 0x0000,
- TLS_RSA_WITH_NULL_MD5 = 0x0001,
- TLS_RSA_WITH_NULL_SHA = 0x0002,
- TLS_RSA_WITH_RC4_128_MD5 = 0x0004,
- TLS_RSA_WITH_RC4_128_SHA = 0x0005,
- TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x000A,
- TLS_RSA_WITH_NULL_SHA256 = 0x003B,
- TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x003C,
- TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x003D,
- TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x000D,
- TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x0010,
- TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x0013,
- TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x0016,
- TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x003E,
- TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x003F,
- TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x0040,
- TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x0067,
- TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x0068,
- TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x0069,
- TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x006A,
- TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x006B,
- TLS_DH_anon_WITH_RC4_128_MD5 = 0x0018,
- TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x001B,
- TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x006C,
- TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x006D,
- TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x009C,
- TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x009D,
- TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 0x009E,
- TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 0x009F,
- TLS_DH_RSA_WITH_AES_128_GCM_SHA256 = 0x00A0,
- TLS_DH_RSA_WITH_AES_256_GCM_SHA384 = 0x00A1,
- TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 = 0x00A2,
- TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 = 0x00A3,
- TLS_DH_DSS_WITH_AES_128_GCM_SHA256 = 0x00A4,
- TLS_DH_DSS_WITH_AES_256_GCM_SHA384 = 0x00A5,
- TLS_DH_anon_WITH_AES_128_GCM_SHA256 = 0x00A6,
- TLS_DH_anon_WITH_AES_256_GCM_SHA384 = 0x00A7,
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0xC023,
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0xC024,
- TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 = 0xC025,
- TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 = 0xC026,
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 0xC027,
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = 0xC028,
- TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 = 0xC029,
- TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 = 0xC02A,
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xC02B,
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xC02C,
- TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = 0xC02D,
- TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = 0xC02E,
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xC02F,
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xC030,
- TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 = 0xC031,
- TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 = 0xC032,
- TLS_EMPTY_RENEGOTIATION_INFO_SCSV = 0x00FF,
-};
-
-/* Defined in <Security/SecureTransport.h> in the 10.8 SDK or later. */
-enum {
- kTLSProtocol11 = 7, /* TLS 1.1 */
- kTLSProtocol12 = 8, /* TLS 1.2 */
-};
-#endif
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
-/* Defined in <Security/CipherSuite.h> in the 10.9 SDK or later. */
-enum {
- TLS_PSK_WITH_RC4_128_SHA = 0x008A,
- TLS_PSK_WITH_3DES_EDE_CBC_SHA = 0x008B,
- TLS_PSK_WITH_AES_128_CBC_SHA = 0x008C,
- TLS_PSK_WITH_AES_256_CBC_SHA = 0x008D,
- TLS_DHE_PSK_WITH_RC4_128_SHA = 0x008E,
- TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA = 0x008F,
- TLS_DHE_PSK_WITH_AES_128_CBC_SHA = 0x0090,
- TLS_DHE_PSK_WITH_AES_256_CBC_SHA = 0x0091,
- TLS_RSA_PSK_WITH_RC4_128_SHA = 0x0092,
- TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA = 0x0093,
- TLS_RSA_PSK_WITH_AES_128_CBC_SHA = 0x0094,
- TLS_RSA_PSK_WITH_AES_256_CBC_SHA = 0x0095,
- TLS_PSK_WITH_NULL_SHA = 0x002C,
- TLS_DHE_PSK_WITH_NULL_SHA = 0x002D,
- TLS_RSA_PSK_WITH_NULL_SHA = 0x002E,
- TLS_PSK_WITH_AES_128_GCM_SHA256 = 0x00A8,
- TLS_PSK_WITH_AES_256_GCM_SHA384 = 0x00A9,
- TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 = 0x00AA,
- TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 = 0x00AB,
- TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 = 0x00AC,
- TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 = 0x00AD,
- TLS_PSK_WITH_AES_128_CBC_SHA256 = 0x00AE,
- TLS_PSK_WITH_AES_256_CBC_SHA384 = 0x00AF,
- TLS_PSK_WITH_NULL_SHA256 = 0x00B0,
- TLS_PSK_WITH_NULL_SHA384 = 0x00B1,
- TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 = 0x00B2,
- TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 = 0x00B3,
- TLS_DHE_PSK_WITH_NULL_SHA256 = 0x00B4,
- TLS_DHE_PSK_WITH_NULL_SHA384 = 0x00B5,
- TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 = 0x00B6,
- TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 = 0x00B7,
- TLS_RSA_PSK_WITH_NULL_SHA256 = 0x00B8,
- TLS_RSA_PSK_WITH_NULL_SHA384 = 0x00B9,
-};
-#endif
-
-enum schan_mode {
- schan_mode_NONE,
- schan_mode_READ,
- schan_mode_WRITE,
- schan_mode_HANDSHAKE,
-};
-
-struct mac_session {
- SSLContextRef context;
- struct schan_transport *transport;
- enum schan_mode mode;
- pthread_mutex_t mutex;
-};
-
-enum {
- schan_proto_SSL,
- schan_proto_TLS,
-};
-
-enum {
- schan_kx_DH_anon_EXPORT,
- schan_kx_DH_anon,
- schan_kx_DH_DSS_EXPORT,
- schan_kx_DH_DSS,
- schan_kx_DH_RSA_EXPORT,
- schan_kx_DH_RSA,
- schan_kx_DHE_DSS_EXPORT,
- schan_kx_DHE_DSS,
- schan_kx_DHE_PSK,
- schan_kx_DHE_RSA_EXPORT,
- schan_kx_DHE_RSA,
- schan_kx_ECDH_anon,
- schan_kx_ECDH_ECDSA,
- schan_kx_ECDH_RSA,
- schan_kx_ECDHE_ECDSA,
- schan_kx_ECDHE_RSA,
- schan_kx_FORTEZZA_DMS,
- schan_kx_NULL,
- schan_kx_PSK,
- schan_kx_RSA_EXPORT,
- schan_kx_RSA_PSK,
- schan_kx_RSA,
-};
-
-enum {
- schan_enc_3DES_EDE_CBC,
- schan_enc_AES_128_CBC,
- schan_enc_AES_128_GCM,
- schan_enc_AES_256_CBC,
- schan_enc_AES_256_GCM,
- schan_enc_DES_CBC,
- schan_enc_DES40_CBC,
- schan_enc_FORTEZZA_CBC,
- schan_enc_IDEA_CBC,
- schan_enc_NULL,
- schan_enc_RC2_CBC,
- schan_enc_RC2_CBC_40,
- schan_enc_RC4_128,
- schan_enc_RC4_40,
-};
-
-enum {
- schan_mac_MD5,
- schan_mac_NULL,
- schan_mac_SHA,
- schan_mac_SHA256,
- schan_mac_SHA384,
-};
-
-
-struct cipher_suite {
- SSLCipherSuite suite;
- int protocol;
- int kx_alg;
- int enc_alg;
- int mac_alg;
-};
-
-/* This table corresponds to the enum in <Security/CipherSuite.h>. */
-static const struct cipher_suite cipher_suites[] = {
-#define CIPHER_SUITE(p, kx, enc, mac) { p##_##kx##_WITH_##enc##_##mac, schan_proto_##p, \
- schan_kx_##kx, schan_enc_##enc, schan_mac_##mac }
- CIPHER_SUITE(SSL, RSA, NULL, MD5),
- CIPHER_SUITE(SSL, RSA, NULL, MD5),
- CIPHER_SUITE(SSL, RSA, NULL, SHA),
- CIPHER_SUITE(SSL, RSA_EXPORT, RC4_40, MD5),
- CIPHER_SUITE(SSL, RSA, RC4_128, MD5),
- CIPHER_SUITE(SSL, RSA, RC4_128, SHA),
- CIPHER_SUITE(SSL, RSA_EXPORT, RC2_CBC_40, MD5),
- CIPHER_SUITE(SSL, RSA, IDEA_CBC, SHA),
- CIPHER_SUITE(SSL, RSA_EXPORT, DES40_CBC, SHA),
- CIPHER_SUITE(SSL, RSA, DES_CBC, SHA),
- CIPHER_SUITE(SSL, RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(SSL, DH_DSS_EXPORT, DES40_CBC, SHA),
- CIPHER_SUITE(SSL, DH_DSS, DES_CBC, SHA),
- CIPHER_SUITE(SSL, DH_DSS, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(SSL, DH_RSA_EXPORT, DES40_CBC, SHA),
- CIPHER_SUITE(SSL, DH_RSA, DES_CBC, SHA),
- CIPHER_SUITE(SSL, DH_RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(SSL, DHE_DSS_EXPORT, DES40_CBC, SHA),
- CIPHER_SUITE(SSL, DHE_DSS, DES_CBC, SHA),
- CIPHER_SUITE(SSL, DHE_DSS, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(SSL, DHE_RSA_EXPORT, DES40_CBC, SHA),
- CIPHER_SUITE(SSL, DHE_RSA, DES_CBC, SHA),
- CIPHER_SUITE(SSL, DHE_RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(SSL, DH_anon_EXPORT, RC4_40, MD5),
- CIPHER_SUITE(SSL, DH_anon, RC4_128, MD5),
- CIPHER_SUITE(SSL, DH_anon_EXPORT, DES40_CBC, SHA),
- CIPHER_SUITE(SSL, DH_anon, DES_CBC, SHA),
- CIPHER_SUITE(SSL, DH_anon, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(SSL, FORTEZZA_DMS, NULL, SHA),
- CIPHER_SUITE(SSL, FORTEZZA_DMS, FORTEZZA_CBC, SHA),
-
- CIPHER_SUITE(TLS, RSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, DH_DSS, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, DH_RSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_DSS, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_RSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, DH_anon, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, RSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, DH_DSS, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, DH_RSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_DSS, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_RSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, DH_anon, AES_256_CBC, SHA),
-
- CIPHER_SUITE(TLS, ECDH_ECDSA, NULL, SHA),
- CIPHER_SUITE(TLS, ECDH_ECDSA, RC4_128, SHA),
- CIPHER_SUITE(TLS, ECDH_ECDSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_ECDSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_ECDSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, NULL, SHA),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, RC4_128, SHA),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_RSA, NULL, SHA),
- CIPHER_SUITE(TLS, ECDH_RSA, RC4_128, SHA),
- CIPHER_SUITE(TLS, ECDH_RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_RSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_RSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, ECDHE_RSA, NULL, SHA),
- CIPHER_SUITE(TLS, ECDHE_RSA, RC4_128, SHA),
- CIPHER_SUITE(TLS, ECDHE_RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, ECDHE_RSA, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, ECDHE_RSA, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_anon, NULL, SHA),
- CIPHER_SUITE(TLS, ECDH_anon, RC4_128, SHA),
- CIPHER_SUITE(TLS, ECDH_anon, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_anon, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, ECDH_anon, AES_256_CBC, SHA),
-
- CIPHER_SUITE(TLS, NULL, NULL, NULL),
- CIPHER_SUITE(TLS, RSA, NULL, MD5),
- CIPHER_SUITE(TLS, RSA, NULL, SHA),
- CIPHER_SUITE(TLS, RSA, RC4_128, MD5),
- CIPHER_SUITE(TLS, RSA, RC4_128, SHA),
- CIPHER_SUITE(TLS, RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, RSA, NULL, SHA256),
- CIPHER_SUITE(TLS, RSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, RSA, AES_256_CBC, SHA256),
- CIPHER_SUITE(TLS, DH_DSS, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, DH_RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_DSS, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_RSA, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, DH_DSS, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, DH_RSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, DHE_DSS, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, DHE_RSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, DH_DSS, AES_256_CBC, SHA256),
- CIPHER_SUITE(TLS, DH_RSA, AES_256_CBC, SHA256),
- CIPHER_SUITE(TLS, DHE_DSS, AES_256_CBC, SHA256),
- CIPHER_SUITE(TLS, DHE_RSA, AES_256_CBC, SHA256),
- CIPHER_SUITE(TLS, DH_anon, RC4_128, MD5),
- CIPHER_SUITE(TLS, DH_anon, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, DH_anon, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, DH_anon, AES_256_CBC, SHA256),
-
- CIPHER_SUITE(TLS, PSK, RC4_128, SHA),
- CIPHER_SUITE(TLS, PSK, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, PSK, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, PSK, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_PSK, RC4_128, SHA),
- CIPHER_SUITE(TLS, DHE_PSK, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_PSK, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, DHE_PSK, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, RSA_PSK, RC4_128, SHA),
- CIPHER_SUITE(TLS, RSA_PSK, 3DES_EDE_CBC, SHA),
- CIPHER_SUITE(TLS, RSA_PSK, AES_128_CBC, SHA),
- CIPHER_SUITE(TLS, RSA_PSK, AES_256_CBC, SHA),
- CIPHER_SUITE(TLS, PSK, NULL, SHA),
- CIPHER_SUITE(TLS, DHE_PSK, NULL, SHA),
- CIPHER_SUITE(TLS, RSA_PSK, NULL, SHA),
-
- CIPHER_SUITE(TLS, RSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, RSA, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, DHE_RSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, DHE_RSA, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, DH_RSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, DH_RSA, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, DHE_DSS, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, DHE_DSS, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, DH_DSS, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, DH_DSS, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, DH_anon, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, DH_anon, AES_256_GCM, SHA384),
-
- CIPHER_SUITE(TLS, PSK, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, PSK, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, DHE_PSK, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, DHE_PSK, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, RSA_PSK, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, RSA_PSK, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, PSK, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, PSK, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, PSK, NULL, SHA256),
- CIPHER_SUITE(TLS, PSK, NULL, SHA384),
- CIPHER_SUITE(TLS, DHE_PSK, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, DHE_PSK, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, DHE_PSK, NULL, SHA256),
- CIPHER_SUITE(TLS, DHE_PSK, NULL, SHA384),
- CIPHER_SUITE(TLS, RSA_PSK, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, RSA_PSK, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, RSA_PSK, NULL, SHA256),
- CIPHER_SUITE(TLS, RSA_PSK, NULL, SHA384),
-
- CIPHER_SUITE(TLS, ECDHE_ECDSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, ECDH_ECDSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, ECDH_ECDSA, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, ECDHE_RSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, ECDHE_RSA, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, ECDH_RSA, AES_128_CBC, SHA256),
- CIPHER_SUITE(TLS, ECDH_RSA, AES_256_CBC, SHA384),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, ECDHE_ECDSA, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, ECDH_ECDSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, ECDH_ECDSA, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, ECDHE_RSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, ECDHE_RSA, AES_256_GCM, SHA384),
- CIPHER_SUITE(TLS, ECDH_RSA, AES_128_GCM, SHA256),
- CIPHER_SUITE(TLS, ECDH_RSA, AES_256_GCM, SHA384),
-
- CIPHER_SUITE(SSL, RSA, RC2_CBC, MD5),
- CIPHER_SUITE(SSL, RSA, IDEA_CBC, MD5),
- CIPHER_SUITE(SSL, RSA, DES_CBC, MD5),
- CIPHER_SUITE(SSL, RSA, 3DES_EDE_CBC, MD5),
-#undef CIPHER_SUITE
-};
-
-
-static const struct cipher_suite* get_cipher_suite(SSLCipherSuite cipher_suite)
-{
- int i;
- for (i = 0; i < ARRAY_SIZE(cipher_suites); i++)
- {
- if (cipher_suites[i].suite == cipher_suite)
- return &cipher_suites[i];
- }
-
- return NULL;
-}
-
-
-static DWORD get_session_protocol(struct mac_session* s)
-{
- SSLProtocol protocol;
- int status;
-
- TRACE("(%p/%p)\n", s, s->context);
-
- status = SSLGetNegotiatedProtocolVersion(s->context, &protocol);
- if (status != noErr)
- {
- ERR("Failed to get session protocol: %d\n", status);
- return 0;
- }
-
- TRACE("protocol %d\n", protocol);
-
- switch (protocol)
- {
- case kSSLProtocol2: return SP_PROT_SSL2_CLIENT;
- case kSSLProtocol3: return SP_PROT_SSL3_CLIENT;
- case kTLSProtocol1: return SP_PROT_TLS1_CLIENT;
- case kTLSProtocol11: return SP_PROT_TLS1_1_CLIENT;
- case kTLSProtocol12: return SP_PROT_TLS1_2_CLIENT;
- default:
- FIXME("unknown protocol %d\n", protocol);
- return 0;
- }
-}
-
-static ALG_ID get_cipher_algid(const struct cipher_suite* c)
-{
- TRACE("(%#x)\n", (unsigned int)c->suite);
-
- switch (c->enc_alg)
- {
- case schan_enc_3DES_EDE_CBC: return CALG_3DES;
- case schan_enc_AES_128_CBC: return CALG_AES_128;
- case schan_enc_AES_256_CBC: return CALG_AES_256;
- case schan_enc_DES_CBC: return CALG_DES;
- case schan_enc_DES40_CBC: return CALG_DES;
- case schan_enc_NULL: return 0;
- case schan_enc_RC2_CBC_40: return CALG_RC2;
- case schan_enc_RC2_CBC: return CALG_RC2;
- case schan_enc_RC4_128: return CALG_RC4;
- case schan_enc_RC4_40: return CALG_RC4;
-
- case schan_enc_AES_128_GCM:
- case schan_enc_AES_256_GCM:
- case schan_enc_FORTEZZA_CBC:
- case schan_enc_IDEA_CBC:
- FIXME("Don't know CALG for encryption algorithm %d, returning 0\n", c->enc_alg);
- return 0;
-
- default:
- FIXME("Unknown encryption algorithm %d for cipher suite %#x, returning 0\n", c->enc_alg, (unsigned int)c->suite);
- return 0;
- }
-}
-
-static unsigned int get_cipher_key_size(const struct cipher_suite* c)
-{
- TRACE("(%#x)\n", (unsigned int)c->suite);
-
- switch (c->enc_alg)
- {
- case schan_enc_3DES_EDE_CBC: return 168;
- case schan_enc_AES_128_CBC: return 128;
- case schan_enc_AES_128_GCM: return 128;
- case schan_enc_AES_256_CBC: return 256;
- case schan_enc_AES_256_GCM: return 256;
- case schan_enc_DES_CBC: return 56;
- case schan_enc_DES40_CBC: return 40;
- case schan_enc_NULL: return 0;
- case schan_enc_RC2_CBC_40: return 40;
- case schan_enc_RC2_CBC: return 128;
- case schan_enc_RC4_128: return 128;
- case schan_enc_RC4_40: return 40;
-
- case schan_enc_FORTEZZA_CBC:
- case schan_enc_IDEA_CBC:
- FIXME("Don't know key size for encryption algorithm %d, returning 0\n", c->enc_alg);
- return 0;
-
- default:
- FIXME("Unknown encryption algorithm %d for cipher suite %#x, returning 0\n", c->enc_alg, (unsigned int)c->suite);
- return 0;
- }
-}
-
-static ALG_ID get_mac_algid(const struct cipher_suite* c)
-{
- TRACE("(%#x)\n", (unsigned int)c->suite);
-
- switch (c->mac_alg)
- {
- case schan_mac_MD5: return CALG_MD5;
- case schan_mac_NULL: return 0;
- case schan_mac_SHA: return CALG_SHA;
- case schan_mac_SHA256: return CALG_SHA_256;
- case schan_mac_SHA384: return CALG_SHA_384;
-
- default:
- FIXME("Unknown hashing algorithm %d for cipher suite %#x, returning 0\n", c->mac_alg, (unsigned)c->suite);
- return 0;
- }
-}
-
-static unsigned int get_mac_key_size(const struct cipher_suite* c)
-{
- TRACE("(%#x)\n", (unsigned int)c->suite);
-
- switch (c->mac_alg)
- {
- case schan_mac_MD5: return 128;
- case schan_mac_NULL: return 0;
- case schan_mac_SHA: return 160;
- case schan_mac_SHA256: return 256;
- case schan_mac_SHA384: return 384;
-
- default:
- FIXME("Unknown hashing algorithm %d for cipher suite %#x, returning 0\n", c->mac_alg, (unsigned)c->suite);
- return 0;
- }
-}
-
-static ALG_ID get_kx_algid(const struct cipher_suite* c)
-{
- TRACE("(%#x)\n", (unsigned int)c->suite);
-
- switch (c->kx_alg)
- {
- case schan_kx_DHE_DSS_EXPORT:
- case schan_kx_DHE_DSS:
- case schan_kx_DHE_PSK:
- case schan_kx_DHE_RSA_EXPORT:
- case schan_kx_DHE_RSA: return CALG_DH_EPHEM;
- case schan_kx_ECDH_anon:
- case schan_kx_ECDH_ECDSA:
- case schan_kx_ECDH_RSA: return CALG_ECDH;
- case schan_kx_ECDHE_ECDSA:
- case schan_kx_ECDHE_RSA: return CALG_ECDH_EPHEM;
- case schan_kx_NULL: return 0;
- case schan_kx_RSA:
- case schan_kx_RSA_EXPORT:
- case schan_kx_RSA_PSK: return CALG_RSA_KEYX;
-
- case schan_kx_DH_anon_EXPORT:
- case schan_kx_DH_anon:
- case schan_kx_DH_DSS_EXPORT:
- case schan_kx_DH_DSS:
- case schan_kx_DH_RSA_EXPORT:
- case schan_kx_DH_RSA:
- case schan_kx_FORTEZZA_DMS:
- case schan_kx_PSK:
- FIXME("Don't know CALG for key exchange algorithm %d for cipher suite %#x, returning 0\n", c->kx_alg, (unsigned)c->suite);
- return 0;
-
- default:
- FIXME("Unknown key exchange algorithm %d for cipher suite %#x, returning 0\n", c->kx_alg, (unsigned)c->suite);
- return 0;
- }
-}
-
-
-/* pull_adapter
- * Callback registered with SSLSetIOFuncs as the read function for a
- * session. Reads data from the session connection. Conforms to the
- * SSLReadFunc type.
- *
- * transport - The session connection
- * buff - The buffer into which to store the read data. Must be at least
- * *buff_len bytes in length.
- * *buff_len - On input, the desired length to read. On successful return,
- * the number of bytes actually read.
- *
- * Returns:
- * noErr on complete success meaning the requested length was successfully
- * read.
- * errSSLWouldBlock when the requested length could not be read without
- * blocking. *buff_len indicates how much was actually read. The
- * caller should try again if/when they want to read more.
- * errSSLClosedGraceful when the connection has closed and there's no
- * more data to be read.
- * other error code for failure.
- */
-static OSStatus pull_adapter(SSLConnectionRef transport, void *buff, SIZE_T *buff_len)
-{
- struct mac_session *s = (struct mac_session*)transport;
- size_t requested = *buff_len;
- int status;
- OSStatus ret;
-
- TRACE("(%p/%p, %p, %p/%lu)\n", s, s->transport, buff, buff_len, *buff_len);
-
- if (s->mode != schan_mode_READ && s->mode != schan_mode_HANDSHAKE)
- {
- WARN("called in mode %u\n", s->mode);
- return noErr;
- }
-
- status = callbacks->pull(s->transport, buff, buff_len);
- if (status == 0)
- {
- if (*buff_len == 0)
- {
- TRACE("Connection closed\n");
- ret = errSSLClosedGraceful;
- }
- else if (*buff_len < requested)
- {
- TRACE("Pulled %lu bytes before would block\n", *buff_len);
- ret = errSSLWouldBlock;
- }
- else
- {
- TRACE("Pulled %lu bytes\n", *buff_len);
- ret = noErr;
- }
- }
- else if (status == -1)
- {
- TRACE("Would block before being able to pull anything\n");
- ret = errSSLWouldBlock;
- }
- else
- {
- FIXME("Unknown status code from schan_pull: %d\n", status);
- ret = ioErr;
- }
-
- return ret;
-}
-
-/* push_adapter
- * Callback registered with SSLSetIOFuncs as the write function for a
- * session. Writes data to the session connection. Conforms to the
- * SSLWriteFunc type.
- *
- * transport - The session connection
- * buff - The buffer of data to write. Must be at least *buff_len bytes in length.
- * *buff_len - On input, the desired length to write. On successful return,
- * the number of bytes actually written.
- *
- * Returns:
- * noErr on complete or partial success; *buff_len indicates how much data
- * was actually written, which may be less than requested.
- * errSSLWouldBlock when no data could be written without blocking. The
- * caller should try again.
- * other error code for failure.
- */
-static OSStatus push_adapter(SSLConnectionRef transport, const void *buff, SIZE_T *buff_len)
-{
- struct mac_session *s = (struct mac_session*)transport;
- int status;
- OSStatus ret;
-
- TRACE("(%p/%p, %p, %p/%lu)\n", s, s->transport, buff, buff_len, *buff_len);
-
- if (s->mode != schan_mode_WRITE && s->mode != schan_mode_HANDSHAKE)
- {
- WARN("called in mode %u\n", s->mode);
- return noErr;
- }
-
- status = callbacks->push(s->transport, buff, buff_len);
- if (status == 0)
- {
- TRACE("Pushed %lu bytes\n", *buff_len);
- ret = noErr;
- }
- else if (status == -1)
- {
- TRACE("Would block before being able to push anything\n");
- ret = errSSLWouldBlock;
- }
- else
- {
- FIXME("Unknown status code from schan_push: %d\n", status);
- ret = ioErr;
- }
-
- return ret;
-}
-
-static const struct {
- DWORD enable_flag;
- SSLProtocol mac_version;
-} protocol_priority_flags[] = {
- {SP_PROT_TLS1_2_CLIENT, kTLSProtocol12},
- {SP_PROT_TLS1_1_CLIENT, kTLSProtocol11},
- {SP_PROT_TLS1_0_CLIENT, kTLSProtocol1},
- {SP_PROT_SSL3_CLIENT, kSSLProtocol3},
- {SP_PROT_SSL2_CLIENT, kSSLProtocol2}
-};
-
-static DWORD supported_protocols;
-
-static DWORD CDECL schan_get_enabled_protocols(void)
-{
- return supported_protocols;
-}
-
-static BOOL CDECL schan_create_session(schan_session *session, schan_credentials *cred)
-{
- struct mac_session *s;
- unsigned i;
- int status;
-
- TRACE("(%p)\n", session);
-
- if (!(s = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(*s)))) return FALSE;
-
- pthread_mutex_init(&s->mutex, NULL);
-
- status = SSLNewContext(cred->credential_use == SECPKG_CRED_INBOUND, &s->context);
- if (status != noErr)
- {
- ERR("Failed to create session context: %d\n", status);
- goto fail;
- }
-
- status = SSLSetConnection(s->context, s);
- if (status != noErr)
- {
- ERR("Failed to set session connection: %d\n", status);
- goto fail;
- }
-
- status = SSLSetEnableCertVerify(s->context, FALSE);
- if (status != noErr)
- {
- ERR("Failed to disable certificate verification: %d\n", status);
- goto fail;
- }
-
- for(i = 0; i < ARRAY_SIZE(protocol_priority_flags); i++) {
- if(!(protocol_priority_flags[i].enable_flag & supported_protocols))
- continue;
-
- status = SSLSetProtocolVersionEnabled(s->context, protocol_priority_flags[i].mac_version,
- (cred->enabled_protocols & protocol_priority_flags[i].enable_flag) != 0);
- if (status != noErr)
- {
- ERR("Failed to set SSL version %d: %d\n", protocol_priority_flags[i].mac_version, status);
- goto fail;
- }
- }
-
- status = SSLSetIOFuncs(s->context, pull_adapter, push_adapter);
- if (status != noErr)
- {
- ERR("Failed to set session I/O funcs: %d\n", status);
- goto fail;
- }
-
- s->mode = schan_mode_NONE;
-
- TRACE(" -> %p/%p\n", s, s->context);
-
- *session = (schan_session)s;
- return TRUE;
-
-fail:
- RtlFreeHeap(GetProcessHeap(), 0, s);
- return FALSE;
-}
-
-static void CDECL schan_dispose_session(schan_session session)
-{
- struct mac_session *s = (struct mac_session*)session;
- int status;
-
- TRACE("(%p/%p)\n", s, s->context);
-
- status = SSLDisposeContext(s->context);
- if (status != noErr)
- ERR("Failed to dispose of session context: %d\n", status);
- pthread_mutex_destroy(&s->mutex);
- RtlFreeHeap(GetProcessHeap(), 0, s);
-}
-
-static void CDECL schan_set_session_transport(schan_session session, struct schan_transport *t)
-{
- struct mac_session *s = (struct mac_session*)session;
-
- TRACE("(%p/%p, %p)\n", s, s->context, t);
-
- s->transport = t;
-}
-
-static void CDECL schan_set_session_target(schan_session session, const char *target)
-{
- struct mac_session *s = (struct mac_session*)session;
-
- TRACE("(%p/%p, %s)\n", s, s->context, debugstr_a(target));
-
- SSLSetPeerDomainName( s->context, target, strlen(target) );
-}
-
-static SECURITY_STATUS CDECL schan_handshake(schan_session session)
-{
- struct mac_session *s = (struct mac_session*)session;
- int status;
-
- TRACE("(%p/%p)\n", s, s->context);
-
- s->mode = schan_mode_HANDSHAKE;
- status = SSLHandshake(s->context);
- s->mode = schan_mode_NONE;
-
- if (status == noErr)
- {
- TRACE("Handshake completed\n");
- return SEC_E_OK;
- }
- else if (status == errSSLWouldBlock)
- {
- TRACE("Continue...\n");
- return SEC_I_CONTINUE_NEEDED;
- }
- else if (errSecErrnoBase <= status && status <= errSecErrnoLimit)
- {
- ERR("Handshake failed: %s\n", strerror(status));
- return SEC_E_INTERNAL_ERROR;
- }
- else
- {
- ERR("Handshake failed: %d\n", status);
- cssmPerror("SSLHandshake", status);
- return SEC_E_INTERNAL_ERROR;
- }
-
- /* Never reached */
- return SEC_E_OK;
-}
-
-static unsigned int CDECL schan_get_session_cipher_block_size(schan_session session)
-{
- struct mac_session* s = (struct mac_session*)session;
- SSLCipherSuite cipherSuite;
- const struct cipher_suite* c;
- int status;
-
- TRACE("(%p/%p)\n", s, s->context);
-
- status = SSLGetNegotiatedCipher(s->context, &cipherSuite);
- if (status != noErr)
- {
- ERR("Failed to get session cipher suite: %d\n", status);
- return 0;
- }
-
- c = get_cipher_suite(cipherSuite);
- if (!c)
- {
- ERR("Unknown session cipher suite: %#x\n", (unsigned int)cipherSuite);
- return 0;
- }
-
- switch (c->enc_alg)
- {
- case schan_enc_3DES_EDE_CBC: return 64;
- case schan_enc_AES_128_CBC: return 128;
- case schan_enc_AES_128_GCM: return 128;
- case schan_enc_AES_256_CBC: return 128;
- case schan_enc_AES_256_GCM: return 128;
- case schan_enc_DES_CBC: return 64;
- case schan_enc_DES40_CBC: return 64;
- case schan_enc_NULL: return 0;
- case schan_enc_RC2_CBC_40: return 64;
- case schan_enc_RC2_CBC: return 64;
- case schan_enc_RC4_128: return 0;
- case schan_enc_RC4_40: return 0;
-
- case schan_enc_FORTEZZA_CBC:
- case schan_enc_IDEA_CBC:
- FIXME("Don't know block size for encryption algorithm %d, returning 0\n", c->enc_alg);
- return 0;
-
- default:
- FIXME("Unknown encryption algorithm %d for cipher suite %#x, returning 0\n", c->enc_alg, (unsigned int)c->suite);
- return 0;
- }
-}
-
-static unsigned int CDECL schan_get_max_message_size(schan_session session)
-{
- FIXME("Returning 1 << 14.\n");
- return 1 << 14;
-}
-
-static ALG_ID CDECL schan_get_key_signature_algorithm(schan_session session)
-{
- struct mac_session* s = (struct mac_session*)session;
- SSLCipherSuite cipherSuite;
- const struct cipher_suite* c;
- int status;
-
- TRACE("(%p/%p)\n", s, s->context);
-
- status = SSLGetNegotiatedCipher(s->context, &cipherSuite);
- if (status != noErr)
- {
- ERR("Failed to get session cipher suite: %d\n", status);
- return 0;
- }
-
- c = get_cipher_suite(cipherSuite);
- if (!c)
- {
- ERR("Unknown session cipher suite: %#x\n", (unsigned int)cipherSuite);
- return 0;
- }
-
- switch (c->kx_alg)
- {
- case schan_kx_DH_DSS_EXPORT:
- case schan_kx_DH_DSS:
- case schan_kx_DHE_DSS_EXPORT:
- case schan_kx_DHE_DSS:
- return CALG_DSS_SIGN;
-
- case schan_kx_DH_RSA_EXPORT:
- case schan_kx_DH_RSA:
- case schan_kx_DHE_RSA_EXPORT:
- case schan_kx_DHE_RSA:
- case schan_kx_ECDH_RSA:
- case schan_kx_ECDHE_RSA:
- case schan_kx_RSA_EXPORT:
- case schan_kx_RSA:
- return CALG_RSA_SIGN;
-
- case schan_kx_ECDH_ECDSA:
- case schan_kx_ECDHE_ECDSA:
- return CALG_ECDSA;
-
- case schan_kx_DH_anon_EXPORT:
- case schan_kx_DH_anon:
- case schan_kx_DHE_PSK:
- case schan_kx_ECDH_anon:
- case schan_kx_FORTEZZA_DMS:
- case schan_kx_NULL:
- case schan_kx_PSK:
- case schan_kx_RSA_PSK:
- FIXME("Don't know key signature algorithm for key exchange algorithm %d, returning 0\n", c->kx_alg);
- return 0;
-
- default:
- FIXME("Unknown key exchange algorithm %d for cipher suite %#x, returning 0\n", c->kx_alg, (unsigned int)c->suite);
- return 0;
- }
-}
-
-static SECURITY_STATUS CDECL schan_get_connection_info(schan_session session, SecPkgContext_ConnectionInfo *info)
-{
- struct mac_session* s = (struct mac_session*)session;
- SSLCipherSuite cipherSuite;
- const struct cipher_suite* c;
- int status;
-
- TRACE("(%p/%p, %p)\n", s, s->context, info);
-
- status = SSLGetNegotiatedCipher(s->context, &cipherSuite);
- if (status != noErr)
- {
- ERR("Failed to get session cipher suite: %d\n", status);
- return SEC_E_INTERNAL_ERROR;
- }
-
- c = get_cipher_suite(cipherSuite);
- if (!c)
- {
- ERR("Unknown session cipher suite: %#x\n", (unsigned int)cipherSuite);
- return SEC_E_INTERNAL_ERROR;
- }
-
- info->dwProtocol = get_session_protocol(s);
- info->aiCipher = get_cipher_algid(c);
- info->dwCipherStrength = get_cipher_key_size(c);
- info->aiHash = get_mac_algid(c);
- info->dwHashStrength = get_mac_key_size(c);
- info->aiExch = get_kx_algid(c);
- /* FIXME: info->dwExchStrength? */
- info->dwExchStrength = 0;
-
- return SEC_E_OK;
-}
-
-static SECURITY_STATUS CDECL schan_get_unique_channel_binding(schan_session session, SecPkgContext_Bindings *bindings)
-{
- FIXME("SECPKG_ATTR_UNIQUE_BINDINGS is unsupported on MacOS\n");
- return SEC_E_UNSUPPORTED_FUNCTION;
-}
-
-static SECURITY_STATUS CDECL schan_get_session_peer_certificate(schan_session session, struct schan_cert_list *list)
-{
- struct mac_session *s = (struct mac_session *)session;
- SECURITY_STATUS ret = SEC_E_OK;
- SecCertificateRef cert;
- CFArrayRef cert_array;
- int status;
- unsigned int size;
- CFIndex i;
- CFDataRef data;
- BYTE *ptr;
-
- TRACE("(%p/%p, %p)\n", s, s->context, list);
-
- status = SSLCopyPeerCertificates(s->context, &cert_array);
- if (status != noErr || !cert_array)
- {
- WARN("SSLCopyPeerCertificates failed: %d\n", status);
- return SEC_E_INTERNAL_ERROR;
- }
-
- list->count = CFArrayGetCount(cert_array);
- size = list->count * sizeof(list->certs[0]);
-
- for (i = 0; i < list->count; i++)
- {
- if (!(cert = (SecCertificateRef)CFArrayGetValueAtIndex(cert_array, i)) ||
- (SecItemExport(cert, kSecFormatX509Cert, 0, NULL, &data) != noErr))
- {
- WARN("Couldn't extract certificate data\n");
- ret = SEC_E_INTERNAL_ERROR;
- goto done;
- }
- size += CFDataGetLength(data);
- CFRelease(data);
- }
-
- if (!(list->certs = RtlAllocateHeap(GetProcessHeap(), 0, size)))
- {
- ret = SEC_E_INSUFFICIENT_MEMORY;
- goto done;
- }
-
- ptr = (BYTE *)&list->certs[list->count];
- for (i = 0; i < list->count; i++)
- {
- if (!(cert = (SecCertificateRef)CFArrayGetValueAtIndex(cert_array, i)) ||
- (SecKeychainItemExport(cert, kSecFormatX509Cert, 0, NULL, &data) != noErr))
- {
- WARN("Couldn't extract certificate data\n");
- ret = SEC_E_INTERNAL_ERROR;
- goto done;
- }
- list->certs[i].cbData = CFDataGetLength(data);
- list->certs[i].pbData = ptr;
- memcpy(list->certs[i].pbData, CFDataGetBytePtr(data), CFDataGetLength(data));
- ptr += CFDataGetLength(data);
- CFRelease(data);
- }
-
-done:
- CFRelease(cert_array);
- return ret;
-}
-
-static SECURITY_STATUS CDECL schan_send(schan_session session, const void *buffer, SIZE_T *length)
-{
- struct mac_session* s = (struct mac_session*)session;
- int status;
-
- TRACE("(%p/%p, %p, %p/%lu)\n", s, s->context, buffer, length, *length);
-
- pthread_mutex_lock(&s->mutex);
- s->mode = schan_mode_WRITE;
-
- status = SSLWrite(s->context, buffer, *length, length);
-
- s->mode = schan_mode_NONE;
- pthread_mutex_unlock(&s->mutex);
-
- if (status == noErr)
- TRACE("Wrote %lu bytes\n", *length);
- else if (status == errSSLWouldBlock)
- {
- if (!*length)
- {
- TRACE("Would block before being able to write anything\n");
- return SEC_I_CONTINUE_NEEDED;
- }
- else
- TRACE("Wrote %lu bytes before would block\n", *length);
- }
- else
- {
- WARN("SSLWrite failed: %d\n", status);
- return SEC_E_INTERNAL_ERROR;
- }
-
- return SEC_E_OK;
-}
-
-static SECURITY_STATUS CDECL schan_recv(schan_session session, void *buffer, SIZE_T *length)
-{
- struct mac_session* s = (struct mac_session*)session;
- int status;
-
- TRACE("(%p/%p, %p, %p/%lu)\n", s, s->context, buffer, length, *length);
-
- pthread_mutex_lock(&s->mutex);
- s->mode = schan_mode_READ;
-
- status = SSLRead(s->context, buffer, *length, length);
-
- s->mode = schan_mode_NONE;
- pthread_mutex_unlock(&s->mutex);
-
- if (status == noErr || status == errSSLClosedGraceful)
- TRACE("Read %lu bytes\n", *length);
- else if (status == errSSLWouldBlock)
- {
- if (!*length)
- {
- TRACE("Would block before being able to read anything\n");
- return SEC_I_CONTINUE_NEEDED;
- }
- else
- TRACE("Read %lu bytes before would block\n", *length);
- }
- else
- {
- WARN("SSLRead failed: %d\n", status);
- return SEC_E_INTERNAL_ERROR;
- }
-
- return SEC_E_OK;
-}
-
-static BOOL CDECL schan_allocate_certificate_credentials(schan_credentials *c, const CERT_CONTEXT *cert,
- const DATA_BLOB *key_blob)
-{
- if (cert) FIXME("no support for certificate credentials on this platform\n");
- c->credentials = NULL;
- return TRUE;
-}
-
-static void CDECL schan_free_certificate_credentials(schan_credentials *c)
-{
-}
-
-static void CDECL schan_set_application_protocols(schan_session session, unsigned char *buffer, unsigned int buflen)
-{
- FIXME("no support for application protocols on this platform\n");
-}
-
-static SECURITY_STATUS CDECL schan_get_application_protocol(schan_session session,
- SecPkgContext_ApplicationProtocol *protocol)
-{
- FIXME("no support for application protocols on this platform\n");
- return SEC_E_UNSUPPORTED_FUNCTION;
-}
-
-static SECURITY_STATUS CDECL schan_set_dtls_mtu(schan_session session, unsigned int mtu)
-{
- FIXME("no support for setting dtls mtu on this platform\n");
- return SEC_E_UNSUPPORTED_FUNCTION;
-}
-
-static void ssl_init(void)
-{
- TRACE("()\n");
-
- supported_protocols = SP_PROT_SSL2_CLIENT | SP_PROT_SSL3_CLIENT | SP_PROT_TLS1_0_CLIENT;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
- if(&SSLGetProtocolVersionMax != NULL) {
- SSLProtocol max_protocol;
- SSLContextRef ctx;
- OSStatus status;
-
- status = SSLNewContext(FALSE, &ctx);
- if(status == noErr) {
- status = SSLGetProtocolVersionMax(ctx, &max_protocol);
- if(status == noErr) {
- if(max_protocol >= kTLSProtocol11)
- supported_protocols |= SP_PROT_TLS1_1_CLIENT;
- if(max_protocol >= kTLSProtocol12)
- supported_protocols |= SP_PROT_TLS1_2_CLIENT;
- }
- SSLDisposeContext(ctx);
- }else {
- WARN("SSLNewContext failed\n");
- }
- }
-#endif
-}
-
-static const struct schan_funcs funcs =
-{
- schan_allocate_certificate_credentials,
- schan_create_session,
- schan_dispose_session,
- schan_free_certificate_credentials,
- schan_get_application_protocol,
- schan_get_connection_info,
- schan_get_enabled_protocols,
- schan_get_key_signature_algorithm,
- schan_get_max_message_size,
- schan_get_session_cipher_block_size,
- schan_get_session_peer_certificate,
- schan_get_unique_channel_binding,
- schan_handshake,
- schan_recv,
- schan_send,
- schan_set_application_protocols,
- schan_set_dtls_mtu,
- schan_set_session_target,
- schan_set_session_transport,
-};
-
-NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
-{
- if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
- ssl_init();
- callbacks = ptr_in;
- *(const struct schan_funcs **)ptr_out = &funcs;
- return STATUS_SUCCESS;
-}
-
-#endif /* HAVE_SECURITY_SECURITY_H && !SONAME_LIBGNUTLS */
--
2.33.0
Sept. 29, 2021