Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SignedMessage.cs
1using System.Diagnostics.CodeAnalysis;
4
6{
10 public class SignedMessage
11 {
17 {
18 this.Data = Data;
19 }
20
27 public static bool TryParse(byte[] RawCertificate, [NotNullWhen(true)] out SignedMessage? Parsed)
28 {
29 Parsed = null;
30
31 if (!ASN1.TryDecodeDer(RawCertificate, out object? Content))
32 return false;
33
34 return TryParse(Content, out Parsed);
35 }
36
43 public static bool TryParse(object? Content, [NotNullWhen(true)] out SignedMessage? Parsed)
44 {
45 Parsed = null;
46
47 if (Content is Vector SignedDataVector)
48 return TryParse(SignedDataVector, out Parsed);
49 else if (Content is SignedData SignedData)
50 {
51 Parsed = new SignedMessage(SignedData);
52 return true;
53 }
54 else
55 return false;
56 }
57
64 public static bool TryParse(Vector SignedDataVector, [NotNullWhen(true)] out SignedMessage? Parsed)
65 {
66 foreach (object Item in SignedDataVector.Elements)
67 {
68 if (TryParse(Item, out Parsed))
69 return true;
70 }
71
72 Parsed = null;
73 return false;
74 }
75
79 public SignedData Data { get; }
80
86 public bool CheckSignature(bool VerifyCertificates)
87 {
88 return this.CheckSignature(VerifyCertificates, null);
89 }
90
97 public bool CheckSignature(bool VerifyCertificates, ICommunicationLayer? Client)
98 {
99 return this.Data.CheckSignature(VerifyCertificates, Client);
100 }
101 }
102}
Static class for parsing and decoding security objects encoded using Abstract Syntax Notation 1 (ASN....
Definition: ASN1.cs:22
static bool TryDecodeDer(byte[] Data, out object? Value)
Decodes a DER-encoded object.
Definition: ASN1.cs:77
Signed Data, as defined in RFC 5652, §5.1.
bool CheckSignature(bool VerifyCertificates, ICommunicationLayer? Client)
Checks if the signature is valid.
static bool TryParse(Vector SignedDataVector, [NotNullWhen(true)] out SignedMessage? Parsed)
Tries to parse an ASN.1-encoded Signed Data structure, as defined in RFC 5652, §5....
bool CheckSignature(bool VerifyCertificates)
Checks if the signature is valid.
static bool TryParse(object? Content, [NotNullWhen(true)] out SignedMessage? Parsed)
Tries to parse an ASN.1-encoded Signed Data structure, as defined in RFC 5652, §5....
static bool TryParse(byte[] RawCertificate, [NotNullWhen(true)] out SignedMessage? Parsed)
Tries to parse an ASN.1-encoded Signed Data structure, as defined in RFC 5652, §5....
Interface for observable classes implementing communication protocols.
class SignedData()
Signed Data, as defined in RFC 5652, §5.1.
Definition: SignedData.cs:14