Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Billy Laws
wine
Commits
0677d8dc
Commit
0677d8dc
authored
3 months ago
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
rsaenh/tests: Add some tests for RC4 salt.
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
parent
3c5f205a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/rsaenh/tests/rsaenh.c
+137
-0
137 additions, 0 deletions
dlls/rsaenh/tests/rsaenh.c
with
137 additions
and
0 deletions
dlls/rsaenh/tests/rsaenh.c
+
137
−
0
View file @
0677d8dc
...
...
@@ -4,6 +4,7 @@
* Copyright (c) 2004 Michael Jung
* Copyright (c) 2006 Juan Lang
* Copyright (c) 2007 Vijay Kiran Kamuju
* Copyright (c) 2025 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -4200,8 +4201,144 @@ static void test_rc2_import(void)
CryptDestroyKey
(
exchange_key
);
}
static
const
BYTE
PRIVATE_EXCH_blob
[
308
]
=
{
0x07
,
0x02
,
0x00
,
0x00
,
0x00
,
0xa4
,
0x00
,
0x00
,
0x52
,
0x53
,
0x41
,
0x32
,
0x00
,
0x02
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x55
,
0x7b
,
0x36
,
0x13
,
0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x4b
,
0xc9
,
0x6f
,
0x78
,
0x1e
,
0xff
,
0x38
,
0xd4
,
0x26
,
0x38
,
0x77
,
0x89
,
0x9b
,
0xf6
,
0x6b
,
0xf7
,
0xaa
,
0xea
,
0xad
,
0x27
,
0x11
,
0x1e
,
0xa5
,
0x98
,
0x23
,
0xcb
,
0xaa
,
0x32
,
0x34
,
0xaf
,
0x19
,
0xd8
,
0x24
,
0x95
,
0xe4
,
0xae
,
0x4e
,
0x03
,
0x1d
,
0x75
,
0xeb
,
0xec
,
0xc1
,
0x09
,
0xd0
,
0x02
,
0xed
,
0x1f
,
0x0e
,
0xcf
,
0x23
,
0xce
,
0xe9
,
0x09
,
0x34
,
0xe3
,
0xc9
,
0xb9
,
0xbb
};
static
void
test_RC4_salt
(
void
)
{
static
const
BYTE
zero
[
11
];
static
const
struct
{
const
char
*
prov
;
DWORD
flags
,
key_length
,
salt_length
;
}
td
[]
=
{
{
MS_DEF_PROV_A
,
0
,
0
,
11
},
{
MS_DEF_PROV_A
,
0
,
40
,
11
},
{
MS_DEF_PROV_A
,
CRYPT_NO_SALT
,
40
,
0
},
{
MS_DEF_PROV_A
,
0
,
56
,
0
},
{
MS_DEF_PROV_A
,
CRYPT_CREATE_SALT
,
56
,
11
},
{
MS_ENHANCED_PROV_A
,
0
,
0
,
0
},
{
MS_ENHANCED_PROV_A
,
0
,
40
,
11
},
{
MS_ENHANCED_PROV_A
,
CRYPT_NO_SALT
,
40
,
0
},
{
MS_ENHANCED_PROV_A
,
CRYPT_CREATE_SALT
,
40
,
0
},
{
MS_ENHANCED_PROV_A
,
CRYPT_CREATE_SALT
,
56
,
0
},
{
MS_ENHANCED_PROV_A
,
CRYPT_CREATE_SALT
,
128
,
0
}
};
HCRYPTPROV
hprov
;
HCRYPTKEY
hkey
,
hkeyx
;
DWORD
i
,
key_length
,
size
,
blob_size
;
void
*
blob
;
BYTE
salt
[
16
],
salt2
[
16
];
CRYPT_DATA_BLOB
data
;
BOOL
ret
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
td
);
i
++
)
{
winetest_push_context
(
"%lu"
,
i
);
ret
=
CryptAcquireContextA
(
&
hprov
,
NULL
,
td
[
i
].
prov
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
ret
=
CryptGenKey
(
hprov
,
CALG_RC4
,
(
td
[
i
].
key_length
<<
16
)
|
td
[
i
].
flags
|
CRYPT_EXPORTABLE
,
&
hkey
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
size
=
sizeof
(
key_length
);
ret
=
CryptGetKeyParam
(
hkey
,
KP_KEYLEN
,
(
BYTE
*
)
&
key_length
,
&
size
,
0
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
if
(
!
strcmp
(
td
[
i
].
prov
,
MS_DEF_PROV_A
))
ok
(
key_length
==
(
td
[
i
].
key_length
?
td
[
i
].
key_length
:
40
),
"got %lu, expected %lu
\n
"
,
key_length
,
td
[
i
].
key_length
);
else
ok
(
key_length
==
(
td
[
i
].
key_length
?
td
[
i
].
key_length
:
128
),
"got %lu, expected %lu
\n
"
,
key_length
,
td
[
i
].
key_length
);
size
=
0xdeadbeef
;
ret
=
CryptGetKeyParam
(
hkey
,
KP_SALT
,
NULL
,
&
size
,
0
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
todo_wine_if
(
i
==
4
||
i
==
9
)
ok
(
size
==
td
[
i
].
salt_length
,
"got %lu, expected %lu
\n
"
,
size
,
td
[
i
].
salt_length
);
if
(
size
)
{
ret
=
CryptGetKeyParam
(
hkey
,
KP_SALT
,
salt
,
&
size
,
0
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
if
(
td
[
i
].
flags
&
CRYPT_CREATE_SALT
)
ok
(
memcmp
(
salt
,
zero
,
size
)
!=
0
,
"wrong salt %.11s
\n
"
,
salt
);
else
todo_wine_if
(
i
==
0
||
i
==
1
||
i
==
6
)
ok
(
memcmp
(
salt
,
zero
,
size
)
==
0
,
"wrong salt %.11s
\n
"
,
salt
);
}
memcpy
(
salt
,
(
const
BYTE
*
)
"0123456789A"
,
11
);
data
.
pbData
=
salt
;
data
.
cbData
=
11
;
ret
=
CryptSetKeyParam
(
hkey
,
KP_SALT_EX
,
(
BYTE
*
)
&
data
,
0
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
ret
=
CryptImportKey
(
hprov
,
PUBLIC_EXCH_blob
,
sizeof
(
PUBLIC_EXCH_blob
),
0
,
0
,
&
hkeyx
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
ret
=
CryptExportKey
(
hkey
,
hkeyx
,
SIMPLEBLOB
,
0
,
NULL
,
&
blob_size
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
blob
=
malloc
(
blob_size
);
ret
=
CryptExportKey
(
hkey
,
hkeyx
,
SIMPLEBLOB
,
0
,
blob
,
&
blob_size
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
CryptDestroyKey
(
hkey
);
CryptDestroyKey
(
hkeyx
);
ret
=
CryptImportKey
(
hprov
,
PRIVATE_EXCH_blob
,
sizeof
(
PRIVATE_EXCH_blob
),
0
,
0
,
&
hkeyx
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
ret
=
CryptImportKey
(
hprov
,
blob
,
blob_size
,
hkeyx
,
0
,
&
hkey
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
size
=
0xdeadbeef
;
ret
=
CryptGetKeyParam
(
hkey
,
KP_SALT
,
NULL
,
&
size
,
0
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
if
((
!
strcmp
(
td
[
i
].
prov
,
MS_DEF_PROV_A
)
&&
!
td
[
i
].
key_length
)
||
td
[
i
].
key_length
==
40
)
ok
(
size
==
11
,
"got %lu, expected 11
\n
"
,
size
);
else
ok
(
size
==
0
,
"got %lu, expected 0
\n
"
,
size
);
ret
=
CryptGetKeyParam
(
hkey
,
KP_SALT
,
salt2
,
&
size
,
0
);
ok
(
ret
,
"error %#lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
salt2
,
zero
,
size
),
"wrong salt %.11s
\n
"
,
salt2
);
free
(
blob
);
CryptDestroyKey
(
hkey
);
CryptDestroyKey
(
hkeyx
);
CryptReleaseContext
(
hprov
,
0
);
winetest_pop_context
();
}
}
START_TEST
(
rsaenh
)
{
test_RC4_salt
();
for
(
iProv
=
0
;
iProv
<
ARRAY_SIZE
(
szProviders
);
iProv
++
)
{
if
(
!
init_base_environment
(
szProviders
[
iProv
],
0
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment