Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Commit

Permalink
throw error when attempting to rsa sign w/ public key (segfault previ…
Browse files Browse the repository at this point in the history
…ously)
  • Loading branch information
tanner0101 committed Feb 28, 2018
1 parent f510082 commit e5dbff5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/Crypto/RSA/OpenSSLRSA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ extension RSAHashAlgorithm {

struct OpenSSLRSA {
static func sign(_ input: Data, for rsa: RSA) throws -> Data {
switch rsa.key.type {
case .public: throw RSAError(identifier: "sign", reason: "Cannot create RSA signature with a public key. A private key is required.")
case .private: break
}

let key = try rsa.key.makeOpenSSLKey()

var siglen: UInt32 = 0
Expand Down

0 comments on commit e5dbff5

Please # to comment.