Skip to content

Commit

Permalink
Upgrade libs (#579)
Browse files Browse the repository at this point in the history
* OpenSSL 3.0.13
* Zlib 1.3.1

IB-7954, IB-7955

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma authored Mar 11, 2024
1 parent 1708e2f commit 1040c91
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 18b028fe785e707265fa0e35590b7537ae1d12ea
vcpkgGitCommitId: 1f619be01b436b796dab797dd1e1721c5676f8ac
vcpkgJsonGlob: ./vcpkg.json
runVcpkgInstall: true
runVcpkgFormatString: "[`install`, `--recurse`, `--clean-after-build`, `--x-install-root`, `$[env.VCPKG_INSTALLED_DIR]`, `--triplet`, `$[env.VCPKG_DEFAULT_TRIPLET]`, `--x-feature`, `tests`]"
Expand Down
51 changes: 3 additions & 48 deletions examples/DigiDocCSharp/DigiDocCSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,59 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{DDEE2029-EA2A-49D2-80CB-F0E2E396B005}</ProjectGuid>
<TargetFramework>net472</TargetFramework>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DigiDocCSharp</RootNamespace>
<AssemblyName>DigiDocCSharp</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<DefineConstants>_WINDOWS</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="digidoc\" />
</ItemGroup>
<ItemGroup>
<None Include="LICENSE.BSD" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
4 changes: 2 additions & 2 deletions examples/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
}
sourceSets.main.java.srcDirs += [libsPath + '.androidarm/include']
namespace 'ee.ria.libdigidocpp'
Expand Down
2 changes: 1 addition & 1 deletion examples/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
classpath 'com.android.tools.build:gradle:8.3.0'
}
}

Expand Down
3 changes: 0 additions & 3 deletions examples/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=false
org.gradle.unsafe.configuration-cache=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=true
android.nonFinalResIds=true
2 changes: 1 addition & 1 deletion examples/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
4 changes: 3 additions & 1 deletion examples/ios/libdigidocpp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1520;
ORGANIZATIONNAME = RIA;
TargetAttributes = {
4E7663971B5A37AC00672ACF = {
Expand Down Expand Up @@ -232,6 +232,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
Expand Down Expand Up @@ -290,6 +291,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
Expand Down
10 changes: 5 additions & 5 deletions examples/ios/libdigidocpp/MasterViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ - (IBAction)runTest:(id)sender {
if(unzResult != UNZ_OK)
break;
std::string fileNameTmp(fileInfo.size_filename, 0);
unzResult = unzGetCurrentFileInfo(open, &fileInfo, fileNameTmp.c_str(), uLong(fileNameTmp.size()), nullptr, 0, nullptr, 0);
unzResult = unzGetCurrentFileInfo(open, &fileInfo, fileNameTmp.data(), uLong(fileNameTmp.size()), nullptr, 0, nullptr, 0);
if(unzResult != UNZ_OK)
break;

Expand All @@ -100,18 +100,18 @@ - (IBAction)runTest:(id)sender {
break;

int size = 0;
char buf[10240];
std::array<char, 10240> buf{};
NSMutableData *data = [[NSMutableData alloc] init];
while((size = unzReadCurrentFile(open, buf, 10240)) > 0)
[data appendBytes:buf length:size];
while((size = unzReadCurrentFile(open, buf.data(), buf.size())) > 0)
[data appendBytes:buf.data() length:size];
unzResult = unzCloseCurrentFile(open);

[data writeToFile:file atomically:YES];
NSString *status = @"OK";
NSString *diagnostics = @"";
NSMutableArray *dataFiles = [[NSMutableArray alloc] init];
try {
std::unique_ptr<digidoc::Container> d(digidoc::Container::open(file.UTF8String));
auto d = digidoc::Container::openPtr(file.UTF8String);
for (const digidoc::DataFile *f: d->dataFiles()) {
[dataFiles addObject:@{
@"f": [NSString stdstring:f->fileName()],
Expand Down
3 changes: 2 additions & 1 deletion examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ plugins {
group 'ee.ria'
sourceSets.main.java.srcDirs += ['/Library/libdigidocpp/include', '/usr/include']
java {
sourceCompatibility = 8
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
}
base {
archivesName = 'libdigidocpp'
Expand Down
39 changes: 8 additions & 31 deletions examples/java/src/main/java/ee/ria/libdigidocpp/libdigidocpp.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package ee.ria.libdigidocpp;

import java.io.ByteArrayInputStream;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.HexFormat;
import java.util.Scanner;

public class libdigidocpp {
Expand Down Expand Up @@ -41,7 +42,7 @@ static void extract(int index, String file) {
Container b = Container.open(file);
assert b != null;
DataFiles d = b.dataFiles();
String dest = FileSystems.getDefault().getPath(d.get(index).fileName()).toAbsolutePath().toString();
String dest = Paths.get(d.get(index).fileName()).toAbsolutePath().toString();
System.out.println("Extracting file " + d.get(index).fileName() + " to " + dest);
d.get(index).saveAs(dest);
}
Expand Down Expand Up @@ -99,25 +100,22 @@ static void sign(String[] args) {

static void websign(String[] args) {
digidoc.initializeLib("libdigidocpp-java", "");
try
try (Scanner scanner = new Scanner(System.in))
{
System.out.println("Creating file: " + args[args.length - 1]);
Container b = Container.create(args[args.length - 1]);
assert b != null;
for (int i = 1; i < args.length - 2; ++i)
b.addDataFile(args[i], "application/octet-stream");

X509Certificate cert = toX509(Files.readAllBytes(FileSystems.getDefault().getPath(args[args.length - 2])));
X509Certificate cert = toX509(Files.readAllBytes(Paths.get(args[args.length - 2])));
Signature c = b.prepareWebSignature(cert.getEncoded(), "time-stamp");
System.out.println("Signature method: " + c.signatureMethod());
System.out.println("Digest to sign: " + toHex(c.dataToSign()));
System.out.println("Digest to sign: " + HexFormat.of().formatHex(c.dataToSign()));
System.out.println("Please enter signed digest in hex: ");

Scanner scanner = new Scanner(System.in);
String signature = scanner.nextLine();
scanner.close();

c.setSignatureValue(fromHex(signature));
c.setSignatureValue(HexFormat.of().parseHex(signature));
c.extendSignatureProfile("time-stamp");
b.save();
}
Expand Down Expand Up @@ -173,35 +171,14 @@ static void verify(String file) {
}

static void version() {
System.out.println("DigiDocCSharp 0.3 libdigidocpp " + digidoc.version());
System.out.println("DigiDocJAVA 0.3 libdigidocpp " + digidoc.version());
}

static X509Certificate toX509(byte[] der) throws CertificateException {
CertificateFactory cf = CertificateFactory.getInstance("X509");
return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(der));
}

private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
static String toHex(byte[] bytes) {
char[] hex = new char[bytes.length * 2];
int i = 0;
for (byte b : bytes) {
hex[i++] = HEX_ARRAY[(b & 0xF0) >>> 4];
hex[i++] = HEX_ARRAY[b & 0x0F];
}
return new String(hex);
}

static byte[] fromHex(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}

static private class ContainerOpen extends ContainerOpenCB
{
@Override
Expand Down
2 changes: 1 addition & 1 deletion patches/vcpkg-ports/openssl/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO openssl/openssl
REF "openssl-${VERSION}"
SHA512 8eb6141c1f3d43aa7dd5a5570c99302910feae0d25ab872c58432e5d11d3e330a069715fd4a0cd03234f3fb3e5e9fba38ef59977f7ecf162a2b048476dbb14c6
SHA512 272223fefae76759de40219dd05ff119b99688a807c1af01360470ac5f390426e45463c1445988bf0a6e4cca23a6e0b1649a78121f9d6f69f92563e307a7fd70
PATCHES
disable-apps.patch
disable-install-docs.patch
Expand Down
2 changes: 1 addition & 1 deletion patches/vcpkg-ports/openssl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openssl",
"version": "3.0.12",
"version": "3.0.13",
"description": "OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.",
"homepage": "https://www.openssl.org",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion prepare_osx_build_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ XERCES_DIR=xerces-c-3.2.5
XALAN_DIR=xalan_c-1.12
XMLSEC_DIR=xml-security-c-2.0.4
XSD=xsd-4.0.0-i686-macosx
OPENSSL_DIR=openssl-3.0.12
OPENSSL_DIR=openssl-3.0.13
LIBXML2_DIR=libxml2-2.11.5
ANDROID_NDK=android-ndk-r26b
FREETYPE_DIR=freetype-2.10.1
Expand Down
2 changes: 1 addition & 1 deletion src/minizip/ioapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream)
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);


/* here is the "old" 32 bits structure structure */
/* here is the "old" 32 bits structure */
typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
Expand Down
8 changes: 4 additions & 4 deletions src/minizip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
const char unz_copyright[] =
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";

/* unz_file_info_interntal contain internal info about a file in zipfile*/
/* unz_file_info64_internal contain internal info about a file in zipfile*/
typedef struct unz_file_info64_internal_s
{
ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
Expand Down Expand Up @@ -450,7 +450,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return CENTRALDIRINVALID;

/* number of the disk with the start of the zip64 end of central directory */
/* number of the disk with the start of the zip64 end of central directory */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return CENTRALDIRINVALID;
if (uL != 0)
Expand Down Expand Up @@ -497,9 +497,9 @@ local unzFile unzOpenInternal(const void *path,
ZPOS64_T central_pos;
uLong uL;

uLong number_disk; /* number of the current dist, used for
uLong number_disk; /* number of the current disk, used for
spanning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used
uLong number_disk_with_CD; /* number the disk with central dir, used
for spanning ZIP, unsupported, always 0*/
ZPOS64_T number_entry_CD; /* total number of entries in
the central dir
Expand Down
2 changes: 1 addition & 1 deletion src/minizip/unzip.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain some info about
the current file
if szFileName!=NULL, the filemane string will be copied in szFileName
if szFileName!=NULL, the filename string will be copied in szFileName
(fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
(extraFieldBufferSize is the size of the buffer).
Expand Down
21 changes: 16 additions & 5 deletions src/minizip/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
return 0;

/* number of the disk with the start of the zip64 end of central directory */
/* number of the disk with the start of the zip64 end of central directory */
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
return 0;
if (uL != 0)
Expand Down Expand Up @@ -614,9 +614,9 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
ZPOS64_T central_pos;
uLong uL;

uLong number_disk; /* number of the current dist, used for
uLong number_disk; /* number of the current disk, used for
spanning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used
uLong number_disk_with_CD; /* number of the disk with central dir, used
for spanning ZIP, unsupported, always 0*/
ZPOS64_T number_entry;
ZPOS64_T number_entry_CD; /* total number of entries in
Expand Down Expand Up @@ -1043,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
return ZIP_PARAMERROR;
#endif

// The filename and comment length must fit in 16 bits.
if ((filename!=NULL) && (strlen(filename)>0xffff))
return ZIP_PARAMERROR;
if ((comment!=NULL) && (strlen(comment)>0xffff))
return ZIP_PARAMERROR;
// The extra field length must fit in 16 bits. If the member also requires
// a Zip64 extra block, that will also need to fit within that 16-bit
// length, but that will be checked for later.
if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
return ZIP_PARAMERROR;

zi = (zip64_internal*)file;

if (zi->in_opened_file_inzip == 1)
Expand Down Expand Up @@ -1597,7 +1608,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si

if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
{
// we can not write more data to the buffer that we have room for.
// we cannot write more data to the buffer that we have room for.
return ZIP_BADZIPFILE;
}

Expand Down Expand Up @@ -1861,7 +1872,7 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
free_linkedlist(&(zi->central_dir));

pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF)
{
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
Expand Down
Loading

0 comments on commit 1040c91

Please sign in to comment.