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
d1ac9c73
Commit
d1ac9c73
authored
Jun 12, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Jun 13, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Implement PKCS7_SIGNER_INFO encoding/decoding.
parent
e1f83a7a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
0 deletions
+160
-0
decode.c
dlls/crypt32/decode.c
+83
-0
encode.c
dlls/crypt32/encode.c
+77
-0
encode.c
dlls/crypt32/tests/encode.c
+0
-0
No files found.
dlls/crypt32/decode.c
View file @
d1ac9c73
...
...
@@ -3659,6 +3659,86 @@ static BOOL WINAPI CRYPT_AsnDecodeIssuingDistPoint(DWORD dwCertEncodingType,
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnDecodeIssuerSerialNumber
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
PCRYPT_DECODE_PARA
pDecodePara
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
BOOL
ret
;
struct
AsnDecodeSequenceItem
items
[]
=
{
{
0
,
offsetof
(
CERT_ISSUER_SERIAL_NUMBER
,
Issuer
),
CRYPT_AsnDecodeDerBlob
,
sizeof
(
CRYPT_DER_BLOB
),
FALSE
,
TRUE
,
offsetof
(
CERT_ISSUER_SERIAL_NUMBER
,
Issuer
.
pbData
)
},
{
ASN_INTEGER
,
offsetof
(
CERT_ISSUER_SERIAL_NUMBER
,
SerialNumber
),
CRYPT_AsnDecodeIntegerInternal
,
sizeof
(
CRYPT_INTEGER_BLOB
),
FALSE
,
TRUE
,
offsetof
(
CERT_ISSUER_SERIAL_NUMBER
,
SerialNumber
.
pbData
),
0
},
};
CERT_ISSUER_SERIAL_NUMBER
*
issuerSerial
=
(
CERT_ISSUER_SERIAL_NUMBER
*
)
pvStructInfo
;
TRACE
(
"%p, %d, %08x, %p, %p, %d
\n
"
,
pbEncoded
,
cbEncoded
,
dwFlags
,
pDecodePara
,
pvStructInfo
,
*
pcbStructInfo
);
ret
=
CRYPT_AsnDecodeSequence
(
dwCertEncodingType
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
pbEncoded
,
cbEncoded
,
dwFlags
,
pDecodePara
,
pvStructInfo
,
pcbStructInfo
,
issuerSerial
?
issuerSerial
->
Issuer
.
pbData
:
NULL
);
if
(
ret
&&
issuerSerial
&&
!
issuerSerial
->
SerialNumber
.
cbData
)
{
SetLastError
(
CRYPT_E_ASN1_CORRUPT
);
ret
=
FALSE
;
}
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnDecodePKCSSignerInfo
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
PCRYPT_DECODE_PARA
pDecodePara
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
{
BOOL
ret
=
FALSE
;
TRACE
(
"%p, %d, %08x, %p, %p, %d
\n
"
,
pbEncoded
,
cbEncoded
,
dwFlags
,
pDecodePara
,
pvStructInfo
,
*
pcbStructInfo
);
__TRY
{
struct
AsnDecodeSequenceItem
items
[]
=
{
{
ASN_INTEGER
,
offsetof
(
CMSG_SIGNER_INFO
,
dwVersion
),
CRYPT_AsnDecodeInt
,
sizeof
(
DWORD
),
FALSE
,
FALSE
,
0
,
0
},
{
ASN_SEQUENCEOF
,
offsetof
(
CMSG_SIGNER_INFO
,
Issuer
),
CRYPT_AsnDecodeIssuerSerialNumber
,
sizeof
(
CERT_ISSUER_SERIAL_NUMBER
),
FALSE
,
TRUE
,
offsetof
(
CMSG_SIGNER_INFO
,
Issuer
.
pbData
),
0
},
{
ASN_SEQUENCEOF
,
offsetof
(
CMSG_SIGNER_INFO
,
HashAlgorithm
),
CRYPT_AsnDecodeAlgorithmId
,
sizeof
(
CRYPT_ALGORITHM_IDENTIFIER
),
FALSE
,
TRUE
,
offsetof
(
CMSG_SIGNER_INFO
,
HashAlgorithm
.
pszObjId
),
0
},
{
ASN_SEQUENCEOF
,
offsetof
(
CMSG_SIGNER_INFO
,
HashEncryptionAlgorithm
),
CRYPT_AsnDecodeAlgorithmId
,
sizeof
(
CRYPT_ALGORITHM_IDENTIFIER
),
FALSE
,
TRUE
,
offsetof
(
CMSG_SIGNER_INFO
,
HashEncryptionAlgorithm
.
pszObjId
),
0
},
{
ASN_CONSTRUCTOR
|
ASN_SETOF
,
offsetof
(
CMSG_SIGNER_INFO
,
AuthAttrs
),
CRYPT_AsnDecodePKCSAttributesInternal
,
sizeof
(
CRYPT_ATTRIBUTES
),
TRUE
,
TRUE
,
offsetof
(
CMSG_SIGNER_INFO
,
AuthAttrs
.
rgAttr
),
0
},
{
ASN_CONSTRUCTOR
|
ASN_SETOF
,
offsetof
(
CMSG_SIGNER_INFO
,
UnauthAttrs
),
CRYPT_AsnDecodePKCSAttributesInternal
,
sizeof
(
CRYPT_ATTRIBUTES
),
TRUE
,
TRUE
,
offsetof
(
CMSG_SIGNER_INFO
,
UnauthAttrs
.
rgAttr
),
0
},
{
ASN_OCTETSTRING
,
offsetof
(
CMSG_SIGNER_INFO
,
EncryptedHash
),
CRYPT_AsnDecodeOctetsInternal
,
sizeof
(
CRYPT_DER_BLOB
),
FALSE
,
TRUE
,
offsetof
(
CMSG_SIGNER_INFO
,
EncryptedHash
.
pbData
),
0
},
};
ret
=
CRYPT_AsnDecodeSequence
(
dwCertEncodingType
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
pbEncoded
,
cbEncoded
,
dwFlags
,
pDecodePara
,
pvStructInfo
,
pcbStructInfo
,
NULL
);
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
}
__ENDTRY
TRACE
(
"returning %d
\n
"
,
ret
);
return
ret
;
}
BOOL
WINAPI
CryptDecodeObjectEx
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
BYTE
*
pbEncoded
,
DWORD
cbEncoded
,
DWORD
dwFlags
,
PCRYPT_DECODE_PARA
pDecodePara
,
void
*
pvStructInfo
,
DWORD
*
pcbStructInfo
)
...
...
@@ -3792,6 +3872,9 @@ BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
case
(
WORD
)
X509_ISSUING_DIST_POINT
:
decodeFunc
=
CRYPT_AsnDecodeIssuingDistPoint
;
break
;
case
(
WORD
)
PKCS7_SIGNER_INFO
:
decodeFunc
=
CRYPT_AsnDecodePKCSSignerInfo
;
break
;
default:
FIXME
(
"%d: unimplemented
\n
"
,
LOWORD
(
lpszStructType
));
}
...
...
dlls/crypt32/encode.c
View file @
d1ac9c73
...
...
@@ -3078,6 +3078,80 @@ static BOOL WINAPI CRYPT_AsnEncodeIssuingDistPoint(DWORD dwCertEncodingType,
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodeIssuerSerialNumber
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
;
const
CERT_ISSUER_SERIAL_NUMBER
*
issuerSerial
=
(
const
CERT_ISSUER_SERIAL_NUMBER
*
)
pvStructInfo
;
struct
AsnEncodeSequenceItem
items
[]
=
{
{
&
issuerSerial
->
Issuer
,
CRYPT_CopyEncodedBlob
,
0
},
{
&
issuerSerial
->
SerialNumber
,
CRYPT_AsnEncodeInteger
,
0
},
};
ret
=
CRYPT_AsnEncodeSequence
(
dwCertEncodingType
,
items
,
sizeof
(
items
)
/
sizeof
(
items
[
0
]),
dwFlags
,
pEncodePara
,
pbEncoded
,
pcbEncoded
);
return
ret
;
}
static
BOOL
WINAPI
CRYPT_AsnEncodePKCSSignerInfo
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
BYTE
*
pbEncoded
,
DWORD
*
pcbEncoded
)
{
BOOL
ret
=
FALSE
;
if
(
!
(
dwCertEncodingType
&
PKCS_7_ASN_ENCODING
))
{
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
__TRY
{
const
CMSG_SIGNER_INFO
*
info
=
(
const
CMSG_SIGNER_INFO
*
)
pvStructInfo
;
if
(
!
info
->
Issuer
.
cbData
)
SetLastError
(
E_INVALIDARG
);
else
{
struct
AsnEncodeSequenceItem
items
[
7
]
=
{
{
&
info
->
dwVersion
,
CRYPT_AsnEncodeInt
,
0
},
{
&
info
->
Issuer
,
CRYPT_AsnEncodeIssuerSerialNumber
,
0
},
{
&
info
->
HashAlgorithm
,
CRYPT_AsnEncodeAlgorithmId
,
0
},
{
&
info
->
HashEncryptionAlgorithm
,
CRYPT_AsnEncodeAlgorithmId
,
0
},
};
DWORD
cItem
=
4
;
if
(
info
->
AuthAttrs
.
cAttr
)
{
items
[
cItem
].
pvStructInfo
=
&
info
->
AuthAttrs
;
items
[
cItem
].
encodeFunc
=
CRYPT_AsnEncodePKCSAttributes
;
cItem
++
;
}
if
(
info
->
UnauthAttrs
.
cAttr
)
{
items
[
cItem
].
pvStructInfo
=
&
info
->
UnauthAttrs
;
items
[
cItem
].
encodeFunc
=
CRYPT_AsnEncodePKCSAttributes
;
cItem
++
;
}
items
[
cItem
].
pvStructInfo
=
&
info
->
EncryptedHash
;
items
[
cItem
].
encodeFunc
=
CRYPT_AsnEncodeOctets
;
cItem
++
;
ret
=
CRYPT_AsnEncodeSequence
(
dwCertEncodingType
,
items
,
cItem
,
dwFlags
,
pEncodePara
,
pbEncoded
,
pcbEncoded
);
}
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
STATUS_ACCESS_VIOLATION
);
}
__ENDTRY
return
ret
;
}
BOOL
WINAPI
CryptEncodeObjectEx
(
DWORD
dwCertEncodingType
,
LPCSTR
lpszStructType
,
const
void
*
pvStructInfo
,
DWORD
dwFlags
,
PCRYPT_ENCODE_PARA
pEncodePara
,
void
*
pvEncoded
,
DWORD
*
pcbEncoded
)
...
...
@@ -3201,6 +3275,9 @@ BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
case
(
WORD
)
X509_ISSUING_DIST_POINT
:
encodeFunc
=
CRYPT_AsnEncodeIssuingDistPoint
;
break
;
case
(
WORD
)
PKCS7_SIGNER_INFO
:
encodeFunc
=
CRYPT_AsnEncodePKCSSignerInfo
;
break
;
default:
FIXME
(
"%d: unimplemented
\n
"
,
LOWORD
(
lpszStructType
));
}
...
...
dlls/crypt32/tests/encode.c
View file @
d1ac9c73
This diff is collapsed.
Click to expand it.
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