Skip to content

Commit

Permalink
Merge pull request #72 from outfoxx/fix/debug-prints
Browse files Browse the repository at this point in the history
Remove debugging prints
  • Loading branch information
kdubb committed Jun 11, 2023
2 parents cb69191 + e52813f commit 55a8a3d
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions Sources/ShieldSecurity/SecKeyPair.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ public struct SecKeyPair {

let encryptedPrivateKeyInfoData = try ASN1Encoder.encode(encryptedPrivateKeyInfo)

printPEM(data: encryptedPrivateKeyInfoData, type: "ENCRYPTED PRIVATE KEY")

return encryptedPrivateKeyInfoData
}

Expand Down Expand Up @@ -522,18 +520,12 @@ private extension SecKey {
privateKeyInfo = try generateECPrivateKeyInfo()
}

let encoded = try ASN1.Encoder.encode(privateKeyInfo)

printPEM(data: encoded, type: "PRIVATE KEY")

return encoded
return try ASN1.Encoder.encode(privateKeyInfo)
}

private func generateRSAPrivateKeyInfo() throws -> PrivateKeyInfo {
let encodedPrivateKey = try encode()

printPEM(data: encodedPrivateKey, type: "RSA PRIVATE KEY")

return PrivateKeyInfo(privateKeyAlgorithm: .init(algorithm: iso.memberBody.us.rsadsi.pkcs.pkcs1.rsaEncryption.oid),
privateKey: encodedPrivateKey)
}
Expand All @@ -557,9 +549,6 @@ private extension SecKey {

let privateKeyData = try ASN1.Encoder.encode(privateKey)

printPEM(data: privateKeyData, type: "EC PRIVATE KEY")


return PrivateKeyInfo(version: .zero,
privateKeyAlgorithm: .init(algorithm: iso.memberBody.us.ansix962.keyType.ecPublicKey.oid,
parameters: ASN1.objectIdentifier(curveOID.fields)),
Expand Down Expand Up @@ -677,11 +666,3 @@ private extension EncryptedPrivateKeyInfo {
encryptedData: encryptedData)
}
}

private func printPEM(data: Data, type: String) {

let base64 = data.base64EncodedString()
let pemBase64 = base64.chunks(ofCount: 64).joined(separator: "\n")

print("-----BEGIN \(type)-----\n\(pemBase64)\n-----END \(type)-----")
}

0 comments on commit 55a8a3d

Please sign in to comment.