Remove useless try to fix warnings (#412)

`getKeyPrimitives` is marked as throws but is not actually throwing
errors and this is yielding warnings. This fixes the warnings.

### Checklist
- [x] I've run tests to see all new and existing tests pass
- [x] I've followed the code style of the rest of the project
- [x] I've read the [Contribution Guidelines](CONTRIBUTING.md)
- [x] I've updated the documentation if necessary

#### If you've made changes to `gyb` files
- [N/A] I've run `./scripts/generate_boilerplate_files_with_gyb.sh` and
included updated generated files in a commit of this pull request

### Motivation:

Currently there's a warning
```
/swift-crypto/Sources/_CryptoExtras/RSA/RSA_boring.swift:67:9: warning: no calls to throwing functions occur within 'try' expression
```
because we're using `try` on a non throwing function. This escalates to
all of the functions that use it.
I'm not sure if removing `throws` from a non-actually-throwing public
function is breaking, as using `try` on a non throwing function only
yields a warning (if not in warnings-as-errors mode) but it actively is
a signature change so it might still be breaking. In case we don't want
to merge this as is, the warning can be removed by simply removing
useless `try`s and we can wait for the next major version to remove the
false-throwers.

### Modifications:

Remove the useless `try` and `throws` where they're not needed.

### Result:

The warning is gone.
This commit is contained in:
Paul Toffoloni authored and GitHub committed 2025-09-22 11:02:42 +00:00
1 parent b1f7679f29
commit 527fef6228
3 files changed
+5 -5

No files matched your search

@@ -132,7 +132,7 @@ extension _RSA.BlindSigning {
}
public func getKeyPrimitives() throws -> Primitives {
let (n, e) = try self.backing.getKeyPrimitives()
let (n, e) = self.backing.getKeyPrimitives()
return Primitives(modulus: n, publicExponent: e)
}
}
+2 -2
View File
@@ -142,7 +142,7 @@ extension _RSA.Signing {
}
public func getKeyPrimitives() throws -> Primitives {
let (n, e) = try self.backing.getKeyPrimitives()
let (n, e) = self.backing.getKeyPrimitives()
return Primitives(modulus: n, publicExponent: e)
}
}
@@ -539,7 +539,7 @@ extension _RSA.Encryption {
fileprivate init(_ backing: BackingPublicKey) { self.backing = backing }
public func getKeyPrimitives() throws -> Primitives {
let (n, e) = try self.backing.getKeyPrimitives()
let (n, e) = self.backing.getKeyPrimitives()
return Primitives(modulus: n, publicExponent: e)
}
}
+2 -2
View File
@@ -63,8 +63,8 @@ internal struct BoringSSLRSAPublicKey: Sendable {
self.backing = backing
}
func getKeyPrimitives() throws -> (n: Data, e: Data) {
try self.backing.getKeyPrimitives()
func getKeyPrimitives() -> (n: Data, e: Data) {
self.backing.getKeyPrimitives()
}
}