Skip to content

Issue 21887: Audit all ciphers to ensure dupctx method is implemented#21933

Closed
nhorman wants to merge 6 commits intoopenssl:masterfrom
nhorman:issue-21887
Closed

Issue 21887: Audit all ciphers to ensure dupctx method is implemented#21933
nhorman wants to merge 6 commits intoopenssl:masterfrom
nhorman:issue-21887

Conversation

@nhorman
Copy link
Copy Markdown
Contributor

@nhorman nhorman commented Sep 1, 2023

It was noted that several cipher implementations were missing their dupctx method, resulting in an inability to use EVP_CIPHER_CTX_dup/copy, which was then ignored because the cipher tests just assume that a failure there was a lack of support, and ignored them. Update the tests to fail on a missing dupctx method, and implement said method in all those that are missing it

Fixes #21887

Checklist
  • tests are added or updated

@nhorman nhorman self-assigned this Sep 1, 2023
@nhorman nhorman added branch: master Applies to master branch branch: 3.0 Applies to openssl-3.0 branch branch: 3.1 Applies to openssl-3.1 (EOL) labels Sep 1, 2023
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Sep 1, 2023
@hlandau
Copy link
Copy Markdown
Member

hlandau commented Sep 4, 2023

Needs rebase

@nhorman
Copy link
Copy Markdown
Contributor Author

nhorman commented Sep 4, 2023

rebase complete

@hlandau hlandau added approval: review pending This pull request needs review by a committer approval: otc review pending tests: present The PR has suitable tests present triaged: feature The issue/pr requests/adds a feature labels Sep 4, 2023
@nhorman nhorman force-pushed the issue-21887 branch 2 times, most recently from 00cb367 to b39dcd5 Compare September 4, 2023 16:23
@nhorman nhorman force-pushed the issue-21887 branch 3 times, most recently from 8e5c1be to c13904d Compare September 5, 2023 13:08
Copy link
Copy Markdown
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

Just nits

Copy link
Copy Markdown
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.

Found an oopsy.

There should be no reason that a cipher can't be duplicated

Fixes openssl#21887
Add dupctx method support to to ciphers implemented with IMPLEMENT_aead_cipher
This includes:
aes-<kbits>-gcm
aria-<kbits>-ccm
aria-<kbits>-gcm
sm4-<kibs>-gcm

Fixes openssl#21887
create a dupctx method for aes_WRAP implementations of all sizes

Fixes openssl#21887
This cipher family has a dupctx function, but was failing because it was
attempting to memdup a field only if it was null

Fix the conditional check to get it working again

Fixes openssl#21887
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Sep 23, 2023
Pretty straightforward, just clone the requested context, no pointers to
fixup

Fixes #21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21933)

Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Sep 23, 2023
There should be no reason that a cipher can't be duplicated

Fixes #21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21933)

(cherry picked from commit 39d857b)
Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Sep 23, 2023
Add dupctx method support to to ciphers implemented with IMPLEMENT_aead_cipher
This includes:
aes-<kbits>-gcm
aria-<kbits>-ccm
aria-<kbits>-gcm
sm4-<kibs>-gcm

Fixes #21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21933)

(cherry picked from commit 0239fb3)
Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Sep 23, 2023
create a dupctx method for aes_WRAP implementations of all sizes

Fixes #21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21933)

(cherry picked from commit 2c021e7)
Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Sep 23, 2023
Same as chacha20 in the last commit, just clone the ctx and its
underlying tlsmac array if its allocated

Fixes #21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21933)

(cherry picked from commit df93b3c)
Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Sep 23, 2023
Pretty straightforward, just clone the requested context, no pointers to
fixup

Fixes #21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21933)

(cherry picked from commit 123c858)
Signed-off-by: fly2x <fly2x@hitls.org>
@alex
Copy link
Copy Markdown
Contributor

alex commented Dec 9, 2023

It looks like this was backported to 3.1, then reverted in #22081, but never re-applied. What needs to happen to get this + the fix for the regression re-applied to 3.1?

@t8m
Copy link
Copy Markdown
Member

t8m commented Dec 12, 2023

I am not sure it is a good idea to backport this. It is not a bug fix in a strict sense.

@alex
Copy link
Copy Markdown
Contributor

alex commented Dec 12, 2023

It is a regression compared to the 1.x series, where dup ctx worked on these ciphers.

@t8m
Copy link
Copy Markdown
Member

t8m commented Dec 12, 2023

Hmm... true, I forgot about that. @nhorman would you please create a backport PRs? I think they need to be separate for 3.1 and 3.0 branches if I am not mistaken. Also please do not forget to add all the later fixes that were applied after the initial PR.

@nhorman
Copy link
Copy Markdown
Contributor Author

nhorman commented Dec 12, 2023

#23018
#23019

Opened to track backporting work

Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
There should be no reason that a cipher can't be duplicated

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
Add dupctx method support to to ciphers implemented with IMPLEMENT_aead_cipher
This includes:
aes-<kbits>-gcm
aria-<kbits>-ccm
aria-<kbits>-gcm

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
create a dupctx method for aes_WRAP implementations of all sizes

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
Same as chacha20 in the last commit, just clone the ctx and its
underlying tlsmac array if its allocated

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
Pretty straightforward, just clone the requested context, no pointers to
fixup

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
There should be no reason that a cipher can't be duplicated

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
Add dupctx method support to to ciphers implemented with IMPLEMENT_aead_cipher
This includes:
aes-<kbits>-gcm
aria-<kbits>-ccm
aria-<kbits>-gcm

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
create a dupctx method for aes_WRAP implementations of all sizes

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
Same as chacha20 in the last commit, just clone the ctx and its
underlying tlsmac array if its allocated

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 20, 2023
Pretty straightforward, just clone the requested context, no pointers to
fixup

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 21, 2023
There should be no reason that a cipher can't be duplicated

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 21, 2023
Add dupctx method support to to ciphers implemented with IMPLEMENT_aead_cipher
This includes:
aes-<kbits>-gcm
aria-<kbits>-ccm
aria-<kbits>-gcm

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 21, 2023
create a dupctx method for aes_WRAP implementations of all sizes

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 21, 2023
Same as chacha20 in the last commit, just clone the ctx and its
underlying tlsmac array if its allocated

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
Liu-ErMeng pushed a commit to Liu-ErMeng/openssl that referenced this pull request Dec 21, 2023
Pretty straightforward, just clone the requested context, no pointers to
fixup

Fixes openssl#21887

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21933)
kafei-cy added a commit to kafei-cy/Tongsuo that referenced this pull request Apr 8, 2026
Include 7 commits:
1. make inability to dup/clone ciphers an error
2. Add dupctx support to aead ciphers
3. implement dupctx for aes_WRAP methods
4. implement dupctx for chacha20_poly1305
5. Add dupctx support to rc4_hmac_md5 algo
6. Fix a key repointing in various ciphers
7. Also with SM4 for Tongsuo, delete some codes tend to CI error.

(Merged from openssl/openssl#23102)
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 Applies to master branch 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.

Audit all ciphers in master branch to ensure EVP_CIPHER_CTX_copy is implemented

6 participants