SecurityInfo
internal class SecurityInfo
A base class for representing security information contained in an ASN.1 structure.
The SecurityInfo
class serves as a base class for various security information objects
used in the ASN.1 structure. It provides the foundation for decoding and extracting security information.
Subclasses should be created to handle specific types of security information.
The ASN.1 data structure SecurityInfos
indicates supported security protocols and is provided by the eMRTD chip.
The data structures SecurityInfos
and SecurityInfo
are defined as follows:
SecurityInfos ::= SET OF SecurityInfo
SecurityInfo ::= SEQUENCE {
protocol OBJECT IDENTIFIER,
requiredData ANY DEFINED BY protocol,
optionalData ANY DEFINED BY protocol OPTIONAL
}
The SecurityInfo
components represent:
protocol
: An object identifier that identifies the supported protocol.requiredData
: An open type that contains protocol-specific mandatory data.optionalData
: An open type that contains protocol-specific optional data.
Subclasses of SecurityInfo
should override the decode(_:)
method to handle the specific decoding
logic for their respective security information types.
The getInstance(node:)
method is used to instantiate the appropriate subclass of SecurityInfo
based on the ObjectIdentifier
(OID) found in the ASN.1 structure.
-
The object identifier (OID) associated with the security information.
Declaration
Swift
private(set) var oid: ObjectIdentifier { get }
-
Initializes a
SecurityInfo
instance.Subclasses of
SecurityInfo
should override thedecode(_:)
method to handle the specific decoding logic for their respective security information types.Declaration
Swift
internal required init(oid: ObjectIdentifier, data: ASN1NodeCollection) throws
Parameters
oid
The
ObjectIdentifier
(OID) associated with the security information.data
The
ASN1NodeCollection
containing the security information. -
Decodes the security information from the given ASN.1 node collection.
Subclasses of
SecurityInfo
should override this method to provide the specific decoding logic for their respective security information types.Throws
An error if decoding fails.
Declaration
Swift
internal func decode(_ data: ASN1NodeCollection) throws
Parameters
data
The
ASN1NodeCollection
containing the security information. -
Creates an instance of a subclass of
SecurityInfo
based on the provided ASN.1 node.The method extracts the
ObjectIdentifier
(OID) and instantiates the appropriate subclass based on the OID.Important
If the OID is not recognized or supported,
nil
is returned.Throws
An error if decoding OID fails.
Declaration
Swift
internal static func getInstance(node: ASN1Node) throws -> SecurityInfo?
Parameters
node
The
ASN1Node
containing security information.Return Value
An instance of a subclass of
SecurityInfo
ornil
if the OID is not recognized or supported.