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
7780caf4
Commit
7780caf4
authored
Sep 12, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Sep 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Use BCrypt algorithm pseudo-handles.
parent
430b9db0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
31 deletions
+12
-31
cert.c
dlls/crypt32/cert.c
+12
-31
No files found.
dlls/crypt32/cert.c
View file @
7780caf4
...
...
@@ -2620,9 +2620,8 @@ done:
static
BOOL
CNG_ImportECCPubKey
(
CERT_PUBLIC_KEY_INFO
*
pubKeyInfo
,
BCRYPT_KEY_HANDLE
*
key
)
{
DWORD
blob_magic
,
ecckey_len
,
size
;
BCRYPT_ALG_HANDLE
alg
=
NULL
;
BCRYPT_ALG_HANDLE
alg
_handle
;
BCRYPT_ECCKEY_BLOB
*
ecckey
;
const
WCHAR
*
sign_algo
;
char
**
ecc_curve
;
NTSTATUS
status
;
...
...
@@ -2645,47 +2644,39 @@ static BOOL CNG_ImportECCPubKey(CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HAN
if
(
!
strcmp
(
*
ecc_curve
,
szOID_ECC_CURVE_P256
))
{
sign_algo
=
BCRYPT_ECDSA_P256_ALGORITHM
;
alg_handle
=
BCRYPT_ECDSA_P256_ALG_HANDLE
;
blob_magic
=
BCRYPT_ECDSA_PUBLIC_P256_MAGIC
;
}
else
if
(
!
strcmp
(
*
ecc_curve
,
szOID_ECC_CURVE_P384
))
{
sign_algo
=
BCRYPT_ECDSA_P384_ALGORITHM
;
alg_handle
=
BCRYPT_ECDSA_P384_ALG_HANDLE
;
blob_magic
=
BCRYPT_ECDSA_PUBLIC_P384_MAGIC
;
}
else
{
FIXME
(
"Unsupported ecc curve type: %s
\n
"
,
*
ecc_curve
);
sign_algo
=
NULL
;
alg_handle
=
NULL
;
blob_magic
=
0
;
}
LocalFree
(
ecc_curve
);
if
(
!
sign_algo
)
if
(
!
alg_handle
)
{
SetLastError
(
NTE_BAD_ALGID
);
return
FALSE
;
}
if
((
status
=
BCryptOpenAlgorithmProvider
(
&
alg
,
sign_algo
,
NULL
,
0
)))
goto
done
;
ecckey_len
=
sizeof
(
BCRYPT_ECCKEY_BLOB
)
+
pubKeyInfo
->
PublicKey
.
cbData
-
1
;
if
(
!
(
ecckey
=
CryptMemAlloc
(
ecckey_len
)))
{
status
=
STATUS_NO_MEMORY
;
goto
done
;
}
return
STATUS_NO_MEMORY
;
ecckey
->
dwMagic
=
blob_magic
;
ecckey
->
cbKey
=
(
pubKeyInfo
->
PublicKey
.
cbData
-
1
)
/
2
;
memcpy
(
ecckey
+
1
,
pubKeyInfo
->
PublicKey
.
pbData
+
1
,
pubKeyInfo
->
PublicKey
.
cbData
-
1
);
status
=
BCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
key
,
(
BYTE
*
)
ecckey
,
ecckey_len
,
0
);
status
=
BCryptImportKeyPair
(
alg
_handle
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
key
,
(
BYTE
*
)
ecckey
,
ecckey_len
,
0
);
CryptMemFree
(
ecckey
);
done:
if
(
alg
)
BCryptCloseAlgorithmProvider
(
alg
,
0
);
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
));
return
!
status
;
}
...
...
@@ -2695,8 +2686,7 @@ static BOOL CNG_ImportRSAPubKey(CERT_PUBLIC_KEY_INFO *info, BCRYPT_KEY_HANDLE *k
DWORD
size
,
modulus_len
,
i
;
BLOBHEADER
*
hdr
;
RSAPUBKEY
*
rsapubkey
;
const
WCHAR
*
rsa_algo
;
BCRYPT_ALG_HANDLE
alg
=
NULL
;
BCRYPT_ALG_HANDLE
alg_handle
;
BCRYPT_RSAKEY_BLOB
*
rsakey
;
BYTE
*
s
,
*
d
;
NTSTATUS
status
;
...
...
@@ -2715,9 +2705,9 @@ static BOOL CNG_ImportRSAPubKey(CERT_PUBLIC_KEY_INFO *info, BCRYPT_KEY_HANDLE *k
}
if
(
hdr
->
aiKeyAlg
==
CALG_RSA_KEYX
)
rsa_algo
=
BCRYPT_RSA_ALGORITHM
;
alg_handle
=
BCRYPT_RSA_ALG_HANDLE
;
else
if
(
hdr
->
aiKeyAlg
==
CALG_RSA_SIGN
)
rsa_algo
=
BCRYPT_RSA_SIGN_ALGORITHM
;
alg_handle
=
BCRYPT_RSA_SIGN_ALG_HANDLE
;
else
{
FIXME
(
"Unsupported RSA algorithm: %#x
\n
"
,
hdr
->
aiKeyAlg
);
...
...
@@ -2726,9 +2716,6 @@ static BOOL CNG_ImportRSAPubKey(CERT_PUBLIC_KEY_INFO *info, BCRYPT_KEY_HANDLE *k
return
FALSE
;
}
if
((
status
=
BCryptOpenAlgorithmProvider
(
&
alg
,
rsa_algo
,
NULL
,
0
)))
goto
done
;
rsapubkey
=
(
RSAPUBKEY
*
)(
hdr
+
1
);
modulus_len
=
size
-
sizeof
(
*
hdr
)
-
sizeof
(
*
rsapubkey
);
...
...
@@ -2736,12 +2723,8 @@ static BOOL CNG_ImportRSAPubKey(CERT_PUBLIC_KEY_INFO *info, BCRYPT_KEY_HANDLE *k
FIXME
(
"RSA pubkey has wrong modulus_len %lu
\n
"
,
modulus_len
);
size
=
sizeof
(
*
rsakey
)
+
sizeof
(
ULONG
)
+
modulus_len
;
if
(
!
(
rsakey
=
CryptMemAlloc
(
size
)))
{
status
=
STATUS_NO_MEMORY
;
goto
done
;
}
return
STATUS_NO_MEMORY
;
rsakey
->
Magic
=
BCRYPT_RSAPUBLIC_MAGIC
;
rsakey
->
BitLength
=
rsapubkey
->
bitlen
;
...
...
@@ -2759,12 +2742,10 @@ static BOOL CNG_ImportRSAPubKey(CERT_PUBLIC_KEY_INFO *info, BCRYPT_KEY_HANDLE *k
for
(
i
=
0
;
i
<
modulus_len
;
i
++
)
d
[
i
]
=
s
[
modulus_len
-
i
-
1
];
status
=
BCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_RSAPUBLIC_BLOB
,
key
,
(
BYTE
*
)
rsakey
,
size
,
0
);
status
=
BCryptImportKeyPair
(
alg
_handle
,
NULL
,
BCRYPT_RSAPUBLIC_BLOB
,
key
,
(
BYTE
*
)
rsakey
,
size
,
0
);
CryptMemFree
(
rsakey
);
done:
LocalFree
(
hdr
);
if
(
alg
)
BCryptCloseAlgorithmProvider
(
alg
,
0
);
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
));
return
!
status
;
}
...
...
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