Skip to content

Deprecate public use of the RAND_DRBG_USED_FLAGS define#7190

Closed
mspncp wants to merge 2 commits intoopenssl:masterfrom
mspncp:pr-deprecate-rand-drbg-used-flags
Closed

Deprecate public use of the RAND_DRBG_USED_FLAGS define#7190
mspncp wants to merge 2 commits intoopenssl:masterfrom
mspncp:pr-deprecate-rand-drbg-used-flags

Conversation

@mspncp
Copy link
Contributor

@mspncp mspncp commented Sep 11, 2018

The new DRBG API added the aforementioned define. However, it
is used internally only and having it defined publicly does not
serve any purpose except causing potential version compatibilty
problems.

@mspncp mspncp added branch: master Applies to master branch branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) labels Sep 11, 2018
@mspncp
Copy link
Contributor Author

mspncp commented Sep 11, 2018

Should I add Fixes #7182 or should this wait until the define is removed?

Copy link
Contributor

@paulidale paulidale Sep 11, 2018

Choose a reason for hiding this comment

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

Would it make more sense to wrapper this and the define above with an deprecated #ifdef?

Copy link
Contributor

Choose a reason for hiding this comment

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

Scratch the prior define. It is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, how do you mean that? The flag is used internally and that will not change. Only the define will be moved from the public header into a private one or to drbg_lib.c, see #7182 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, one could deprecate it and use a slightly renamed constant internally, as @mattcaswell suggested in #7182 (comment). But is it worth the effort?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd favour the final approach -- leave the current define there with its current value but wrapped:

#if OPENSSL_API_COMPAT < 0x10200000L
# define RAND_DRBG_USED_FLAGS  (RAND_DRBG_FLAG_CTR_NO_DF)
#endif

Then add a new define to an internal header file that takes over the duties of the one. RAND_DRBG_ALL_FLAGS?

We can't deprecate something in a header by leaving it there. If we need it internally and we want to deprecate it, it should move to an internal header file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, convinced. I'll do it and use your name suggestion. But it's too late in the night now for me to scratch my head whether the internal define should go into drbg_lib.c only or into an internal header...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm happy to grab this one and run with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd go for drbg_lib.c since it isn't used anywhere else.
It also doesn't need to be a #define. const unsigned int?
The name could then be kept but in lower case.

@mspncp mspncp force-pushed the pr-deprecate-rand-drbg-used-flags branch from 372cb69 to a09ddda Compare September 12, 2018 05:55
@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

Reworked the pr following @paulidale's suggestions. Squashed the fixups, since it's a small pr.

@mspncp mspncp force-pushed the pr-deprecate-rand-drbg-used-flags branch from a09ddda to 47649fe Compare September 12, 2018 06:04
@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

Note: new commit message

    Replace the public RAND_DRBG_USED_FLAGS #define by an internal constant

    The new DRBG API added the aforementioned #define. However, it is
    used internally only and having it defined publicly does not serve
    any purpose except causing potential version compatibility problems.

    Fixes #7182

The new DRBG API added the aforementioned #define. However, it is
used internally only and having it defined publicly does not serve
any purpose except causing potential version compatibility problems.

Fixes openssl#7182
@mspncp mspncp force-pushed the pr-deprecate-rand-drbg-used-flags branch from 47649fe to fb08daa Compare September 12, 2018 06:16
Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

Approved. Got to be the shortest lived symbol from introduction to deprecation.

@mattcaswell mattcaswell added the approval: done This pull request has the required number of approvals label Sep 12, 2018
@mattcaswell
Copy link
Member

Should I add Fixes #7182 or should this wait until the define is removed?

I would add it. The deprecation in the header file is enough of a prompt for us to come back later and remove it.

@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

I would add it. The deprecation in the header file is enough of a prompt for us to come back later and remove it.

Agreed. In fact, I already added it in fb08daa after addressing @paulidale's comments.

@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

Approved. Got to be the shortest lived symbol from introduction to deprecation.

I like scoring records ;-)

@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

Thanks for your approval, Matt. I'll wait for Pauli's feedback nevertheless, since it was his suggestion.

Copy link
Contributor

@paulidale paulidale left a comment

Choose a reason for hiding this comment

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

One formatting nit but approved either way.

static const unsigned int rand_drbg_used_flags =
RAND_DRBG_FLAG_CTR_NO_DF |
/* add new entries before this line */
0;
Copy link
Contributor

Choose a reason for hiding this comment

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

These two lines should go I think.

i.e. either

static const unsigned int rand_drbg_used_flags =
    RAND_DRBG_FLAG_CTR_NO_DF ;

or everything on one line (if it fits);
Future items being added with the | leading the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original intention was to be diff-friendly, i.e., adding one flag will produce only a single line diff. But I understand that it violates the coding style guidelines, so I'll change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Diffs don't handle things that move across files well.
Still approved.

@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

approved either way.

It looks like you did not press the [Approve] button yet.

@paulidale
Copy link
Contributor

Sorry about missing the radio button selection.

levitte pushed a commit that referenced this pull request Sep 12, 2018
The new DRBG API added the aforementioned #define. However, it is
used internally only and having it defined publicly does not serve
any purpose except causing potential version compatibility problems.

Fixes #7182

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #7190)
levitte pushed a commit that referenced this pull request Sep 12, 2018
The new DRBG API added the aforementioned #define. However, it is
used internally only and having it defined publicly does not serve
any purpose except causing potential version compatibility problems.

Fixes #7182

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #7190)

(cherry picked from commit c402e94)
@mspncp
Copy link
Contributor Author

mspncp commented Sep 12, 2018

Merged, thanks!

@mspncp mspncp closed this Sep 12, 2018
@mspncp mspncp mentioned this pull request Sep 12, 2018
2 tasks
@mspncp mspncp added this to the 1.1.1a milestone Oct 23, 2018
@mspncp mspncp deleted the pr-deprecate-rand-drbg-used-flags branch October 28, 2018 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants