Skip to content

Commit

Permalink
Added OpenSSL lazy load
Browse files Browse the repository at this point in the history
Implements #27
  • Loading branch information
ceztko committed Dec 4, 2023
1 parent d0360f9 commit 09cb7e1
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 143 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Digital Signature Appearances" document specification

### 1.0
- Remove PdfEncryptMD5Base::GetMD5Binary and PdfEncryptMD5Base::GetMD5String and use common functions
- PdfFontManager: Add font hash to cache descriptor
- PdfField: Evaluate make a virtual getValueObject()
- Evaluate removing PdfObject::Null and PdfVariant::Null and introduce nullptr_t constructor overloads
Expand Down
2 changes: 2 additions & 0 deletions src/podofo/auxiliary/basetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace PoDoFo
}
charbuff_t(std::string&& str)
: std::string(std::move(str)) { }
charbuff_t(const char* str, size_t size)
: std::string(str, size) { }
explicit charbuff_t(const bufferview& view)
: std::string(view.data(), view.size()) { }
explicit charbuff_t(const std::string_view& view)
Expand Down
15 changes: 15 additions & 0 deletions src/podofo/main/PdfCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <podofo/private/PdfDeclarationsPrivate.h>
#include "podofo/private/OpenSSLInternal.h"
#include "PdfCommon.h"
#include "PdfFontManager.h"

Expand All @@ -19,6 +20,20 @@ PODOFO_EXPORT PdfLogSeverity s_MaxLogSeverity = PdfLogSeverity::Information;

PODOFO_EXPORT LogMessageCallback s_LogMessageCallback;

PODOFO_EXPORT ssl::OpenSSLMain s_SSL;

void ssl::Init()
{
// Initialize the OpenSSL singleton
static struct InitOpenSSL
{
InitOpenSSL()
{
s_SSL.Init();
}
} s_init;
}

void PdfCommon::AddFontDirectory(const string_view& path)
{
PdfFontManager::AddFontDirectory(path);
Expand Down
21 changes: 21 additions & 0 deletions src/podofo/main/PdfDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,27 @@ enum class PdfBlendMode
Luminosity,
};

enum class PdfSignatureType
{
Unknown = 0,
PAdES_B = 1,
Pkcs7 = 2,
};

enum class PdfEncryptionAlgorithm
{
Unknown = 0,
RSA,
};

enum class PdfHashingAlgorithm
{
Unknown = 0,
SHA256,
SHA384,
SHA512,
};

};

ENABLE_BITMASK_OPERATORS(PoDoFo::PdfSaveOptions);
Expand Down
3 changes: 2 additions & 1 deletion src/podofo/main/PdfSignerCms.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <chrono>
#include "PdfSigner.h"
#include "PdfSigningCommon.h"

extern "C"
{
Expand All @@ -34,6 +33,8 @@ namespace PoDoFo
nullable<std::chrono::seconds> SigningTimeUTC;
};

using PdfSigningService = std::function<void(bufferview, bool, charbuff&)>;

/** This class computes a CMS signature according to RFC 5652
*/
class PODOFO_API PdfSignerCms : public PdfSigner
Expand Down
38 changes: 0 additions & 38 deletions src/podofo/main/PdfSigningCommon.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/podofo/private/CmsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <chrono>

#include <podofo/main/PdfSigningCommon.h>
#include <podofo/main/PdfDeclarations.h>

extern "C"
{
Expand Down

0 comments on commit 09cb7e1

Please sign in to comment.