-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add support for pkcs1 oaep sha256 #206
Conversation
fb3b750
to
015421c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some notes, please also update RSA_security.swift.
Sources/_CryptoExtras/RSA/RSA.swift
Outdated
case sha384 | ||
case sha512 | ||
case sha512_256 | ||
case blake2b256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excessive, let's just have only the digests we actually support.
@@ -36,8 +36,13 @@ final class TestRSAEncryption: XCTestCase { | |||
|
|||
let derPubKey = derPrivKey.publicKey | |||
|
|||
guard group.sha == "SHA-1", group.mgfSha == "SHA-1" else { | |||
// We currently only support SHA-1 OAEP, which is very legacy but oh well. | |||
let padding: _RSA.Encryption.Padding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a new set of test vectors: https://github.com/google/wycheproof/blob/master/testvectors/rsa_oaep_2048_sha256_mgf1sha256_test.json
Motivation Add RSA OAEP-sha256 support in addition to the increasingly aged SHA-1 implementation. Modifications * Add a `Digest` enum to `_RSA.Encryption.Padding` * Add a digest associated type to the `.pkcs1_oaep` padding enum case to allow us to distinguish different digest hash functions. * Add a `PKCS1_OAEP_SHA256` public static let to allow users to use the new hash function. * Enable SHA-256 RSA encryption tests Result * Support for RSA OAEP-sha256
3ed779c
to
0974a60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, hang-on: we need a Security.framework equivalent.
4f7fd18
to
3966fa4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @rnro, thanks!
Add support for pkcs1 oaep sha256
Motivation
Add RSA OAEP-sha256 support in addition to the increasingly aged SHA-1
implementation.
Modifications
Digest
enum to_RSA.Encryption.Padding
.pkcs1_oaep
padding enum caseto allow us to distinguish different digest hash functions.
PKCS1_OAEP_SHA256
public static let to allow users to use thenew hash function.
Result
NOTE: This change sticks with the BoringSSL default behaviour and the case which uses the new SHA-256 digest hash function also uses SHA-256 as its mask generation function.