From 005288002936b16dce66912f06fcd1ba09ed2508 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 12 Nov 2015 17:32:38 +0700 Subject: Use culture-independent prefix-check in MacUtilities.GetMac - Fix for https://github.com/bcgit/bc-csharp/pull/40 (modified from original patch) --- crypto/test/src/security/test/TestMacUtil.cs | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 crypto/test/src/security/test/TestMacUtil.cs (limited to 'crypto/test/src') diff --git a/crypto/test/src/security/test/TestMacUtil.cs b/crypto/test/src/security/test/TestMacUtil.cs new file mode 100644 index 000000000..1eb6f35b0 --- /dev/null +++ b/crypto/test/src/security/test/TestMacUtil.cs @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using System.Threading; + +using NUnit.Framework; + +using Org.BouncyCastle.Crypto; + +namespace Org.BouncyCastle.Security.Tests +{ + [TestFixture] + public class TestMacUtilities + { + [Test] + public void TestCultureIndependence() + { + Thread t = Thread.CurrentThread; + CultureInfo ci = t.CurrentCulture; + try + { + /* + * In Hungarian, the "CS" in "HMACSHA256" is linguistically a single character, so "HMAC" is not a prefix. + */ + t.CurrentCulture = new CultureInfo("hu-HU"); + IMac mac = MacUtilities.GetMac("HMACSHA256"); + Assert.NotNull(mac); + } + catch (Exception e) + { + Assert.Fail("Culture-specific lookup failed: " + e.Message); + } + finally + { + t.CurrentCulture = ci; + } + } + } +} -- cgit 1.5.1