From d2657b54f3770099cef898fb74a90121eb644f70 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Wed, 23 Apr 2025 16:32:47 +0800 Subject: [PATCH] feat: Add configurable buffer size for file signature verification --- Sources/Minisign/Minisign.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Minisign/Minisign.swift b/Sources/Minisign/Minisign.swift index 4093222..bf40538 100644 --- a/Sources/Minisign/Minisign.swift +++ b/Sources/Minisign/Minisign.swift @@ -87,13 +87,12 @@ public struct PublicKey: Sendable { /// /// This method reads the file in chunks to avoid loading the entire file into memory, but does so in a blocking manner. /// It's recommended to use this method in a background thread or task. - public func isValidSignature(_ signature: Signature, forFileAt url: URL) throws -> Bool { + public func isValidSignature(_ signature: Signature, forFileAt url: URL, bufferSize: Int = 8192) throws -> Bool { guard signature.signatureAlgorithm == .hashedEdDSA else { throw SignatureVerifyError.algorithmNotSupportedForFile } var blake2b = try! BLAKE2b() let fileHandle = try FileHandle(forReadingFrom: url) - let bufferSize = 4096 while true { let data = fileHandle.readData(ofLength: bufferSize) if data.isEmpty { break }