Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
5d388941
Commit
5d388941
authored
Feb 22, 2006
by
Juan Lang
Committed by
Alexandre Julliard
Feb 22, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Tidy up tests.
Fix up encoded data to use BYTE arrays rather than strings, and remove extraneous NULL bytes from the end of some of them
parent
d740f342
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
140 deletions
+145
-140
encode.c
dlls/crypt32/tests/encode.c
+55
-54
store.c
dlls/crypt32/tests/store.c
+90
-86
No files found.
dlls/crypt32/tests/encode.c
View file @
5d388941
...
@@ -32,13 +32,13 @@ struct encodedInt
...
@@ -32,13 +32,13 @@ struct encodedInt
const
BYTE
*
encoded
;
const
BYTE
*
encoded
;
};
};
static
const
BYTE
bin1
[]
=
{
0x02
,
0x01
,
0x01
,
0
};
static
const
BYTE
bin1
[]
=
{
0x02
,
0x01
,
0x01
};
static
const
BYTE
bin2
[]
=
{
0x02
,
0x01
,
0x7f
,
0
};
static
const
BYTE
bin2
[]
=
{
0x02
,
0x01
,
0x7f
};
static
const
BYTE
bin3
[]
=
{
0x02
,
0x02
,
0x00
,
0x80
,
0
};
static
const
BYTE
bin3
[]
=
{
0x02
,
0x02
,
0x00
,
0x80
};
static
const
BYTE
bin4
[]
=
{
0x02
,
0x02
,
0x01
,
0x00
,
0
};
static
const
BYTE
bin4
[]
=
{
0x02
,
0x02
,
0x01
,
0x00
};
static
const
BYTE
bin5
[]
=
{
0x02
,
0x01
,
0x80
,
0
};
static
const
BYTE
bin5
[]
=
{
0x02
,
0x01
,
0x80
};
static
const
BYTE
bin6
[]
=
{
0x02
,
0x02
,
0xff
,
0x7f
,
0
};
static
const
BYTE
bin6
[]
=
{
0x02
,
0x02
,
0xff
,
0x7f
};
static
const
BYTE
bin7
[]
=
{
0x02
,
0x04
,
0xba
,
0xdd
,
0xf0
,
0x0d
,
0
};
static
const
BYTE
bin7
[]
=
{
0x02
,
0x04
,
0xba
,
0xdd
,
0xf0
,
0x0d
};
static
const
struct
encodedInt
ints
[]
=
{
static
const
struct
encodedInt
ints
[]
=
{
{
1
,
bin1
},
{
1
,
bin1
},
...
@@ -335,8 +335,8 @@ static void test_decodeInt(DWORD dwEncoding)
...
@@ -335,8 +335,8 @@ static void test_decodeInt(DWORD dwEncoding)
"Expected STATUS_ACCESS_VIOLATION, got %08lx
\n
"
,
GetLastError
());
"Expected STATUS_ACCESS_VIOLATION, got %08lx
\n
"
,
GetLastError
());
}
}
static
const
BYTE
bin18
[]
=
{
0x0a
,
0x01
,
0x01
,
0
};
static
const
BYTE
bin18
[]
=
{
0x0a
,
0x01
,
0x01
};
static
const
BYTE
bin19
[]
=
{
0x0a
,
0x05
,
0x00
,
0xff
,
0xff
,
0xff
,
0x80
,
0
};
static
const
BYTE
bin19
[]
=
{
0x0a
,
0x05
,
0x00
,
0xff
,
0xff
,
0xff
,
0x80
};
/* These are always encoded unsigned, and aren't constrained to be any
/* These are always encoded unsigned, and aren't constrained to be any
* particular value
* particular value
...
@@ -482,11 +482,11 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType,
...
@@ -482,11 +482,11 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType,
}
}
static
const
BYTE
bin20
[]
=
{
static
const
BYTE
bin20
[]
=
{
0x17
,
0x0d
,
'0'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'Z'
,
0
};
0x17
,
0x0d
,
'0'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'Z'
};
static
const
BYTE
bin21
[]
=
{
static
const
BYTE
bin21
[]
=
{
0x18
,
0x0f
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'Z'
,
0
};
0x18
,
0x0f
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'Z'
};
static
const
BYTE
bin22
[]
=
{
static
const
BYTE
bin22
[]
=
{
0x18
,
0x0f
,
'2'
,
'1'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'Z'
,
0
};
0x18
,
0x0f
,
'2'
,
'1'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'Z'
};
static
const
struct
encodedFiletime
times
[]
=
{
static
const
struct
encodedFiletime
times
[]
=
{
{
{
2005
,
6
,
1
,
6
,
16
,
10
,
0
,
0
},
bin20
},
{
{
2005
,
6
,
1
,
6
,
16
,
10
,
0
,
0
},
bin20
},
...
@@ -507,37 +507,37 @@ static void test_encodeFiletime(DWORD dwEncoding)
...
@@ -507,37 +507,37 @@ static void test_encodeFiletime(DWORD dwEncoding)
}
}
static
const
BYTE
bin23
[]
=
{
static
const
BYTE
bin23
[]
=
{
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'.'
,
'0'
,
'0'
,
'0'
,
'Z'
,
0
};
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'.'
,
'0'
,
'0'
,
'0'
,
'Z'
};
static
const
BYTE
bin24
[]
=
{
static
const
BYTE
bin24
[]
=
{
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'.'
,
'9'
,
'9'
,
'9'
,
'Z'
,
0
};
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'.'
,
'9'
,
'9'
,
'9'
,
'Z'
};
static
const
BYTE
bin25
[]
=
{
static
const
BYTE
bin25
[]
=
{
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'+'
,
'0'
,
'1'
,
'0'
,
'0'
,
0
};
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'+'
,
'0'
,
'1'
,
'0'
,
'0'
};
static
const
BYTE
bin26
[]
=
{
static
const
BYTE
bin26
[]
=
{
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'-'
,
'0'
,
'1'
,
'0'
,
'0'
,
0
};
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'-'
,
'0'
,
'1'
,
'0'
,
'0'
};
static
const
BYTE
bin27
[]
=
{
static
const
BYTE
bin27
[]
=
{
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'-'
,
'0'
,
'1'
,
'1'
,
'5'
,
0
};
0x18
,
0x13
,
'1'
,
'9'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'0'
,
'0'
,
'-'
,
'0'
,
'1'
,
'1'
,
'5'
};
static
const
BYTE
bin28
[]
=
{
static
const
BYTE
bin28
[]
=
{
0x18
,
0x0a
,
'2'
,
'1'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
0
};
0x18
,
0x0a
,
'2'
,
'1'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
};
static
const
BYTE
bin29
[]
=
{
static
const
BYTE
bin29
[]
=
{
0x17
,
0x0a
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
0
};
0x17
,
0x0a
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
};
static
const
BYTE
bin30
[]
=
{
static
const
BYTE
bin30
[]
=
{
0x17
,
0x0b
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'Z'
,
0
};
0x17
,
0x0b
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'Z'
};
static
const
BYTE
bin31
[]
=
{
static
const
BYTE
bin31
[]
=
{
0x17
,
0x0d
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'+'
,
'0'
,
'1'
,
0
};
0x17
,
0x0d
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'+'
,
'0'
,
'1'
};
static
const
BYTE
bin32
[]
=
{
static
const
BYTE
bin32
[]
=
{
0x17
,
0x0d
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'-'
,
'0'
,
'1'
,
0
};
0x17
,
0x0d
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'-'
,
'0'
,
'1'
};
static
const
BYTE
bin33
[]
=
{
static
const
BYTE
bin33
[]
=
{
0x17
,
0x0f
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'+'
,
'0'
,
'1'
,
'0'
,
'0'
,
0
};
0x17
,
0x0f
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'+'
,
'0'
,
'1'
,
'0'
,
'0'
};
static
const
BYTE
bin34
[]
=
{
static
const
BYTE
bin34
[]
=
{
0x17
,
0x0f
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'-'
,
'0'
,
'1'
,
'0'
,
'0'
,
0
};
0x17
,
0x0f
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
'1'
,
'0'
,
'-'
,
'0'
,
'1'
,
'0'
,
'0'
};
static
const
BYTE
bin35
[]
=
{
static
const
BYTE
bin35
[]
=
{
0x17
,
0x08
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
,
0
};
0x17
,
0x08
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
'1'
,
'6'
};
static
const
BYTE
bin36
[]
=
{
static
const
BYTE
bin36
[]
=
{
0x18
,
0x0f
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'Z'
,
0
};
0x18
,
0x0f
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'a'
,
'Z'
};
static
const
BYTE
bin37
[]
=
{
static
const
BYTE
bin37
[]
=
{
0x18
,
0x04
,
'2'
,
'1'
,
'4'
,
'5'
,
0
};
0x18
,
0x04
,
'2'
,
'1'
,
'4'
,
'5'
};
static
const
BYTE
bin38
[]
=
{
static
const
BYTE
bin38
[]
=
{
0x18
,
0x08
,
'2'
,
'1'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
,
0
};
0x18
,
0x08
,
'2'
,
'1'
,
'4'
,
'5'
,
'0'
,
'6'
,
'0'
,
'6'
};
static
void
test_decodeFiletime
(
DWORD
dwEncoding
)
static
void
test_decodeFiletime
(
DWORD
dwEncoding
)
{
{
...
@@ -1297,13 +1297,13 @@ struct encodedBits
...
@@ -1297,13 +1297,13 @@ struct encodedBits
const
BYTE
*
decoded
;
const
BYTE
*
decoded
;
};
};
static
const
unsigned
char
bin52
[]
=
{
0x03
,
0x03
,
0x00
,
0xff
,
0xff
,
0
};
static
const
unsigned
char
bin52
[]
=
{
0x03
,
0x03
,
0x00
,
0xff
,
0xff
};
static
const
unsigned
char
bin53
[]
=
{
0xff
,
0xff
,
0
};
static
const
unsigned
char
bin53
[]
=
{
0xff
,
0xff
};
static
const
unsigned
char
bin54
[]
=
{
0x03
,
0x03
,
0x01
,
0xff
,
0xfe
,
0
};
static
const
unsigned
char
bin54
[]
=
{
0x03
,
0x03
,
0x01
,
0xff
,
0xfe
};
static
const
unsigned
char
bin55
[]
=
{
0xff
,
0xfe
,
0
};
static
const
unsigned
char
bin55
[]
=
{
0xff
,
0xfe
};
static
const
unsigned
char
bin56
[]
=
{
0x03
,
0x02
,
0x01
,
0xfe
,
0
};
static
const
unsigned
char
bin56
[]
=
{
0x03
,
0x02
,
0x01
,
0xfe
};
static
const
unsigned
char
bin57
[]
=
{
0xfe
,
0
};
static
const
unsigned
char
bin57
[]
=
{
0xfe
};
static
const
unsigned
char
bin58
[]
=
{
0x03
,
0x01
,
0x00
,
0
};
static
const
unsigned
char
bin58
[]
=
{
0x03
,
0x01
,
0x00
};
static
const
struct
encodedBits
bits
[]
=
{
static
const
struct
encodedBits
bits
[]
=
{
/* normal test cases */
/* normal test cases */
...
@@ -1406,10 +1406,10 @@ struct Constraints2
...
@@ -1406,10 +1406,10 @@ struct Constraints2
const
BYTE
*
encoded
;
const
BYTE
*
encoded
;
};
};
static
const
unsigned
char
bin59
[]
=
{
0x30
,
0x00
,
0
};
static
const
unsigned
char
bin59
[]
=
{
0x30
,
0x00
};
static
const
unsigned
char
bin60
[]
=
{
0x30
,
0x03
,
0x01
,
0x01
,
0xff
,
0
};
static
const
unsigned
char
bin60
[]
=
{
0x30
,
0x03
,
0x01
,
0x01
,
0xff
};
static
const
unsigned
char
bin61
[]
=
{
0x30
,
0x03
,
0x02
,
0x01
,
0x00
,
0
};
static
const
unsigned
char
bin61
[]
=
{
0x30
,
0x03
,
0x02
,
0x01
,
0x00
};
static
const
unsigned
char
bin62
[]
=
{
0x30
,
0x06
,
0x01
,
0x01
,
0xff
,
0x02
,
0x01
,
0x01
,
0
};
static
const
unsigned
char
bin62
[]
=
{
0x30
,
0x06
,
0x01
,
0x01
,
0xff
,
0x02
,
0x01
,
0x01
};
static
const
struct
Constraints2
constraints2
[]
=
{
static
const
struct
Constraints2
constraints2
[]
=
{
/* empty constraints */
/* empty constraints */
{
{
FALSE
,
FALSE
,
0
},
bin59
},
{
{
FALSE
,
FALSE
,
0
},
bin59
},
...
@@ -1495,11 +1495,12 @@ static void test_encodeBasicConstraints(DWORD dwEncoding)
...
@@ -1495,11 +1495,12 @@ static void test_encodeBasicConstraints(DWORD dwEncoding)
/* FIXME: test encoding with subject type. */
/* FIXME: test encoding with subject type. */
}
}
static
const
unsigned
char
bin63
[]
=
{
0x30
,
0x06
,
0x01
,
0x01
,
0x01
,
0x02
,
0x01
,
0x01
,
0
};
static
const
unsigned
char
bin63
[]
=
{
0x30
,
0x06
,
0x01
,
0x01
,
0x01
,
0x02
,
0x01
,
0x01
};
static
void
test_decodeBasicConstraints
(
DWORD
dwEncoding
)
static
void
test_decodeBasicConstraints
(
DWORD
dwEncoding
)
{
{
static
const
BYTE
inverted
[]
=
"
\x30\x06\x02\x01\x01\x01\x01\xff
"
;
static
const
BYTE
inverted
[]
=
{
0x30
,
0x06
,
0x02
,
0x01
,
0x01
,
0x01
,
0x01
,
0xff
};
static
const
struct
Constraints2
badBool
=
{
{
TRUE
,
TRUE
,
1
},
bin63
};
static
const
struct
Constraints2
badBool
=
{
{
TRUE
,
TRUE
,
1
},
bin63
};
DWORD
i
;
DWORD
i
;
BOOL
ret
;
BOOL
ret
;
...
@@ -1986,28 +1987,28 @@ static const BYTE aKey[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd,
...
@@ -1986,28 +1987,28 @@ static const BYTE aKey[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd,
static
const
BYTE
params
[]
=
{
0x02
,
0x01
,
0x01
};
static
const
BYTE
params
[]
=
{
0x02
,
0x01
,
0x01
};
static
const
unsigned
char
bin64
[]
=
{
static
const
unsigned
char
bin64
[]
=
{
0x30
,
0x0b
,
0x30
,
0x06
,
0x06
,
0x02
,
0x2a
,
0x03
,
0x05
,
0x00
,
0x03
,
0x01
,
0x00
,
0
};
0x30
,
0x0b
,
0x30
,
0x06
,
0x06
,
0x02
,
0x2a
,
0x03
,
0x05
,
0x00
,
0x03
,
0x01
,
0x00
};
static
const
unsigned
char
bin65
[]
=
{
static
const
unsigned
char
bin65
[]
=
{
0x30
,
0x09
,
0x30
,
0x04
,
0x06
,
0x02
,
0x2a
,
0x03
,
0x03
,
0x01
,
0x00
,
0
};
0x30
,
0x09
,
0x30
,
0x04
,
0x06
,
0x02
,
0x2a
,
0x03
,
0x03
,
0x01
,
0x00
};
static
const
unsigned
char
bin66
[]
=
{
static
const
unsigned
char
bin66
[]
=
{
0x30
,
0x0f
,
0x30
,
0x0a
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x05
,
0x00
,
0x03
,
0x01
,
0x00
,
0
};
0x30
,
0x0f
,
0x30
,
0x0a
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x05
,
0x00
,
0x03
,
0x01
,
0x00
};
static
const
unsigned
char
bin67
[]
=
{
static
const
unsigned
char
bin67
[]
=
{
0x30
,
0x0d
,
0x30
,
0x08
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x03
,
0x01
,
0x00
,
0
};
0x30
,
0x0d
,
0x30
,
0x08
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x03
,
0x01
,
0x00
};
static
const
unsigned
char
bin68
[]
=
{
static
const
unsigned
char
bin68
[]
=
{
0x30
,
0x1f
,
0x30
,
0x0a
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x05
,
0x00
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x30
,
0x1f
,
0x30
,
0x0a
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x05
,
0x00
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
,
0
};
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
};
static
const
unsigned
char
bin69
[]
=
{
static
const
unsigned
char
bin69
[]
=
{
0x30
,
0x1d
,
0x30
,
0x08
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x30
,
0x1d
,
0x30
,
0x08
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
,
0
};
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
};
static
const
unsigned
char
bin70
[]
=
{
static
const
unsigned
char
bin70
[]
=
{
0x30
,
0x20
,
0x30
,
0x0b
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x01
,
0x01
,
0x30
,
0x20
,
0x30
,
0x0b
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x01
,
0x01
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
,
0
};
0x0f
};
static
const
unsigned
char
bin71
[]
=
{
static
const
unsigned
char
bin71
[]
=
{
0x30
,
0x20
,
0x30
,
0x0b
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x01
,
0x01
,
0x30
,
0x20
,
0x30
,
0x0b
,
0x06
,
0x06
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x01
,
0x01
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x03
,
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
,
0
};
0x0f
};
static
unsigned
char
bin72
[]
=
{
0x05
,
0x00
,
0
};
static
unsigned
char
bin72
[]
=
{
0x05
,
0x00
};
static
const
struct
encodedPublicKey
pubKeys
[]
=
{
static
const
struct
encodedPublicKey
pubKeys
[]
=
{
/* with a bogus OID */
/* with a bogus OID */
...
@@ -2084,10 +2085,10 @@ static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected,
...
@@ -2084,10 +2085,10 @@ static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected,
static
void
test_decodePublicKeyInfo
(
DWORD
dwEncoding
)
static
void
test_decodePublicKeyInfo
(
DWORD
dwEncoding
)
{
{
static
const
BYTE
bogusPubKeyInfo
[]
=
static
const
BYTE
bogusPubKeyInfo
[]
=
{
0x30
,
0x22
,
0x30
,
0x0d
,
0x06
,
0x06
,
"
\x30\x22\x30\x0d\x06\x06\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x01\x01
"
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x01
,
0x01
,
0x01
,
0x01
,
0x03
,
"
\x03\x11\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e
"
0x11
,
0x00
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
0x08
,
0x09
,
"
\x0f
"
;
0x0a
,
0x0b
,
0x0c
,
0x0d
,
0x0e
,
0x0f
}
;
DWORD
i
;
DWORD
i
;
BOOL
ret
;
BOOL
ret
;
BYTE
*
buf
=
NULL
;
BYTE
*
buf
=
NULL
;
...
...
dlls/crypt32/tests/store.c
View file @
5d388941
...
@@ -42,14 +42,16 @@ struct CertPropIDHeader
...
@@ -42,14 +42,16 @@ struct CertPropIDHeader
};
};
static
const
BYTE
emptyCert
[]
=
{
0x30
,
0x00
};
static
const
BYTE
emptyCert
[]
=
{
0x30
,
0x00
};
static
const
BYTE
bigCert
[]
=
"
\x30\x7a\x02\x01\x01\x30\x02\x06\x00
"
static
const
BYTE
bigCert
[]
=
{
0x30
,
0x7a
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
"
\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0a\x4a\x75\x61\x6e\x20\x4c
"
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
"
\x61\x6e\x67\x00\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30
"
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x22
,
"
\x30\x30\x30\x5a\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30
"
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
"
\x30\x5a\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0a\x4a\x75\x61\x6e
"
0x30
,
0x30
,
0x30
,
0x5a
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
"
\x20\x4c\x61\x6e\x67\x00\x30\x07\x30\x02\x06\x00\x03\x01\x00\xa3\x16\x30\x14
"
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
"
\x30\x12\x06\x03\x55\x1d\x13\x01\x01\xff\x04\x08\x30\x06\x01\x01\xff\x02\x01
"
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
"
\x01
"
;
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x07
,
0x30
,
0x02
,
0x06
,
0x00
,
0x03
,
0x01
,
0x00
,
0xa3
,
0x16
,
0x30
,
0x14
,
0x30
,
0x12
,
0x06
,
0x03
,
0x55
,
0x1d
,
0x13
,
0x01
,
0x01
,
0xff
,
0x04
,
0x08
,
0x30
,
0x06
,
0x01
,
0x01
,
0xff
,
0x02
,
0x01
,
0x01
};
static
const
BYTE
signedBigCert
[]
=
{
static
const
BYTE
signedBigCert
[]
=
{
0x30
,
0x81
,
0x93
,
0x30
,
0x7a
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x30
,
0x81
,
0x93
,
0x30
,
0x7a
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
...
@@ -95,16 +97,16 @@ static void testDupCert(void)
...
@@ -95,16 +97,16 @@ static void testDupCert(void)
BOOL
ret
;
BOOL
ret
;
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
&
context
);
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
&
context
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
GetLastError
());
ok
(
context
!=
NULL
,
"Expected a valid cert context
\n
"
);
ok
(
context
!=
NULL
,
"Expected a valid cert context
\n
"
);
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)
-
1
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)),
"Unexpected encoded cert in context
\n
"
);
"Unexpected encoded cert in context
\n
"
);
ok
(
context
->
hCertStore
==
store
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
store
,
"Unexpected store
\n
"
);
...
@@ -112,11 +114,11 @@ static void testDupCert(void)
...
@@ -112,11 +114,11 @@ static void testDupCert(void)
ok
(
dupContext
!=
NULL
,
"Expected valid duplicate
\n
"
);
ok
(
dupContext
!=
NULL
,
"Expected valid duplicate
\n
"
);
if
(
dupContext
)
if
(
dupContext
)
{
{
ok
(
dupContext
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
dupContext
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
),
dupContext
->
cbCertEncoded
);
dupContext
->
cbCertEncoded
);
ok
(
!
memcmp
(
dupContext
->
pbCertEncoded
,
bigCert
,
ok
(
!
memcmp
(
dupContext
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)
-
1
),
sizeof
(
bigCert
)),
"Unexpected encoded cert in context
\n
"
);
"Unexpected encoded cert in context
\n
"
);
ok
(
dupContext
->
hCertStore
==
store
,
"Unexpected store
\n
"
);
ok
(
dupContext
->
hCertStore
==
store
,
"Unexpected store
\n
"
);
CertFreeCertificateContext
(
dupContext
);
CertFreeCertificateContext
(
dupContext
);
...
@@ -192,7 +194,7 @@ static void testMemStore(void)
...
@@ -192,7 +194,7 @@ static void testMemStore(void)
GetLastError
());
GetLastError
());
/* add a cert to store1 */
/* add a cert to store1 */
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
bigCert
,
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
&
context
);
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
&
context
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
context
!=
NULL
,
"Expected a valid cert context
\n
"
);
ok
(
context
!=
NULL
,
"Expected a valid cert context
\n
"
);
if
(
context
)
if
(
context
)
...
@@ -200,10 +202,10 @@ static void testMemStore(void)
...
@@ -200,10 +202,10 @@ static void testMemStore(void)
DWORD
size
;
DWORD
size
;
BYTE
*
buf
;
BYTE
*
buf
;
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)
-
1
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)),
"Unexpected encoded cert in context
\n
"
);
"Unexpected encoded cert in context
\n
"
);
ok
(
context
->
hCertStore
==
store1
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
store1
,
"Unexpected store
\n
"
);
...
@@ -283,15 +285,15 @@ static void testMemStore(void)
...
@@ -283,15 +285,15 @@ static void testMemStore(void)
ok
(
store1
!=
NULL
,
"CertOpenStore failed: %ld
\n
"
,
GetLastError
());
ok
(
store1
!=
NULL
,
"CertOpenStore failed: %ld
\n
"
,
GetLastError
());
/* yep, this succeeds */
/* yep, this succeeds */
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
bigCert
,
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
&
context
);
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
&
context
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
context
!=
NULL
,
"Expected a valid cert context
\n
"
);
ok
(
context
!=
NULL
,
"Expected a valid cert context
\n
"
);
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected cert of %d bytes, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)
-
1
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
sizeof
(
bigCert
)),
"Unexpected encoded cert in context
\n
"
);
"Unexpected encoded cert in context
\n
"
);
ok
(
context
->
hCertStore
==
store1
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
store1
,
"Unexpected store
\n
"
);
ret
=
CertDeleteCertificateFromStore
(
context
);
ret
=
CertDeleteCertificateFromStore
(
context
);
...
@@ -301,14 +303,16 @@ static void testMemStore(void)
...
@@ -301,14 +303,16 @@ static void testMemStore(void)
CertCloseStore
(
store1
,
0
);
CertCloseStore
(
store1
,
0
);
}
}
static
const
BYTE
bigCert2
[]
=
"
\x30\x7a\x02\x01\x01\x30\x02\x06\x00
"
static
const
BYTE
bigCert2
[]
=
{
0x30
,
0x7a
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
"
\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0a\x41\x6c\x65\x78\x20\x4c
"
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
"
\x61\x6e\x67\x00\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30
"
0x0a
,
0x41
,
0x6c
,
0x65
,
0x78
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x22
,
"
\x30\x30\x30\x5a\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30
"
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
"
\x30\x5a\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0a\x41\x6c\x65\x78
"
0x30
,
0x30
,
0x30
,
0x5a
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
"
\x20\x4c\x61\x6e\x67\x00\x30\x07\x30\x02\x06\x00\x03\x01\x00\xa3\x16\x30\x14
"
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
"
\x30\x12\x06\x03\x55\x1d\x13\x01\x01\xff\x04\x08\x30\x06\x01\x01\xff\x02\x01
"
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
"
\x01
"
;
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x07
,
0x30
,
0x02
,
0x06
,
0x00
,
0x03
,
0x01
,
0x00
,
0xa3
,
0x16
,
0x30
,
0x14
,
0x30
,
0x12
,
0x06
,
0x03
,
0x55
,
0x1d
,
0x13
,
0x01
,
0x01
,
0xff
,
0x04
,
0x08
,
0x30
,
0x06
,
0x01
,
0x01
,
0xff
,
0x02
,
0x01
,
0x01
};
static
void
testCollectionStore
(
void
)
static
void
testCollectionStore
(
void
)
{
{
...
@@ -321,7 +325,7 @@ static void testCollectionStore(void)
...
@@ -321,7 +325,7 @@ static void testCollectionStore(void)
/* Try adding a cert to any empty collection */
/* Try adding a cert to any empty collection */
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
...
@@ -330,7 +334,7 @@ static void testCollectionStore(void)
...
@@ -330,7 +334,7 @@ static void testCollectionStore(void)
store1
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
store1
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
/* Add the memory store to the collection, without allowing adding */
/* Add the memory store to the collection, without allowing adding */
ret
=
CertAddStoreToCollection
(
collection
,
store1
,
0
,
0
);
ret
=
CertAddStoreToCollection
(
collection
,
store1
,
0
,
0
);
...
@@ -345,7 +349,7 @@ static void testCollectionStore(void)
...
@@ -345,7 +349,7 @@ static void testCollectionStore(void)
}
}
/* Check that adding to the collection isn't allowed */
/* Check that adding to the collection isn't allowed */
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
bigCert2
,
sizeof
(
bigCert2
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert2
,
sizeof
(
bigCert2
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
...
@@ -379,7 +383,7 @@ static void testCollectionStore(void)
...
@@ -379,7 +383,7 @@ static void testCollectionStore(void)
ok
(
ret
,
"CertAddStoreToCollection failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddStoreToCollection failed: %08lx
\n
"
,
GetLastError
());
/* Check that adding to the collection is allowed */
/* Check that adding to the collection is allowed */
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
bigCert2
,
sizeof
(
bigCert2
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert2
,
sizeof
(
bigCert2
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
/* Now check that it was actually added to store2 */
/* Now check that it was actually added to store2 */
context
=
CertEnumCertificatesInStore
(
store2
,
NULL
);
context
=
CertEnumCertificatesInStore
(
store2
,
NULL
);
...
@@ -397,8 +401,8 @@ static void testCollectionStore(void)
...
@@ -397,8 +401,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
"Unexpected cert
\n
"
);
...
@@ -407,8 +411,8 @@ static void testCollectionStore(void)
...
@@ -407,8 +411,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert2
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert2
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert2
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert2
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert2
,
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert2
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
...
@@ -423,8 +427,8 @@ static void testCollectionStore(void)
...
@@ -423,8 +427,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
"Unexpected cert
\n
"
);
...
@@ -433,8 +437,8 @@ static void testCollectionStore(void)
...
@@ -433,8 +437,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert2
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert2
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert2
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert2
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert2
,
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert2
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
...
@@ -455,8 +459,8 @@ static void testCollectionStore(void)
...
@@ -455,8 +459,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection2
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection2
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
"Unexpected cert
\n
"
);
...
@@ -465,8 +469,8 @@ static void testCollectionStore(void)
...
@@ -465,8 +469,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection2
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection2
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert2
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert2
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert2
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert2
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert2
,
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert2
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
...
@@ -499,10 +503,10 @@ static void testCollectionStore(void)
...
@@ -499,10 +503,10 @@ static void testCollectionStore(void)
ok
(
store2
!=
0
,
"CertOpenStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
store2
!=
0
,
"CertOpenStore failed: %08lx
\n
"
,
GetLastError
());
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
store1
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ret
=
CertAddEncodedCertificateToStore
(
store2
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
store2
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
collection
=
CertOpenStore
(
CERT_STORE_PROV_COLLECTION
,
0
,
0
,
collection
=
CertOpenStore
(
CERT_STORE_PROV_COLLECTION
,
0
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
...
@@ -521,8 +525,8 @@ static void testCollectionStore(void)
...
@@ -521,8 +525,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
"Unexpected cert
\n
"
);
...
@@ -531,8 +535,8 @@ static void testCollectionStore(void)
...
@@ -531,8 +535,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
"Unexpected cert
\n
"
);
...
@@ -546,7 +550,7 @@ static void testCollectionStore(void)
...
@@ -546,7 +550,7 @@ static void testCollectionStore(void)
* only call CertDeleteCertificateFromStore with contexts enumerated from
* only call CertDeleteCertificateFromStore with contexts enumerated from
* the store.
* the store.
context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
sizeof(bigCert)
- 1
);
sizeof(bigCert));
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
GetLastError());
if (context)
if (context)
...
@@ -572,8 +576,8 @@ static void testCollectionStore(void)
...
@@ -572,8 +576,8 @@ static void testCollectionStore(void)
if
(
context
)
if
(
context
)
{
{
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
hCertStore
==
collection
,
"Unexpected store
\n
"
);
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
)
-
1
,
ok
(
context
->
cbCertEncoded
==
sizeof
(
bigCert
),
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
)
-
1
,
"Expected size %d, got %ld
\n
"
,
sizeof
(
bigCert
),
context
->
cbCertEncoded
);
context
->
cbCertEncoded
);
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
ok
(
!
memcmp
(
context
->
pbCertEncoded
,
bigCert
,
context
->
cbCertEncoded
),
"Unexpected cert
\n
"
);
"Unexpected cert
\n
"
);
...
@@ -685,7 +689,7 @@ static void testRegStore(void)
...
@@ -685,7 +689,7 @@ static void testRegStore(void)
* added to the cache..
* added to the cache..
*/
*/
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
bigCert2
,
sizeof
(
bigCert2
)
-
1
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert2
,
sizeof
(
bigCert2
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08lx
\n
"
,
GetLastError
());
GetLastError
());
/* so flush the cache to force a commit.. */
/* so flush the cache to force a commit.. */
...
@@ -693,7 +697,7 @@ static void testRegStore(void)
...
@@ -693,7 +697,7 @@ static void testRegStore(void)
ok
(
ret
,
"CertControlStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertControlStore failed: %08lx
\n
"
,
GetLastError
());
/* and check that the expected subkey was written. */
/* and check that the expected subkey was written. */
size
=
sizeof
(
hash
);
size
=
sizeof
(
hash
);
ret
=
CryptHashCertificate
(
0
,
0
,
0
,
bigCert2
,
sizeof
(
bigCert2
)
-
1
,
ret
=
CryptHashCertificate
(
0
,
0
,
0
,
bigCert2
,
sizeof
(
bigCert2
),
hash
,
&
size
);
hash
,
&
size
);
ok
(
ret
,
"CryptHashCertificate failed: %ld
\n
"
,
GetLastError
());
ok
(
ret
,
"CryptHashCertificate failed: %ld
\n
"
,
GetLastError
());
strcpy
(
subKeyName
,
certificates
);
strcpy
(
subKeyName
,
certificates
);
...
@@ -723,9 +727,9 @@ static void testRegStore(void)
...
@@ -723,9 +727,9 @@ static void testRegStore(void)
ok
(
hdr
!=
NULL
,
"Expected to find a cert property
\n
"
);
ok
(
hdr
!=
NULL
,
"Expected to find a cert property
\n
"
);
if
(
hdr
)
if
(
hdr
)
{
{
ok
(
hdr
->
cb
==
sizeof
(
bigCert2
)
-
1
,
ok
(
hdr
->
cb
==
sizeof
(
bigCert2
),
"Unexpected size %ld of cert property, expected %d
\n
"
,
"Unexpected size %ld of cert property, expected %d
\n
"
,
hdr
->
cb
,
sizeof
(
bigCert2
)
-
1
);
hdr
->
cb
,
sizeof
(
bigCert2
));
ok
(
!
memcmp
((
BYTE
*
)
hdr
+
sizeof
(
*
hdr
),
bigCert2
,
ok
(
!
memcmp
((
BYTE
*
)
hdr
+
sizeof
(
*
hdr
),
bigCert2
,
hdr
->
cb
),
"Unexpected cert in cert property
\n
"
);
hdr
->
cb
),
"Unexpected cert in cert property
\n
"
);
}
}
...
@@ -765,7 +769,7 @@ static void testRegStore(void)
...
@@ -765,7 +769,7 @@ static void testRegStore(void)
if
(
subKey
)
if
(
subKey
)
{
{
BYTE
buf
[
sizeof
(
struct
CertPropIDHeader
)
*
2
+
sizeof
(
hash
)
+
BYTE
buf
[
sizeof
(
struct
CertPropIDHeader
)
*
2
+
sizeof
(
hash
)
+
sizeof
(
bigCert
)
-
1
],
*
ptr
;
sizeof
(
bigCert
)],
*
ptr
;
DWORD
certCount
=
0
;
DWORD
certCount
=
0
;
struct
CertPropIDHeader
*
hdr
;
struct
CertPropIDHeader
*
hdr
;
...
@@ -779,9 +783,9 @@ static void testRegStore(void)
...
@@ -779,9 +783,9 @@ static void testRegStore(void)
hdr
=
(
struct
CertPropIDHeader
*
)
ptr
;
hdr
=
(
struct
CertPropIDHeader
*
)
ptr
;
hdr
->
propID
=
CERT_CERT_PROP_ID
;
hdr
->
propID
=
CERT_CERT_PROP_ID
;
hdr
->
unknown1
=
1
;
hdr
->
unknown1
=
1
;
hdr
->
cb
=
sizeof
(
bigCert
)
-
1
;
hdr
->
cb
=
sizeof
(
bigCert
);
ptr
+=
sizeof
(
*
hdr
);
ptr
+=
sizeof
(
*
hdr
);
memcpy
(
ptr
,
bigCert
,
sizeof
(
bigCert
)
-
1
);
memcpy
(
ptr
,
bigCert
,
sizeof
(
bigCert
));
rc
=
RegSetValueExA
(
subKey
,
"Blob"
,
0
,
REG_BINARY
,
buf
,
rc
=
RegSetValueExA
(
subKey
,
"Blob"
,
0
,
REG_BINARY
,
buf
,
sizeof
(
buf
));
sizeof
(
buf
));
...
@@ -808,7 +812,7 @@ static void testRegStore(void)
...
@@ -808,7 +812,7 @@ static void testRegStore(void)
*/
*/
size
=
sizeof
(
hash
);
size
=
sizeof
(
hash
);
ret
=
CryptHashCertificate
(
0
,
0
,
0
,
bigCert2
,
ret
=
CryptHashCertificate
(
0
,
0
,
0
,
bigCert2
,
sizeof
(
bigCert2
)
-
1
,
hash
,
&
size
);
sizeof
(
bigCert2
),
hash
,
&
size
);
ok
(
ret
,
"CryptHashCertificate failed: %ld
\n
"
,
GetLastError
());
ok
(
ret
,
"CryptHashCertificate failed: %ld
\n
"
,
GetLastError
());
strcpy
(
subKeyName
,
certificates
);
strcpy
(
subKeyName
,
certificates
);
for
(
i
=
0
,
ptr
=
subKeyName
+
sizeof
(
certificates
)
-
1
;
for
(
i
=
0
,
ptr
=
subKeyName
+
sizeof
(
certificates
)
-
1
;
...
@@ -820,7 +824,7 @@ static void testRegStore(void)
...
@@ -820,7 +824,7 @@ static void testRegStore(void)
if
(
subKey
)
if
(
subKey
)
{
{
BYTE
buf
[
sizeof
(
struct
CertPropIDHeader
)
*
2
+
sizeof
(
hash
)
+
BYTE
buf
[
sizeof
(
struct
CertPropIDHeader
)
*
2
+
sizeof
(
hash
)
+
sizeof
(
bigCert2
)
-
1
],
*
ptr
;
sizeof
(
bigCert2
)],
*
ptr
;
DWORD
certCount
=
0
;
DWORD
certCount
=
0
;
PCCERT_CONTEXT
context
;
PCCERT_CONTEXT
context
;
struct
CertPropIDHeader
*
hdr
;
struct
CertPropIDHeader
*
hdr
;
...
@@ -836,9 +840,9 @@ static void testRegStore(void)
...
@@ -836,9 +840,9 @@ static void testRegStore(void)
hdr
=
(
struct
CertPropIDHeader
*
)
ptr
;
hdr
=
(
struct
CertPropIDHeader
*
)
ptr
;
hdr
->
propID
=
CERT_CERT_PROP_ID
;
hdr
->
propID
=
CERT_CERT_PROP_ID
;
hdr
->
unknown1
=
1
;
hdr
->
unknown1
=
1
;
hdr
->
cb
=
sizeof
(
bigCert2
)
-
1
;
hdr
->
cb
=
sizeof
(
bigCert2
);
ptr
+=
sizeof
(
*
hdr
);
ptr
+=
sizeof
(
*
hdr
);
memcpy
(
ptr
,
bigCert2
,
sizeof
(
bigCert2
)
-
1
);
memcpy
(
ptr
,
bigCert2
,
sizeof
(
bigCert2
));
rc
=
RegSetValueExA
(
subKey
,
"Blob"
,
0
,
REG_BINARY
,
buf
,
rc
=
RegSetValueExA
(
subKey
,
"Blob"
,
0
,
REG_BINARY
,
buf
,
sizeof
(
buf
));
sizeof
(
buf
));
...
@@ -1112,7 +1116,7 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
...
@@ -1112,7 +1116,7 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
static
void
testCertProperties
(
void
)
static
void
testCertProperties
(
void
)
{
{
PCCERT_CONTEXT
context
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
PCCERT_CONTEXT
context
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
)
-
1
);
bigCert
,
sizeof
(
bigCert
));
ok
(
context
!=
NULL
,
"CertCreateCertificateContext failed: %08lx
\n
"
,
ok
(
context
!=
NULL
,
"CertCreateCertificateContext failed: %08lx
\n
"
,
GetLastError
());
GetLastError
());
...
@@ -1201,7 +1205,7 @@ static void testCertProperties(void)
...
@@ -1201,7 +1205,7 @@ static void testCertProperties(void)
NULL
);
NULL
);
ok
(
ret
,
"CertSetCertificateContextProperty failed: %08lx
\n
"
,
ok
(
ret
,
"CertSetCertificateContextProperty failed: %08lx
\n
"
,
GetLastError
());
GetLastError
());
checkHash
(
bigCert
,
sizeof
(
bigCert
)
-
1
,
CALG_SHA1
,
context
,
checkHash
(
bigCert
,
sizeof
(
bigCert
),
CALG_SHA1
,
context
,
CERT_HASH_PROP_ID
);
CERT_HASH_PROP_ID
);
/* Now that the hash property is set, we should get one property when
/* Now that the hash property is set, we should get one property when
...
@@ -1217,7 +1221,7 @@ static void testCertProperties(void)
...
@@ -1217,7 +1221,7 @@ static void testCertProperties(void)
ok
(
numProps
==
1
,
"Expected 1 properties, got %ld
\n
"
,
numProps
);
ok
(
numProps
==
1
,
"Expected 1 properties, got %ld
\n
"
,
numProps
);
/* Check a few other implicit properties */
/* Check a few other implicit properties */
checkHash
(
bigCert
,
sizeof
(
bigCert
)
-
1
,
CALG_MD5
,
context
,
checkHash
(
bigCert
,
sizeof
(
bigCert
),
CALG_MD5
,
context
,
CERT_MD5_HASH_PROP_ID
);
CERT_MD5_HASH_PROP_ID
);
checkHash
(
checkHash
(
context
->
pCertInfo
->
Subject
.
pbData
,
context
->
pCertInfo
->
Subject
.
pbData
,
...
@@ -1245,7 +1249,7 @@ static void testAddSerialized(void)
...
@@ -1245,7 +1249,7 @@ static void testAddSerialized(void)
{
{
BOOL
ret
;
BOOL
ret
;
HCERTSTORE
store
;
HCERTSTORE
store
;
BYTE
buf
[
sizeof
(
struct
CertPropIDHeader
)
*
2
+
20
+
sizeof
(
bigCert
)
-
1
]
=
BYTE
buf
[
sizeof
(
struct
CertPropIDHeader
)
*
2
+
20
+
sizeof
(
bigCert
)]
=
{
0
};
{
0
};
BYTE
hash
[
20
];
BYTE
hash
[
20
];
struct
CertPropIDHeader
*
hdr
;
struct
CertPropIDHeader
*
hdr
;
...
@@ -1274,40 +1278,40 @@ static void testAddSerialized(void)
...
@@ -1274,40 +1278,40 @@ static void testAddSerialized(void)
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
/* Test with a bad size in property header */
/* Test with a bad size in property header */
hdr
->
cb
=
sizeof
(
bigCert
)
-
2
;
hdr
->
cb
=
sizeof
(
bigCert
)
-
1
;
memcpy
(
buf
+
sizeof
(
struct
CertPropIDHeader
),
bigCert
,
sizeof
(
bigCert
)
-
1
);
memcpy
(
buf
+
sizeof
(
struct
CertPropIDHeader
),
bigCert
,
sizeof
(
bigCert
));
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
NULL
,
NULL
);
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
0
,
0
,
0
,
NULL
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
0
,
NULL
,
NULL
);
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_NEW
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
0
,
NULL
,
NULL
);
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
/* Kosher size in property header, but no context type */
/* Kosher size in property header, but no context type */
hdr
->
cb
=
sizeof
(
bigCert
)
-
1
;
hdr
->
cb
=
sizeof
(
bigCert
);
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
NULL
,
NULL
);
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
0
,
0
,
0
,
NULL
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
0
,
NULL
,
NULL
);
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_NEW
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
0
,
NULL
,
NULL
);
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
...
@@ -1319,13 +1323,13 @@ static void testAddSerialized(void)
...
@@ -1319,13 +1323,13 @@ static void testAddSerialized(void)
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
0
,
0
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_NEW
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
0
,
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
...
@@ -1337,12 +1341,12 @@ static void testAddSerialized(void)
...
@@ -1337,12 +1341,12 @@ static void testAddSerialized(void)
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND got %08lx
\n
"
,
GetLastError
());
"Expected ERROR_FILE_NOT_FOUND got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
0
,
0
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
CERT_STORE_CERTIFICATE_CONTEXT_FLAG
,
NULL
,
NULL
);
CERT_STORE_CERTIFICATE_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND got %08lx
\n
"
,
GetLastError
());
"Expected ERROR_FILE_NOT_FOUND got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_NEW
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
CERT_STORE_CERTIFICATE_CONTEXT_FLAG
,
NULL
,
NULL
);
0
,
CERT_STORE_CERTIFICATE_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND got %08lx
\n
"
,
GetLastError
());
"Expected ERROR_FILE_NOT_FOUND got %08lx
\n
"
,
GetLastError
());
...
@@ -1353,7 +1357,7 @@ static void testAddSerialized(void)
...
@@ -1353,7 +1357,7 @@ static void testAddSerialized(void)
CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
* as does this
* as does this
ret = CertAddSerializedElementToStore(store, buf,
ret = CertAddSerializedElementToStore(store, buf,
sizeof(struct CertPropIDHeader) + sizeof(bigCert)
- 1
, 0, 0,
sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
*/
*/
/* Everything okay, but buffer's too big */
/* Everything okay, but buffer's too big */
...
@@ -1362,7 +1366,7 @@ static void testAddSerialized(void)
...
@@ -1362,7 +1366,7 @@ static void testAddSerialized(void)
ok
(
ret
,
"CertAddSerializedElementToStore failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddSerializedElementToStore failed: %08lx
\n
"
,
GetLastError
());
/* Everything okay, check it's not re-added */
/* Everything okay, check it's not re-added */
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
,
CERT_STORE_ADD_NEW
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
CERT_STORE_CERTIFICATE_CONTEXT_FLAG
,
NULL
,
NULL
);
0
,
CERT_STORE_CERTIFICATE_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_EXISTS
,
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_EXISTS
,
"Expected CRYPT_E_EXISTS, got %08lx
\n
"
,
GetLastError
());
"Expected CRYPT_E_EXISTS, got %08lx
\n
"
,
GetLastError
());
...
@@ -1376,7 +1380,7 @@ static void testAddSerialized(void)
...
@@ -1376,7 +1380,7 @@ static void testAddSerialized(void)
* when queried, is the real hash rather than the bogus hash.
* when queried, is the real hash rather than the bogus hash.
*/
*/
hdr
=
(
struct
CertPropIDHeader
*
)(
buf
+
sizeof
(
struct
CertPropIDHeader
)
+
hdr
=
(
struct
CertPropIDHeader
*
)(
buf
+
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
)
-
1
);
sizeof
(
bigCert
));
hdr
->
propID
=
CERT_HASH_PROP_ID
;
hdr
->
propID
=
CERT_HASH_PROP_ID
;
hdr
->
unknown1
=
1
;
hdr
->
unknown1
=
1
;
hdr
->
cb
=
sizeof
(
hash
);
hdr
->
cb
=
sizeof
(
hash
);
...
@@ -1391,7 +1395,7 @@ static void testAddSerialized(void)
...
@@ -1391,7 +1395,7 @@ static void testAddSerialized(void)
BYTE
hashVal
[
20
],
realHash
[
20
];
BYTE
hashVal
[
20
],
realHash
[
20
];
DWORD
size
=
sizeof
(
hashVal
);
DWORD
size
=
sizeof
(
hashVal
);
ret
=
CryptHashCertificate
(
0
,
0
,
0
,
bigCert
,
sizeof
(
bigCert
)
-
1
,
ret
=
CryptHashCertificate
(
0
,
0
,
0
,
bigCert
,
sizeof
(
bigCert
),
realHash
,
&
size
);
realHash
,
&
size
);
ok
(
ret
,
"CryptHashCertificate failed: %08lx
\n
"
,
GetLastError
());
ok
(
ret
,
"CryptHashCertificate failed: %08lx
\n
"
,
GetLastError
());
ret
=
CertGetCertificateContextProperty
(
context
,
CERT_HASH_PROP_ID
,
ret
=
CertGetCertificateContextProperty
(
context
,
CERT_HASH_PROP_ID
,
...
...
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