Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b84e11ec
Commit
b84e11ec
authored
Jun 29, 2013
by
Qian Hong
Committed by
Alexandre Julliard
Jul 01, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsaenh/tests: Added more key state tests.
parent
20bf0291
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
4 deletions
+150
-4
rsaenh.c
dlls/rsaenh/tests/rsaenh.c
+150
-4
No files found.
dlls/rsaenh/tests/rsaenh.c
View file @
b84e11ec
...
...
@@ -773,7 +773,7 @@ static void test_3des112(void)
HCRYPTKEY
hKey
;
BOOL
result
;
DWORD
dwLen
;
unsigned
char
pbData
[
16
];
unsigned
char
pbData
[
16
]
,
enc_data
[
16
],
bad_data
[
16
]
;
int
i
;
result
=
derive_key
(
CALG_3DES_112
,
&
hKey
,
0
);
...
...
@@ -800,6 +800,7 @@ static void test_3des112(void)
result
=
CryptEncrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
memcpy
(
enc_data
,
pbData
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
...
...
@@ -811,6 +812,42 @@ static void test_3des112(void)
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
/* Test bad data:
Decrypting a block of bad data with Final = TRUE should restore the
initial state of the key as well as decrypting a block of good data.
*/
/* Changing key state by setting Final = FALSE */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
FALSE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
/* Restoring key state by decrypting bad_data with Final = TRUE */
memcpy
(
bad_data
,
enc_data
,
cTestData
[
i
].
buflen
);
bad_data
[
cTestData
[
i
].
buflen
-
1
]
=
~
bad_data
[
cTestData
[
i
].
buflen
-
1
];
SetLastError
(
0xdeadbeef
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
bad_data
,
&
dwLen
);
ok
(
!
result
,
"CryptDecrypt should failed!
\n
"
);
ok
(
GetLastError
()
==
NTE_BAD_DATA
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
/* Checking key state */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
enclen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
enclen
);
todo_wine
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
if
((
dwLen
!=
cTestData
[
i
].
enclen
)
||
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
enclen
))
{
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
}
result
=
CryptDestroyKey
(
hKey
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
...
...
@@ -821,7 +858,7 @@ static void test_des(void)
HCRYPTKEY
hKey
;
BOOL
result
;
DWORD
dwLen
,
dwMode
;
unsigned
char
pbData
[
16
];
unsigned
char
pbData
[
16
]
,
enc_data
[
16
],
bad_data
[
16
]
;
int
i
;
result
=
derive_key
(
CALG_DES
,
&
hKey
,
56
);
...
...
@@ -856,6 +893,7 @@ static void test_des(void)
result
=
CryptEncrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
memcpy
(
enc_data
,
pbData
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
...
...
@@ -867,6 +905,41 @@ static void test_des(void)
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
/* Test bad data:
Decrypting a block of bad data with Final = TRUE should restore the
initial state of the key as well as decrypting a block of good data.
*/
/* Changing key state by setting Final = FALSE */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
FALSE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
/* Restoring key state by decrypting bad_data with Final = TRUE */
memcpy
(
bad_data
,
enc_data
,
cTestData
[
i
].
buflen
);
bad_data
[
cTestData
[
i
].
buflen
-
1
]
=
~
bad_data
[
cTestData
[
i
].
buflen
-
1
];
SetLastError
(
0xdeadbeef
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
bad_data
,
&
dwLen
);
ok
(
!
result
,
"CryptDecrypt should failed!
\n
"
);
ok
(
GetLastError
()
==
NTE_BAD_DATA
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
/* Checking key state */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
enclen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
enclen
);
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
if
((
dwLen
!=
cTestData
[
i
].
enclen
)
||
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
enclen
))
{
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
}
result
=
CryptDestroyKey
(
hKey
);
...
...
@@ -878,7 +951,7 @@ static void test_3des(void)
HCRYPTKEY
hKey
;
BOOL
result
;
DWORD
dwLen
;
unsigned
char
pbData
[
16
];
unsigned
char
pbData
[
16
]
,
enc_data
[
16
],
bad_data
[
16
]
;
static
const
BYTE
des3
[
16
]
=
{
0x7b
,
0xba
,
0xdd
,
0xa2
,
0x39
,
0xd3
,
0x7b
,
0xb3
,
0xc7
,
0x51
,
0x81
,
0x41
,
0x53
,
0xe8
,
0xcf
,
0xeb
};
...
...
@@ -906,6 +979,7 @@ static void test_3des(void)
result
=
CryptEncrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
memcpy
(
enc_data
,
pbData
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
...
...
@@ -917,6 +991,42 @@ static void test_3des(void)
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
/* Test bad data:
Decrypting a block of bad data with Final = TRUE should restore the
initial state of the key as well as decrypting a block of good data.
*/
/* Changing key state by setting Final = FALSE */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
FALSE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
/* Restoring key state by decrypting bad_data with Final = TRUE */
memcpy
(
bad_data
,
enc_data
,
cTestData
[
i
].
buflen
);
bad_data
[
cTestData
[
i
].
buflen
-
1
]
=
~
bad_data
[
cTestData
[
i
].
buflen
-
1
];
SetLastError
(
0xdeadbeef
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
bad_data
,
&
dwLen
);
ok
(
!
result
,
"CryptDecrypt should failed!
\n
"
);
ok
(
GetLastError
()
==
NTE_BAD_DATA
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
/* Checking key state */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
enclen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
enclen
);
todo_wine
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
if
((
dwLen
!=
cTestData
[
i
].
enclen
)
||
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
enclen
))
{
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
}
result
=
CryptDestroyKey
(
hKey
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
...
...
@@ -927,7 +1037,7 @@ static void test_aes(int keylen)
HCRYPTKEY
hKey
;
BOOL
result
;
DWORD
dwLen
;
unsigned
char
pbData
[
16
];
unsigned
char
pbData
[
16
]
,
enc_data
[
16
],
bad_data
[
16
]
;
int
i
;
switch
(
keylen
)
...
...
@@ -969,7 +1079,43 @@ static void test_aes(int keylen)
result
=
CryptEncrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
memcpy
(
enc_data
,
pbData
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
enclen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
enclen
);
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
if
((
dwLen
!=
cTestData
[
i
].
enclen
)
||
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
enclen
))
{
printBytes
(
"expected"
,
cTestData
[
i
].
decstr
,
cTestData
[
i
].
strlen
);
printBytes
(
"got"
,
pbData
,
dwLen
);
}
/* Test bad data:
Decrypting a block of bad data with Final = TRUE should restore the
initial state of the key as well as decrypting a block of good data.
*/
/* Changing key state by setting Final = FALSE */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
FALSE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
/* Restoring key state by decrypting bad_data with Final = TRUE */
memcpy
(
bad_data
,
enc_data
,
cTestData
[
i
].
buflen
);
bad_data
[
cTestData
[
i
].
buflen
-
1
]
=
~
bad_data
[
cTestData
[
i
].
buflen
-
1
];
SetLastError
(
0xdeadbeef
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
bad_data
,
&
dwLen
);
ok
(
!
result
,
"CryptDecrypt should failed!
\n
"
);
ok
(
GetLastError
()
==
NTE_BAD_DATA
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
buflen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
buflen
);
ok
(
memcmp
(
pbData
,
cTestData
[
i
].
decstr
,
cTestData
[
1
].
enclen
)
==
0
,
"decryption incorrect %d
\n
"
,
i
);
/* Checking key state */
dwLen
=
cTestData
[
i
].
buflen
;
memcpy
(
pbData
,
enc_data
,
cTestData
[
i
].
buflen
);
result
=
CryptDecrypt
(
hKey
,
0
,
TRUE
,
0
,
pbData
,
&
dwLen
);
ok
(
result
,
"%08x
\n
"
,
GetLastError
());
ok
(
dwLen
==
cTestData
[
i
].
enclen
,
"length incorrect, got %d, expected %d
\n
"
,
dwLen
,
cTestData
[
i
].
enclen
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment