summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-11-12 17:32:38 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-11-12 17:32:38 +0700
commit005288002936b16dce66912f06fcd1ba09ed2508 (patch)
tree08addda717ec485c44c2babefe1441fd31dac1d8 /crypto/test/src
parentAdd sanity check on input length (diff)
downloadBouncyCastle.NET-ed25519-005288002936b16dce66912f06fcd1ba09ed2508.tar.xz
Use culture-independent prefix-check in MacUtilities.GetMac
- Fix for https://github.com/bcgit/bc-csharp/pull/40 (modified from original patch)
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/security/test/TestMacUtil.cs38
1 files changed, 38 insertions, 0 deletions
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; + } + } + } +}