mirror of
https://github.com/laosb/swift-minisign.git
synced 2025-05-17 09:21:08 +00:00
Compare commits
No commits in common. "main" and "0.1.1" have entirely different histories.
4 changed files with 13 additions and 14 deletions
|
@ -8,8 +8,9 @@ let package = Package(
|
|||
platforms: [
|
||||
.macOS(.v10_15),
|
||||
.iOS(.v13),
|
||||
.watchOS(.v6),
|
||||
.visionOS(.v1),
|
||||
.tvOS(.v13),
|
||||
.watchOS(.v6)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, making them visible to other packages.
|
||||
|
@ -27,7 +28,7 @@ let package = Package(
|
|||
.default(enabledTraits: ["UseSwiftCrypto"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-crypto", "1.0.0" ..< "4.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-crypto", from: "2.0.0"),
|
||||
.package(url: "https://github.com/lovetodream/swift-blake2", from: "0.1.0")
|
||||
],
|
||||
targets: [
|
||||
|
@ -44,6 +45,5 @@ let package = Package(
|
|||
name: "MinisignTests",
|
||||
dependencies: ["Minisign"]
|
||||
),
|
||||
],
|
||||
swiftLanguageModes: [.v6]
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// swift-tools-version: 5.9
|
||||
// swift-tools-version: 5.8
|
||||
|
||||
import PackageDescription
|
||||
|
||||
|
@ -7,8 +7,9 @@ let package = Package(
|
|||
platforms: [
|
||||
.macOS(.v10_15),
|
||||
.iOS(.v13),
|
||||
.watchOS(.v6),
|
||||
.visionOS(.v1),
|
||||
.tvOS(.v13),
|
||||
.watchOS(.v6),
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, making them visible to other packages.
|
||||
|
@ -18,7 +19,7 @@ let package = Package(
|
|||
)
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-crypto", "1.0.0" ..< "4.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-crypto", from: "2.0.0"),
|
||||
.package(url: "https://github.com/lovetodream/swift-blake2", from: "0.1.0"),
|
||||
],
|
||||
targets: [
|
||||
|
@ -39,5 +40,5 @@ let package = Package(
|
|||
dependencies: ["Minisign"]
|
||||
),
|
||||
],
|
||||
swiftLanguageVersions: [.version("6"), .v5]
|
||||
swiftLanguageModes: [.version("6"), .v5],
|
||||
)
|
|
@ -1,8 +1,5 @@
|
|||
# Swift Minisign
|
||||
|
||||
[](https://swiftpackageindex.com/laosb/swift-minisign)
|
||||
[](https://swiftpackageindex.com/laosb/swift-minisign)
|
||||
|
||||
Swift implementation of Minisign, a simple and secure tool for signing and verifying files.
|
||||
|
||||
This is a fork of [slarew/swift-minisign](https://github.com/slarew/swift-minisign), with these improvements:
|
||||
|
|
|
@ -6,9 +6,9 @@ import BLAKE2
|
|||
import Foundation
|
||||
|
||||
#if UseSwiftCrypto
|
||||
@preconcurrency import Crypto
|
||||
import Crypto
|
||||
#else
|
||||
@preconcurrency import CryptoKit
|
||||
import CryptoKit
|
||||
#endif
|
||||
|
||||
public enum SignatureAlgorithm: Sendable, RawRepresentable {
|
||||
|
@ -87,12 +87,13 @@ 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, bufferSize: Int = 8192) throws -> Bool {
|
||||
public func isValidSignature(_ signature: Signature, forFileAt url: URL) 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 }
|
||||
|
|
Loading…
Add table
Reference in a new issue