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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ShareViewModel: ShareViewModelProtocol, Loggable {

@discardableResult
func importFiles(_ items: [ImportedFileItem]) async -> Bool {
ShareViewModel.logger().debug("Importing files...")
ShareViewModel.logger().info("Importing files...")
guard !items.isEmpty else {
await MainActor.run { [weak self] in
self?.status = .failed
Expand All @@ -57,7 +57,7 @@ class ShareViewModel: ShareViewModelProtocol, Loggable {
)

if isImported {
ShareViewModel.logger().debug("Files imported successfully")
ShareViewModel.logger().info("Files imported successfully")
} else {
ShareViewModel.logger().error("Could not import files")
}
Expand Down Expand Up @@ -178,7 +178,7 @@ class ShareViewModel: ShareViewModelProtocol, Loggable {
}

func downloadFileFromUrl(_ itemUrl: URL) async -> Bool {
ShareViewModel.logger().debug("Downloading file from \(itemUrl.absoluteString)")
ShareViewModel.logger().info("Downloading file from \(itemUrl.absoluteString)")

do {
let destinationURL = try Directories.getTempDirectory(
Expand All @@ -198,7 +198,7 @@ class ShareViewModel: ShareViewModelProtocol, Loggable {
for await progress in request.downloadProgress() {
let fileName = itemUrl.lastPathComponent
let downloadProgress = progress.fractionCompleted * 100
ShareViewModel.logger().debug(
ShareViewModel.logger().info(
"\(String(format: "Download progress for file '%@': %.2f%%", fileName, downloadProgress))"
)
}
Expand Down
1 change: 1 addition & 0 deletions Modules/CommonsLib/Sources/CommonsLib/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public struct Constants {
}

public struct File {
public static let LibDigidocLog = "libdigidocpp.log"
public static let LDAPCertsPem = "ldapCerts.pem"
}

Expand Down
4 changes: 2 additions & 2 deletions Modules/CommonsLib/Sources/CommonsLib/System/SystemUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
public struct SystemUtil: Loggable {
public static var isSimulator: Bool {
#if targetEnvironment(simulator)
logger().debug("App is running on a simulator")
logger().info("App is running on a simulator")
return true
#else
return false
Expand All @@ -32,7 +32,7 @@ public struct SystemUtil: Loggable {
public static func getOSVersion() -> String {
let osVersion = ProcessInfo.processInfo.operatingSystemVersion
let versionString = "\(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)"
logger().debug("Operating system version: \(versionString)")
logger().info("Operating system version: \(versionString)")
return versionString
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
}

public func initConfiguration(cacheDir: URL, proxyInfo: ProxyInfo) async throws {
ConfigurationLoader.logger().debug("Initializing configuration")
ConfigurationLoader.logger().info("Initializing configuration")

if !fileManager.fileExists(atPath: cacheDir.resolvedPath) {
try fileManager.createDirectory(
Expand All @@ -70,11 +70,11 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
try await loadConfigurationProperty()

if try await shouldCheckForUpdates() {
ConfigurationLoader.logger().debug("Checking for configuration updates...")
ConfigurationLoader.logger().info("Checking for configuration updates...")
try await loadCentralConfiguration(cacheDir: cacheDir, proxyInfo: proxyInfo)
}

ConfigurationLoader.logger().debug("Finished initializing configuration")
ConfigurationLoader.logger().info("Finished initializing configuration")

finishConfigurationUpdate()
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
fileManager.fileExists(atPath: signatureFile.resolvedPath)

if configFilesExist {
ConfigurationLoader.logger().debug("Initializing cached configuration")
ConfigurationLoader.logger().info("Initializing cached configuration")

let confFileContents = try String(contentsOf: confFile, encoding: .utf8)
let publicKeyContents = try String(contentsOf: publicKeyFile, encoding: .utf8)
Expand All @@ -141,7 +141,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
from: Data(contentsOf: confFile)
)

ConfigurationLoader.logger().debug(
ConfigurationLoader.logger().info(
"Using cached configuration version \(configurationProvider.metaInf.serial)"
)

Expand Down Expand Up @@ -179,7 +179,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
updateConfiguration(configurationProvider)
}
} else {
ConfigurationLoader.logger().debug(
ConfigurationLoader.logger().info(
"Cached configuration not found. Initializing default configuration")
try await loadDefaultConfiguration(cacheDir: configDir)
}
Expand Down Expand Up @@ -239,7 +239,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
ConfigurationProvider.self, from: Data(contentsOf: confDataURL)
)

ConfigurationLoader.logger().debug(
ConfigurationLoader.logger().info(
"Initializing default configuration version \(configurationProvider.metaInf.serial)"
)

Expand Down Expand Up @@ -281,7 +281,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
).trimmingCharacters(in: .whitespaces)

if !centralSignature.isEmpty && currentSignature != centralSignature.data(using: .utf8) {
ConfigurationLoader.logger().debug("Found new configuration")
ConfigurationLoader.logger().info("Found new configuration")

let centralConfig = try await centralConfigurationRepository.fetchConfiguration(
proxyInfo: proxyInfo
Expand All @@ -293,7 +293,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
let centralConfigurationProvider = try JSONDecoder().decode(
ConfigurationProvider.self, from: Data(centralConfig.utf8)
)
ConfigurationLoader.logger().debug(
ConfigurationLoader.logger().info(
"Initializing configuration version \(centralConfigurationProvider.metaInf.serial)"
)

Expand Down Expand Up @@ -337,7 +337,7 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable {
try await loadCachedConfiguration(afterCentralCheck: true, cacheDir: configDir)
}
} else {
ConfigurationLoader.logger().debug(
ConfigurationLoader.logger().info(
"New configuration not found. Using cached configuration"
)
try await loadCachedConfiguration(afterCentralCheck: true, cacheDir: configDir)
Expand Down
6 changes: 3 additions & 3 deletions Modules/CryptoLib/Sources/CryptoSwift/CryptoContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ extension CryptoContainer {
dataFiles: [URL],
containerUtil: ContainerUtilProtocol = Container.shared.containerUtil(),
) async throws -> CryptoContainerProtocol {
logger().debug("Opening or creating crypto container. Found \(dataFiles.count) datafile(s)")
logger().info("Opening or creating crypto container. Found \(dataFiles.count) datafile(s)")
guard let firstFile = dataFiles.first else {
logger().error("Unable to create or open crypto container. First datafile is nil")
throw CryptoError.containerCreationFailed(
Expand Down Expand Up @@ -240,10 +240,10 @@ extension CryptoContainer {
}

if dataFiles.count == 1 && isFirstDataFileContainer {
CryptoContainer.logger().debug("Opening existing crypto container")
CryptoContainer.logger().info("Opening existing crypto container")
return try await open(containerFile: containerFile)
} else {
CryptoContainer.logger().debug("Creating a new crypto container")
CryptoContainer.logger().info("Creating a new crypto container")
return try await create(
containerFile: containerFile,
dataFiles: dataFiles,
Expand Down
20 changes: 10 additions & 10 deletions Modules/CryptoLib/Sources/CryptoSwift/Ldap/OpenLdap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
if fileManager.fileExists(atPath: ldapCertFilePath) {
filePath = ldapCertFilePath
} else {
OpenLdap.logger().debug("File ldapCerts.pem does not exist at directory path: \(ldapCertFilePath)")
OpenLdap.logger().info("File ldapCerts.pem does not exist at directory path: \(ldapCertFilePath)")
filePath = nil
}
}

let searchType = SearchType(from: identityCode)
if case .personalCode = searchType {
OpenLdap.logger().debug("Searching with personal code from LDAP")
OpenLdap.logger().info("Searching with personal code from LDAP")
var result = [Addressee]()
var tooManyResults = false
for url in await self.ldapConfiguration.getLdapPersonURLS() {
Expand All @@ -116,7 +116,7 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
return (result, tooManyResults)
} else {
if let ldapCorpURL = await self.ldapConfiguration.getLdapCorpURL() {
OpenLdap.logger().debug("Searching with corporation keyword from LDAP")
OpenLdap.logger().info("Searching with corporation keyword from LDAP")
let (addresses, found) = OpenLdap.search(
searchType: searchType,
url: ldapCorpURL,
Expand Down Expand Up @@ -145,7 +145,7 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
var ldapConnectionReset = 0
let result = ldap_set_option(nil, LDAP_OPT_X_TLS_NEWCTX, &ldapConnectionReset)
guard result == LDAP_SUCCESS else {
OpenLdap.logger().debug(
OpenLdap.logger().info(
"ldap_set_option(LDAP_OPT_X_TLS_NEWCTX) failed: \(String(cString: ldap_err2string(result)))"
)
return ([], 0)
Expand All @@ -167,14 +167,14 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
if let ldap = ldap { ldap_destroy(ldap) }
}
guard ldapReturnCode == LDAP_SUCCESS else {
OpenLdap.logger().debug("Failed to initialize LDAP: \(String(cString: ldap_err2string(ldapReturnCode)))")
OpenLdap.logger().info("Failed to initialize LDAP: \(String(cString: ldap_err2string(ldapReturnCode)))")
return ([], 0)
}

var ldapVersion = LDAP_VERSION3
ldapReturnCode = ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, &ldapVersion)
guard ldapReturnCode == LDAP_SUCCESS else {
OpenLdap.logger().debug(
OpenLdap.logger().info(
"ldap_set_option(PROTOCOL_VERSION) failed: \(String(cString: ldap_err2string(ldapReturnCode)))"
)
return ([], 0)
Expand All @@ -186,7 +186,7 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
} else {
distinguishedName.remove(at: distinguishedName.startIndex)
}
OpenLdap.logger().debug("Searching from LDAP. Url: \(url) \(distinguishedName) \(searchType.filter)")
OpenLdap.logger().info("Searching from LDAP. Url: \(url) \(distinguishedName) \(searchType.filter)")
var msgId: Int32 = 0
var attr = Array("userCertificate;binary".utf8CString)
ldapReturnCode = attr.withUnsafeMutableBufferPointer { attr in
Expand All @@ -209,7 +209,7 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
}

guard ldapReturnCode == LDAP_SUCCESS else {
OpenLdap.logger().debug("ldap_search_ext failed: \(String(cString: ldap_err2string(ldapReturnCode)))")
OpenLdap.logger().info("ldap_search_ext failed: \(String(cString: ldap_err2string(ldapReturnCode)))")
return ([], 0)
}

Expand All @@ -231,7 +231,7 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
case Int32(LDAP_SUCCESS):
break
default:
OpenLdap.logger().debug("ldap_result failed: \(String(cString: ldap_err2string(ldapReturnCode)))")
OpenLdap.logger().info("ldap_result failed: \(String(cString: ldap_err2string(ldapReturnCode)))")
return (addressees: result, totalAddressees: totalAddressees)
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ final public class OpenLdap: OpenLdapProtocol, Loggable {
}

if let namePointer = ldap_get_dn(ldap, currentMessage) {
OpenLdap.logger().debug("Result (\(result.count)) \(String(cString: namePointer))")
OpenLdap.logger().info("Result (\(result.count)) \(String(cString: namePointer))")
ldap_memfree(namePointer)
}
}
Expand Down
34 changes: 17 additions & 17 deletions Modules/IdCardLib/Sources/IdCardLib/CardActions/CardReaderNFC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class CardReaderNFC: CardReader, Loggable {
init(_ tag: NFCISO7816Tag, CAN: String) async throws {
self.tag = tag

CardReaderNFC.logger().debug("Select CardAccess")
CardReaderNFC.logger().info("Select CardAccess")
_ = try await tag.sendCommand(cls: 0x00, ins: 0xA4, p1Byte: 0x02, p2Byte: 0x0C, data: Data([0x01, 0x1C]))
CardReaderNFC.logger().debug("Read CardAccess")
CardReaderNFC.logger().info("Read CardAccess")
let data = try await tag.sendCommand(cls: 0x00, ins: 0xB0, p1Byte: 0x00, p2Byte: 0x00, leByte: 256)

guard let (mappingType, parameterId) = TLV.sequenceOfRecords(from: data)?
Expand Down Expand Up @@ -102,9 +102,9 @@ class CardReaderNFC: CardReader, Loggable {

// Step1 - General Authentication
let nonceEnc = try await tag.sendPaceCommand(records: [], tagExpected: 0x80)
CardReaderNFC.logger().debug("Challenge \(nonceEnc.value.toHex)")
CardReaderNFC.logger().info("Challenge \(nonceEnc.value.toHex)")
let nonce = try CardReaderNFC.decryptNonce(CAN: CAN, encryptedNonce: nonceEnc.value)
CardReaderNFC.logger().debug("Nonce \(nonce.toHex)")
CardReaderNFC.logger().info("Nonce \(nonce.toHex)")

// Step2
let (terminalPubKey, terminalPrivKey) = domain.makeKeyPair()
Expand All @@ -115,25 +115,25 @@ class CardReaderNFC: CardReader, Loggable {
)],
tagExpected: 0x82
)
CardReaderNFC.logger().debug("Mapping key \(mappingKey.value.toHex)")
CardReaderNFC.logger().info("Mapping key \(mappingKey.value.toHex)")
guard let cardPubKey = try ECPublicKey(domain: domain, point: mappingKey.value)
else { throw IdCardInternalError.authenticationFailed }

// Mapping
let nonceS = BInt(magnitude: nonce)
let mappingBasePoint = ECPublicKey(privateKey: try ECPrivateKey(domain: domain, s: nonceS)) // S*G
// swiftlint:disable line_length
CardReaderNFC.logger().debug("Card Key x: \(mappingBasePoint.w.x.asMagnitudeBytes().toHex, privacy: .public), y: \(mappingBasePoint.w.y.asMagnitudeBytes().toHex, privacy: .public)")
CardReaderNFC.logger().info("Card Key x: \(mappingBasePoint.w.x.asMagnitudeBytes().toHex, privacy: .public), y: \(mappingBasePoint.w.y.asMagnitudeBytes().toHex, privacy: .public)")
// swiftlint:enable line_length
let sharedSecretH = try domain.multiplyPoint(cardPubKey.w, terminalPrivKey.s)
// swiftlint:disable line_length
CardReaderNFC.logger().debug("Shared Secret x: \(sharedSecretH.x.asMagnitudeBytes().toHex, privacy: .public), y: \(sharedSecretH.y.asMagnitudeBytes().toHex, privacy: .public)")
CardReaderNFC.logger().info("Shared Secret x: \(sharedSecretH.x.asMagnitudeBytes().toHex, privacy: .public), y: \(sharedSecretH.y.asMagnitudeBytes().toHex, privacy: .public)")
// swiftlint:enable line_length
let mappedPoint = try domain.addPoints(mappingBasePoint.w, sharedSecretH) // MAP G = (S*G) + H

// Ephemeral data
// swiftlint:disable line_length
CardReaderNFC.logger().debug("Mapped point x: \(mappedPoint.x.asMagnitudeBytes().toHex, privacy: .public), y: \(mappedPoint.y.asMagnitudeBytes().toHex, privacy: .public)")
CardReaderNFC.logger().info("Mapped point x: \(mappedPoint.x.asMagnitudeBytes().toHex, privacy: .public), y: \(mappedPoint.y.asMagnitudeBytes().toHex, privacy: .public)")
// swiftlint:enable line_length
let mappedDomain = try Domain.instance(
name: domain.name + " Mapped",
Expand All @@ -153,17 +153,17 @@ class CardReaderNFC: CardReader, Loggable {
)],
tagExpected: 0x84
)
CardReaderNFC.logger().debug("Card Ephermal key \(ephemeralKey.value.toHex)")
CardReaderNFC.logger().info("Card Ephermal key \(ephemeralKey.value.toHex)")
guard let ephemeralCardPubKey = try ECPublicKey(domain: mappedDomain, point: ephemeralKey.value)
else { throw IdCardInternalError.authenticationFailed }

// Derive shared secret and session keys
let sharedSecret = try terminalEphemeralPrivKey.sharedSecret(pubKey: ephemeralCardPubKey)
CardReaderNFC.logger().debug("Shared secret \(sharedSecret.toHex)")
CardReaderNFC.logger().info("Shared secret \(sharedSecret.toHex)")
ksEnc = CardReaderNFC.KDF(key: sharedSecret, counter: 1)
ksMac = CardReaderNFC.KDF(key: sharedSecret, counter: 2)
CardReaderNFC.logger().debug("KS.Enc \(self.ksEnc.toHex)")
CardReaderNFC.logger().debug("KS.Mac \(self.ksMac.toHex)")
CardReaderNFC.logger().info("KS.Enc \(self.ksEnc.toHex)")
CardReaderNFC.logger().info("KS.Mac \(self.ksMac.toHex)")

// Mutual authentication
let macCalc = try AES.CMAC(key: ksMac)
Expand All @@ -183,7 +183,7 @@ class CardReaderNFC: CardReader, Loggable {
)],
tagExpected: 0x86
)
CardReaderNFC.logger().debug("Mac response \(macValue.data.toHex)")
CardReaderNFC.logger().info("Mac response \(macValue.data.toHex)")

// verify chip's MAC
let macResult = TLV(tag: 0x7f49, records: [
Expand Down Expand Up @@ -229,14 +229,14 @@ class CardReaderNFC: CardReader, Loggable {
case 0x87: tlvEnc = tlv
case 0x99: tlvRes = tlv
case 0x8E: tlvMac = tlv
default: CardReaderNFC.logger().debug("Unknown tag")
default: CardReaderNFC.logger().info("Unknown tag")
}
}
return (tlvEnc, tlvRes, tlvMac)
}

func transmit(_ apduData: Bytes) async throws -> (responseData: Bytes, sw: UInt16) {
CardReaderNFC.logger().debug("Plain >: \(apduData.toHex)")
CardReaderNFC.logger().info("Plain >: \(apduData.toHex)")
guard let apdu = NFCISO7816APDU(data: Data(apduData)) else {
throw IdCardInternalError.invalidAPDU
}
Expand Down Expand Up @@ -269,12 +269,12 @@ class CardReaderNFC: CardReader, Loggable {
throw IdCardInternalError.invalidMACValue
}
guard let tlvEnc else {
CardReaderNFC.logger().debug("Plain <: \(tlvRes.value.toHex)")
CardReaderNFC.logger().info("Plain <: \(tlvRes.value.toHex)")
return (.init(), UInt16(tlvRes.value[0], tlvRes.value[1]))
}
let ivValue = try AES.CBC(key: ksEnc).encrypt(SSC)
let responseData = try (try AES.CBC(key: ksEnc, ivVal: ivValue).decrypt(tlvEnc.value[1...])).removePadding()
CardReaderNFC.logger().debug("Plain <: \(responseData.toHex) \(tlvRes.value.toHex)")
CardReaderNFC.logger().info("Plain <: \(responseData.toHex) \(tlvRes.value.toHex)")
return (Bytes(responseData), UInt16(tlvRes.value[0], tlvRes.value[1]))
}

Expand Down
Loading