From f853d6b6b8b4bdad2231d1fb0fbe9980f7fbd39b Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 17 Mar 2021 15:29:55 +0100 Subject: [PATCH 1/5] Make parent and sub properties on ASN1Object public --- ASN1Decoder/ASN1Object.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ASN1Decoder/ASN1Object.swift b/ASN1Decoder/ASN1Object.swift index 90da609..8773c28 100644 --- a/ASN1Decoder/ASN1Object.swift +++ b/ASN1Decoder/ASN1Object.swift @@ -33,9 +33,9 @@ public class ASN1Object: CustomStringConvertible { public var identifier: ASN1Identifier? - var sub: [ASN1Object]? + public var sub: [ASN1Object]? - weak var parent: ASN1Object? + public weak var parent: ASN1Object? public func sub(_ index: Int) -> ASN1Object? { if let sub = self.sub, index >= 0, index < sub.count { From 1e33e83b8cec79e2a221ec3adf50e4bb4677bd5a Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 17 Mar 2021 15:34:34 +0100 Subject: [PATCH 2/5] Only allow read access to parent and sub properties --- ASN1Decoder/ASN1Object.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ASN1Decoder/ASN1Object.swift b/ASN1Decoder/ASN1Object.swift index 8773c28..43e0f3b 100644 --- a/ASN1Decoder/ASN1Object.swift +++ b/ASN1Decoder/ASN1Object.swift @@ -33,9 +33,9 @@ public class ASN1Object: CustomStringConvertible { public var identifier: ASN1Identifier? - public var sub: [ASN1Object]? + public internal(set) var sub: [ASN1Object]? - public weak var parent: ASN1Object? + public internal(set) weak var parent: ASN1Object? public func sub(_ index: Int) -> ASN1Object? { if let sub = self.sub, index >= 0, index < sub.count { From 4b7a3efbdefad0677dc77c3fdbcb97ca5f9ba703 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 17 Mar 2021 15:40:31 +0100 Subject: [PATCH 3/5] Expose toIntValue helper --- ASN1Decoder/ASN1Decoder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ASN1Decoder/ASN1Decoder.swift b/ASN1Decoder/ASN1Decoder.swift index 690ac21..26b8126 100644 --- a/ASN1Decoder/ASN1Decoder.swift +++ b/ASN1Decoder/ASN1Decoder.swift @@ -199,7 +199,7 @@ enum ASN1Error: Error { } extension Data { - func toIntValue() -> UInt64? { + public func toIntValue() -> UInt64? { if self.count > 8 { // check if suitable for UInt64 return nil } From 0ce4c51e36b6cc0bbad3891bdec1b559a20018ba Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Mon, 3 May 2021 13:53:08 +0200 Subject: [PATCH 4/5] Cleanup --- ASN1Decoder/OID.swift | 2 +- ASN1Decoder/PKCS7_Signature.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ASN1Decoder/OID.swift b/ASN1Decoder/OID.swift index efd69a6..8542214 100644 --- a/ASN1Decoder/OID.swift +++ b/ASN1Decoder/OID.swift @@ -22,7 +22,7 @@ public enum OID: String { case md5WithRSAEncryption = "1.2.840.113549.1.1.4" case sha1WithRSAEncryption = "1.2.840.113549.1.1.5" - //Digest algorithms + // Digest algorithms case sha1 = "1.3.14.3.2.26" case pkcsSha256 = "1.3.6.1.4.1.22554.1.2.1" case sha2Family = "1.3.6.1.4.1.22554.1.2" diff --git a/ASN1Decoder/PKCS7_Signature.swift b/ASN1Decoder/PKCS7_Signature.swift index cf17d5c..b6514ee 100644 --- a/ASN1Decoder/PKCS7_Signature.swift +++ b/ASN1Decoder/PKCS7_Signature.swift @@ -25,7 +25,7 @@ import Foundation extension PKCS7 { public var signatures: [SignatureInfo]? { - //Signer infos sequence. https://tools.ietf.org/html/rfc5652#section-5.3 + // Signer infos sequence. https://tools.ietf.org/html/rfc5652#section-5.3 guard let signerInfos = mainBlock.sub(4) else {return nil} From 86539b0d1db6027b37ceb1b9cedf6c24bfee5c5e Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Mon, 3 May 2021 13:56:52 +0200 Subject: [PATCH 5/5] Ensure empty weborderLineItem is parsed as nil instead of 0 --- ASN1Decoder/ASN1Decoder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ASN1Decoder/ASN1Decoder.swift b/ASN1Decoder/ASN1Decoder.swift index 26b8126..e5d7b65 100644 --- a/ASN1Decoder/ASN1Decoder.swift +++ b/ASN1Decoder/ASN1Decoder.swift @@ -200,7 +200,7 @@ enum ASN1Error: Error { extension Data { public func toIntValue() -> UInt64? { - if self.count > 8 { // check if suitable for UInt64 + if self.count > 8 || self.isEmpty { // check if suitable for UInt64 return nil }