public enum DicomTlsCipherSuiteType typedef NS_ENUM(NSInteger, LTDicomTlsCipherSuiteType) {LTDicomTlsCipherSuiteTypeNone = 0,LTDicomTlsCipherSuiteTypeDheRsaWithDesCbcSha = 0x12,LTDicomTlsCipherSuiteTypeDheRsaWith3DesEdeCbcSha = 0x13,LTDicomTlsCipherSuiteTypeDheRsaAes256Sha = 0x14,};
public enum class DicomTlsCipherSuiteType | Value | Member | Description |
|---|---|---|
| 0 | None | No cipher suite has been agreed upon yet. |
| 18 | DheRsaWithDesCbcSha | (Deprecated do not use) TLS_RSA_WITH_DES_CBC_SHA |
| 19 | DheRsaWith3DesEdeCbcSha | (Deprecated do not use) TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA |
| 20 | DheRsaAes256Sha | (Deprecated do not use) DHE_RSA_AES_256_SHA (SSL3) |
| 21 | RsaWithAes128CbcSha | TLS_RSA_WITH_AES_128_CBC_SHA (TLS 1.0) |
| 22 | RsaWith3DesEdeCbcSha | TLS_RSA_WITH_3DES_EDE_CBC_SHA (TLS 1.0) |
| 23 | DheRsaWithAes128GcmSha256 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 (TLS 1.2) |
| 24 | EcdheRsaWithAes128GcmSha256 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (TLS 1.2) |
| 25 | DheRsaWithAes256GcmSha384 | TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 (TLS 1.2) |
| 26 | EcdheRsaWithAes256GcmSha384 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (TLS 1.2) |
| 27 | EcdheEcdsaWithAes256GcmSha384 | TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (TLS 1.2) |
| 30 | EcdheEcdsaWithAes256Ccm | TLS_ECDHE_ECDSA_WITH_AES_256_CCM (TLS 1.2) |
| 31 | EcdheEcdsaWithAes256Ccm8 | TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 (TLS 1.2) |
| 32 | EcdheEcdsaWithChacha20Poly1305Sha256 | TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (TLS 1.2) |
| 33 | EcdheRsaWithChacha20Poly1305Sha256 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (TLS 1.2) |
| 34 | EcdheEcdsaWithAes128GcmSha256 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (TLS 1.2) |
| 37 | EcdheEcdsaWithAes128Ccm | TLS_ECDHE_ECDSA_WITH_AES_128_CCM (TLS 1.2) |
| 38 | EcdheEcdsaWithAes128Ccm8 | TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 (TLS 1.2) |
| 39 | DheRsaWithAes256Ccm | TLS_DHE_RSA_WITH_AES_256_CCM (TLS 1.2) |
| 40 | DheRsaWithChacha20Poly1305Sha256 | TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (TLS 1.2) |
| 41 | DheRsaWithAes128Ccm | TLS_DHE_RSA_WITH_AES_128_CCM (TLS 1.2) |
| 42 | DheRsaWithAes128Ccm8 | TLS_DHE_RSA_WITH_AES_128_CCM_8 (TLS 1.2) |
| 48 | Aes256GcmSha384 | TLS_AES_256_GCM_SHA384 (TLS 1.3) |
| 49 | Chacha20Poly1305Sha256 | TLS_CHACHA20_POLY1305_SHA256 (TLS 1.3) |
| 50 | Aes128GcmSha256 | TLS_AES_128_GCM_SHA256 (TLS 1.3) |
| 51 | Aes128CcmSha256 | TLS_AES_128_CCM_SHA256 (TLS 1.3) |
| 52 | Aes128Ccm8Sha256 | TLS_AES_128_CCM_8_SHA256 (TLS 1.3) |
Currently, only the cipher suites listed are supported by LEADTOOLS.
This is a comprehensive sample that shows how to use DICOM Secure communication using TLS.
using Leadtools;using Leadtools.Dicom;[StructLayout(LayoutKind.Sequential)]public struct MSG{public IntPtr hwnd;public uint message;public IntPtr wParam;public IntPtr lParam;public uint time;public System.Drawing.Point p;}public enum WaitReturn{Complete,Timeout,}class Utils{[DllImport("user32.dll")][return: MarshalAs(UnmanagedType.Bool)]static extern bool PeekMessage(out MSG lpMsg, IntPtr hWnd,uint wMsgFilterMin, uint wMsgFilterMax,uint wRemoveMsg);[DllImport("user32.dll")]static extern bool TranslateMessage([In] ref MSG lpMsg);[DllImport("user32.dll")]static extern IntPtr DispatchMessage([In] ref MSG lpmsg);const uint PM_REMOVE = 1;public static WaitReturn WaitForComplete(double mill, WaitHandle wh){TimeSpan goal = new TimeSpan(DateTime.Now.AddMilliseconds(mill).Ticks);do{MSG msg = new MSG();if (PeekMessage(out msg, IntPtr.Zero, 0, 0, PM_REMOVE)){TranslateMessage(ref msg);DispatchMessage(ref msg);}if (wh.WaitOne(new TimeSpan(0, 0, 0), false)){return WaitReturn.Complete;}if (goal.CompareTo(new TimeSpan(DateTime.Now.Ticks)) < 0){return WaitReturn.Timeout;}} while (true);}public static void SetupTlsContext(DicomNet net, string certName){string serverCA = Path.Combine(LEAD_VARS.ImagesDir, "ca.pem");if (net != null){DicomOpenSslContextCreationSettings settings = new DicomOpenSslContextCreationSettings(// represents DicomOpenSslContextCreationSettings.MethodTypeDicomSslMethodType.SslV23,// represents DicomOpenSslContextCreationSettings.CertificationAuthoritiesFileNameserverCA,// represents DicomOpenSslContextCreationSettings.VerificationFlagsDicomOpenSslVerificationFlags.Peer | DicomOpenSslVerificationFlags.FailIfNoPeerCertificate,// represents DicomOpenSslContextCreationSettings.MaximumVerificationDepth2,// represents DicomOpenSslContextCreationSettings.OptionsDicomOpenSslOptionsFlags.NoSslV2 | DicomOpenSslOptionsFlags.AllBugWorkarounds);net.Initialize(null, DicomNetSecurityMode.Tls, settings);net.SetTlsClientCertificate(certName, DicomTlsCertificateType.Pem, null);}}}//// Secure client (TLS)//class Client : DicomNet{AutoResetEvent waitEvent = new AutoResetEvent(false);string clientPEM = Path.Combine(LEAD_VARS.ImagesDir, "client.pem");public Client(): base(null, DicomNetSecurityMode.Tls){SetTlsCipherSuiteByIndex(0, DicomTlsCipherSuiteType.DheRsaWithDesCbcSha);Utils.SetupTlsContext(this, clientPEM);}public bool Wait(){WaitReturn ret;ret = Utils.WaitForComplete((5 * 60) * 1000, waitEvent);return (ret == WaitReturn.Complete);}protected override void OnConnect(DicomExceptionCode error){waitEvent.Set();}protected override string OnPrivateKeyPassword(bool encryption){return "test";}protected override void OnSecureLinkReady(DicomExceptionCode error){waitEvent.Set();}}//// Secure server (TLS)//class ServerConnection : DicomNet{string serverPEM = Path.Combine(LEAD_VARS.ImagesDir, "server.pem");public ServerConnection(): base(null, DicomNetSecurityMode.Tls){SetTlsCipherSuiteByIndex(0, DicomTlsCipherSuiteType.DheRsaWith3DesEdeCbcSha);SetTlsClientCertificate(serverPEM, DicomTlsCertificateType.Pem, null);}protected override string OnPrivateKeyPassword(bool encryption){return "test";}// The OnVerify callback gets called twice, once for each certificate in the certificate chain.protected override int OnVerify(int ok, string certificateString, DicomSecurityCertificateException ex){string certificateMessageString = "Received Client Certificate:\n" + certificateString;// Log that the SCP received the Client CertificateDebug.WriteLine(certificateMessageString);if (ex.Code != DicomSecurityCertificateExceptionCode.Success){string message = string.Format("Error {0}: {1}", ex.Code, ex.Message);// Log the error with Client CertificateDebug.WriteLine(message);}return ok;}}class Server : DicomNet{string serverPEM = Path.Combine(LEAD_VARS.ImagesDir, "server.pem");ServerConnection client;public Server(): base(null, DicomNetSecurityMode.Tls){SetTlsCipherSuiteByIndex(0, DicomTlsCipherSuiteType.DheRsaWith3DesEdeCbcSha);Utils.SetupTlsContext(this, serverPEM);}protected override void OnAccept(DicomExceptionCode error){client = new ServerConnection();Utils.SetupTlsContext(client, serverPEM);Accept(client);}protected override string OnPrivateKeyPassword(bool encryption){return "test";}protected override void Dispose(bool __p1){client.Dispose();base.Dispose(__p1);}}public void TLSSecuritySample(){//Assert test to check file exists before running codestring clientPEM = Path.Combine(LEAD_VARS.ImagesDir, "ca.pem");Assert.IsTrue(File.Exists(clientPEM) == true, "Missing file: " + clientPEM);DicomEngine.Startup();DicomNet.Startup();using (Server server = new Server()){using (Client client = new Client()){server.Listen("127.0.0.1", 104, 1); // start serverclient.Connect(null, 1000, "127.0.0.1", 104); // connect to serverif (!client.Wait()) // wait for connection to finish{Debug.Fail("Connection timed out");}Debug.Assert(client.IsConnected(), "Client not connected");//// Wait for authenication//if (!client.Wait()){Debug.Fail("Connection timed out waiting for authenication");}// Once two computers have negotiated the ciphersuite, and have// authenticated each other, they can begin transferring// messages and data between them.//Now we can get detailed information about the Cipher SuiteDicomTlsCipherSuiteType cipherSuite = client.GetTlsCipherSuite();// Can also call GetTlsCipherSuiteByIndexDebug.WriteLine("Encryption Algorithm is : {0}", client.GetTlsEncryptionAlgorithm(cipherSuite));Debug.WriteLine("Authentication Algorithm is : {0}", client.GetTlsAuthenticationAlgorithm(cipherSuite));Debug.WriteLine("Integrity Algorithm is : {0}", client.GetTlsIntegrityAlgorithm(cipherSuite));Debug.WriteLine("Key Exchange Algorithm is : {0}", client.GetTlsKeyExchangeAlgorithm(cipherSuite));Debug.WriteLine("Encryption Key Length is : {0}", client.GetTlsEncryptionKeyLength(cipherSuite));Debug.WriteLine("Mutual Authentication Key Length is : {0}", client.GetTlsMutualAuthenticationKeyLength(cipherSuite));// Continue with normal dicom communicationclient.CloseForced(true);}server.CloseForced(true);}DicomEngine.Shutdown();DicomNet.Shutdown();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}
GetTlsCipherSuiteByIndex Method
SetTlsCipherSuiteByIndex Method
GetTlsEncryptionAlgorithm Method
GetTlsAuthenticationAlgorithm Method
GetTlsIntegrityAlgorithm Method
GetTlsKeyExchangeAlgorithm Method
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
