Skip to content

Conversation

@CXuesong
Copy link
Contributor

Summary

padding used in RSACng.Encrypt accepts a RSAEncryptionPadding instance, but exception description for CryptographicException used link to RSASignaturePadding. RSACng.Encrypt from RefSrc makes me thinking this exception description should be the same as the one from RSACng.Decrypt.

@mairaw mairaw added this to the July 2019 milestone Jul 28, 2019
mairaw
mairaw previously requested changes Jul 28, 2019
Copy link
Contributor

@mairaw mairaw left a comment

Choose a reason for hiding this comment

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

Thank you for noticing and fixing the exception issue @CXuesong. I left a suggestion for you to consider before we merge this.

<paramref name="padding" /> is <see langword="null" />.</exception>
<exception cref="T:System.Security.Cryptography.CryptographicException">
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSASignaturePadding.Pkcs1" /> or <see cref="P:System.Security.Cryptography.RSASignaturePadding.Pss" />.</exception>
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception>
Copy link
Contributor

@mairaw mairaw Jul 28, 2019

Choose a reason for hiding this comment

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

Suggested change
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception>
<paramref name="padding" />.<see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> isn't equal to <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" /> or <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception>

Copy link
Member

Choose a reason for hiding this comment

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

I think that's the wrong "or", Maira. The exception is thrown if the padding mode isn't (pkcs1 or oaep), the only two supported modes. I read the "-or-" version as it throws always (throws if != pkcs1, and throws if != oaep... nothing is both, so throws always)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have copied this statement from the same documentation from the Decrypt method, and I think that one should work.

<returns>The decrypted data.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="data" /> is <see langword="null" />.
-or-
<paramref name="padding" /> is <see langword="null" />.</exception>
<exception cref="T:System.Security.Cryptography.CryptographicException">
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception>
</Docs>

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I'll reword my suggestion. If both conditions should be met, I think we should use and then. Perhaps we might also need to review the Decrypt exception condition @CXuesong.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bartonjs can you review my suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

<paramref name="padding" />.<see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> isn't equal to <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" /> or <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception> looks reasonable to me.

Except that P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1 should probably be F:System.Security.Cryptography.RSAEncryptionPaddingMode.Pkcs1

@mairaw mairaw added the ✨ 1st-time dotnet-api-docs contributor! Indicates PRs from new contributors to the dotnet-api-docs repository label Jul 28, 2019
@carlossanlop
Copy link
Contributor

@bartonjs is actively documenting these files too. Mentioning him here so he takes a look before merging, @mairaw.

@CXuesong
Copy link
Contributor Author

CXuesong commented Aug 8, 2019

Is there any change I need to make before this PR can be accepted? After looking at @mairaw 's & @bartonjs 's comments, I think I may keep current version without changing into "-- or --" version.

@mairaw
Copy link
Contributor

mairaw commented Aug 8, 2019

Checking latest comments now...

@mairaw mairaw added the waiting-on-feedback Indicates PRs that are waiting for feedback from SMEs before they can be merged label Aug 8, 2019
@CXuesong
Copy link
Contributor Author

CXuesong commented Aug 9, 2019

Done modification. In this case, may I also change the exception description in RSACng.Decrypt to keep them consistent?

<exception cref="T:System.Security.Cryptography.CryptographicException">
<paramref name="padding" /> does not equal <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Pkcs1" />, or else the <see cref="P:System.Security.Cryptography.RSAEncryptionPadding.Mode" /> of <paramref name="padding" /> does not equal <see cref="F:System.Security.Cryptography.RSAEncryptionPaddingMode.Oaep" />.</exception>
</Docs>

@carlossanlop
Copy link
Contributor

@CXuesong would you mind rebasing your branch to the latest content in master? @bartonjs has been adding a lot of improvements to the Cryptography API documentation.

@bartonjs would you mind answering @CXuesong 's question?

@bartonjs
Copy link
Member

Well, my update of RSA (including this file) is currently in PR, so rebasing should be put off a tiny bit (if I have to make another round of updates I can just take this into mine).

And, yeah, making Decrypt match Encrypt seems good 😄

@bartonjs
Copy link
Member

My updates to the RSA classes went in, so rebasing this and incorporating the change for Decrypt are now actionable.

@BillWagner
Copy link
Member

ping @carlossanlop @bartonjs

Can one of you help me get the correct status of this one? What is the next action?

@BillWagner BillWagner modified the milestones: July 2019, March 2020 Mar 2, 2020
@mairaw mairaw dismissed their stale review March 2, 2020 23:59

stale review

@carlossanlop carlossanlop merged commit 9a9a22f into dotnet:master Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ 1st-time dotnet-api-docs contributor! Indicates PRs from new contributors to the dotnet-api-docs repository waiting-on-feedback Indicates PRs that are waiting for feedback from SMEs before they can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants