Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused Signing.loadPublicKey(with:) #2714

Merged
merged 1 commit into from
Jun 27, 2023
Merged
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
10 changes: 0 additions & 10 deletions Sources/Logging/Strings/ConfigureStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ enum ConfigureStrings {

case public_key_could_not_be_found(fileName: String)

case public_key_is_empty

case public_key_could_not_load_key

case custom_entitlements_computation_enabled

case custom_entitlements_computation_enabled_but_no_app_user_id
Expand Down Expand Up @@ -164,12 +160,6 @@ extension ConfigureStrings: LogMessage {
case let .public_key_could_not_be_found(fileName):
return "Could not find public key '\(fileName)'"

case .public_key_is_empty:
return "Attempted to load an empty public key."

case .public_key_could_not_load_key:
return "Failed to load public key. Ensure that it's a valid ed25519 key."

case .custom_entitlements_computation_enabled:
return "Entering customEntitlementComputation mode. CustomerInfo cache will not be " +
"automatically fetched. Anonymous user IDs will be disallowed, logOut will be disabled, " +
Expand Down
22 changes: 0 additions & 22 deletions Sources/Security/Signing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,6 @@ extension CryptoKit.Curve25519.Signing.PublicKey: SigningPublicKey {}

// MARK: - Internal implementation (visible for tests)

extension Signing {

/// Parses the binary `key` and returns a `PublicKey`
/// - Throws: ``ErrorCode/configurationError`` if the certificate couldn't be loaded.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *)
static func loadPublicKey(with data: Data) throws -> PublicKey {
guard !data.isEmpty else {
throw ErrorUtils.configurationError(message: Strings.configure.public_key_is_empty.description)
}

do {
return try CryptoKit.Curve25519.Signing.PublicKey(rawRepresentation: data)
} catch {
throw ErrorUtils.configurationError(
message: Strings.configure.public_key_could_not_load_key.description,
underlyingError: error
)
}
}

}

extension Signing.SignatureParameters {

var asData: Data {
Expand Down
11 changes: 0 additions & 11 deletions Tests/UnitTests/Security/SigningTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ class SigningTests: TestCase {
expect(key.rawRepresentation).toNot(beEmpty())
}

func testThrowsErrorIfPublicKeyFileCannotBeParsed() throws {
expect {
try Signing.loadPublicKey(with: .init([1, 2, 3]))
}.to(throwError { error in
expect(error).to(matchError(ErrorCode.configurationError))
expect(error.localizedDescription) == "There is an issue with your configuration. " +
"Check the underlying error for more details. Failed to load public key. " +
"Ensure that it's a valid ed25519 key."
})
}

func testVerifySignatureWithInvalidSignatureReturnsFalseAndLogsError() throws {
let logger = TestLogHandler()

Expand Down