diff options
author | Martin Baulig <martin.baulig@xamarin.com> | 2016-09-30 14:47:22 +0300 |
---|---|---|
committer | Martin Baulig <martin.baulig@xamarin.com> | 2016-09-30 15:07:26 +0300 |
commit | 0f8f0c543c1f19b10b3bf46ca606db4903e3b708 (patch) | |
tree | 477664d1d8ef83aac4364bb6645a9cf1fbfab2c7 /mcs/class/Mono.Btls.Interface | |
parent | fb93be4490897141525ee95fb4bfb7413d5d0815 (diff) |
[BTLS]: Add managed BTLS sources.
* external/boringssl: unmanaged code from Google (added earlier).
* mono/btls: unmanaged BTLS lives here (added earlier).
* System/Mono.Btls: managed BTLS lives here.
* Mono.Btls.Interface: The purpose of this assembly is to allow test suites
such as xamarin/web-tests to test parts of the BTLS APIs without making
System.dll's internals visible. It is not a stable and maintained API.
Diffstat (limited to 'mcs/class/Mono.Btls.Interface')
21 files changed, 1237 insertions, 0 deletions
diff --git a/mcs/class/Mono.Btls.Interface/Makefile b/mcs/class/Mono.Btls.Interface/Makefile new file mode 100644 index 00000000000..ea7e128a3f0 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Makefile @@ -0,0 +1,12 @@ +thisdir = class/Mono.Btls.Interface +SUBDIRS = +include ../../build/rules.make + +LIBRARY = Mono.Btls.Interface.dll +LIB_REFS = System Mono.Security +LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:SECURITY_DEP + +include ../../build/library.make + +$(the_lib): ../Mono.Security/Makefile + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface.dll.sources b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface.dll.sources new file mode 100644 index 00000000000..710e06d35b9 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface.dll.sources @@ -0,0 +1,22 @@ +./Properties/AssemblyInfo.cs +../../build/common/Consts.cs +../../build/common/Locale.cs +../../build/common/MonoTODOAttribute.cs + +Mono.Btls.Interface/BtlsObject.cs +Mono.Btls.Interface/BtlsProvider.cs +Mono.Btls.Interface/BtlsX509.cs +Mono.Btls.Interface/BtlsX509Chain.cs +Mono.Btls.Interface/BtlsX509Error.cs +Mono.Btls.Interface/BtlsX509Format.cs +Mono.Btls.Interface/BtlsX509Lookup.cs +Mono.Btls.Interface/BtlsX509Name.cs +Mono.Btls.Interface/BtlsX509Purpose.cs +Mono.Btls.Interface/BtlsX509Store.cs +Mono.Btls.Interface/BtlsX509StoreCtx.cs +Mono.Btls.Interface/BtlsX509StoreManager.cs +Mono.Btls.Interface/BtlsX509StoreType.cs +Mono.Btls.Interface/BtlsX509TrustKind.cs +Mono.Btls.Interface/BtlsX509VerifyFlags.cs +Mono.Btls.Interface/BtlsX509VerifyParam.cs +Mono.Btls.Interface/VersionInfo.cs diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsObject.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsObject.cs new file mode 100644 index 00000000000..b2e607c1773 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsObject.cs @@ -0,0 +1,73 @@ +// +// BtlsObject.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Btls.Interface +{ + public abstract class BtlsObject : IDisposable + { + MonoBtlsObject instance; + + internal MonoBtlsObject Instance { + get { + if (!IsValid) + throw new ObjectDisposedException (GetType ().Name); + return instance; + } + } + + internal BtlsObject (MonoBtlsObject instance) + { + this.instance = instance; + } + + public bool IsValid { + get { return instance != null && instance.IsValid; } + } + + protected void Dispose (bool disposing) + { + if (disposing) { + if (instance != null) { + instance.Dispose (); + instance = null; + } + } + } + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + ~BtlsObject () + { + Dispose (false); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsProvider.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsProvider.cs new file mode 100644 index 00000000000..6a8d8106253 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsProvider.cs @@ -0,0 +1,106 @@ +// +// BtlsProvider.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Mono.Security.Interface; +using System.Security.Cryptography.X509Certificates; + +namespace Mono.Btls.Interface +{ + public static class BtlsProvider + { + public static bool IsSupported () + { + return MonoBtlsProvider.IsSupported (); + } + + public static MonoTlsProvider GetProvider () + { + return new MonoBtlsProvider (); + } + + public static BtlsX509 CreateNative (byte[] data, BtlsX509Format format) + { + var x509 = MonoBtlsX509.LoadFromData (data, (MonoBtlsX509Format)format); + return new BtlsX509 (x509); + } + + public static X509Certificate CreateCertificate (byte[] data, BtlsX509Format format, bool disallowFallback = false) + { + return MonoBtlsProvider.CreateCertificate (data, (MonoBtlsX509Format)format, disallowFallback); + } + + public static X509Certificate2 CreateCertificate2 (byte[] data, BtlsX509Format format, bool disallowFallback = false) + { + return MonoBtlsProvider.CreateCertificate2 (data, (MonoBtlsX509Format)format, disallowFallback); + } + + public static X509Certificate2 CreateCertificate2 (byte[] data, string password, bool disallowFallback = false) + { + return MonoBtlsProvider.CreateCertificate2 (data, password, disallowFallback); + } + + public static BtlsX509Chain CreateNativeChain () + { + return new BtlsX509Chain (new MonoBtlsX509Chain ()); + } + + public static BtlsX509Store CreateNativeStore () + { + return new BtlsX509Store (new MonoBtlsX509Store ()); + } + + public static BtlsX509StoreCtx CreateNativeStoreCtx () + { + return new BtlsX509StoreCtx (new MonoBtlsX509StoreCtx ()); + } + + public static X509Chain CreateChain () + { + return MonoBtlsProvider.CreateChain (); + } + + public static string GetSystemStoreLocation () + { + return MonoBtlsProvider.GetSystemStoreLocation (); + } + + public static BtlsX509VerifyParam GetVerifyParam_SslClient () + { + return new BtlsX509VerifyParam (MonoBtlsX509VerifyParam.GetSslClient ()); + } + + public static BtlsX509VerifyParam GetVerifyParam_SslServer () + { + return new BtlsX509VerifyParam (MonoBtlsX509VerifyParam.GetSslServer ()); + } + + public static X509Chain GetManagedChain (BtlsX509Chain chain) + { + return MonoBtlsProvider.GetManagedChain (chain.Instance); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509.cs new file mode 100644 index 00000000000..abcdafbf006 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509.cs @@ -0,0 +1,132 @@ +// +// BtlsX509.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Security.Cryptography; + +namespace Mono.Btls.Interface +{ + public class BtlsX509 : BtlsObject + { + new internal MonoBtlsX509 Instance { + get { return (MonoBtlsX509)base.Instance; } + } + + internal BtlsX509 (MonoBtlsX509 x509) + : base (x509) + { + } + + public BtlsX509Name GetSubjectName () + { + return new BtlsX509Name (Instance.GetSubjectName ()); + } + + public BtlsX509Name GetIssuerName () + { + return new BtlsX509Name (Instance.GetIssuerName ()); + } + + public string GetSubjectNameString () + { + return Instance.GetSubjectNameString (); + } + + public string GetIssuerNameString () + { + return Instance.GetIssuerNameString (); + } + + public byte[] GetRawData (BtlsX509Format format) + { + return Instance.GetRawData ((MonoBtlsX509Format)format); + } + + public byte[] GetCertHash () + { + return Instance.GetCertHash (); + } + + public DateTime GetNotBefore () + { + return Instance.GetNotBefore (); + } + + public DateTime GetNotAfter () + { + return Instance.GetNotAfter (); + } + + public byte[] GetPublicKeyData () + { + return Instance.GetPublicKeyData (); + } + + public byte[] GetSerialNumber (bool mono_style) + { + return Instance.GetSerialNumber (mono_style); + } + + public int GetVersion () + { + return Instance.GetVersion (); + } + + public Oid GetSignatureAlgorithm () + { + return Instance.GetSignatureAlgorithm (); + } + + public AsnEncodedData GetPublicKeyAsn1 () + { + return Instance.GetPublicKeyAsn1 (); + } + + public AsnEncodedData GetPublicKeyParameters () + { + return Instance.GetPublicKeyParameters (); + } + + public long GetSubjectNameHash () + { + using (var name = GetSubjectName ()) + return name.GetHash (); + } + + public void Print (Stream stream) + { + using (var bio = MonoBtlsBio.CreateMonoStream (stream)) + Instance.Print (bio); + } + + public void ExportAsPEM (Stream stream, bool includeHumanReadableForm) + { + using (var bio = MonoBtlsBio.CreateMonoStream (stream)) + Instance.ExportAsPEM (bio, includeHumanReadableForm); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Chain.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Chain.cs new file mode 100644 index 00000000000..38e9ec5814e --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Chain.cs @@ -0,0 +1,58 @@ +// +// BtlsX509Chain.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Btls.Interface +{ + public class BtlsX509Chain : BtlsObject + { + new internal MonoBtlsX509Chain Instance { + get { return (MonoBtlsX509Chain)base.Instance; } + } + + internal BtlsX509Chain (MonoBtlsX509Chain chain) + : base (chain) + { + } + + public int Count { + get { return Instance.Count; } + } + + public BtlsX509 this[int index] { + get { + var x509 = Instance.GetCertificate (index); + return new BtlsX509 (x509.Copy ()); + } + } + + public void Add (BtlsX509 x509) + { + Instance.AddCertificate (x509.Instance); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Error.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Error.cs new file mode 100644 index 00000000000..089b4f23e09 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Error.cs @@ -0,0 +1,110 @@ +// +// BtlsX509Error.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + // Keep in sync with NativeBoringX509Error + public enum BtlsX509Error + { + OK = 0, + /* illegal error (for uninitialized values, to avoid X509_V_OK): 1 */ + + UNABLE_TO_GET_ISSUER_CERT = 2, + UNABLE_TO_GET_CRL = 3, + UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4, + UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5, + UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6, + CERT_SIGNATURE_FAILURE = 7, + CRL_SIGNATURE_FAILURE = 8, + CERT_NOT_YET_VALID = 9, + CERT_HAS_EXPIRED = 10, + CRL_NOT_YET_VALID = 11, + CRL_HAS_EXPIRED = 12, + ERROR_IN_CERT_NOT_BEFORE_FIELD = 13, + ERROR_IN_CERT_NOT_AFTER_FIELD = 14, + ERROR_IN_CRL_LAST_UPDATE_FIELD = 15, + ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16, + OUT_OF_MEM = 17, + DEPTH_ZERO_SELF_SIGNED_CERT = 18, + SELF_SIGNED_CERT_IN_CHAIN = 19, + UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20, + UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21, + CERT_CHAIN_TOO_LONG = 22, + CERT_REVOKED = 23, + INVALID_CA = 24, + PATH_LENGTH_EXCEEDED = 25, + INVALID_PURPOSE = 26, + CERT_UNTRUSTED = 27, + CERT_REJECTED = 28, + /* These are 'informational' when looking for issuer cert */ + SUBJECT_ISSUER_MISMATCH = 29, + AKID_SKID_MISMATCH = 30, + AKID_ISSUER_SERIAL_MISMATCH = 31, + KEYUSAGE_NO_CERTSIGN = 32, + + UNABLE_TO_GET_CRL_ISSUER = 33, + UNHANDLED_CRITICAL_EXTENSION = 34, + KEYUSAGE_NO_CRL_SIGN = 35, + UNHANDLED_CRITICAL_CRL_EXTENSION = 36, + INVALID_NON_CA = 37, + PROXY_PATH_LENGTH_EXCEEDED = 38, + KEYUSAGE_NO_DIGITAL_SIGNATURE = 39, + PROXY_CERTIFICATES_NOT_ALLOWED = 40, + + INVALID_EXTENSION = 41, + INVALID_POLICY_EXTENSION = 42, + NO_EXPLICIT_POLICY = 43, + DIFFERENT_CRL_SCOPE = 44, + UNSUPPORTED_EXTENSION_FEATURE = 45, + + UNNESTED_RESOURCE = 46, + + PERMITTED_VIOLATION = 47, + EXCLUDED_VIOLATION = 48, + SUBTREE_MINMAX = 49, + UNSUPPORTED_CONSTRAINT_TYPE = 51, + UNSUPPORTED_CONSTRAINT_SYNTAX = 52, + UNSUPPORTED_NAME_SYNTAX = 53, + CRL_PATH_VALIDATION_ERROR = 54, + + /* Suite B mode algorithm violation */ + SUITE_B_INVALID_VERSION = 56, + SUITE_B_INVALID_ALGORITHM = 57, + SUITE_B_INVALID_CURVE = 58, + SUITE_B_INVALID_SIGNATURE_ALGORITHM = 59, + SUITE_B_LOS_NOT_ALLOWED = 60, + SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 = 61, + + /* Host, email and IP check errors */ + HOSTNAME_MISMATCH = 62, + EMAIL_MISMATCH = 63, + IP_ADDRESS_MISMATCH = 64, + + /* The application is not happy */ + APPLICATION_VERIFICATION = 50 + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Format.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Format.cs new file mode 100644 index 00000000000..6ff63cec120 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Format.cs @@ -0,0 +1,37 @@ +// +// BtlsX509Format.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Btls.Interface +{ + // Keep in sync with NativeBoringX509Format + public enum BtlsX509Format + { + DER = 1, + PEM = 2 + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Lookup.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Lookup.cs new file mode 100644 index 00000000000..836088fdd5b --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Lookup.cs @@ -0,0 +1,72 @@ +// +// BtlsX509Lookup.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Security.Cryptography; + +namespace Mono.Btls.Interface +{ + public class BtlsX509Lookup : BtlsObject + { + new internal MonoBtlsX509Lookup Instance { + get { return (MonoBtlsX509Lookup)base.Instance; } + } + + internal BtlsX509Lookup (MonoBtlsX509Lookup lookup) + : base (lookup) + { + } + + public void Initialize () + { + Instance.Initialize (); + } + + public void Shutdown () + { + Instance.Shutdown (); + } + + public BtlsX509 LookupBySubject (BtlsX509Name name) + { + var x509 = Instance.LookupBySubject (name.Instance); + if (x509 == null) + return null; + + return new BtlsX509 (x509); + } + + public void LoadFile (string file, BtlsX509Format type) + { + Instance.LoadFile (file, (MonoBtlsX509FileType)type); + } + + public void AddDirectory (string dir, BtlsX509Format type) + { + Instance.AddDirectory (dir, (MonoBtlsX509FileType)type); + } + } +} diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Name.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Name.cs new file mode 100644 index 00000000000..69ca5a9e201 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Name.cs @@ -0,0 +1,62 @@ +// +// BtlsX509Name.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace Mono.Btls.Interface +{ + public class BtlsX509Name : BtlsObject + { + new internal MonoBtlsX509Name Instance { + get { return (MonoBtlsX509Name)base.Instance; } + } + + internal BtlsX509Name (MonoBtlsX509Name name) + : base (name) + { + } + + public string GetString () + { + return Instance.GetString (); + } + + public byte[] GetRawData (bool use_canon_enc) + { + return Instance.GetRawData (use_canon_enc); + } + + public long GetHash () + { + return Instance.GetHash (); + } + + public long GetHashOld () + { + return Instance.GetHashOld (); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Purpose.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Purpose.cs new file mode 100644 index 00000000000..ac906dfe85c --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Purpose.cs @@ -0,0 +1,43 @@ +// +// BtlsX509Purpose.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + // Keep in sync with NativeBoringX509Purpose + public enum BtlsX509Purpose + { + SSL_CLIENT = 1, + SSL_SERVER = 2, + NS_SSL_SERVER = 3, + SMIME_SIGN = 4, + SMIME_ENCRYPT = 5, + CRL_SIGN = 6, + ANY = 7, + OCSP_HELPER = 8, + TIMESTAMP_SIGN = 9, + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Store.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Store.cs new file mode 100644 index 00000000000..7b8f03fc7a6 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509Store.cs @@ -0,0 +1,91 @@ +// +// BtlsX509Store.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Security.Cryptography.X509Certificates; + +namespace Mono.Btls.Interface +{ + public class BtlsX509Store : BtlsObject + { + new internal MonoBtlsX509Store Instance { + get { return (MonoBtlsX509Store)base.Instance; } + } + + internal BtlsX509Store (MonoBtlsX509Store store) + : base (store) + { + } + + public void LoadLocations (string file, string path) + { + Instance.LoadLocations (file, path); + } + + public void AddTrustedRoots () + { + Instance.AddTrustedRoots (); + } + + public void AddCertificate (BtlsX509 x509) + { + Instance.AddCertificate (x509.Instance); + } + + public int GetCount () + { + return Instance.GetCount (); + } + + public void AddLookup (X509CertificateCollection certificates, BtlsX509TrustKind trust) + { + Instance.AddCollection (certificates, (MonoBtlsX509TrustKind)trust); + } + + static MonoBtlsX509FileType GetFileType (BtlsX509Format format) + { + switch (format) { + case BtlsX509Format.DER: + return MonoBtlsX509FileType.ASN1; + case BtlsX509Format.PEM: + return MonoBtlsX509FileType.PEM; + default: + throw new NotSupportedException (); + } + } + + public void AddDirectoryLookup (string dir, BtlsX509Format format) + { + Instance.AddDirectoryLookup (dir, GetFileType (format)); + } + + public void AddFileLookup (string file, BtlsX509Format format) + { + Instance.AddFileLookup (file, GetFileType (format)); + } + + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreCtx.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreCtx.cs new file mode 100644 index 00000000000..97d4a066f66 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreCtx.cs @@ -0,0 +1,71 @@ +// +// BtlsX509StoreCtx.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + public class BtlsX509StoreCtx : BtlsObject + { + new internal MonoBtlsX509StoreCtx Instance { + get { return (MonoBtlsX509StoreCtx)base.Instance; } + } + + internal BtlsX509StoreCtx (MonoBtlsX509StoreCtx ctx) + : base (ctx) + { + } + + public void Initialize (BtlsX509Store store, BtlsX509Chain chain) + { + Instance.Initialize (store.Instance, chain.Instance); + } + + public void SetVerifyParam (BtlsX509VerifyParam param) + { + Instance.SetVerifyParam (param.Instance); + } + + public int Verify () + { + return Instance.Verify (); + } + + public BtlsX509Error GetError () + { + return (BtlsX509Error)Instance.GetError (); + } + + public Exception GetException () + { + return Instance.GetException (); + } + + public BtlsX509Chain GetChain () + { + return new BtlsX509Chain (Instance.GetChain ()); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreManager.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreManager.cs new file mode 100644 index 00000000000..1989ff44f27 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreManager.cs @@ -0,0 +1,44 @@ +// +// BtlsX509StoreManager.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Security.Cryptography; + +namespace Mono.Btls.Interface +{ + public static class BtlsX509StoreManager + { + public static bool HasStore (BtlsX509StoreType type) + { + return MonoBtlsX509StoreManager.HasStore ((MonoBtlsX509StoreType)type); + } + + public static string GetStorePath (BtlsX509StoreType type) + { + return MonoBtlsX509StoreManager.GetStorePath ((MonoBtlsX509StoreType)type); + } + } +} diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreType.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreType.cs new file mode 100644 index 00000000000..acdfb98d4c9 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509StoreType.cs @@ -0,0 +1,43 @@ +// +// BtlsX509StoreType.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; +using System.Security.Cryptography; + +namespace Mono.Btls.Interface +{ + // Keep in sync with MonoBtlsX509StoreType + public enum BtlsX509StoreType + { + Custom, + MachineTrustedRoots, + MachineIntermediateCA, + MachineUntrusted, + UserTrustedRoots, + UserIntermediateCA, + UserUntrusted + } +} diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509TrustKind.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509TrustKind.cs new file mode 100644 index 00000000000..9338ec61dbf --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509TrustKind.cs @@ -0,0 +1,42 @@ +// +// BtlsX509TrustKind.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + // Keep in sync with MonoBtlsX509TrustKind + [Flags] + public enum BtlsX509TrustKind + { + DEFAULT = 0, + TRUST_CLIENT = 1, + TRUST_SERVER = 2, + TRUST_ALL = 4, + REJECT_CLIENT = 32, + REJECT_SERVER = 64, + REJECT_ALL = 128 + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509VerifyFlags.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509VerifyFlags.cs new file mode 100644 index 00000000000..02640c82a17 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509VerifyFlags.cs @@ -0,0 +1,38 @@ +// +// BtlsX509VerifyFlags.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + // Keep in sync with NativeBoringX509VerifyFlags + public enum BtlsX509VerifyFlags + { + DEFAULT = 0, + CRL_CHECK = 1, + CRL_CHECK_ALL = 2, + X509_STRIC = 4 + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509VerifyParam.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509VerifyParam.cs new file mode 100644 index 00000000000..8d4e5eba5e3 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/BtlsX509VerifyParam.cs @@ -0,0 +1,91 @@ +// +// BtlsX509VerifyParam.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + public class BtlsX509VerifyParam : BtlsObject + { + new internal MonoBtlsX509VerifyParam Instance { + get { return (MonoBtlsX509VerifyParam)base.Instance; } + } + + internal BtlsX509VerifyParam (MonoBtlsX509VerifyParam param) + : base (param) + { + } + + public BtlsX509VerifyParam Copy () + { + return new BtlsX509VerifyParam (Instance.Copy ()); + } + + public void SetName (string name) + { + Instance.SetName (name); + } + + public void SetHost (string name) + { + Instance.SetHost (name); + } + + public void AddHost (string name) + { + Instance.AddHost (name); + } + + public BtlsX509VerifyFlags GetFlags () + { + return (BtlsX509VerifyFlags)Instance.GetFlags (); + } + + public void SetFlags (BtlsX509VerifyFlags flags) + { + Instance.SetFlags ((ulong)flags); + } + + public void SetPurpose (BtlsX509Purpose purpose) + { + Instance.SetPurpose ((MonoBtlsX509Purpose)purpose); + } + + public int GetDepth () + { + return Instance.GetDepth (); + } + + public void SetDepth (int depth) + { + Instance.SetDepth (depth); + } + + public void SetTime (DateTime time) + { + Instance.SetTime (time); + } + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/VersionInfo.cs b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/VersionInfo.cs new file mode 100644 index 00000000000..726c4ba88b3 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Mono.Btls.Interface/VersionInfo.cs @@ -0,0 +1,34 @@ +// +// VersionInfo.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +namespace Mono.Btls.Interface +{ + public static class VersionInfo + { + public const string Version = "1.0.0"; + } +} + diff --git a/mcs/class/Mono.Btls.Interface/Properties/AssemblyInfo.cs b/mcs/class/Mono.Btls.Interface/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..5ff0bcb3b95 --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/Properties/AssemblyInfo.cs @@ -0,0 +1,47 @@ +// +// AssemblyInfo.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) + +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Reflection; +using System.Resources; +using System.Security; +using System.Security.Permissions; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about the system assembly + +[assembly: AssemblyVersion (Consts.FxVersion)] + +[assembly: AssemblyCompany ("MONO development team")] +[assembly: AssemblyCopyright ("(c) 2016 Xamarin")] +[assembly: AssemblyDescription ("Mono.Btls.Interface")] +[assembly: AssemblyProduct ("MONO CLI")] +[assembly: AssemblyTitle ("Mono.Btls.Interface")] +[assembly: CLSCompliant (true)] +[assembly: ComVisible (false)] +[assembly: NeutralResourcesLanguage ("en-US")] + diff --git a/mcs/class/Mono.Btls.Interface/README.md b/mcs/class/Mono.Btls.Interface/README.md new file mode 100644 index 00000000000..81e169c8b2b --- /dev/null +++ b/mcs/class/Mono.Btls.Interface/README.md @@ -0,0 +1,9 @@ +Mono.Btls.Interface +=================== + +The purpose of this assembly is to allow test suites such as xamarin/web-tests +(https://github.com/xamarin/web-tests/tree/stable) to test parts of BTLS without +making System.dll internals visible. + +It should not be considered a stable and maintained API for third parties. + |