diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c59f5594..ef1996eb1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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`]" diff --git a/examples/DigiDocCSharp/DigiDocCSharp.csproj b/examples/DigiDocCSharp/DigiDocCSharp.csproj index 69d7450e0..38fda419d 100644 --- a/examples/DigiDocCSharp/DigiDocCSharp.csproj +++ b/examples/DigiDocCSharp/DigiDocCSharp.csproj @@ -1,59 +1,14 @@ - - + - Debug - x64 - {DDEE2029-EA2A-49D2-80CB-F0E2E396B005} + net472 Exe - Properties - DigiDocCSharp - DigiDocCSharp - v4.7.2 - 512 - - - AnyCPU - true - full - bin\Debug\ - DEBUG;TRACE - prompt - true - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt + false true - false _WINDOWS - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/android/app/build.gradle b/examples/android/app/build.gradle index f2fa7d03a..1412c240f 100644 --- a/examples/android/app/build.gradle +++ b/examples/android/app/build.gradle @@ -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' diff --git a/examples/android/build.gradle b/examples/android/build.gradle index 55d77fb7c..4b27da348 100644 --- a/examples/android/build.gradle +++ b/examples/android/build.gradle @@ -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' } } diff --git a/examples/android/gradle.properties b/examples/android/gradle.properties index 420b1a75b..bb40acb4a 100644 --- a/examples/android/gradle.properties +++ b/examples/android/gradle.properties @@ -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 \ No newline at end of file diff --git a/examples/android/gradle/wrapper/gradle-wrapper.properties b/examples/android/gradle/wrapper/gradle-wrapper.properties index 7bdc135de..2c1042aca 100644 --- a/examples/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/android/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/examples/ios/libdigidocpp.xcodeproj/project.pbxproj b/examples/ios/libdigidocpp.xcodeproj/project.pbxproj index 4ed89b7b1..672f50d69 100644 --- a/examples/ios/libdigidocpp.xcodeproj/project.pbxproj +++ b/examples/ios/libdigidocpp.xcodeproj/project.pbxproj @@ -162,7 +162,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1500; + LastUpgradeCheck = 1520; ORGANIZATIONNAME = RIA; TargetAttributes = { 4E7663971B5A37AC00672ACF = { @@ -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"; @@ -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"; diff --git a/examples/ios/libdigidocpp/MasterViewController.mm b/examples/ios/libdigidocpp/MasterViewController.mm index bef6eb98f..684310714 100644 --- a/examples/ios/libdigidocpp/MasterViewController.mm +++ b/examples/ios/libdigidocpp/MasterViewController.mm @@ -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; @@ -100,10 +100,10 @@ - (IBAction)runTest:(id)sender { break; int size = 0; - char buf[10240]; + std::array 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]; @@ -111,7 +111,7 @@ - (IBAction)runTest:(id)sender { NSString *diagnostics = @""; NSMutableArray *dataFiles = [[NSMutableArray alloc] init]; try { - std::unique_ptr 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()], diff --git a/examples/java/build.gradle b/examples/java/build.gradle index c1ce29cba..75984e600 100755 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -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' diff --git a/examples/java/src/main/java/ee/ria/libdigidocpp/libdigidocpp.java b/examples/java/src/main/java/ee/ria/libdigidocpp/libdigidocpp.java index 5ff995e76..bbe59f2bc 100644 --- a/examples/java/src/main/java/ee/ria/libdigidocpp/libdigidocpp.java +++ b/examples/java/src/main/java/ee/ria/libdigidocpp/libdigidocpp.java @@ -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 { @@ -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); } @@ -99,7 +100,7 @@ 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]); @@ -107,17 +108,14 @@ static void websign(String[] args) { 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(); } @@ -173,7 +171,7 @@ 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 { @@ -181,27 +179,6 @@ static X509Certificate toX509(byte[] der) throws CertificateException { 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 diff --git a/patches/vcpkg-ports/openssl/portfile.cmake b/patches/vcpkg-ports/openssl/portfile.cmake index a6f03be8e..4b86c7de9 100644 --- a/patches/vcpkg-ports/openssl/portfile.cmake +++ b/patches/vcpkg-ports/openssl/portfile.cmake @@ -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 diff --git a/patches/vcpkg-ports/openssl/vcpkg.json b/patches/vcpkg-ports/openssl/vcpkg.json index 9b764a2c4..9703b2531 100644 --- a/patches/vcpkg-ports/openssl/vcpkg.json +++ b/patches/vcpkg-ports/openssl/vcpkg.json @@ -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", diff --git a/prepare_osx_build_environment.sh b/prepare_osx_build_environment.sh index 78a0f8086..7c9b02225 100755 --- a/prepare_osx_build_environment.sh +++ b/prepare_osx_build_environment.sh @@ -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 diff --git a/src/minizip/ioapi.h b/src/minizip/ioapi.h index c588a18d0..a2d2e6e60 100644 --- a/src/minizip/ioapi.h +++ b/src/minizip/ioapi.h @@ -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; diff --git a/src/minizip/unzip.c b/src/minizip/unzip.c index ed763f89f..ea05b7d62 100644 --- a/src/minizip/unzip.c +++ b/src/minizip/unzip.c @@ -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 */ @@ -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) @@ -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 diff --git a/src/minizip/unzip.h b/src/minizip/unzip.h index 14105840f..5cfc9c627 100644 --- a/src/minizip/unzip.h +++ b/src/minizip/unzip.h @@ -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). diff --git a/src/minizip/zip.c b/src/minizip/zip.c index 3d3d4cadd..60bdffac3 100644 --- a/src/minizip/zip.c +++ b/src/minizip/zip.c @@ -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) @@ -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 @@ -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) @@ -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; } @@ -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); diff --git a/src/minizip/zip.h b/src/minizip/zip.h index 5fc084132..3e230d340 100644 --- a/src/minizip/zip.h +++ b/src/minizip/zip.h @@ -177,9 +177,9 @@ extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, filename : the filename in zip (if NULL, '-' without quote will be used *zipfi contain supplemental information if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header + contains the extrafield data for the local header if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header + contains the extrafield data for the global header if comment != NULL, comment contain the comment string method contain the compression method (0 for store, Z_DEFLATED for deflate) level contain the level of compression (can be Z_DEFAULT_COMPRESSION) diff --git a/vcpkg.json b/vcpkg.json index 6c877372a..c299785cc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -8,7 +8,7 @@ "features": { "tests": { "description": "Build tests", "dependencies": ["boost-test"] } }, - "builtin-baseline": "18b028fe785e707265fa0e35590b7537ae1d12ea", + "builtin-baseline": "1f619be01b436b796dab797dd1e1721c5676f8ac", "vcpkg-configuration": { "overlay-ports": [ "patches/vcpkg-ports/openssl",