summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-11-13 13:33:11 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-11-13 13:33:11 +0700
commiteab9d0b29e10560e11e32c764971f51a9eb3116c (patch)
tree8df1d5b12840e72639df45f5c0a2589acdeacca1 /crypto
parentFix length check (diff)
downloadBouncyCastle.NET-ed25519-eab9d0b29e10560e11e32c764971f51a9eb3116c.tar.xz
According to RFC 6066, host_name should use ASCII encoding
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/tls/ServerName.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/src/crypto/tls/ServerName.cs b/crypto/src/crypto/tls/ServerName.cs
index 3d1e8f844..d42055b78 100644
--- a/crypto/src/crypto/tls/ServerName.cs
+++ b/crypto/src/crypto/tls/ServerName.cs
@@ -1,5 +1,6 @@
 using System;
 using System.IO;
+using System.Text;
 
 using Org.BouncyCastle.Utilities;
 
@@ -51,10 +52,10 @@ namespace Org.BouncyCastle.Crypto.Tls
             switch (mNameType)
             {
             case Tls.NameType.host_name:
-                byte[] utf8Encoding = Strings.ToUtf8ByteArray((string)mName);
-                if (utf8Encoding.Length < 1)
+                byte[] asciiEncoding = Encoding.ASCII.GetBytes((string)mName);
+                if (asciiEncoding.Length < 1)
                     throw new TlsFatalAlert(AlertDescription.internal_error);
-                TlsUtilities.WriteOpaque16(utf8Encoding, output);
+                TlsUtilities.WriteOpaque16(asciiEncoding, output);
                 break;
             default:
                 throw new TlsFatalAlert(AlertDescription.internal_error);
@@ -78,10 +79,10 @@ namespace Org.BouncyCastle.Crypto.Tls
             {
             case Tls.NameType.host_name:
             {
-                byte[] utf8Encoding = TlsUtilities.ReadOpaque16(input);
-                if (utf8Encoding.Length < 1)
+                byte[] asciiEncoding = TlsUtilities.ReadOpaque16(input);
+                if (asciiEncoding.Length < 1)
                     throw new TlsFatalAlert(AlertDescription.decode_error);
-                name = Strings.FromUtf8ByteArray(utf8Encoding);
+                name = Encoding.ASCII.GetString(asciiEncoding);
                 break;
             }
             default: