Duplicate Key Types in `cert_key_types` Passed to `find_cert_chain` · Issue #4763 · randombit/botan · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered an issue where the API function Botan::Credentials_Manager::find_cert_chain is receiving duplicate key types through its cert_key_types parameter.
After some debugging, I tracked the root cause to the two Certificate_13 constructors that invoke the filter_signature_schemes function:
/** * Create a Server Certificate message*/Certificate_13::Certificate_13(const Client_Hello_13& client_hello,
Credentials_Manager& credentials_manager,
Callbacks& callbacks,
Certificate_Type cert_type) :
// RFC 8446 4.4.2:// [In the case of server authentication], this field// SHALL be zero length
m_request_context(), m_side(Connection_Side::Server) {
BOTAN_ASSERT_NOMSG(client_hello.extensions().has<Signature_Algorithms>());
constauto key_types = filter_signature_schemes(client_hello.signature_schemes());
//something else......
}
/** * Create a Client Certificate message*/Certificate_13::Certificate_13(const Certificate_Request_13& cert_request,
std::string_view hostname,
Credentials_Manager& credentials_manager,
Callbacks& callbacks,
Certificate_Type cert_type) :
m_request_context(cert_request.context()), m_side(Connection_Side::Client) {
constauto key_types = filter_signature_schemes(cert_request.signature_schemes());
//something else......
}
In both constructors, filter_signature_schemes converts the provided signature schemes into a std::vector<std::string> of key types. For example, if signature_schemes() returns algorithms such as "RSA_PSS_SHA384" and "RSA_PSS_SHA512", the filtering process results in a vector containing ["RSA", "RSA"], thus creating duplicate entries.
Potential Solution:
One straightforward approach to resolve this issue is to change the container in filter_signature_schemes from a std::vector<std::string> to a std::set<std::string>. But this operation may change the API function Botan::Credentials_Manager::find_cert_chain.
I would appreciate feedback on this approach and am happy to work on a patch if it aligns with the project's direction.
The text was updated successfully, but these errors were encountered:
We cannot immediately change the API here since that would break compatability with existing clients. We might be able to deduplicate them before invoking the callback though - @reneme what do you think?
Interesting finding @Seele-Official and thanks for the analysis that seems logical to me. I think deduplicating those entries won't do any harm (and this is the intended behavior anyway). I do like the std::set idea, because it clearly communicates this intent (and the small number of options won't cause performance issues from using a non-contiguous container either). Perhaps we could introduce that new API as an overload and deprecate the old one?
I have encountered an issue where the API function
Botan::Credentials_Manager::find_cert_chain
is receiving duplicate key types through itscert_key_types
parameter.After some debugging, I tracked the root cause to the two
Certificate_13
constructors that invoke thefilter_signature_schemes
function:In both constructors,
filter_signature_schemes
converts the provided signature schemes into astd::vector<std::string>
of key types. For example, ifsignature_schemes()
returns algorithms such as"RSA_PSS_SHA384"
and"RSA_PSS_SHA512"
, the filtering process results in a vector containing["RSA", "RSA"]
, thus creating duplicate entries.Potential Solution:
One straightforward approach to resolve this issue is to change the container in
filter_signature_schemes
from astd::vector<std::string>
to astd::set<std::string>
. But this operation may change the API functionBotan::Credentials_Manager::find_cert_chain
.I would appreciate feedback on this approach and am happy to work on a patch if it aligns with the project's direction.
The text was updated successfully, but these errors were encountered: