Skip to content

Simple ASN1 utils for DSA based on PACKET#9111

Closed
mattcaswell wants to merge 5 commits intoopenssl:masterfrom
mattcaswell:simple-asn1-utils
Closed

Simple ASN1 utils for DSA based on PACKET#9111
mattcaswell wants to merge 5 commits intoopenssl:masterfrom
mattcaswell:simple-asn1-utils

Conversation

@mattcaswell
Copy link
Member

This is based on the PR by @davidmakepeace in #9067. It uses all the same commits as there, but then adds some additional ones to convert the code to use the PACKET API instead.

This is WIP because I have not yet tackled WPACKET. I ran out of time today. Hopefully it is enough for now to get a feel for what it would look like. I'll work on WPACKET next week.

@mattcaswell
Copy link
Member Author

Note: the interesting changes are in the asn1_dsa.c file in the decode* functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

that last clause looks strange. perhaps a comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, it looked strange because it wasn't quite right. Fixed...and I actually ended up removing this whole function anyway.

@paulidale
Copy link
Contributor

I'd like to see the encode side, this is where WPACKET doesn't match up with ASN.1 so nicely.

Would a fuller ropes implementation be worthwhile? With the variable length representation of ASN.1, it might be reasonable.

In my ideal world, ASN.1 decoding would be done using a grammar and a generated parser.

@richsalz
Copy link
Contributor

richsalz commented Jun 8, 2019

I agree the encode side is the harder part, particularly for nested structures, as opposed to a simple sequence. Do we know what ASN1 we will have to have in the FIPS module? I am against a fuller ropes implementation until we know it's needed. You can always allocate the max space, keep a stack, and backpatch and squeeze up for example.

@levitte
Copy link
Member

levitte commented Jun 8, 2019

particularly for nested structures, as opposed to a simple sequence.

... although, if DSA sigs are the only use case, maybe there's not much to worry about...
(at some point, someone will have to decide whether we're just going to do the simplest thing for what we see right this moment, or if we're going to make something a bit more feature complete)

@richsalz
Copy link
Contributor

richsalz commented Jun 8, 2019

@mattcaswell
Copy link
Member Author

I updated this to use the WPACKET API as well. As part of that I gave WPACKET the ability to write to a NULL buffer so the number of bytes required can be calculated before later initialising the buffer.

@mattcaswell
Copy link
Member Author

Update pushed addressing the comment rewording suggestion.

@mattcaswell mattcaswell changed the title WIP: Simple ASN1 utils for DSA based on PACKET Simple ASN1 utils for DSA based on PACKET Jun 11, 2019
@mattcaswell
Copy link
Member Author

Taken this out of "WIP"

Copy link
Member

Choose a reason for hiding this comment

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

"Results in... " rather than "Returns"

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

davidmakepeace and others added 5 commits July 1, 2019 10:43
Adds simple utility functions to allow both the default and fips providers to
encode and decode DSA-Sig-Value and ECDSA-Sig-Value (DSA_SIG and ECDSA_SIG
structures) to/from ASN.1 DER without requiring those providers to have a
dependency on the asn1 module.
This means the WPACKET API can be used for calculating the number of
bytes that would have been written if a non-NULL buffer had been used.
This enables us to calculate the number of length bytes required when
encoding ASN.1
@mattcaswell
Copy link
Member Author

Rebased to resolve a conflict with master.

Ping?

@paulidale
Copy link
Contributor

I'm okay to approve both this and #9067. Has a decision been made as to which is preferred?

@mattcaswell
Copy link
Member Author

Has a decision been made as to which is preferred?

Well no decision has been made as such. My own view is I strongly prefer the PACKET/WPACKET approach. Outside of that there hasn't been much discussion. My -1 on #9067 still stands. No one so far has seen fit to take that one to a vote. If an OMC member wants to take that to a vote then I'd be happy to take the debate to the OMC. Otherwise, I'd be happy to take an approval of this forward without a vote.

@richsalz
Copy link
Contributor

richsalz commented Jul 2, 2019

My -1 on #9067

I think it's wrong to block a PR without being willing to call a vote.

@paulidale paulidale added the branch: master Applies to master branch label Jul 15, 2019
@paulidale
Copy link
Contributor

Merged to master after removing end of line trailing space.

@paulidale paulidale closed this Jul 15, 2019
levitte pushed a commit that referenced this pull request Jul 15, 2019
Adds simple utility functions to allow both the default and fips providers to
encode and decode DSA-Sig-Value and ECDSA-Sig-Value (DSA_SIG and ECDSA_SIG
structures) to/from ASN.1 DER without requiring those providers to have a
dependency on the asn1 module.

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #9111)
levitte pushed a commit that referenced this pull request Jul 15, 2019
levitte pushed a commit that referenced this pull request Jul 15, 2019
levitte pushed a commit that referenced this pull request Jul 15, 2019
This means the WPACKET API can be used for calculating the number of
bytes that would have been written if a non-NULL buffer had been used.
This enables us to calculate the number of length bytes required when
encoding ASN.1

Reviewed-by: Paul Dale <[email protected]>
(Merged from #9111)
levitte pushed a commit that referenced this pull request Jul 15, 2019
levitte pushed a commit that referenced this pull request Jul 15, 2019
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #9111)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants