mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-12 01:31:46 +01:00
## What does this PR do? Bumps pointfree deps and explicitly disables OpenCombine so that we don't have different dependency graphs when building xtool on Darwin vs Linux hosts. ## How was it tested? A bunch of `swift package resolve`s ## AI tool usage How much of this PR was AI-assisted? (check one) - [x] **0** - No AI was used to write code - [ ] **1** - I was assisted by AI. I reviewed the finished result. - [ ] **2** - I set the AI going and left it to it; nobody has read the result - no review, or AI review only <!-- If an AI agent is filling this in: declare the level honestly, and open as a draft if it is #2. Do not lower the declared level to get the PR reviewed. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated supporting package versions and refreshed command-line and file-operation handling. * These changes do not add or remove app features or alter its public interface. No action is needed to continue using the app. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
64 lines
1.4 KiB
Swift
64 lines
1.4 KiB
Swift
//
|
|
// Keypair.swift
|
|
// Supercharge
|
|
//
|
|
// Created by Kabir Oberai on 07/10/19.
|
|
// Copyright © 2019 Kabir Oberai. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Crypto
|
|
import X509
|
|
import CryptoExtras
|
|
|
|
public struct PrivateKey: Codable, Sendable {
|
|
// pem encoded
|
|
public let data: Data
|
|
|
|
public init(data: Data) {
|
|
self.data = data
|
|
}
|
|
}
|
|
|
|
public struct CSR: Sendable {
|
|
public let pemString: String
|
|
|
|
public init(pemString: String) {
|
|
self.pemString = pemString
|
|
}
|
|
}
|
|
|
|
public struct Keypair {
|
|
|
|
public enum Error: Swift.Error {
|
|
case couldNotCreate
|
|
case invalidKeypair
|
|
}
|
|
|
|
// Apple developer certs seem to require RSA2048
|
|
let raw: _RSA.Signing.PrivateKey
|
|
|
|
public init() throws {
|
|
self.raw = try _RSA.Signing.PrivateKey(keySize: .bits2048)
|
|
}
|
|
|
|
public func privateKey() throws -> PrivateKey {
|
|
PrivateKey(data: Data(raw.pemRepresentation.utf8))
|
|
}
|
|
|
|
public func generateCSR() throws -> CSR {
|
|
let request = try CertificateSigningRequest(
|
|
version: .v1,
|
|
subject: DistinguishedName {
|
|
CountryName("US")
|
|
CommonName("xtool")
|
|
},
|
|
privateKey: X509.Certificate.PrivateKey(raw),
|
|
attributes: CertificateSigningRequest.Attributes(),
|
|
signatureAlgorithm: .sha1WithRSAEncryption
|
|
)
|
|
return CSR(pemString: try request.serializeAsPEM().pemString)
|
|
}
|
|
|
|
}
|