2using System.Diagnostics.CodeAnalysis;
3using System.Security.Cryptography.Pkcs;
40 public override ushort
Tag => 0x77;
59 public override bool TryParse(
byte[] Value, TravelDocumentsClient Client,
64 if (Client.AppInfo?.HasAtLeastLdsVersion(1, 8) ??
false)
70 Client.Warning(
"Could not parse Signed CMS:\r\n\r\n " +
71 Convert.ToBase64String(Value, Base64FormattingOptions.InsertLineBreaks));
83 ContentOid =
SignedData.Data.EncapsulatedContentOid;
87 if (!Client.PermitPlatformDependentValidation)
96 SignedCms SignedDataX =
new();
97 SignedDataX.Decode(Value);
99 SignedDataX.CheckSignature(
true);
101 Content = SignedDataX.ContentInfo?.Content;
102 ContentOid = SignedDataX.ContentInfo?.ContentType?.Value;
104 Log.
Debug(
"Platform/OS-independent signature validation failed, but Platform/OS-dependent signature validation successful. Check communication logs for more details.");
106 Client.Warning(
"Platform/OS-independent signature validation failed, but Platform/OS-dependent signature validation successful:\r\n\r\n" +
107 Convert.ToBase64String(Value, Base64FormattingOptions.InsertLineBreaks));
111 Client.Warning(
"Could not validate signatures in Signed CMS:\r\n\r\n " +
112 Convert.ToBase64String(Value, Base64FormattingOptions.InsertLineBreaks));
117 if (Content is
null ||
string.IsNullOrEmpty(ContentOid))
122 Client.Warning(
"OID not recognized: " + ContentOid);
132 if (ParsedContent is not Vector ContentVector)
149 Client.Exception(ex);
169 if (!(this.
LdsSecurityObject?.DataGroupHashValues?.TryGetValue(Nr, out
byte[]? ExpectedDigest) ??
false))
173 if (HashFunctions is
null)
176 int i, c = ExpectedDigest.Length;
182 if (Digest.Length != c)
185 for (i = 0; i < c; i++)
187 if (Digest[i] != ExpectedDigest[i])
Static class for parsing and decoding security objects encoded using Abstract Syntax Notation 1 (ASN....
static bool TryInstantiate(string Oid, [NotNullWhen(true)] out ISecurityObject? Object)
Tries to instantiate a new object of a given OID.
static int ReportOidNotRecognized(string Oid)
Records an OID as not recognized.
static int ReportOidNotConfigured(string Oid)
Records an OID as not configured properly.
static bool TryDecodeDer(byte[] Data, out object? Value)
Decodes a DER-encoded object.
Document Security Object. Reference: §4.6.2, EF.SOD, ICAO Doc 9303-10, Table 36.
DocumentSecurityObject(byte[] Value, SignedData? SignedData, LdsSecurityObject LdsSecurityObject)
Document Security Object. Reference: §4.6.2, EF.SOD, ICAO Doc 9303-10, Table 36.
DocumentSecurityObject()
Document Security Object. Reference: §4.6.2, EF.SOD, ICAO Doc 9303-10, Table 36.
SignedData? SignedData
Signed data.
bool ValidateDataGroup(int Nr, byte[] DataRead)
Validates data read from a data group, using the information in the LDS Security Object.
override ushort Tag
Tag value.
override bool TryParse(byte[] Value, TravelDocumentsClient Client, [NotNullWhen(true)] out IDataObject? Parsed)
Tries to parse a binary representation of the data object.
LdsSecurityObject? LdsSecurityObject
>LDS Security Object.
Abstract base class for hash functions.
abstract byte[] ComputeHash(byte[] Data)
Computes a Hash Digest from binary data.
LDS Security Object V1. Reference: §4.6.2.3, ICAO Doc 9303-10.
HashFunction?[] HashFunctions
Hash Functions used
override bool IsConfigured
If the object has been configured.
override string Oid
OID identifying the type of object.
override bool Configure(Vector SecurityInfo)
If the object can be configured by the security information provided.
Abstract base class for security objects.
Signed Data, as defined in RFC 5652, §5.1.
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....
Static class managing the application event log. Applications and services log events on this static ...
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Interface for security objects.