Skip to content

CMP extension to OpenSSL, incremental PR chunk 2: CRMF code#7646

Closed
DDvO wants to merge 47 commits intoopenssl:masterfrom
mpeylo:cmp_incremental2
Closed

CMP extension to OpenSSL, incremental PR chunk 2: CRMF code#7646
DDvO wants to merge 47 commits intoopenssl:masterfrom
mpeylo:cmp_incremental2

Conversation

@DDvO
Copy link
Contributor

@DDvO DDvO commented Nov 16, 2018

Certificate Management Protocol (CMP, RFC 4210) extension to OpenSSL.
Also includes CRMF (RFC 4211) and HTTP transfer (RFC 6712).

CMP and CRMF functionality is added to libcrypto, and the cmp app to the openssl CLI.
Adds extensive man pages and tests. Integration into build scripts.

Incremental pull request as suggested by @mattcaswell: #6811 (comment).

Initial chunk, reviewed and approved in #7328, consists of the CRMF API
as declared in the header file include/openssl/crmf.h
and its documentation in doc/man3/OSSL_CRMF_*.pod

This second chunk adds the CRMF implementation (crypto/crmf/)
and integrates it in INSTALL, Configure, crypto/build.info, crypto/err/err.c, crypto/err/err_all.c, crypto/err/openssl.ec, crypto/err/openssl.txt, include/openssl/err.h, include/openssl/crmferr.h, and util/libcrypto.num.

Checklist
  • documentation is added or updated
  • tests are added or updated

@DDvO
Copy link
Contributor Author

DDvO commented Nov 21, 2018

@bernd-edlinger and @FdaSilvaYY, thank you for your review comments.
I've just reacted to all of them and done the respective improvements.

@DDvO
Copy link
Contributor Author

DDvO commented Mar 12, 2019

I've just rebased this PR again due to those ever-annoying conflicts in the auto-generated util/libcrypto.num.

@DDvO
Copy link
Contributor Author

DDvO commented Mar 12, 2019

@bernd-edlinger, do you see anything more to do after the recent minor improvements, or can you meanwhile approve this?

@bernd-edlinger
Copy link
Member

I wanted to approve already, but found a few things I overlooked before.

@DDvO
Copy link
Contributor Author

DDvO commented Mar 12, 2019

I wanted to approve already, but found a few things I overlooked before.

I've meanwhile handled all of them, and Travis CI and AppVeyor have passed again :)

@DDvO
Copy link
Contributor Author

DDvO commented Mar 12, 2019

Very pleased that this is now fully approved :-)
Thanks, also in the name of @mpeylo,
to all reviewers: @bernd-edlinger, @FdaSilvaYY, @mattcaswell, and @mspncp.

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.

Reconfirm

@mattcaswell mattcaswell 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 Mar 12, 2019
levitte pushed a commit that referenced this pull request Mar 12, 2019
in INSTALL, Configure, crypto/build.info, include/openssl/crmferr.h,
crypto/err/, include/openssl/err.h, and (to be updated:) util/libcrypto.num

Reviewed-by: Bernd Edlinger <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #7646)
@mattcaswell
Copy link
Member

Woop! Pushed! Thanks all!

So...chunk 3 now?

@DDvO
Copy link
Contributor Author

DDvO commented Mar 12, 2019

So...chunk 3 now?

Basically yes :)

Martin and me just need some time now to rebase our CMP code on this
and consolidate some internal feature branches before we can push the next chunk.

And I think we need to clarify first what exactly is going to be part of chunk 3:
it could be the full CMP API, i.e., all CMP header files, yet due to their size I suppose it will be helpful to break this up, starting for instance with a lower-level portion regarding basic CMP messages handling. Even this is going to be larger than the CRMF implementation.

@mattcaswell
Copy link
Member

Choose the smallest self-contained piece that you can find. Ideally one that can be committed as-is so that we don't have multiple PRs in-flight that depend on each other.

@DDvO
Copy link
Contributor Author

DDvO commented Apr 4, 2019

So...chunk 3 now?

Here it is: #8669

@DDvO DDvO mentioned this pull request May 8, 2019
if (EVP_PKEY_decrypt(pkctx, NULL, &eksize, encKey->data, encKey->length)
<= 0
|| (ek = OPENSSL_malloc(eksize)) == NULL
|| EVP_PKEY_decrypt(pkctx, ek, &eksize, encKey->data,
Copy link
Member

Choose a reason for hiding this comment

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

you don't use eksize, you dont cleat the ek which is secret, right?

Copy link
Member

Choose a reason for hiding this comment

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

is the encKey->data authenticated, or could this be used for a padding oracle?

Copy link
Contributor

@Akretsch Akretsch Sep 5, 2019

Choose a reason for hiding this comment

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

Fixed: eksize is now used for clearing ek in #9774 .
If CRMF (and therefore encSymmKey as part of EncryptedValue) is used in context of a CMP PKIMessage, the PKIMessage has to be protected in the most use cases. Protections means applying password based or signature based message integrity. See RFC4210, chapter 5.1.3 .

goto oom;
EVP_CIPHER_CTX_set_padding(evp_ctx, 0);

if (!EVP_DecryptInit(evp_ctx, cipher, ek, iv)
Copy link
Member

Choose a reason for hiding this comment

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

you don't check that eksize is equal to EVP_CIPHER_key_length
or try to set EVP_CIPHER_CTX_set_key_length in case it is a variable key length?

Copy link
Contributor

Choose a reason for hiding this comment

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

Added the check in #9774

EVP_PKEY_CTX_free(pkctx);
OPENSSL_free(outbuf);
EVP_CIPHER_CTX_free(evp_ctx);
OPENSSL_free(ek);
Copy link
Member

Choose a reason for hiding this comment

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

OPENSSL_clear_free?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #9774

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants