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

WIP: Add RSAES-OAEP support #95

Merged
12 commits merged into from
Feb 10, 2019
Next Next commit
Add RSAES_OAEP type to AsymmetricKeyAlgorithm
  • Loading branch information
Alexandre Garrefa committed Jul 18, 2018
commit 78c87543d526776e2c8fc1c18888f61caa2b8e9b
2 changes: 2 additions & 0 deletions JOSESwift/Sources/Algorithms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public enum SignatureAlgorithm: String {
/// An algorithm for asymmetric encryption and decryption.
///
/// - RSA1_5: [RSAES-PKCS1-v1_5](https://tools.ietf.org/html/rfc7518#section-4.2)
/// - RSAES-OAEP: [RSAES-OAEP](https://tools.ietf.org/html/rfc7518#section-4.3)
public enum AsymmetricKeyAlgorithm: String {
case RSA1_5 = "RSA1_5"
case RSAES_OAEP = "RSAES-OAEP"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little picky but, I think we should name it like in the JWA rfc, as the underscore in RSA1_5 is only because the algorithm parameter is named like this.

Copy link
Contributor Author

@garrefa garrefa Jul 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum... in this case whats your suggestion for the name? The RFC uses RSAES-OAEP or RSAES OAEP, both are not possible in swift enums. RSAESOAEP? just OAEP?

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 🤦‍♂️ forgot about that. Looking at the SymmetricKeyAlgorithm, A256CBC-HS512 is written as A256CBCHS512, so RSAESOAEP it is.

Copy link

@ghost ghost Jul 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right @garrefa 🙂 - is not possible in Swift enums.

Guys, the "alg" parameter value is RSA-OAEP not RSAES-OAEP according to the RFC. What do you think of RSA_OAEP of RSAOAEP?

@garrefa If you have any suggestion for a more consistent naming scheme, we'd be happy to adopt it. 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would go for RSAOAEP 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link

@lkomorowski lkomorowski Sep 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello guys. I think it's amazing that you decided to fill the gap and create this library. It is super useful for newbies in cartography like me.

I just want to let you know @garrefa that I did some testing of this branch and it seems that JwtSecurityTokenHandler class from .NET framework is not able to decode tokens with "alg": "RSAES-OAEP" parameter in the header, yet it works fine with RSA-OAEP version. I think that it may be connected with @daniel-mohemian's suggestion that according to RFC standard this param should has value RSA-OAEP.

}

/// An algorithm for symmetric encryption and decryption.
Expand Down