From 184077ebeabe315ec4dc13e2670868422f7b9594 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 5 Apr 2020 21:16:59 +0700 Subject: Add OtherName support and refactoring --- crypto/test/src/test/PkixNameConstraintsTest.cs | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crypto/test') diff --git a/crypto/test/src/test/PkixNameConstraintsTest.cs b/crypto/test/src/test/PkixNameConstraintsTest.cs index 073f9f2a3..65f39dcd2 100644 --- a/crypto/test/src/test/PkixNameConstraintsTest.cs +++ b/crypto/test/src/test/PkixNameConstraintsTest.cs @@ -197,6 +197,37 @@ namespace Org.BouncyCastle.Tests constraintValidator.checkPermitted( new GeneralName(GeneralName.DirectoryName, new X509Name(true, "cn=Valid DN nameConstraints EE Certificate Test1, ou=permittedSubtree1, o=Test Certificates 2011, c=US"))); + + GeneralName name = new GeneralName(GeneralName.OtherName, new OtherName(new DerObjectIdentifier("1.1"), DerNull.Instance)); + GeneralSubtree subtree = new GeneralSubtree(name); + + PkixNameConstraintValidator validator = new PkixNameConstraintValidator(); + validator.IntersectPermittedSubtree(new DerSequence(subtree)); + + name = new GeneralName(GeneralName.OtherName, new OtherName(new DerObjectIdentifier("1.1"), DerNull.Instance)); + subtree = new GeneralSubtree(name); + + validator = new PkixNameConstraintValidator(); + validator.IntersectPermittedSubtree(new DerSequence(subtree)); + validator.AddExcludedSubtree(subtree); + + try + { + validator.checkExcluded(name); + } + catch (PkixNameConstraintValidatorException e) + { + IsEquals("OtherName is from an excluded subtree.", e.Message); + } + + try + { + validator.checkPermitted(name); + } + catch (PkixNameConstraintValidatorException e) + { + Fail(e.Message); + } } /** -- cgit 1.4.1