Skip to content

Commit

Permalink
Comp revocation development (#120)
Browse files Browse the repository at this point in the history
* Fix verification fields

* Minor changes in responce

* Fixed visibility of enums to public

* Update Core Extensions

* Added corrected localisation strings

* Fixed Warnings

* Fixed QR Code crash

* minor fix

* minor

* Added Networking to core

* Added BlumFilter functionality

* Prepared DataCenter to adding Revocations, fixed Bloom filter SHA256

* Added revocation main URL

* Added Revocation request

* Updated request factory

* Added chunk request

* Added zip loading

* UVCI and country code concat UVCI  hashes accessors

* Certificate signature hash calculation

* Marked incorrect public key for the signature algorithm check

* Added UI screens for loading

* Signature hash finalized

* Added revocation Functionality

* Imported BloomFilter

* Changed status of x and y

* Added UI

* Added minor

* Updated validity

* removed unnecessary file

* Added new revocation section

* fixed certificate hash

* feat: prefix check revocation

* RevocationServiceProtocol

* minor

* Fixed last commit

* Added revoc enum

* Added temp header

* Added temp SliceType

* Refactored API

* Refactored changes

* fix: core

* Added field to Hcert

* minor chages

* fixed crash with no internet

* Updated storage

* Added new API to Verifier, removed old API

* Added Headers

* increased buildld num

* minor fixes

Co-authored-by: IgorKhomiak <[email protected]>
Co-authored-by: Denis Melenevsky <[email protected]>
Co-authored-by: Paul Ballmann <[email protected]>
  • Loading branch information
4 people authored May 5, 2022
1 parent 0da9ac3 commit f1bcb3b
Show file tree
Hide file tree
Showing 17 changed files with 523 additions and 667 deletions.
29 changes: 17 additions & 12 deletions Sources/Extensions/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,23 @@ extension Date {
static let dateTimeFormatter = formatter(for: "yyyy-MM-dd HH:mm", utcPosix: false)
static let dateFormatterOffset = formatter(for: "yyyy-MM-dd'T'HH:mm:ssZZZZZ")
static let dateFormatterFractional = formatter(for: "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX")

// 2022-03-30T15:23:39Z
public var isoString: String {
Date.isoFormatter.string(from: self)
}

public var isoString: String {
Date.isoFormatter.string(from: self)
}
public var dateString: String {
Date.dateFormatter.string(from: self)
}
public var dateTimeString: String {
Date.dateTimeFormatter.string(from: self)
}
public var dateString: String {
Date.dateFormatter.string(from: self)
}

public var dateOffsetString: String {
Date.dateFormatterOffset.string(from: self)
}

public var dateTimeString: String {
Date.dateTimeFormatter.string(from: self)
}

public init?(isoString: String) {
guard let date = Date.isoFormatter.date(from: isoString) else { return nil }
Expand All @@ -83,7 +88,7 @@ extension Date {
} else {
return nil
}
}
}

public init?(rfc3339DateTimeString str: String) {
var str = str
Expand Down
18 changes: 9 additions & 9 deletions Sources/Extensions/String+JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import Foundation

extension String {
var asJSONDict: [String: AnyObject] {
if let data = data(using: .utf8) {
do {
let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: AnyObject]
return json ?? [:]
} catch {
var asJSONDict: [String: AnyObject] {
if let data = data(using: .utf8) {
do {
let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: AnyObject]
return json ?? [:]
} catch {
return [:]
}
}
return [:]
}
}
return [:]
}
}
56 changes: 25 additions & 31 deletions Sources/Extensions/SwiftCBOR.CBOR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,49 +37,43 @@ extension SwiftCBOR.CBOR {
public func toString() -> String {
switch self {
case let .byteString(val):
let fallBack = "[" + val.map { "\($0)" }.joined(separator: ", ") + "]"
// if
// let child = try? SwiftCBOR.CBOR.decode(val),
// case .map(_) = child
// {
// return child.toString()
// }
return fallBack
let fallBack = "[" + val.map { "\($0)" }.joined(separator: ", ") + "]"
return fallBack
case let .unsignedInt(val):
return "\(val)"
return "\(val)"
case let .negativeInt(val):
return "-\(val + 1)"
return "-\(val + 1)"
case let .utf8String(val):
return "\"\(sanitize(value: val))\""
return "\"\(sanitize(value: val))\""
case let .array(vals):
var str = ""
for val in vals {
str += (str.isEmpty ? "" : ", ") + val.toString()
}
return "[\(str)]"
var str = ""
for val in vals {
str += (str.isEmpty ? "" : ", ") + val.toString()
}
return "[\(str)]"
case let .map(vals):
var str = ""
for pair in vals {
let val = pair.value
if case .undefined = val {
continue
var str = ""
for pair in vals {
let val = pair.value
if case .undefined = val {
continue
}
let key = "\"\(pair.key.toString().trimmingCharacters(in: ["\""]))\""
str += (str.isEmpty ? "" : ", ") + "\(key): \(val.toString())"
}
let key = "\"\(pair.key.toString().trimmingCharacters(in: ["\""]))\""
str += (str.isEmpty ? "" : ", ") + "\(key): \(val.toString())"
}
return "{\(str)}"
return "{\(str)}"
case let .boolean(val):
return String(describing: val)
return String(describing: val)
case .null, .undefined:
return "null"
return "null"
case let .float(val):
return "\(val)"
return "\(val)"
case let .double(val):
return "\(val)"
return "\(val)"
case let .date(val):
return "\"\(val.isoString)\""
return "\"\(val.isoString)\""
default:
return "\"unsupported data\""
return "\"unsupported data\""
}
}
}
88 changes: 0 additions & 88 deletions Sources/Extensions/UIViewController.swift

This file was deleted.

66 changes: 0 additions & 66 deletions Sources/Extensions/UserDefaults+.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/Models/CoreManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import AppKit

public class CoreManager {
public static var shared = CoreManager()
lazy public var config = HCertConfig.default
public static var config = HCertConfig.default
public static var publicKeyEncoder: PublicKeyStorageDelegate?

#if os(iOS)
Expand Down
25 changes: 18 additions & 7 deletions Sources/Models/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum HCertValidity {
case valid
case invalid
case ruleInvalid
case revocated
case revoked
}

public let attributeKeys: [AttributeKey: [String]] = [
Expand All @@ -78,12 +78,6 @@ public enum InfoSectionStyle {
case fixedWidthFont
}

public enum RuleValidationResult: Int {
case failed = 0
case passed
case open
}

public class ParseErrors {
var errors: [ParseError] = []
}
Expand All @@ -106,4 +100,21 @@ public enum RevocationMode: String {
case point = "POINT"
case vector = "VECTOR"
case coordinate = "COORDINATE"

public func partitionOffset() -> UInt8 {
switch self {
case .point:
return 0
case .vector:
return 8
case .coordinate:
return 16
}
}
}

public var sliceType: SliceType = .VARHASHLIST

public enum SliceType: String {
case BLOOMFILTER, VARHASHLIST
}
Loading

0 comments on commit f1bcb3b

Please sign in to comment.