From b8a1620138556fc1fd84675a2012788a7891c525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Tue, 26 Nov 2019 03:26:25 +0100 Subject: [PATCH] ALG_ID, wincrypt.h line 358 --- TH-NETII Windows API.sln | 15 + .../THNETII.WinApi.Sample.Native/main.c | 6 +- .../ALG_CLASS.cs | 13 + src/THNETII.WinApi.Headers.WinCrypt/ALG_ID.cs | 344 ++++++++++++++++++ .../ALG_SID_ANY.cs | 10 + .../ALG_SID_BLOCK.cs | 31 ++ .../ALG_SID_DH.cs | 15 + .../ALG_SID_DSS.cs | 13 + .../ALG_SID_HASH.cs | 24 ++ .../ALG_SID_RSA.cs | 14 + .../ALG_SID_SCHANNEL.cs | 16 + .../ALG_SID_STREAM.cs | 11 + .../ALG_SID_THIRDPARTY.cs | 10 + .../ALG_TYPE.cs | 15 + .../GlobalSuppressions.cs | 9 + .../THNETII.WinApi.Headers.WinCrypt.csproj | 21 ++ .../WinCryptConstants.cs | 199 ++++++++++ .../WinCryptFunctions.cs | 17 + 18 files changed, 780 insertions(+), 3 deletions(-) create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_CLASS.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_ID.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_ANY.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_BLOCK.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DH.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DSS.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_HASH.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_RSA.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_SCHANNEL.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_STREAM.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_THIRDPARTY.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/ALG_TYPE.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/GlobalSuppressions.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/THNETII.WinApi.Headers.WinCrypt.csproj create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/WinCryptConstants.cs create mode 100644 src/THNETII.WinApi.Headers.WinCrypt/WinCryptFunctions.cs diff --git a/TH-NETII Windows API.sln b/TH-NETII Windows API.sln index 1d34306c..6f4ce2ea 100644 --- a/TH-NETII Windows API.sln +++ b/TH-NETII Windows API.sln @@ -82,6 +82,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.File EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "THNETII.WinApi.Headers.SysInfoApi", "src\THNETII.WinApi.Headers.SysInfoApi\THNETII.WinApi.Headers.SysInfoApi.csproj", "{75FD2E4B-27C9-49D0-8869-99C934DAACCF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "THNETII.WinApi.Headers.WinCrypt", "src\THNETII.WinApi.Headers.WinCrypt\THNETII.WinApi.Headers.WinCrypt.csproj", "{30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -416,6 +418,18 @@ Global {75FD2E4B-27C9-49D0-8869-99C934DAACCF}.Release|x64.Build.0 = Release|Any CPU {75FD2E4B-27C9-49D0-8869-99C934DAACCF}.Release|x86.ActiveCfg = Release|Any CPU {75FD2E4B-27C9-49D0-8869-99C934DAACCF}.Release|x86.Build.0 = Release|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Debug|x64.ActiveCfg = Debug|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Debug|x64.Build.0 = Debug|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Debug|x86.ActiveCfg = Debug|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Debug|x86.Build.0 = Debug|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Release|Any CPU.Build.0 = Release|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Release|x64.ActiveCfg = Release|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Release|x64.Build.0 = Release|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Release|x86.ActiveCfg = Release|Any CPU + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -449,6 +463,7 @@ Global {3B25A551-FBEC-4515-9D98-226C51A6E74F} = {9689DB3E-1ED7-478C-AC14-C734B0397619} {DC49BB25-34E5-4B07-A527-F341D2EF833B} = {9689DB3E-1ED7-478C-AC14-C734B0397619} {75FD2E4B-27C9-49D0-8869-99C934DAACCF} = {9689DB3E-1ED7-478C-AC14-C734B0397619} + {30E313F6-A4DB-4352-8F2D-497EFD2F1CA8} = {9689DB3E-1ED7-478C-AC14-C734B0397619} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6EF7C9CF-E403-4B60-AB44-5F9FFEB668B7} diff --git a/src-native-c/THNETII.WinApi.Sample.Native/main.c b/src-native-c/THNETII.WinApi.Sample.Native/main.c index f10c4824..55beca65 100644 --- a/src-native-c/THNETII.WinApi.Sample.Native/main.c +++ b/src-native-c/THNETII.WinApi.Sample.Native/main.c @@ -1,11 +1,11 @@ #include -#include +#include int main(int argc, char* argv[]) { - OSVERSIONINFOW instance; + ALG_ID instance; const int size = sizeof(instance); - const int value = VER_PLATFORM_WIN32_NT; + const int value = ALG_CLASS_ALL; const void* ptr = GetVersionEx; diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_CLASS.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_CLASS.cs new file mode 100644 index 00000000..a80a5042 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_CLASS.cs @@ -0,0 +1,13 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + public enum ALG_CLASS + { + ALG_CLASS_ANY = WinCryptConstants.ALG_CLASS_ANY, + ALG_CLASS_SIGNATURE = WinCryptConstants.ALG_CLASS_SIGNATURE, + ALG_CLASS_MSG_ENCRYPT = WinCryptConstants.ALG_CLASS_MSG_ENCRYPT, + ALG_CLASS_DATA_ENCRYPT = WinCryptConstants.ALG_CLASS_DATA_ENCRYPT, + ALG_CLASS_HASH = WinCryptConstants.ALG_CLASS_HASH, + ALG_CLASS_KEY_EXCHANGE = WinCryptConstants.ALG_CLASS_KEY_EXCHANGE, + ALG_CLASS_ALL = WinCryptConstants.ALG_CLASS_ALL, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_ID.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_ID.cs new file mode 100644 index 00000000..6c6f0bc7 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_ID.cs @@ -0,0 +1,344 @@ +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Linq; +using System.Runtime.InteropServices; + +using THNETII.InteropServices.Bitwise; + +namespace THNETII.WinApi.Native.WinCrypt +{ + using static ALG_CLASS; + using static ALG_TYPE; + + /// + /// The ALG_ID data type specifies an algorithm identifier. Parameters of this data type are passed to most of the functions in CryptoAPI. + /// + /// + /// Microsoft Docs page: ALG_ID + /// + /// Cryptography Functions + /// + /// + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + "(), nq}")] + [StructLayout(LayoutKind.Sequential)] + public struct ALG_ID : IEquatable, IEquatable + { + private static readonly ALG_CLASS[] known_classes = + (ALG_CLASS[])Enum.GetValues(typeof(ALG_CLASS)); + private static readonly ALG_TYPE[] known_types = + (ALG_TYPE[])Enum.GetValues(typeof(ALG_TYPE)); + + private static readonly Bitfield32 classbitfield = Bitfield32.FromMask(7 << 13); + private static readonly Bitfield32 typebitfield = Bitfield32.FromMask(15 << 9); + private static readonly Bitfield32 sidbitfield = Bitfield32.FromMask(511); + + private readonly int value; + + public ALG_ID(int alg_id) : this() => value = alg_id; + public ALG_ID(ALG_CLASS @class, ALG_TYPE type, int sid) : this() + { + classbitfield.WriteMasked(ref value, (int)@class); + typebitfield.WriteMasked(ref value, (int)type); + sidbitfield.WriteMasked(ref value, sid); + } + + public int Value => value; + + public ALG_CLASS Class => (ALG_CLASS)classbitfield.ReadMasked(value); + public ALG_TYPE Type => (ALG_TYPE)typebitfield.ReadMasked(value); + public int SubId => sidbitfield.ReadMasked(value); + + public bool Equals(ALG_ID other) => Equals(other.value); + public bool Equals(int other) => value.Equals(other); + public override bool Equals(object obj) => obj switch + { + int other_value => Equals(other_value), + ALG_ID other_id => Equals(other_id), + _ => false, + }; + + public override int GetHashCode() => value.GetHashCode(); + public static bool operator ==(ALG_ID left, ALG_ID right) => + left.Equals(right); + public static bool operator !=(ALG_ID left, ALG_ID right) => + !(left == right); + public static bool operator ==(ALG_ID left, int right) => + left.Equals(right); + public static bool operator !=(ALG_ID left, int right) => + !(left == right); + public static bool operator ==(int left, ALG_ID right) => + right.Equals(left); + public static bool operator !=(int left, ALG_ID right) => + !(left == right); + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = "Constructor")] + public static implicit operator ALG_ID(int alg_id) => new ALG_ID(alg_id); + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(Value))] + public static explicit operator int(ALG_ID alg_id) => alg_id.value; + + public void Deconstruct(out ALG_CLASS @class, out ALG_TYPE type, + out int sid) => (@class, type, sid) = (Class, Type, SubId); + + internal string DebuggerDisplay() + { + var (@class, type, sid) = this; + + string class_string = known_classes.Contains(@class) + ? @class.ToString() + : $"({((uint)@class) >> 13} << 13)"; + string type_string = known_types.Contains(type) + ? type.ToString() + : $"({((uint)type) >> 9} << 9)"; + + string sid_string = + @class switch + { + ALG_CLASS_HASH => GetEnumToStringOrNull(sid), + _ => null, + } + ?? type switch + { + ALG_TYPE_ANY => GetEnumToStringOrNull(sid), + ALG_TYPE_THIRDPARTY => GetEnumToStringOrNull(sid), + ALG_TYPE_RSA => GetEnumToStringOrNull(sid), + ALG_TYPE_DSS => GetEnumToStringOrNull(sid), + ALG_TYPE_BLOCK => GetEnumToStringOrNull(sid), + ALG_TYPE_STREAM => GetEnumToStringOrNull(sid), + ALG_TYPE_DH => GetEnumToStringOrNull(sid), + ALG_TYPE_SECURECHANNEL => GetEnumToStringOrNull(sid), + _ => null + } + ?? sid.ToString(CultureInfo.InvariantCulture); + + return $"{class_string} | {type_string} | {sid_string}"; + + static string GetEnumToStringOrNull(int sid) + where TEnum : unmanaged, Enum + { + var @enum = default(TEnum); + unsafe + { + TEnum* pEnumValue = &@enum; + int* pEnumInt = (int*)pEnumValue; + *pEnumInt = sid; + } + return ((TEnum[])Enum.GetValues(typeof(TEnum))).Contains(@enum) + ? @enum.ToString() + : null; + } + } + + // algorithm identifier definitions + /// + /// MD2 hashing algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_MD2 { get; } = WinCryptConstants.CALG_MD2; + /// + /// MD4 hashing algorithm. + /// + public static ALG_ID CALG_MD4 { get; } = WinCryptConstants.CALG_MD4; + /// + /// MD5 hashing algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_MD5 { get; } = WinCryptConstants.CALG_MD5; + /// + /// SHA hashing algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_SHA { get; } = WinCryptConstants.CALG_SHA; + /// + public static ALG_ID CALG_SHA1 { get; } = WinCryptConstants.CALG_SHA1; + /// + /// MAC keyed hash algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + [Obsolete("Deprecated. Don't use.")] + public static ALG_ID CALG_MAC { get; } = WinCryptConstants.CALG_MAC; + /// + /// RSA public key signature algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_RSA_SIGN { get; } = WinCryptConstants.CALG_RSA_SIGN; + /// + /// DSA public key signature algorithm. + /// + public static ALG_ID CALG_DSS_SIGN { get; } = WinCryptConstants.CALG_DSS_SIGN; + /// + /// No signature algorithm. + /// + public static ALG_ID CALG_NO_SIGN { get; } = WinCryptConstants.CALG_NO_SIGN; + /// + /// RSA public key exchange algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_RSA_KEYX { get; } = WinCryptConstants.CALG_RSA_KEYX; + /// + /// DES encryption algorithm. + /// + public static ALG_ID CALG_DES { get; } = WinCryptConstants.CALG_DES; + /// + /// Two-key triple DES encryption with effective key length equal to 112 bits. + /// + public static ALG_ID CALG_3DES_112 { get; } = WinCryptConstants.CALG_3DES_112; + /// + /// Triple DES encryption algorithm. + /// + public static ALG_ID CALG_3DES { get; } = WinCryptConstants.CALG_3DES; + /// + /// DESX encryption algorithm. + /// + public static ALG_ID CALG_DESX { get; } = WinCryptConstants.CALG_DESX; + /// + /// RC2 block encryption algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_RC2 { get; } = WinCryptConstants.CALG_RC2; + /// + /// RC4 stream encryption algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_RC4 { get; } = WinCryptConstants.CALG_RC4; + /// + /// SEAL encryption algorithm. This algorithm is not supported. + /// + public static ALG_ID CALG_SEAL { get; } = WinCryptConstants.CALG_SEAL; + /// + /// Diffie-Hellman store and forward key exchange algorithm. + /// + public static ALG_ID CALG_DH_SF { get; } = WinCryptConstants.CALG_DH_SF; + /// + /// Diffie-Hellman ephemeral key exchange algorithm. + /// + public static ALG_ID CALG_DH_EPHEM { get; } = WinCryptConstants.CALG_DH_EPHEM; + /// + /// Temporary algorithm identifier for handles of Diffie-Hellman–agreed keys. + /// + public static ALG_ID CALG_AGREEDKEY_ANY { get; } = WinCryptConstants.CALG_AGREEDKEY_ANY; + /// + /// KEA key exchange algorithm (FORTEZZA). This algorithm is not supported. + /// + public static ALG_ID CALG_KEA_KEYX { get; } = WinCryptConstants.CALG_KEA_KEYX; + /// + /// Hughes MD5 hashing algorithm. + /// + public static ALG_ID CALG_HUGHES_MD5 { get; } = WinCryptConstants.CALG_HUGHES_MD5; + /// + /// Skipjack block encryption algorithm (FORTEZZA). This algorithm is not supported. + /// + public static ALG_ID CALG_SKIPJACK { get; } = WinCryptConstants.CALG_SKIPJACK; + /// + /// TEK (FORTEZZA). This algorithm is not supported. + /// + public static ALG_ID CALG_TEK { get; } = WinCryptConstants.CALG_TEK; + /// + /// An algorithm to create a 40-bit DES key that has parity bits and zeroed key bits to make its key length 64 bits. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + [Obsolete("Deprecated. Do not use")] + public static ALG_ID CALG_CYLINK_MEK { get; } = WinCryptConstants.CALG_CYLINK_MEK; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_SSL3_SHAMD5 { get; } = WinCryptConstants.CALG_SSL3_SHAMD5; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_SSL3_MASTER { get; } = WinCryptConstants.CALG_SSL3_MASTER; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_SCHANNEL_MASTER_HASH { get; } = WinCryptConstants.CALG_SCHANNEL_MASTER_HASH; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_SCHANNEL_MAC_KEY { get; } = WinCryptConstants.CALG_SCHANNEL_MAC_KEY; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_SCHANNEL_ENC_KEY { get; } = WinCryptConstants.CALG_SCHANNEL_ENC_KEY; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_PCT1_MASTER { get; } = WinCryptConstants.CALG_PCT1_MASTER; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_SSL2_MASTER { get; } = WinCryptConstants.CALG_SSL2_MASTER; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_TLS1_MASTER { get; } = WinCryptConstants.CALG_TLS1_MASTER; + /// + /// RC5 block encryption algorithm. + /// + public static ALG_ID CALG_RC5 { get; } = WinCryptConstants.CALG_RC5; + /// + /// HMAC keyed hash algorithm. This algorithm is supported by the Microsoft Base Cryptographic Provider. + /// + public static ALG_ID CALG_HMAC { get; } = WinCryptConstants.CALG_HMAC; + /// + /// Used by the Schannel.dll operations system. This should not be used by applications. + /// + public static ALG_ID CALG_TLS1PRF { get; } = WinCryptConstants.CALG_TLS1PRF; + /// + /// One way function hashing algorithm. + /// + public static ALG_ID CALG_HASH_REPLACE_OWF { get; } = WinCryptConstants.CALG_HASH_REPLACE_OWF; + /// + /// 128 bit AES. This algorithm is supported by the Microsoft AES Cryptographic Provider. + /// + public static ALG_ID CALG_AES_128 { get; } = WinCryptConstants.CALG_AES_128; + /// + /// 192 bit AES. This algorithm is supported by the Microsoft AES Cryptographic Provider. + /// + public static ALG_ID CALG_AES_192 { get; } = WinCryptConstants.CALG_AES_192; + /// + /// 256 bit AES. This algorithm is supported by the Microsoft AES Cryptographic Provider. + /// + public static ALG_ID CALG_AES_256 { get; } = WinCryptConstants.CALG_AES_256; + /// + /// Advanced Encryption Standard (AES). This algorithm is supported by the Microsoft AES Cryptographic Provider. + /// + public static ALG_ID CALG_AES { get; } = WinCryptConstants.CALG_AES; + /// + /// 256 bit SHA hashing algorithm. This algorithm is supported by Microsoft Enhanced RSA and AES Cryptographic Provider. + /// Windows XP with SP3: This algorithm is supported by the Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype). + /// Windows XP with SP2, Windows XP with SP1 and Windows XP: This algorithm is not supported. + /// + public static ALG_ID CALG_SHA_256 { get; } = WinCryptConstants.CALG_SHA_256; + /// + /// 384 bit SHA hashing algorithm. This algorithm is supported by Microsoft Enhanced RSA and AES Cryptographic Provider. + /// Windows XP with SP3: This algorithm is supported by the Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype). + /// Windows XP with SP2, Windows XP with SP1 and Windows XP: This algorithm is not supported. + /// + public static ALG_ID CALG_SHA_384 { get; } = WinCryptConstants.CALG_SHA_384; + /// + /// 512 bit SHA hashing algorithm. This algorithm is supported by Microsoft Enhanced RSA and AES Cryptographic Provider. + /// Windows XP with SP3: This algorithm is supported by the Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype). + /// Windows XP with SP2, Windows XP with SP1 and Windows XP: This algorithm is not supported. + /// + public static ALG_ID CALG_SHA_512 { get; } = WinCryptConstants.CALG_SHA_512; + /// + /// Elliptic curve Diffie-Hellman key exchange algorithm. + /// This algorithm is supported only through Cryptography API: Next Generation. + /// Windows Server 2003 and Windows XP: This algorithm is not supported. + /// + public static ALG_ID CALG_ECDH { get; } = WinCryptConstants.CALG_ECDH; + /// + /// Ephemeral elliptic curve Diffie-Hellman key exchange algorithm. + /// This algorithm is supported only through Cryptography API: Next Generation. + /// Windows Server 2003 and Windows XP: This algorithm is not supported. + /// + public static ALG_ID CALG_ECDH_EPHEM { get; } = WinCryptConstants.CALG_ECDH_EPHEM; + /// + /// Elliptic curve Menezes, Qu, and Vanstone (MQV) key exchange algorithm. This algorithm is not supported. + /// + public static ALG_ID CALG_ECMQV { get; } = WinCryptConstants.CALG_ECMQV; + /// + /// Elliptic curve digital signature algorithm. + /// This algorithm is supported only through Cryptography API: Next Generation. + /// Windows Server 2003 and Windows XP: This algorithm is not supported. + /// + public static ALG_ID CALG_ECDSA { get; } = WinCryptConstants.CALG_ECDSA; + public static ALG_ID CALG_NULLCIPHER { get; } = WinCryptConstants.CALG_NULLCIPHER; + public static ALG_ID CALG_THIRDPARTY_KEY_EXCHANGE { get; } = WinCryptConstants.CALG_THIRDPARTY_KEY_EXCHANGE; + public static ALG_ID CALG_THIRDPARTY_SIGNATURE { get; } = WinCryptConstants.CALG_THIRDPARTY_SIGNATURE; + public static ALG_ID CALG_THIRDPARTY_CIPHER { get; } = WinCryptConstants.CALG_THIRDPARTY_CIPHER; + public static ALG_ID CALG_THIRDPARTY_HASH { get; } = WinCryptConstants.CALG_THIRDPARTY_HASH; + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_ANY.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_ANY.cs new file mode 100644 index 00000000..fb0ef3dc --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_ANY.cs @@ -0,0 +1,10 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Generic sub-ids + /// + public enum ALG_SID_ANY + { + ALG_SID_ANY = WinCryptConstants.ALG_SID_ANY, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_BLOCK.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_BLOCK.cs new file mode 100644 index 00000000..4060bbdb --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_BLOCK.cs @@ -0,0 +1,31 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Block cipher sub ids + /// + public enum ALG_SID_BLOCK + { + // DES sub_ids + ALG_SID_DES = WinCryptConstants.ALG_SID_DES, + ALG_SID_3DES = WinCryptConstants.ALG_SID_3DES, + ALG_SID_DESX = WinCryptConstants.ALG_SID_DESX, + ALG_SID_IDEA = WinCryptConstants.ALG_SID_IDEA, + ALG_SID_CAST = WinCryptConstants.ALG_SID_CAST, + ALG_SID_SAFERSK64 = WinCryptConstants.ALG_SID_SAFERSK64, + ALG_SID_SAFERSK128 = WinCryptConstants.ALG_SID_SAFERSK128, + ALG_SID_3DES_112 = WinCryptConstants.ALG_SID_3DES_112, + ALG_SID_CYLINK_MEK = WinCryptConstants.ALG_SID_CYLINK_MEK, + ALG_SID_RC5 = WinCryptConstants.ALG_SID_RC5, + ALG_SID_AES_128 = WinCryptConstants.ALG_SID_AES_128, + ALG_SID_AES_192 = WinCryptConstants.ALG_SID_AES_192, + ALG_SID_AES_256 = WinCryptConstants.ALG_SID_AES_256, + ALG_SID_AES = WinCryptConstants.ALG_SID_AES, + + // Fortezza sub-ids + ALG_SID_SKIPJACK = WinCryptConstants.ALG_SID_SKIPJACK, + ALG_SID_TEK = WinCryptConstants.ALG_SID_TEK, + + // RC2 sub-ids + ALG_SID_RC2 = WinCryptConstants.ALG_SID_RC2, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DH.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DH.cs new file mode 100644 index 00000000..029b0850 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DH.cs @@ -0,0 +1,15 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Diffie-Hellman sub-ids + /// + public enum ALG_SID_DH + { + ALG_SID_DH_SANDF = WinCryptConstants.ALG_SID_DH_SANDF, + ALG_SID_DH_EPHEM = WinCryptConstants.ALG_SID_DH_EPHEM, + ALG_SID_AGREED_KEY_ANY = WinCryptConstants.ALG_SID_AGREED_KEY_ANY, + ALG_SID_KEA = WinCryptConstants.ALG_SID_KEA, + ALG_SID_ECDH = WinCryptConstants.ALG_SID_ECDH, + ALG_SID_ECDH_EPHEM = WinCryptConstants.ALG_SID_ECDH_EPHEM, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DSS.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DSS.cs new file mode 100644 index 00000000..c26fedcd --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_DSS.cs @@ -0,0 +1,13 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// DSS sub-ids + /// + public enum ALG_SID_DSS + { + ALG_SID_DSS_ANY = WinCryptConstants.ALG_SID_DSS_ANY, + ALG_SID_DSS_PKCS = WinCryptConstants.ALG_SID_DSS_PKCS, + ALG_SID_DSS_DMS = WinCryptConstants.ALG_SID_DSS_DMS, + ALG_SID_ECDSA = WinCryptConstants.ALG_SID_ECDSA, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_HASH.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_HASH.cs new file mode 100644 index 00000000..2479950b --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_HASH.cs @@ -0,0 +1,24 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Hash sub ids + /// + public enum ALG_SID_HASH + { + ALG_SID_MD2 = WinCryptConstants.ALG_SID_MD2, + ALG_SID_MD4 = WinCryptConstants.ALG_SID_MD4, + ALG_SID_MD5 = WinCryptConstants.ALG_SID_MD5, + ALG_SID_SHA = WinCryptConstants.ALG_SID_SHA, + ALG_SID_SHA1 = WinCryptConstants.ALG_SID_SHA1, + ALG_SID_MAC = WinCryptConstants.ALG_SID_MAC, + ALG_SID_RIPEMD = WinCryptConstants.ALG_SID_RIPEMD, + ALG_SID_RIPEMD160 = WinCryptConstants.ALG_SID_RIPEMD160, + ALG_SID_SSL3SHAMD5 = WinCryptConstants.ALG_SID_SSL3SHAMD5, + ALG_SID_HMAC = WinCryptConstants.ALG_SID_HMAC, + ALG_SID_TLS1PRF = WinCryptConstants.ALG_SID_TLS1PRF, + ALG_SID_HASH_REPLACE_OWF = WinCryptConstants.ALG_SID_HASH_REPLACE_OWF, + ALG_SID_SHA_256 = WinCryptConstants.ALG_SID_SHA_256, + ALG_SID_SHA_384 = WinCryptConstants.ALG_SID_SHA_384, + ALG_SID_SHA_512 = WinCryptConstants.ALG_SID_SHA_512, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_RSA.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_RSA.cs new file mode 100644 index 00000000..ae542ca4 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_RSA.cs @@ -0,0 +1,14 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// RSA sub-ids + /// + public enum ALG_SID_RSA + { + ALG_SID_RSA_ANY = WinCryptConstants.ALG_SID_RSA_ANY, + ALG_SID_RSA_PKCS = WinCryptConstants.ALG_SID_RSA_PKCS, + ALG_SID_RSA_MSATWORK = WinCryptConstants.ALG_SID_RSA_MSATWORK, + ALG_SID_RSA_ENTRUST = WinCryptConstants.ALG_SID_RSA_ENTRUST, + ALG_SID_RSA_PGP = WinCryptConstants.ALG_SID_RSA_PGP, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_SCHANNEL.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_SCHANNEL.cs new file mode 100644 index 00000000..209680a2 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_SCHANNEL.cs @@ -0,0 +1,16 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Secure channel sub ids + /// + public enum ALG_SID_SCHANNEL + { + ALG_SID_SSL3_MASTER = WinCryptConstants.ALG_SID_SSL3_MASTER, + ALG_SID_SCHANNEL_MASTER_HASH = WinCryptConstants.ALG_SID_SCHANNEL_MASTER_HASH, + ALG_SID_SCHANNEL_MAC_KEY = WinCryptConstants.ALG_SID_SCHANNEL_MAC_KEY, + ALG_SID_PCT1_MASTER = WinCryptConstants.ALG_SID_PCT1_MASTER, + ALG_SID_SSL2_MASTER = WinCryptConstants.ALG_SID_SSL2_MASTER, + ALG_SID_TLS1_MASTER = WinCryptConstants.ALG_SID_TLS1_MASTER, + ALG_SID_SCHANNEL_ENC_KEY = WinCryptConstants.ALG_SID_SCHANNEL_ENC_KEY, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_STREAM.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_STREAM.cs new file mode 100644 index 00000000..28d8fe65 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_STREAM.cs @@ -0,0 +1,11 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Stream cipher sub-ids + /// + public enum ALG_SID_STREAM + { + ALG_SID_RC4 = WinCryptConstants.ALG_SID_RC4, + ALG_SID_SEAL = WinCryptConstants.ALG_SID_SEAL, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_THIRDPARTY.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_THIRDPARTY.cs new file mode 100644 index 00000000..a9c60409 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_SID_THIRDPARTY.cs @@ -0,0 +1,10 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + /// + /// Generic ThirdParty sub-ids + /// + public enum ALG_SID_THIRDPARTY + { + ALG_SID_THIRDPARTY_ANY = WinCryptConstants.ALG_SID_THIRDPARTY_ANY, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/ALG_TYPE.cs b/src/THNETII.WinApi.Headers.WinCrypt/ALG_TYPE.cs new file mode 100644 index 00000000..0316965c --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/ALG_TYPE.cs @@ -0,0 +1,15 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + public enum ALG_TYPE + { + ALG_TYPE_ANY = WinCryptConstants.ALG_TYPE_ANY, + ALG_TYPE_DSS = WinCryptConstants.ALG_TYPE_DSS, + ALG_TYPE_RSA = WinCryptConstants.ALG_TYPE_RSA, + ALG_TYPE_BLOCK = WinCryptConstants.ALG_TYPE_BLOCK, + ALG_TYPE_STREAM = WinCryptConstants.ALG_TYPE_STREAM, + ALG_TYPE_DH = WinCryptConstants.ALG_TYPE_DH, + ALG_TYPE_SECURECHANNEL = WinCryptConstants.ALG_TYPE_SECURECHANNEL, + ALG_TYPE_ECDH = WinCryptConstants.ALG_TYPE_ECDH, + ALG_TYPE_THIRDPARTY = WinCryptConstants.ALG_TYPE_THIRDPARTY, + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/GlobalSuppressions.cs b/src/THNETII.WinApi.Headers.WinCrypt/GlobalSuppressions.cs new file mode 100644 index 00000000..6a6fec51 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/GlobalSuppressions.cs @@ -0,0 +1,9 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] +[assembly: SuppressMessage("Naming", "CA1712: Do not prefix enum values with type name")] diff --git a/src/THNETII.WinApi.Headers.WinCrypt/THNETII.WinApi.Headers.WinCrypt.csproj b/src/THNETII.WinApi.Headers.WinCrypt/THNETII.WinApi.Headers.WinCrypt.csproj new file mode 100644 index 00000000..feb0f2dc --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/THNETII.WinApi.Headers.WinCrypt.csproj @@ -0,0 +1,21 @@ + + + + + true + 8 + netstandard1.3;netstandard2.0 + true + CS1591 + THNETII.WinApi.Native.WinCrypt + + + + + + + + + + + diff --git a/src/THNETII.WinApi.Headers.WinCrypt/WinCryptConstants.cs b/src/THNETII.WinApi.Headers.WinCrypt/WinCryptConstants.cs new file mode 100644 index 00000000..873cf78c --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/WinCryptConstants.cs @@ -0,0 +1,199 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + public static class WinCryptConstants + { + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 144 + // + // Algorithm IDs and Flags + // + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 153 + // Algorithm classes + // certenrolld_begin -- ALG_CLASS_* + public const int ALG_CLASS_ANY = 0; + public const int ALG_CLASS_SIGNATURE = 1 << 13; + public const int ALG_CLASS_MSG_ENCRYPT = 2 << 13; + public const int ALG_CLASS_DATA_ENCRYPT = 3 << 13; + public const int ALG_CLASS_HASH = 4 << 13; + public const int ALG_CLASS_KEY_EXCHANGE = 5 << 13; + public const int ALG_CLASS_ALL = 7 << 13; + // certenrolld_end + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 164 + // Algorithm types + public const int ALG_TYPE_ANY = 0; + public const int ALG_TYPE_DSS = 1 << 9; + public const int ALG_TYPE_RSA = 2 << 9; + public const int ALG_TYPE_BLOCK = 3 << 9; + public const int ALG_TYPE_STREAM = 4 << 9; + public const int ALG_TYPE_DH = 5 << 9; + public const int ALG_TYPE_SECURECHANNEL = 6 << 9; + public const int ALG_TYPE_ECDH = 7 << 9; + public const int ALG_TYPE_THIRDPARTY = 8 << 9; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 179 + // Generic sub-ids + public const int ALG_SID_ANY = 0; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 182 + // Generic ThirdParty sub-ids + public const int ALG_SID_THIRDPARTY_ANY = 0; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 187 + // Some RSA sub-ids + public const int ALG_SID_RSA_ANY = 0; + public const int ALG_SID_RSA_PKCS = 1; + public const int ALG_SID_RSA_MSATWORK = 2; + public const int ALG_SID_RSA_ENTRUST = 3; + public const int ALG_SID_RSA_PGP = 4; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 194 + // Some DSS sub-ids + // + public const int ALG_SID_DSS_ANY = 0; + public const int ALG_SID_DSS_PKCS = 1; + public const int ALG_SID_DSS_DMS = 2; + public const int ALG_SID_ECDSA = 3; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 203 + // Block cipher sub ids + // DES sub_ids + public const int ALG_SID_DES = 1; + public const int ALG_SID_3DES = 3; + public const int ALG_SID_DESX = 4; + public const int ALG_SID_IDEA = 5; + public const int ALG_SID_CAST = 6; + public const int ALG_SID_SAFERSK64 = 7; + public const int ALG_SID_SAFERSK128 = 8; + public const int ALG_SID_3DES_112 = 9; + public const int ALG_SID_CYLINK_MEK = 12; + public const int ALG_SID_RC5 = 13; + public const int ALG_SID_AES_128 = 14; + public const int ALG_SID_AES_192 = 15; + public const int ALG_SID_AES_256 = 16; + public const int ALG_SID_AES = 17; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 222 + // Fortezza sub-ids + public const int ALG_SID_SKIPJACK = 10; + public const int ALG_SID_TEK = 11; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 226 + // KP_MODE + public const int CRYPT_MODE_CBCI = 6;// ANSI CBC Interleaved + public const int CRYPT_MODE_CFBP = 7;// ANSI CFB Pipelined + public const int CRYPT_MODE_OFBP = 8;// ANSI OFB Pipelined + public const int CRYPT_MODE_CBCOFM = 9;// ANSI CBC + OF Masking + public const int CRYPT_MODE_CBCOFMI = 10;// ANSI CBC + OFM Interleaved + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 233 + // RC2 sub-ids + public const int ALG_SID_RC2 = 2; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 236 + // Stream cipher sub-ids + public const int ALG_SID_RC4 = 1; + public const int ALG_SID_SEAL = 2; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 240 + // Diffie-Hellman sub-ids + public const int ALG_SID_DH_SANDF = 1; + public const int ALG_SID_DH_EPHEM = 2; + public const int ALG_SID_AGREED_KEY_ANY = 3; + public const int ALG_SID_KEA = 4; + public const int ALG_SID_ECDH = 5; + public const int ALG_SID_ECDH_EPHEM = 6; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 250 + // Hash sub ids + public const int ALG_SID_MD2 = 1; + public const int ALG_SID_MD4 = 2; + public const int ALG_SID_MD5 = 3; + public const int ALG_SID_SHA = 4; + public const int ALG_SID_SHA1 = 4; + public const int ALG_SID_MAC = 5; + public const int ALG_SID_RIPEMD = 6; + public const int ALG_SID_RIPEMD160 = 7; + public const int ALG_SID_SSL3SHAMD5 = 8; + public const int ALG_SID_HMAC = 9; + public const int ALG_SID_TLS1PRF = 10; + public const int ALG_SID_HASH_REPLACE_OWF = 11; + public const int ALG_SID_SHA_256 = 12; + public const int ALG_SID_SHA_384 = 13; + public const int ALG_SID_SHA_512 = 14; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 271 + // secure channel sub ids + public const int ALG_SID_SSL3_MASTER = 1; + public const int ALG_SID_SCHANNEL_MASTER_HASH = 2; + public const int ALG_SID_SCHANNEL_MAC_KEY = 3; + public const int ALG_SID_PCT1_MASTER = 4; + public const int ALG_SID_SSL2_MASTER = 5; + public const int ALG_SID_TLS1_MASTER = 6; + public const int ALG_SID_SCHANNEL_ENC_KEY = 7; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 281 + // misc ECC sub ids + public const int ALG_SID_ECMQV = 1; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 285 + // Our silly example sub-id + public const int ALG_SID_EXAMPLE = 80; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 295 + // algorithm identifier definitions + public const int CALG_MD2 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2; + public const int CALG_MD4 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4; + public const int CALG_MD5 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5; + public const int CALG_SHA = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA; + public const int CALG_SHA1 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1; + public const int CALG_MAC = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC;// Deprecated. Don't use. + public const int CALG_RSA_SIGN = ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; + public const int CALG_DSS_SIGN = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY; + public const int CALG_NO_SIGN = ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | ALG_SID_ANY; + public const int CALG_RSA_KEYX = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY; + public const int CALG_DES = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES; + public const int CALG_3DES_112 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES_112; + public const int CALG_3DES = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES; + public const int CALG_DESX = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX; + public const int CALG_RC2 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2; + public const int CALG_RC4 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4; + public const int CALG_SEAL = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL; + public const int CALG_DH_SF = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_SANDF; + public const int CALG_DH_EPHEM = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_EPHEM; + public const int CALG_AGREEDKEY_ANY = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_AGREED_KEY_ANY; + public const int CALG_KEA_KEYX = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_KEA; + public const int CALG_HUGHES_MD5 = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_MD5; + public const int CALG_SKIPJACK = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_SKIPJACK; + public const int CALG_TEK = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_TEK; + public const int CALG_CYLINK_MEK = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_CYLINK_MEK;// Deprecated. Do not use + public const int CALG_SSL3_SHAMD5 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SSL3SHAMD5; + public const int CALG_SSL3_MASTER = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL3_MASTER; + public const int CALG_SCHANNEL_MASTER_HASH = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MASTER_HASH; + public const int CALG_SCHANNEL_MAC_KEY = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MAC_KEY; + public const int CALG_SCHANNEL_ENC_KEY = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_ENC_KEY; + public const int CALG_PCT1_MASTER = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_PCT1_MASTER; + public const int CALG_SSL2_MASTER = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL2_MASTER; + public const int CALG_TLS1_MASTER = ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_TLS1_MASTER; + public const int CALG_RC5 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC5; + public const int CALG_HMAC = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HMAC; + public const int CALG_TLS1PRF = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF; + public const int CALG_HASH_REPLACE_OWF = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HASH_REPLACE_OWF; + public const int CALG_AES_128 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128; + public const int CALG_AES_192 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192; + public const int CALG_AES_256 = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256; + public const int CALG_AES = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES; + public const int CALG_SHA_256 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256; + public const int CALG_SHA_384 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384; + public const int CALG_SHA_512 = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512; + public const int CALG_ECDH = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH; + public const int CALG_ECDH_EPHEM = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ECDH | ALG_SID_ECDH_EPHEM; + public const int CALG_ECMQV = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV; + public const int CALG_ECDSA = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA; + public const int CALG_NULLCIPHER = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_ANY | 0; + public const int CALG_THIRDPARTY_KEY_EXCHANGE = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_THIRDPARTY | ALG_SID_THIRDPARTY_ANY; + public const int CALG_THIRDPARTY_SIGNATURE = ALG_CLASS_SIGNATURE | ALG_TYPE_THIRDPARTY | ALG_SID_THIRDPARTY_ANY; + public const int CALG_THIRDPARTY_CIPHER = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_THIRDPARTY | ALG_SID_THIRDPARTY_ANY; + public const int CALG_THIRDPARTY_HASH = ALG_CLASS_HASH | ALG_TYPE_THIRDPARTY | ALG_SID_THIRDPARTY_ANY; + } +} diff --git a/src/THNETII.WinApi.Headers.WinCrypt/WinCryptFunctions.cs b/src/THNETII.WinApi.Headers.WinCrypt/WinCryptFunctions.cs new file mode 100644 index 00000000..e6cc3704 --- /dev/null +++ b/src/THNETII.WinApi.Headers.WinCrypt/WinCryptFunctions.cs @@ -0,0 +1,17 @@ +namespace THNETII.WinApi.Native.WinCrypt +{ + public static class WinCryptFunctions + { + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\wincrypt.h, line 148 + // ALG_ID crackers + #region GET_ALG_CLASS macro + public static int GET_ALG_CLASS(int x) => (x & (7 << 13)); + #endregion + #region GET_ALG_TYPE macro + public static int GET_ALG_TYPE(int x) => (x & (15 << 9)); + #endregion + #region GET_ALG_SID macro + public static int GET_ALG_SID(int x) => (x & (511)); + #endregion + } +}