1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | // |
5 | // Strong name APIs which are not exposed publicly, but are built into StrongName.lib |
6 | // |
7 | |
8 | #ifndef _STRONGNAME_INTERNAL_H |
9 | #define _STRONGNAME_INTERNAL_H |
10 | |
11 | #include <strongname.h> |
12 | |
13 | #include <wincrypt.h> |
14 | |
15 | // NTDDI_VERSION is currently defined as XP SP2. |
16 | // Strongname api's that use this are supported on XP SP3 and later, so we can use them. |
17 | #ifndef ALG_SID_SHA_256 |
18 | #define ALG_SID_SHA_256 12 |
19 | #define ALG_SID_SHA_384 13 |
20 | #define ALG_SID_SHA_512 14 |
21 | #define CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256) |
22 | #define CALG_SHA_384 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384) |
23 | #define CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) |
24 | #endif //ALG_SID_SHA_256 |
25 | |
26 | // Determine the number of bytes in a public key |
27 | DWORD StrongNameSizeOfPublicKey(const PublicKeyBlob &keyPublicKey); |
28 | |
29 | bool StrongNameIsValidPublicKey(__in_ecount(cbPublicKeyBlob) const BYTE *pbPublicKeyBlob, DWORD cbPublicKeyBlob, bool fImporKey); |
30 | bool StrongNameIsValidPublicKey(const PublicKeyBlob &keyPublicKey, bool fImportKey); |
31 | |
32 | // Determine if a public key is the ECMA key |
33 | bool StrongNameIsEcmaKey(__in_ecount(cbKey) const BYTE *pbKey, DWORD cbKey); |
34 | bool StrongNameIsEcmaKey(const PublicKeyBlob &keyPublicKey); |
35 | |
36 | bool StrongNameIsTheKey(__in_ecount(cbKey) const BYTE *pbKey, DWORD cbKey); |
37 | |
38 | #if defined(CROSSGEN_COMPILE) && !defined(PLATFORM_UNIX) |
39 | |
40 | // Verify the format of a public key blob |
41 | bool StrongNameIsValidKeyPair(__in_ecount(cbKeyPair) const BYTE *pbKeyPair, DWORD cbKeyPair); |
42 | |
43 | bool GetBytesFromHex(LPCUTF8 szHexString, ULONG cchHexString, BYTE** buffer, ULONG *cbBufferSize); |
44 | |
45 | bool StrongNameCryptAcquireContext(HCRYPTPROV *phProv, LPCWSTR pwszContainer, LPCWSTR pwszProvider, DWORD dwProvType, DWORD dwFlags); |
46 | #endif // (CROSSGEN_COMPILE && !PLATFORM_UNIX) |
47 | |
48 | bool StrongNameIsSilverlightPlatformKey(__in_ecount(cbKey) const BYTE *pbKey, DWORD cbKey); |
49 | bool StrongNameIsSilverlightPlatformKey(const PublicKeyBlob &keyPublicKey); |
50 | |
51 | #endif // !_STRONGNAME_INTERNAL_H |
52 | |