Skip to content

Commit

Permalink
Store previous signature in memory
Browse files Browse the repository at this point in the history
IB-8030

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Apr 17, 2024
1 parent 8a28362 commit adeb851
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
if(POLICY CMP0122)
cmake_policy(SET CMP0122 NEW)
endif()
project(libdigidocpp VERSION 3.17.0)
project(libdigidocpp VERSION 3.17.1)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)

include(VersionInfo)
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param(
[string]$vcpkg_dir = (split-path -parent $vcpkg),
[string]$vcpkg_installed = $libdigidocpp,
[string]$buildver = "0",
[string]$msiversion = "3.17.0.$buildver",
[string]$msiversion = "3.17.1.$buildver",
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.msi",
[string]$cmake = "cmake.exe",
[string]$generator = "NMake Makefiles",
Expand Down
18 changes: 14 additions & 4 deletions src/SignatureXAdES_B.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ Signatures::Signatures(istream &data, ASiContainer *container)
properties.schema_location(URI_ID_DSIG, File::fullPathUrl(xsdPath + "/xmldsig-core-schema.xsd"));
properties.schema_location(ASIC_NAMESPACE, File::fullPathUrl(xsdPath + "/en_31916201v010101.xsd"));
properties.schema_location(OPENDOCUMENT_NAMESPACE, File::fullPathUrl(xsdPath + "/OpenDocument_dsig.xsd"));
parseDOM(data, properties.schema_location());
copy << data.rdbuf();

parseDOM(copy, properties.schema_location());

try
{
Expand Down Expand Up @@ -208,12 +210,20 @@ void Signatures::reloadDOM()
// Save to file an parse it again, to make XML Canonicalization work
// correctly as expected by the Canonical XML 1.0 specification.
// Hope, the next Canonical XMl specification fixes the white spaces preserving "bug".
stringstream ofs;
save(ofs);
parseDOM(ofs);
copy.str({});
copy.clear();
saveXML(copy);
parseDOM(copy);
}

void Signatures::save(ostream &os) const
{
if(copy.str().empty())
return saveXML(os);
os << copy.str();
}

void Signatures::saveXML(ostream &os) const
{
try
{
Expand Down
3 changes: 3 additions & 0 deletions src/SignatureXAdES_B.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <map>
#include <memory>
#include <sstream>

namespace digidoc
{
Expand Down Expand Up @@ -57,8 +58,10 @@ namespace digidoc

private:
void parseDOM(std::istream &data, const std::string &schema_location = {});
void saveXML(std::ostream &os) const;

std::unique_ptr<xercesc::DOMDocument> doc;
std::stringstream copy;
};

class SignatureXAdES_B : public Signature
Expand Down

0 comments on commit adeb851

Please sign in to comment.