Skip to content
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

Have OSSL_PARAM_allocate_from_text() fail on odd number of hex digits #23374

Closed
wants to merge 3 commits into from

Conversation

levitte
Copy link
Member

@levitte levitte commented Jan 23, 2024

The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes #23373

The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes openssl#23373
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Jan 23, 2024
@levitte levitte added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 branch: 3.2 Merge to openssl-3.2 triaged: bug The issue/pr is/fixes a bug labels Jan 23, 2024
@levitte
Copy link
Member Author

levitte commented Jan 23, 2024

Test coming up

… digits

This adds a test that I hope is comprehensive enough
@levitte
Copy link
Member Author

levitte commented Jan 23, 2024

With this PR, the added test succeeds. Applied alone on master, it fails like this:

$ make test TESTS=test_params
make depend && make _tests
make[1]: Entering directory '/home/levitte/gitwrk/openssl.net/official/_build'
make[1]: Leaving directory '/home/levitte/gitwrk/openssl.net/official/_build'
make[1]: Entering directory '/home/levitte/gitwrk/openssl.net/official/_build'
make run_tests
make[2]: Entering directory '/home/levitte/gitwrk/openssl.net/official/_build'
( SRCTOP=../master \
  BLDTOP=. \
  PERL="/usr/bin/perl" \
  FIPSKEY="f4556650ac31d35461610bac4ed81b1a181b2d8a43ea2854cbae22ca74560813" \
  EXE_EXT= \
  /usr/bin/perl ../master/test/run_tests.pl test_params )
00-prep_fipsmodule_cnf.t .. ok   
All tests successful.
Files=1, Tests=1,  1 wallclock secs ( 0.00 usr  0.01 sys +  0.26 cusr  0.02 csys =  0.29 CPU)
Result: PASS
04-test_params.t .. 
    # ERROR: (bool) 'OSSL_PARAM_allocate_from_text(&param, params_from_text, "hexoctets", values[i], 0, NULL) == false' failed @ ../master/test/params_test.c:682
    # true
    # ERROR:  @ ../master/test/params_test.c:687
    # unexpected OSSL_PARAM_allocate_from_text() success for 'octets' "F"
    # 
    # OPENSSL_TEST_RAND_SEED=1706016382
    not ok 3 - test_more_allocate_from_text
# ------------------------------------------------------------------------------
../../util/wrap.pl ../../test/params_test => 1
not ok 1 - running params_test
04-test_params.t .. 1/? --------------------------------------------------------
#   Failed test 'running params_test'
#   at /home/levitte/gitwrk/openssl.net/official/_build/../master/util/perl/OpenSSL/Test/Simple.pm line 77.
04-test_params.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 

Test Summary Report
-------------------
04-test_params.t (Wstat: 256 (exited 1) Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1,  0 wallclock secs ( 0.01 usr  0.00 sys +  0.19 cusr  0.00 csys =  0.20 CPU)
Result: FAIL
make[2]: *** [Makefile:3858: run_tests] Error 1
make[2]: Leaving directory '/home/levitte/gitwrk/openssl.net/official/_build'
make[1]: *** [Makefile:3855: _tests] Error 2
make[1]: Leaving directory '/home/levitte/gitwrk/openssl.net/official/_build'
make: *** [Makefile:3853: tests] Fel 2

@levitte levitte added the tests: present The PR has suitable tests present label Jan 23, 2024
*buf_n = strlen(value) >> 1;
size_t hexdigits = strlen(value);
if ((hexdigits % 2) != 0) {
/* We don't accept an off number of hex digits */
Copy link
Member

Choose a reason for hiding this comment

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

Nit: s/off/odd/

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@tom-cosgrove-arm tom-cosgrove-arm left a comment

Choose a reason for hiding this comment

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

LGTM; minor comment above

@tom-cosgrove-arm tom-cosgrove-arm added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jan 24, 2024
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Jan 25, 2024
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

openssl-machine pushed a commit that referenced this pull request Jan 25, 2024
The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes #23373

Reviewed-by: Tom Cosgrove <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #23374)
openssl-machine pushed a commit that referenced this pull request Jan 25, 2024
The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes #23373

Reviewed-by: Tom Cosgrove <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #23374)

(cherry picked from commit ea6268c)
@t8m
Copy link
Member

t8m commented Jan 25, 2024

Merged to the master, 3.2, 3.1 and 3.0 branches. Thank you.

@t8m t8m closed this Jan 25, 2024
openssl-machine pushed a commit that referenced this pull request Jan 25, 2024
The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes #23373

Reviewed-by: Tom Cosgrove <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #23374)

(cherry picked from commit ea6268c)
openssl-machine pushed a commit that referenced this pull request Jan 25, 2024
The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes #23373

Reviewed-by: Tom Cosgrove <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #23374)

(cherry picked from commit ea6268c)
@levitte levitte deleted the fix-23373 branch January 29, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 branch: 3.2 Merge to openssl-3.2 severity: fips change The pull request changes FIPS provider sources tests: present The PR has suitable tests present triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent behavior for MAC hexkey of length 1
4 participants