Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ jobs:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install Swift-sh
run: brew install swift-sh
- name: Install Swift-sh and FlatBuffers
run: brew install swift-sh flatbuffers
- name: Build and Archive
env:
APP_PROVISIONING_PROFILE_UUID: ${{ secrets.APP_PROVISIONING_PROFILE_UUID }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
with:
submodules: recursive

- name: Install FlatBuffers
run: brew install flatbuffers

# Creating sample files needed to build, but not needed for CodeQL.
# .plist files need a sample structure to avoid error: "unable to read input file as a property list"
- name: Create sample files
Expand Down
82 changes: 34 additions & 48 deletions CryptoLib/CryptoLib.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CryptoLib/CryptoLib/AbstractSmartToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ import Foundation
func getCertificate() throws -> Data
func decrypt(_ data: Data, pin1: String) throws -> Data
func derive(_ data: Data, pin1: String) throws -> Data
func authenticate(_ data: Data, pin1: String) throws -> Data
}
32 changes: 0 additions & 32 deletions CryptoLib/CryptoLib/Addressee.h

This file was deleted.

28 changes: 0 additions & 28 deletions CryptoLib/CryptoLib/Addressee.m

This file was deleted.

69 changes: 69 additions & 0 deletions CryptoLib/CryptoLib/Addressee.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// Addressee.swift
// CryptoLib
/*
* Copyright 2017 - 2024 Riigi Infosüsteemi Amet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

import Foundation
import ASN1Decoder

public class Addressee: NSObject {
@objc public var data: Data
public let identifier: String
public let givenName: String?
public let surname: String?
public let certType: CertType
public var validTo: Date?

@objc public init(cn: String, certType: CertType, validTo: Date?, data: Data) {
let split = cn.split(separator: ",").map { String($0) }
if split.count > 1 {
surname = split[0]
givenName = split[1]
identifier = split[2]
} else {
surname = nil
givenName = nil
identifier = cn
}
self.certType = certType
self.validTo = validTo
self.data = data
}

@objc convenience public init(cn: String, pub: Data) {
self.init(cn: cn, certType: .UnknownType, validTo: nil, data: pub)
}

convenience init(cert: Data) {
let x509 = try? X509Certificate(der: cert)
self.init(cn: x509?.subject(oid: OID.commonName)?.joined(separator: ",") ?? "", certType: x509?.certType() ?? .UnknownType, validTo: x509?.notAfter, data: cert)
}

public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? Addressee else { return false }
return
data == other.data &&
identifier == other.identifier &&
givenName == other.givenName &&
surname == other.surname &&
certType == other.certType &&
validTo == other.validTo
}
}
102 changes: 102 additions & 0 deletions CryptoLib/CryptoLib/CDoc2Settings.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// CryptoDataFile.swift
// CryptoLib
/*
* Copyright 2017 - 2024 Riigi Infosüsteemi Amet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

import Foundation

public class CDoc2Settings: NSObject {
public static let kUseCDoc2Encryption = "kUseCDoc2Encryption"
public static let kUseCDoc2OnlineEncryption = "kUseCDoc2OnlineEncryption"
public static let kUseCDoc2SelectedService = "kUseCDoc2SelectedService"
public static let kUseCDoc2UUID = "kUseCDoc2UUID"
public static let kUseCDoc2PostURL = "kUseCDoc2PostURL"
public static let kUseCDoc2FetchURL = "kUseCDoc2FetchURL"

private static func set(_ key: String, value: Bool) {
UserDefaults.standard.set(value, forKey: key)
}

private static func get(_ key: String) -> Bool {
return UserDefaults.standard.bool(forKey: key)
}

private static func setString(_ key: String, value: String?) {
UserDefaults.standard.set(value, forKey: key)
}

private static func getString(_ key: String) -> String? {
return UserDefaults.standard.string(forKey: key)
}

public class var useEncryption: Bool {
get { get(kUseCDoc2Encryption) }
set { set(kUseCDoc2Encryption, value: newValue) }
}

public class var useOnlineEncryption: Bool {
get { get(kUseCDoc2OnlineEncryption) }
set { set(kUseCDoc2OnlineEncryption, value: newValue) }
}

public class var cdoc2SelectedService: String? {
get { getString(kUseCDoc2SelectedService) }
set { setString(kUseCDoc2SelectedService, value: newValue) }
}

public class var cdoc2UUID: String? {
get { getString(kUseCDoc2UUID) }
set { setString(kUseCDoc2UUID, value: newValue) }
}

public class var cdoc2PostURL: String? {
get { getString(kUseCDoc2PostURL) }
set { setString(kUseCDoc2PostURL, value: newValue) }
}

public class var cdoc2FetchURL: String? {
get { getString(kUseCDoc2FetchURL) }
set { setString(kUseCDoc2FetchURL, value: newValue) }
}

@objc public class func isEncryptionEnabled() -> Bool {
return get(kUseCDoc2Encryption)
}

@objc public class func isOnlineEncryptionEnabled() -> Bool {
return get(kUseCDoc2OnlineEncryption)
}

@objc public class func getSelectedService() -> String? {
return getString(kUseCDoc2SelectedService)
}

@objc public class func getUUID() -> String? {
return getString(kUseCDoc2UUID)
}

@objc public class func getPostURL() -> String? {
return getString(kUseCDoc2PostURL)
}

@objc public class func getFetchURL() -> String? {
return getString(kUseCDoc2FetchURL)
}
}
31 changes: 0 additions & 31 deletions CryptoLib/CryptoLib/CdocInfo.h

This file was deleted.

27 changes: 0 additions & 27 deletions CryptoLib/CryptoLib/CdocInfo.m

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CdocParser.h
// CdocInfo.swift
// CryptoLib
/*
* Copyright 2017 - 2024 Riigi Infosüsteemi Amet
Expand All @@ -20,11 +20,19 @@
*
*/

#import <Foundation/Foundation.h>
#import "CdocInfo.h"
import Foundation

@interface CdocParser : NSObject
- (CdocInfo*)parseCdocInfo:(NSString*)fullpath;
@end
public class CdocInfo: NSObject {
public let addressees: [Addressee]
public let dataFiles: [CryptoDataFile]

@objc public init(addressees: [Addressee] = []) {
self.addressees = addressees
self.dataFiles = []
}

@objc public init(addressees: [Addressee] = [], dataFiles: [CryptoDataFile] = []) {
self.addressees = addressees
self.dataFiles = dataFiles
}
}
39 changes: 0 additions & 39 deletions CryptoLib/CryptoLib/CdocParser.m

This file was deleted.

Loading