Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BasicConstraints.cs
1using System;
2
4{
9 {
10 private bool certificateAuthority = false;
11 private int pathLengthConstraint = int.MaxValue;
12 private KeyUsage? keyUsage = null;
13 protected bool configured;
14
18 public override string Oid => "2.5.29.19";
19
23 public override bool IsConfigured => this.configured;
24
30 public override bool Configure(Vector SecurityInfo)
31 {
32 if (SecurityInfo.LastElementNested is Vector BasicConstraints)
33 {
34 int c = BasicConstraints.Length;
35 int i = 0;
36
37 if (i < c && BasicConstraints[i] is KeyUsage KeyUsage)
38 {
39 i++;
40 this.keyUsage = KeyUsage;
41 }
42
43 if (i < c && BasicConstraints[i] is bool CertificateAuthority)
44 {
45 i++;
46 this.certificateAuthority = CertificateAuthority;
47 }
48
49 if (i < c && BasicConstraints[i] is System.Numerics.BigInteger PathLengthConstraint &&
50 PathLengthConstraint >= int.MinValue &&
51 PathLengthConstraint <= int.MaxValue)
52 {
53 i++;
54 this.pathLengthConstraint = (int)PathLengthConstraint;
55 }
56
57 if (i < c)
58 return false;
59
60 this.configured = true;
61
62 return true;
63 }
64 else if (SecurityInfo.LastElement is null ||
65 (SecurityInfo.LastElement is Array A && A.Length == 0))
66 {
67 this.configured = true;
68 return true;
69 }
70 else
71 return false;
72 }
73
77 public bool CertificateAuthority => this.certificateAuthority;
78
82 public int PathLengthConstraint => this.pathLengthConstraint;
83
87 public KeyUsage? KeyUsage => this.keyUsage;
88 }
89}
override bool Configure(Vector SecurityInfo)
If the object can be configured by the security information provided.
Abstract base class for security objects.