mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 590
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
In order to reproduce the problem, one needs to just create PkixNameConstraintValidator and call IntersectPermittedSubtree(Asn1Sequence) method in bouncy-castle FIPS.
In the code then, the following logic will always trigger KeyNotFoundException (decompiled code):
public void IntersectPermittedSubtree(Asn1Sequence permitted)
{
IDictionary<int, ISet<GeneralSubtree>> dictionary = (IDictionary<int, ISet<GeneralSubtree>>) new Dictionary<int, ISet<GeneralSubtree>>();
foreach (object obj in permitted)
{
GeneralSubtree instance = GeneralSubtree.GetInstance(obj);
int tagNo = instance.Base.TagNo;
if (dictionary[tagNo] == null)
dictionary[tagNo] = (ISet<GeneralSubtree>) new HashSet<GeneralSubtree>();
dictionary[tagNo].Add(instance);
}
IEnumerator<KeyValuePair<int, ISet<GeneralSubtree>>> enumerator = dictionary.GetEnumerator();
....
}
In particular, if (dictionary[tagNo] == null) check will always trigger such exception, since Dictionary was just created and therefore it's empty. Instead, TryGetValue should be used, similar to regular bouncy-castle code
Product Deployment
Deployment format: [netstandard2.0]
Version [Assembly: bcpkix-fips-1.0.2]
Desktop
OS: [Windows 11 64-bit]
Browser [N/A]
Version [N/A]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working