1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:27:43 +00:00

LibPDF: Remove a pointless template specialization

We can just have two functions with actual names instead of specializing
on a bool template parameter.

No behavior change.
This commit is contained in:
Nico Weber 2023-07-10 15:40:18 -04:00 committed by Andreas Kling
parent deb0c53779
commit 92d2895057
2 changed files with 6 additions and 8 deletions

View file

@ -95,8 +95,7 @@ StandardSecurityHandler::StandardSecurityHandler(Document* document, size_t revi
{ {
} }
template<> ByteBuffer StandardSecurityHandler::compute_user_password_value_v2(ByteBuffer password_string)
ByteBuffer StandardSecurityHandler::compute_user_password_value<true>(ByteBuffer password_string)
{ {
// Algorithm 4: Computing the encryption dictionary's U (user password) // Algorithm 4: Computing the encryption dictionary's U (user password)
// value (Security handlers of revision 2) // value (Security handlers of revision 2)
@ -116,8 +115,7 @@ ByteBuffer StandardSecurityHandler::compute_user_password_value<true>(ByteBuffer
return output; return output;
} }
template<> ByteBuffer StandardSecurityHandler::compute_user_password_value_v3_and_newer(ByteBuffer password_string)
ByteBuffer StandardSecurityHandler::compute_user_password_value<false>(ByteBuffer password_string)
{ {
// Algorithm 5: Computing the encryption dictionary's U (user password) // Algorithm 5: Computing the encryption dictionary's U (user password)
// value (Security handlers of revision 3 or greater) // value (Security handlers of revision 3 or greater)
@ -177,9 +175,9 @@ bool StandardSecurityHandler::try_provide_user_password(StringView password_stri
// supplied password string. // supplied password string.
ByteBuffer password_buffer = MUST(ByteBuffer::copy(password_string.bytes())); ByteBuffer password_buffer = MUST(ByteBuffer::copy(password_string.bytes()));
if (m_revision == 2) { if (m_revision == 2) {
password_buffer = compute_user_password_value<true>(password_buffer); password_buffer = compute_user_password_value_v2(password_buffer);
} else { } else {
password_buffer = compute_user_password_value<false>(password_buffer); password_buffer = compute_user_password_value_v3_and_newer(password_buffer);
} }
// b) If the result of step (a) is equal to the value of the encryption // b) If the result of step (a) is equal to the value of the encryption

View file

@ -41,8 +41,8 @@ protected:
void decrypt(NonnullRefPtr<Object>, Reference reference) const override; void decrypt(NonnullRefPtr<Object>, Reference reference) const override;
private: private:
template<bool is_revision_2> ByteBuffer compute_user_password_value_v2(ByteBuffer password_string);
ByteBuffer compute_user_password_value(ByteBuffer password_string); ByteBuffer compute_user_password_value_v3_and_newer(ByteBuffer password_string);
ByteBuffer compute_encryption_key(ByteBuffer password_string); ByteBuffer compute_encryption_key(ByteBuffer password_string);