Skip to content

Modifications to PR #262 made during review. - #344

Closed
briansmith wants to merge 0 commit into
masterfrom
padding
Closed

briansmith wants to merge 0 commit into
masterfrom
padding

Conversation

@briansmith

Copy link
Copy Markdown
Owner

@samscott89 Could you please take a look at these changes I am proposing for your PR?

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

:sigh: All of these changes are just supposed to be un-indenting and re-wrapping the code.

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ditto. I'll verify that I didn't actually change the code in any significant way other than reformatting it.

@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 1fa60373cab9636811ee4fffffc52228712ef211 on padding into * on master*.

@samscott89 samscott89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look great. Left a few minor formatting comments. Other than that I think the only thing to be addressed is the lack of PSS padding tests.

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This condition fits fine on one line.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I've now split it into two conditions so that the code coverage can see whether we're testing both checks.

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space missing from start of the line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(Next line would need an additional space as well)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also fits in one 80-char line now.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: why assert over debug_assert or returning an error?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I changed it to a debug_assert!.

Comment thread src/rsa/padding.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you've added iter in untrusted 0.3.2, is it worth updating this code to use that instead, similarly to how you've written the equivalent code in encode?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yes, that's exactly what I want to happen.

Comment thread src/rsa/signing.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Spaces around the operator: mod_len * 8?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread src/rsa/rsa.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As you commented in the other thread, PUBLIC_MODULUS_MAX_BITS is a better name for this.

Comment thread src/rsa/pss_verify_tests.txt Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Outstanding tasks for this file:

  • Rename to rsa_pss_verify_padding_tests.txt.
  • Add failing cases.
  • Cover more digest types.

Would it be simpler to add these cases to the existing rsa_pss_verify_tests.txt file instead? The only reason I could see that these should have independent tests is if the padding functions were made public.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can make a start on adding failing cases.

Comment thread src/rsa/verification.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the closing bracket be on the line below, at the same indentation level as line 127?

Comment thread third-party/NIST/README.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These lines can be deleted since we not longer store the NIST tests here.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed.

@briansmith

Copy link
Copy Markdown
Owner Author

@samscott89 Please check out the new commits I appended to this series to address your concerns. Let me know if you want me to squash them into the prior commits before or after you review them.

Pay special attention to the change I made to the PSS encoding, passing in the actual bit length of the public modulus instead of 8 * mod_len. I think this was another bug, triggered by me saying that we only needed to support moduli that are even multiples of 8 for signing.

Also, do you want to take over the remaining tasks? I definitely don't want to steal this from you.

@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 5f139ea on padding into * on master*.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 5f139ea on padding into * on master*.

Comment thread src/bits.rs
use error;

#[derive(Clone, Copy, Eq, PartialEq)]
pub struct BitLength {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be called just Length since it will presumably always be used as bits::Length vs bits::BitLength?

Also, is this not practically the canonical example for using newtypes?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I agree it's weird to have bits::BitLength but I also think bits::Length or bit::Length is too clever. I found out that these names that only make sense with module prefixes don't work well in rustdoc (see error::Unspecified which rustdoc presents as just Unspecified, which is confusing).

I think we probably should create a "prelude" of common types that are used internally in ring and use those types (only) unprefixed. I think BitLength is a prime candidate for that.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Regarding newtypes, see #350. The problem is that we have to constructors: from bits, and from bytes. A newtype would make the from-bits constructor implicit, but I'd rather have the constructors be used explicitly. However, we may want to switch to newtype style if it helps work around the lack of const fn.

@samscott89

Copy link
Copy Markdown
Contributor

Yup, all looks good to me. The BitLength additional particularly seems like a good idea project-wide. Would it make sense to (in a separate PR) try and type all lengths? So that there is ByteLength(usize) and BitLength(usize) or something? Or is it okay to assume that all non-BitLength lengths are in bytes?

Also, do you want to take over the remaining tasks? I definitely don't want to steal this from you.

I'm more than happy to, and allow you to move onto something else. I think you've given me enough help at this point for me to get it across the finish line. I'm not worried about it being 'stolen' from me though, I'm just looking to learn/help as much as I can.

If you could squash it down to a reasonable number of commits (perhaps original commit + review or something?), that would be great. I'll then pull the padding branch and continue in the original PR.

@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 5f139ea on padding into * on master*.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 5f139ea on padding into * on master*.

@briansmith

Copy link
Copy Markdown
Owner Author

Yup, all looks good to me. The BitLength additional particularly seems like a good idea project-wide.

I filed #350 for this.

Would it make sense to (in a separate PR) try and type all lengths? So that there is ByteLength(usize) and BitLength(usize) or something? Or is it okay to assume that all non-BitLength lengths are in bytes?

I think we should just assume all non-BitLength lengths are in bytes. Otherwise we'd have to move ByteLength (at least) to untrusted.

Also, do you want to take over the remaining tasks? I definitely don't want to steal this from you.
I'm more than happy to, and allow you to move onto something else. I think you've given me enough help at this point for me to get it across the finish line. I'm not worried about it being 'stolen' from me though, I'm just looking to learn/help as much as I can.

If you could squash it down to a reasonable number of commits (perhaps original commit + review or something?), that would be great. I'll then pull the padding branch and continue in the original PR.

Will do.

@briansmith

Copy link
Copy Markdown
Owner Author

I squashed and landed all these changes onto master. See discussion in #262.

@briansmith
briansmith deleted the padding branch November 15, 2016 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants