Skip to content

Commit 132f5b2

Browse files
authored
Merge pull request #1060 from beatt83/fix/rsa_private_key
fix: externalRepresentation condition to validate if key is private should be d not prime
2 parents f03fd66 + 8bcf97a commit 132f5b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/CryptoSwift/RSA/RSA.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public final class RSA: DERCodable {
6161
public let keySizeBytes: Int
6262

6363
/// The underlying primes used to generate the Private Exponent
64-
private let primes: (p: BigUInteger, q: BigUInteger)?
64+
public let primes: (p: BigUInteger, q: BigUInteger)?
6565

6666
/// Initialize with RSA parameters
6767
/// - Parameters:
@@ -388,7 +388,7 @@ extension RSA {
388388
/// ```
389389
///
390390
public func externalRepresentation() throws -> Data {
391-
if self.primes != nil {
391+
if self.d != nil {
392392
return try Data(self.privateKeyDER())
393393
} else {
394394
return try Data(self.publicKeyDER())

0 commit comments

Comments
 (0)