Content-Length: 261328 | pFad | https://github.com/mrdepth/ASN1Decoder

00 GitHub - mrdepth/ASN1Decoder: ASN1Decoder written in Swift
Skip to content

mrdepth/ASN1Decoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASN1Decoder

ASN1Decoder written in Swift

Usage:

public struct SignedData: ASN1Decodable {
    public var version: Int
    public var digestAlgorithms: [AlgorithmIdentifier]
    public var encapContentInfo: EncapsulatedContentInfo
    public var certificates: [Any]?
    public var crls: [Any]?
    public var signerInfos: [SignerInfo]

    public init(from decoder: ASN1DecoderProtocol) throws {
        var c = try decoder.sequenceContainer(encoded: .sequence)
        version = try c.decode(Int.self, encoded: .integer)
        var algorightms = try c.setContainer(encoded: .set)
        digestAlgorithms = try algorightms.decodeSequence(of: AlgorithmIdentifier.self, encoded: .none)
        encapContentInfo = try c.decode(EncapsulatedContentInfo.self, encoded: .none)
        
        var set = try? c.setContainer(encoded: .implicit(.contextSpecific(0), .implicit(.set)))
        certificates = try? set?.decodeSequenceOfAny()
        
        set = try? c.setContainer(encoded: .implicit(.contextSpecific(1), .implicit(.set)))
        crls = try? set?.decodeSequenceOfAny()
        
        var set2 = try c.setContainer(encoded: .set)
        signerInfos = try set2.decodeSequence(of: SignerInfo.self, encoded: .none)
    }
}

let data = try ASN1Decoder().decode(SignedData.self, from: data)

About

ASN1Decoder written in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/mrdepth/ASN1Decoder

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy