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

rsa #83

merged 4 commits into from Feb 28, 2018


1 participant
Copy link

tanner0101 commented Feb 28, 2018

  • adds RS256, RS384, and RS512 signature support to JWT
// create public and private key (only public required for verification)
let privateKey: Data = ...
let publicKey: Data = ...
let privateSigner = JWTSigner.rs256(key: .private2048(privateKey))
let publicSigner = JWTSigner.rs256(key: .public2048(publicKey))

// serialize jwt (requires private key)
let payload: TestPayload = ...
var jwt = JWT(payload: payload)
_ = try jwt.sign(using: publicSigner) // throws, can't sign w/ public signer
let data = try jwt.sign(using: privateSigner)

// parse jwt (public and private key work)
let parsed = try JWT<TestPayload>(from: data, verifiedUsing: publicSigner)
let parsed2 = try JWT<TestPayload>(from: data, verifiedUsing: privateSigner) // also works

Fixes #81


@tanner0101 tanner0101 added this to the 3.0.0-rc.1 milestone Feb 28, 2018

@tanner0101 tanner0101 self-assigned this Feb 28, 2018

tanner0101 added some commits Feb 28, 2018

@tanner0101 tanner0101 merged commit 33a088a into beta Feb 28, 2018

1 check passed

ci/circleci: linux Your tests passed on CircleCI!

@tanner0101 tanner0101 deleted the rsa branch Feb 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment