├── .github ├── dependabot.yml └── workflows │ ├── main.yml │ └── release.yml ├── .gitignore ├── .shellcheckrc ├── LICENSE ├── README.en.md ├── README.md ├── cie-java ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── app │ └── m0rf30 │ │ ├── carousel │ │ ├── Cie.java │ │ ├── CieCard.java │ │ └── carousel.java │ │ └── cieid │ │ ├── AESFast.java │ │ ├── Firma │ │ ├── FileDrop.java │ │ ├── MoveablePicture.java │ │ ├── PdfPreview.java │ │ └── VerifyTable.java │ │ ├── IntroFrame.java │ │ ├── Logger.java │ │ ├── MainApplication.java │ │ ├── MainFrame.java │ │ ├── Middleware.java │ │ ├── MiniWebView.java │ │ ├── PINNoticeDialog.java │ │ ├── ProxyInfoManager.java │ │ └── util │ │ └── Utils.java │ ├── com │ └── ugos │ │ ├── crypt │ │ └── hash │ │ │ └── SHA1.java │ │ └── util │ │ └── Runner.java │ └── main │ └── resources │ └── app │ └── m0rf30 │ └── cieid │ └── res │ ├── Allura-Regular.ttf │ ├── Firma │ ├── 1x │ │ ├── Coppia file certificato.png │ │ ├── Coppia file firma.png │ │ ├── firma.png │ │ ├── firma_gray @1x.png │ │ ├── generica.png │ │ ├── p7m.png │ │ ├── pdf.png │ │ └── upload.png │ ├── 2x │ │ ├── Coppia file certificato@2x.png │ │ ├── Coppia file firma@2x.png │ │ ├── firma@2x.png │ │ ├── generica@2x.png │ │ ├── p7m@2x.png │ │ ├── p7m@2x_gray.png │ │ ├── pdf@2x.png │ │ ├── pdf@2x_gray.png │ │ └── upload@2x.png │ ├── 3x │ │ ├── Coppia file certificato@3x.png │ │ ├── Coppia file firma@3x.png │ │ ├── firma@3x.png │ │ ├── generica@3x.png │ │ ├── p7m@3x.png │ │ ├── pdf@3x.png │ │ └── upload@3x.png │ ├── 4x │ │ ├── Coppia file certificato@4x.png │ │ ├── Coppia file firma@4x.png │ │ ├── firma@4x.png │ │ ├── generica@4x.png │ │ ├── p7m@4x.png │ │ ├── pdf@4x.png │ │ └── upload@4x.png │ ├── Coppia file certificato.png │ ├── Coppia file firma.png │ ├── calendar.png │ ├── check.png │ ├── cross.png │ ├── firma@4x.png │ ├── firma_gray.png │ ├── generica.png │ ├── green_checkbox.png │ ├── medal.png │ ├── orange_checkbox.png │ ├── p7m.png │ ├── p7m_grey.png │ ├── pdd_gray.png │ ├── pdf.png │ ├── upload.png │ └── user.png │ ├── Logo_Cie_ID_Windowed@2x.png │ ├── Risorsa 14.png │ ├── Risorsa 14@2x.png │ ├── Risorsa 15.png │ ├── Risorsa 15@2x.png │ ├── Risorsa 16.png │ ├── Risorsa 16@2x.png │ ├── Risorsa 17.png │ ├── Risorsa 17@2x.png │ ├── Risorsa 18.png │ ├── Risorsa 18@2x.png │ ├── Risorsa 19.png │ ├── Risorsa 19@2x.png │ ├── Risorsa 20.png │ ├── Risorsa 20@2x.png │ ├── Risorsa 21.png │ ├── Risorsa 21@2x.png │ ├── Risorsa 22.png │ ├── Risorsa 22@2x.png │ ├── Risorsa 23.png │ ├── Risorsa 23@2x.png │ ├── Risorsa 24.png │ ├── Risorsa 24@2x.png │ ├── Risorsa 25.png │ ├── Risorsa 25@2x.png │ ├── back@2x.png │ ├── check.png │ ├── cie.jpg │ ├── cross.png │ ├── down@2x.png │ ├── flusso_intro_01.png │ ├── flusso_intro_02.png │ ├── forward@2x.png │ ├── html │ ├── icona_aiuto@2x.png │ ├── icona_assistenza.png │ ├── icona_assistenza@2x.png │ ├── icona_lettore_card_white.png │ ├── icona_lettore_card_white@2x.png │ ├── icona_lettore_card_white_small.png │ ├── icona_sblocco_carta.png │ ├── logo-cie@2x copia.png │ ├── logoIPZS.png │ ├── logo_MinisteroInterno.png │ ├── logo_circle.png │ ├── settings_icon.png │ └── up@2x.png ├── data ├── app.m0rf30.cieid.desktop ├── app.m0rf30.cieid.metainfo.xml ├── app.m0rf30.cieid.svg ├── cieid.sh └── libcie-pkcs11.module ├── docs ├── aiuto.html ├── aiuto.md ├── images │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ └── 6.png ├── privacy.html ├── privacy.md ├── style.css ├── tutorial.html └── tutorial.md ├── libs ├── .clang-format ├── meson.build ├── pkcs11 │ └── src │ │ ├── CSP │ │ ├── AbilitaCIE.cpp │ │ ├── AbilitaCIE.h │ │ ├── FirmaConCIE.cpp │ │ ├── FirmaConCIE.h │ │ ├── IAS.cpp │ │ ├── PINManager.cpp │ │ ├── PINManager.h │ │ ├── VerificaConCIE.cpp │ │ └── VerificaConCIE.h │ │ ├── LOGGER │ │ └── Logger.cpp │ │ ├── PKCS11 │ │ ├── CIEP11Template.cpp │ │ ├── CIEP11Template.h │ │ ├── CardContext.cpp │ │ ├── CardContext.h │ │ ├── CardTemplate.cpp │ │ ├── CardTemplate.h │ │ ├── Mechanism.cpp │ │ ├── Mechanism.h │ │ ├── P11Object.cpp │ │ ├── P11Object.h │ │ ├── PKCS11Functions.cpp │ │ ├── PKCS11Functions.h │ │ ├── Slot.cpp │ │ ├── Slot.h │ │ ├── pkcs11.h │ │ ├── pkcs11f.h │ │ ├── session.cpp │ │ └── session.h │ │ ├── Sign │ │ ├── CIESign.cpp │ │ ├── CIESign.h │ │ ├── CIEVerify.cpp │ │ └── CIEVerify.h │ │ ├── Util │ │ ├── UtilException.cpp │ │ └── util.cpp │ │ └── keys.h ├── shared │ └── src │ │ ├── CSP │ │ ├── ATR.cpp │ │ ├── ATR.h │ │ ├── ExtAuthKey.cpp │ │ └── IAS.h │ │ ├── Crypto │ │ ├── AES.cpp │ │ ├── AES.h │ │ ├── ASNParser.cpp │ │ ├── ASNParser.h │ │ ├── Base64.cpp │ │ ├── Base64.h │ │ ├── CryptoUtil.h │ │ ├── DES3.cpp │ │ ├── DES3.h │ │ ├── MAC.cpp │ │ ├── MAC.h │ │ ├── MD5.cpp │ │ ├── MD5.h │ │ ├── RSA.cpp │ │ ├── RSA.h │ │ ├── SHA1.cpp │ │ ├── SHA1.h │ │ ├── SHA256.cpp │ │ ├── SHA512.cpp │ │ ├── sha256.h │ │ └── sha512.h │ │ ├── LOGGER │ │ └── Logger.h │ │ ├── PCSC │ │ ├── APDU.cpp │ │ ├── APDU.h │ │ ├── CardLocker.cpp │ │ ├── CardLocker.h │ │ ├── PCSC.cpp │ │ ├── PCSC.h │ │ ├── Token.cpp │ │ └── Token.h │ │ ├── PKCS11 │ │ ├── cryptoki.h │ │ ├── pkcs11.h │ │ ├── pkcs11f.h │ │ └── pkcs11t.h │ │ ├── Sign │ │ ├── CIEEngine.h │ │ ├── definitions.h │ │ └── disigonsdk.h │ │ └── Util │ │ ├── Array.cpp │ │ ├── Array.h │ │ ├── CacheLib.cpp │ │ ├── CacheLib.h │ │ ├── CryptoppUtils.cpp │ │ ├── CryptoppUtils.h │ │ ├── IniSettings.cpp │ │ ├── IniSettings.h │ │ ├── ModuleInfo.cpp │ │ ├── ModuleInfo.h │ │ ├── SyncroEvent.cpp │ │ ├── SyncroEvent.h │ │ ├── SyncroMutex.cpp │ │ ├── SyncroMutex.h │ │ ├── TLV.cpp │ │ ├── TLV.h │ │ ├── UUCByteArray.cpp │ │ ├── UUCByteArray.h │ │ ├── UUCHashtable.hpp │ │ ├── UUCProperties.cpp │ │ ├── UUCProperties.h │ │ ├── UUCStringTable.cpp │ │ ├── UUCStringTable.h │ │ ├── UUCTextFileReader.cpp │ │ ├── UUCTextFileReader.h │ │ ├── UtilException.h │ │ ├── defines.h │ │ ├── funccallinfo.cpp │ │ ├── funccallinfo.h │ │ ├── log.cpp │ │ ├── log.h │ │ └── util.h └── sign-sdk │ ├── include │ ├── Base64.h │ ├── BaseSigner.h │ ├── BigInteger.h │ ├── BigIntegerAlgorithms.h │ ├── BigIntegerLibrary.h │ ├── BigIntegerUtils.h │ ├── BigUnsigned.h │ ├── BigUnsignedInABase.h │ ├── CIEEngineHelper.h │ ├── CIESigner.h │ ├── CardMod.h │ ├── CertStore.h │ ├── CounterSignatureGenerator.h │ ├── LdapCrl.h │ ├── M7MParser.h │ ├── NumberlikeArray.h │ ├── PdfSignatureGenerator.h │ ├── PdfVerifier.h │ ├── SignatureGenerator.h │ ├── SignedDataGeneratorEx.h │ ├── SignedDocument.h │ ├── SignerInfoGenerator.h │ ├── TSAClient.h │ ├── UUCHashtable.h │ ├── UUCLogger.h │ ├── UUCProperties.h │ ├── UUCStringTable.h │ ├── UUCTextFileReader.h │ ├── UUCTextFileWriter.h │ ├── XAdESGenerator.h │ ├── XAdESVerifier.h │ ├── base64-std.h │ └── keys.h │ └── src │ ├── ASN1 │ ├── ASN1BitString.cpp │ ├── ASN1BitString.h │ ├── ASN1Boolean.cpp │ ├── ASN1Boolean.h │ ├── ASN1Exception.h │ ├── ASN1GenericSequence.cpp │ ├── ASN1GenericSequence.h │ ├── ASN1Integer.cpp │ ├── ASN1Integer.h │ ├── ASN1Null.cpp │ ├── ASN1Null.h │ ├── ASN1Object.cpp │ ├── ASN1Object.h │ ├── ASN1ObjectIdentifier.cpp │ ├── ASN1ObjectIdentifier.h │ ├── ASN1Octetstring.cpp │ ├── ASN1Octetstring.h │ ├── ASN1OptionalField.cpp │ ├── ASN1OptionalField.h │ ├── ASN1Sequence.cpp │ ├── ASN1Sequence.h │ ├── ASN1Setof.cpp │ ├── ASN1Setof.h │ ├── ASN1UTCTime.cpp │ ├── ASN1UTCTime.h │ ├── AlgorithmIdentifier.cpp │ ├── AlgorithmIdentifier.h │ ├── Certificate.cpp │ ├── Certificate.h │ ├── CertificateInfo.cpp │ ├── CertificateInfo.h │ ├── ContentInfo.cpp │ ├── ContentInfo.h │ ├── ContentType.cpp │ ├── ContentType.h │ ├── Crl.cpp │ ├── Crl.h │ ├── DigestInfo.cpp │ ├── DigestInfo.h │ ├── IssuerAndSerialNumber.cpp │ ├── IssuerAndSerialNumber.h │ ├── Name.cpp │ ├── Name.h │ ├── OCSPRequest.cpp │ ├── OCSPRequest.h │ ├── PKIStatusInfo.cpp │ ├── PKIStatusInfo.h │ ├── RSAPrivateKey.cpp │ ├── RSAPrivateKey.h │ ├── RSAPublicKey.cpp │ ├── RSAPublicKey.h │ ├── RelativeDistinguishedName.cpp │ ├── RelativeDistinguishedName.h │ ├── SignedData.cpp │ ├── SignedData.h │ ├── SignerInfo.cpp │ ├── SignerInfo.h │ ├── SubjectPublicKeyInfo.cpp │ ├── SubjectPublicKeyInfo.h │ ├── TSTInfo.cpp │ ├── TSTInfo.h │ ├── TimeStampData.cpp │ ├── TimeStampData.h │ ├── TimeStampRequest.cpp │ ├── TimeStampRequest.h │ ├── TimeStampResponse.cpp │ ├── TimeStampResponse.h │ ├── TimeStampToken.cpp │ ├── TimeStampToken.h │ ├── UUCBufferedReader.cpp │ └── UUCBufferedReader.h │ ├── Base64.cpp │ ├── BigInteger.cpp │ ├── BigIntegerAlgorithms.cpp │ ├── BigIntegerUtils.cpp │ ├── BigUnsigned.cpp │ ├── BigUnsignedInABase.cpp │ ├── CIEEngine.c │ ├── CIEEngineHelper.c │ ├── CIESigner.cpp │ ├── CSP │ └── IAS.cpp │ ├── CertStore.cpp │ ├── CounterSignatureGenerator.cpp │ ├── M7MParser.cpp │ ├── PCSC.cpp │ ├── PdfSignatureGenerator.cpp │ ├── PdfVerifier.cpp │ ├── SignatureGenerator.cpp │ ├── SignedDataGeneratorEx.cpp │ ├── SignedDocument.cpp │ ├── SignerInfoGenerator.cpp │ ├── TSAClient.cpp │ ├── Token.cpp │ ├── UUCLogger.cpp │ ├── UUCProperties.cpp │ ├── UUCStringTable.cpp │ ├── UUCTextFileReader.cpp │ ├── UUCTextFileWriter.cpp │ ├── Util │ ├── UtilException.cpp │ └── util.cpp │ ├── XAdESGenerator.cpp │ ├── XAdESVerifier.cpp │ ├── definitions.cpp │ └── disigonsdk.cpp └── packages ├── cie-middleware └── PKGBUILD ├── flatpak └── app.m0rf30.cieid.yml └── yap.json /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Basic set up for three package managers 2 | 3 | version: 2 4 | updates: 5 | 6 | # Maintain dependencies for GitHub Actions 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" 11 | 12 | # Maintain dependencies for gradle 13 | - package-ecosystem: "gradle" 14 | directory: "/cie-java" 15 | schedule: 16 | interval: "weekly" 17 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the main branch 8 | push: 9 | pull_request: 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | # This workflow contains a single job called "build" 17 | gradle: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: actions/setup-java@v4 22 | with: 23 | distribution: temurin 24 | java-version: 17 25 | 26 | - name: Execute Gradle build 27 | run: | 28 | cie-java/gradlew -b cie-java/build.gradle standalone 29 | 30 | - name: Install Dependencies 31 | run: > 32 | sudo apt update; 33 | sudo apt install -y g++ libcrypto++-dev 34 | libcrypto++8 libcurl4-openssl-dev libfontconfig1-dev 35 | libfreetype6-dev libpcsclite-dev libpcsclite1 libpng-dev libpodofo-dev 36 | libssl-dev libssl3 libxml2 libxml2-dev 37 | pcscd pkg-config python3-pip unzip 38 | 39 | - uses: actions/setup-python@v5 40 | with: 41 | python-version: "3.x" 42 | - run: pip install meson ninja 43 | env: 44 | CC: gcc 45 | - run: meson setup builddir libs 46 | - run: meson configure -Dprefix=/usr builddir 47 | - run: meson compile -C builddir 48 | 49 | - uses: actions/upload-artifact@v4 50 | if: failure() 51 | with: 52 | name: Linux_Meson_Testlog 53 | path: builddir/meson-logs/testlog.txt 54 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | # Controls when the workflow will run 4 | on: 5 | push: 6 | tags: 7 | - "*" 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 12 | jobs: 13 | # This workflow contains a single job called "build" 14 | build: 15 | # The type of runner that the job will run on 16 | runs-on: ubuntu-latest 17 | 18 | # Steps represent a sequence of tasks that will be executed as part of the job 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 21 | - uses: actions/checkout@v4 22 | 23 | # Runs a set of commands using the runners shell 24 | - name: Detect version 25 | run: echo "::set-output name=version::$(cat packages/cie-middleware/PKGBUILD | grep pkgver | cut -d\" -f2)" 26 | id: version 27 | 28 | - name: Build 29 | run: | 30 | docker run --entrypoint=bash -v $(pwd):/project m0rf30/yap-ubuntu-jammy:1.40 -c "cd /project; \ 31 | yap prepare ubuntu-jammy; \ 32 | yap build ubuntu-jammy /project/packages" 33 | docker run --entrypoint=bash -v $(pwd):/project m0rf30/yap-rocky-9:1.40 -c "cd /project; \ 34 | yap prepare rocky-9; \ 35 | yap build rocky-9 /project/packages" 36 | 37 | for i in $(ls artifacts/*.deb); do sha256sum $i >> SHA256SUMS; done 38 | for i in $(ls artifacts/*.rpm); do sha256sum $i >> SHA256SUMS; done 39 | 40 | - name: Archive production artifacts 41 | uses: actions/upload-artifact@v4 42 | with: 43 | name: "cie-middleware-${{ steps.version.outputs.version }}" 44 | path: | 45 | artifacts/*.deb 46 | artifacts/*.rpm 47 | SHA256SUMS 48 | 49 | - uses: "marvinpinto/action-automatic-releases@latest" 50 | with: 51 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 52 | prerelease: false 53 | title: "cie-middleware-${{ steps.version.outputs.version }}" 54 | files: | 55 | artifacts/*.deb 56 | artifacts/*.rpm 57 | SHA256SUMS 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.VC.db 2 | *.VC.opendb 3 | *.a 4 | *.d 5 | *.log 6 | *.o 7 | *.orig 8 | *.so 9 | .cache/ 10 | .flatpak-builder/ 11 | .idea/ 12 | .trunk 13 | .vscode 14 | .vscode-ctags 15 | /cie-java/.gradle 16 | /cie-java/bin 17 | CMakeCache.txt 18 | CMakeFiles/ 19 | Makefile 20 | build/ 21 | builddir/ 22 | cmake_install.cmake 23 | meson-info/ 24 | meson-logs/ 25 | meson-private/ 26 | CIEID-standalone.jar 27 | -------------------------------------------------------------------------------- /.shellcheckrc: -------------------------------------------------------------------------------- 1 | enable=all 2 | source-path=SCRIPTDIR 3 | disable=SC2154 4 | 5 | # If you're having issues with shellcheck following source, disable the errors via: 6 | # disable=SC1090 7 | # disable=SC1091 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, Developers Italia 4 | Copyright (c) 2017, Istituto Poligrafico e Zecca dello Stato 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /cie-java/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | // Apply the java plugin to add support for Java 3 | id 'java' 4 | 5 | // Apply the application plugin to add support for building a CLI application. 6 | id 'application' 7 | id "com.diffplug.spotless" version "7.0.4" 8 | } 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | spotless { 15 | format 'misc', { 16 | // define the files to apply `misc` to 17 | target '*.gradle', '*.md', '.gitignore' 18 | 19 | // define the steps to apply to those files 20 | trimTrailingWhitespace() 21 | leadingSpacesToTabs() 22 | endWithNewline() 23 | } 24 | java { 25 | // apply a specific flavor of google-java-format 26 | googleJavaFormat('1.17.0').aosp() 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation 'commons-io:commons-io:2.19.0' 32 | implementation 'com.google.code.gson:gson:2.13.1' 33 | implementation 'net.java.dev.jna:jna:5.17.0' 34 | implementation 'org.apache.pdfbox:pdfbox:3.0.5' 35 | } 36 | 37 | sourceSets { 38 | main { 39 | java { 40 | srcDirs = ['src'] 41 | } 42 | } 43 | } 44 | 45 | tasks.withType(JavaCompile) { 46 | options.compilerArgs += "-Xlint:deprecation" 47 | options.encoding = "UTF-8" 48 | } 49 | 50 | task standalone(type: Jar) { 51 | dependsOn configurations.runtimeClasspath 52 | archiveClassifier = 'standalone' 53 | from sourceSets.main.output 54 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE 55 | from(configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }) { 56 | exclude "META-INF/*.SF" 57 | exclude "META-INF/*.DSA" 58 | exclude "META-INF/*.RSA" 59 | } 60 | manifest { 61 | attributes 'Implementation-Title': 'CIEID Desktop Application', 62 | 'Built-By': System.getProperty('user.name'), 63 | 'Built-JDK': System.getProperty('java.version'), 64 | 'Main-Class': 'app.m0rf30.cieid.MainApplication' 65 | } 66 | } 67 | 68 | task fetchDeps { 69 | description = "Force gradle to cache all dependencies" 70 | doLast { sourceSets.main.runtimeClasspath.files } 71 | } 72 | 73 | allprojects { 74 | tasks.withType(AbstractArchiveTask).configureEach { 75 | preserveFileTimestamps = false 76 | reproducibleFileOrder = true 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /cie-java/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /cie-java/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /cie-java/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'CIEID' 2 | -------------------------------------------------------------------------------- /cie-java/src/app/m0rf30/carousel/Cie.java: -------------------------------------------------------------------------------- 1 | package app.m0rf30.carousel; 2 | 3 | public class Cie { 4 | 5 | String name; 6 | String serialNumber; 7 | String pan; 8 | Boolean isCustomSign; 9 | 10 | public Cie(String pan, String name, String serialNumber) { 11 | this.name = name; 12 | this.serialNumber = serialNumber; 13 | this.pan = pan; 14 | this.isCustomSign = false; 15 | } 16 | 17 | public String getName() { 18 | return this.name; 19 | } 20 | 21 | public String getSerialNumber() { 22 | return this.serialNumber; 23 | } 24 | 25 | public String getPan() { 26 | return pan; 27 | } 28 | 29 | public void setPan(String pan) { 30 | this.pan = pan; 31 | } 32 | 33 | public Boolean getIsCustomSign() { 34 | return isCustomSign; 35 | } 36 | 37 | public void setIsCustomSign(Boolean isCustomSign) { 38 | this.isCustomSign = isCustomSign; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cie-java/src/app/m0rf30/cieid/MiniWebView.java: -------------------------------------------------------------------------------- 1 | package app.m0rf30.cieid; 2 | 3 | import java.awt.BorderLayout; 4 | import java.net.MalformedURLException; 5 | import java.net.URL; 6 | import javax.swing.JEditorPane; 7 | import javax.swing.JPanel; 8 | import javax.swing.JScrollPane; 9 | import javax.swing.event.HyperlinkEvent; 10 | import javax.swing.event.HyperlinkListener; 11 | import javax.swing.text.html.HTMLDocument; 12 | import javax.swing.text.html.HTMLFrameHyperlinkEvent; 13 | 14 | public class MiniWebView extends JPanel implements HyperlinkListener { 15 | 16 | private final JEditorPane displayEditorPane = new JEditorPane(); 17 | 18 | public MiniWebView() { 19 | setLayout(new BorderLayout()); 20 | displayEditorPane.setContentType("text/html"); 21 | displayEditorPane.setEditable(false); 22 | displayEditorPane.addHyperlinkListener(this); 23 | 24 | add(new JScrollPane(displayEditorPane), BorderLayout.CENTER); 25 | } 26 | 27 | public void showPage(String url) { 28 | try { 29 | showPage(new URL(url)); 30 | } catch (MalformedURLException e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | 35 | public void showPage(URL pageUrl) { 36 | try { 37 | displayEditorPane.setPage(pageUrl); 38 | } catch (Exception e) { 39 | System.out.println("Unable to load page"); 40 | } 41 | } 42 | 43 | public void hyperlinkUpdate(HyperlinkEvent event) { 44 | HyperlinkEvent.EventType eventType = event.getEventType(); 45 | if (eventType == HyperlinkEvent.EventType.ACTIVATED) { 46 | if (event instanceof HTMLFrameHyperlinkEvent) { 47 | HTMLFrameHyperlinkEvent linkEvent = (HTMLFrameHyperlinkEvent) event; 48 | HTMLDocument document = (HTMLDocument) displayEditorPane.getDocument(); 49 | document.processHTMLFrameHyperlinkEvent(linkEvent); 50 | } else { 51 | showPage(event.getURL()); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /cie-java/src/com/ugos/util/Runner.java: -------------------------------------------------------------------------------- 1 | package com.ugos.util; 2 | 3 | import java.util.Timer; 4 | import java.util.TimerTask; 5 | 6 | public class Runner { 7 | public static void run(Runnable run) { 8 | new Thread(run).start(); 9 | } 10 | 11 | public static void run(Runnable run, int stackSize) { 12 | new Thread(new ThreadGroup("runnable"), run, "runnable", stackSize).start(); 13 | } 14 | 15 | public static void runDelayed(final Runnable run, int delay) { 16 | TimerTask tt = 17 | new TimerTask() { 18 | 19 | @Override 20 | public void run() { 21 | run.run(); 22 | } 23 | }; 24 | 25 | new Timer().schedule(tt, delay); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Allura-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Allura-Regular.ttf -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/Coppia file certificato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/Coppia file certificato.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/Coppia file firma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/Coppia file firma.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/firma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/firma.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/firma_gray @1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/firma_gray @1x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/generica.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/generica.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/p7m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/p7m.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/pdf.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/1x/upload.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/Coppia file certificato@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/Coppia file certificato@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/Coppia file firma@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/Coppia file firma@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/firma@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/firma@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/generica@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/generica@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/p7m@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/p7m@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/p7m@2x_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/p7m@2x_gray.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/pdf@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/pdf@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/pdf@2x_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/pdf@2x_gray.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/upload@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/2x/upload@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/Coppia file certificato@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/Coppia file certificato@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/Coppia file firma@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/Coppia file firma@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/firma@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/firma@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/generica@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/generica@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/p7m@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/p7m@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/pdf@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/pdf@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/upload@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/3x/upload@3x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/Coppia file certificato@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/Coppia file certificato@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/Coppia file firma@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/Coppia file firma@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/firma@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/firma@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/generica@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/generica@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/p7m@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/p7m@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/pdf@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/pdf@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/upload@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/4x/upload@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/Coppia file certificato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/Coppia file certificato.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/Coppia file firma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/Coppia file firma.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/calendar.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/check.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/cross.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/firma@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/firma@4x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/firma_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/firma_gray.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/generica.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/generica.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/green_checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/green_checkbox.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/medal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/medal.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/orange_checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/orange_checkbox.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/p7m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/p7m.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/p7m_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/p7m_grey.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/pdd_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/pdd_gray.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/pdf.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/upload.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Firma/user.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Logo_Cie_ID_Windowed@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Logo_Cie_ID_Windowed@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 14.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 14@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 14@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 15.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 15@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 15@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 16.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 16@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 17.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 17@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 17@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 18.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 18@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 18@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 19.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 19@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 19@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 20.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 20@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 21.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 21@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 21@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 22.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 22@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 22@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 23.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 23@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 23@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 24.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 24@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 24@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 25.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 25@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/Risorsa 25@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/back@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/check.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/cie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/cie.jpg -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/cross.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/down@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/down@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/flusso_intro_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/flusso_intro_01.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/flusso_intro_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/flusso_intro_02.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/forward@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/forward@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/html: -------------------------------------------------------------------------------- 1 | ../../../../../../../../docs/ -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_aiuto@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_aiuto@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_assistenza.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_assistenza.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_assistenza@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_assistenza@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_lettore_card_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_lettore_card_white.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_lettore_card_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_lettore_card_white@2x.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_lettore_card_white_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_lettore_card_white_small.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/icona_sblocco_carta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/icona_sblocco_carta.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/logo-cie@2x copia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/logo-cie@2x copia.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/logoIPZS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/logoIPZS.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/logo_MinisteroInterno.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/logo_MinisteroInterno.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/logo_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/logo_circle.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/settings_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/settings_icon.png -------------------------------------------------------------------------------- /cie-java/src/main/resources/app/m0rf30/cieid/res/up@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/cie-java/src/main/resources/app/m0rf30/cieid/res/up@2x.png -------------------------------------------------------------------------------- /data/app.m0rf30.cieid.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Name=Cie ID 4 | Comment=Middleware for electronic Italian Identity Card 5 | Name[it]=Cie ID 6 | Comment[it]=Middleware della CIE (Carta di Identità Elettronica) 7 | Exec=cieid 8 | Icon=app.m0rf30.cieid 9 | Type=Application 10 | Terminal=false 11 | StartupNotify=false 12 | Encoding=UTF-8 13 | Categories=Utility; 14 | StartupWMClass=app-m0rf30-cieid-MainApplication 15 | -------------------------------------------------------------------------------- /data/app.m0rf30.cieid.metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | app.m0rf30.cieid 4 | Cie ID 5 | Software for the usage of the Italian Electronic Identity Card 7 | CC0-1.0 8 | BSD-3-Clause 9 | 10 |

11 | Software for the usage of the Italian Electronic Identity Card. 12 |

13 |

14 | Access to PA services, signing and verification of documents 15 |

16 |
17 | 18 | M0Rf30 19 | 20 | https://github.com/M0Rf30/cie-middleware-linux 21 | https://github.com/M0Rf30/cie-middleware-linux/issues 24 | app.m0rf30.cieid.desktop 25 | 30 | 31 | 32 | 33 | 34 |
35 | -------------------------------------------------------------------------------- /data/cieid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Use CIEID_PATH if set, otherwise default to /usr 4 | : "${PREFIX:=/usr}" 5 | 6 | exec java \ 7 | -Xms1G \ 8 | -Xmx1G \ 9 | -Djna.library.path="${PREFIX}/lib" \ 10 | -Dawt.useSystemAAFontSettings=on \ 11 | -Dsun.java2d.uiScale.enabled=true \ 12 | -Dsun.java2d.uiScale=2.0 \ 13 | -classpath "${PREFIX}/share/cieid/cieid.jar" \ 14 | app.m0rf30.cieid.MainApplication "$@" 15 | -------------------------------------------------------------------------------- /data/libcie-pkcs11.module: -------------------------------------------------------------------------------- 1 | # This file describes how to load the libcie-pkcs11 module 2 | # See: http://p11-glue.freedesktop.org/doc/p11-kit/config.html 3 | 4 | # This is a relative path, which means it will be loaded from 5 | # the p11-kit default path which is usually $(libdir)/pkcs11. 6 | module: libcie-pkcs11.so 7 | -------------------------------------------------------------------------------- /docs/aiuto.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Aiuto Cie ID 8 | 9 | 10 | 11 | 12 |

Assistenza per i cittadini

13 |

Per richiedere il blocco della propria CIE, bisogna contattare il numero

14 |

800263388 fornendo i seguenti dati:

15 | 32 |

Il servizio è attivo dal lunedì al venerdì dalle 8:00 alle 18:00

33 |

e il sabato dalle ore 8:00 alle 14:00.

34 |

Il servizio è valido solo per la nuova CIE.

35 |

Nel caso in cui il cittadino sia in possesso di una vecchia CIE la procedura

36 |

d’interdizione resta inalterata: bisogna recarsi presso il comune di rilascio

37 |

dopo aver sporto denuncia presso le forze dell’ordine.

38 |

Per segnalazioni inerenti il portale

39 |

http://www.cartaidentita.interno.gov.it

40 |

o il servizio

41 |

http://agendacie.interno.gov.it bisogna

42 |

inviare una e-mail all’indirizzo di assistenza indicato qui sotto specificando i

43 |

dettagli della richiesta.

44 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/aiuto.md: -------------------------------------------------------------------------------- 1 | # Assistenza per i cittadini 2 | 3 | Per richiedere il blocco della propria **CIE**, bisogna contattare il numero 4 | **800263388** fornendo i seguenti dati: 5 | 6 | - Nome 7 | - Cognome 8 | - Codice fiscale 9 | - Numero della CIE se disponibile 10 | - Estremi della denuncia presentata alle forze dell'ordine 11 | 12 | Il servizio è attivo dal **lunedì** al **venerdì** dalle **8:00** alle **18:00** 13 | e il **sabato** dalle ore **8:00** alle **14:00**. 14 | 15 | Il servizio è valido solo per la nuova CIE. 16 | 17 | Nel caso in cui il cittadino sia in possesso di una vecchia CIE la procedura 18 | d'interdizione resta inalterata: bisogna recarsi presso il comune di rilascio 19 | dopo aver sporto denuncia presso le forze dell'ordine. 20 | 21 | Per segnalazioni inerenti il portale 22 | [http://www.cartaidentita.interno.gov.it](http://www.cartaidentita.interno.gov.it) 23 | 24 | o il servizio 25 | [http://agendacie.interno.gov.it](http://agendacie.interno.gov.it) bisogna 26 | inviare una e-mail all'indirizzo di assistenza indicato qui sotto specificando i 27 | dettagli della richiesta. 28 | -------------------------------------------------------------------------------- /docs/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/docs/images/1.png -------------------------------------------------------------------------------- /docs/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/docs/images/2.png -------------------------------------------------------------------------------- /docs/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/docs/images/3.png -------------------------------------------------------------------------------- /docs/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/docs/images/4.png -------------------------------------------------------------------------------- /docs/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/docs/images/5.png -------------------------------------------------------------------------------- /docs/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/M0Rf30/cie-middleware-linux/39d793d595008fd2611bb7711e03c5b5355efa3b/docs/images/6.png -------------------------------------------------------------------------------- /docs/tutorial.md: -------------------------------------------------------------------------------- 1 | # Come usare Cie ID 2 | 3 | Avvia il browser Firefox per iniziare la configurazione. Clicca sul pulsante 4 | delle impostazioni, in alto a destra, quindi su **Impostazioni**. 5 | 6 | ![description1](./images/1.png) 7 | 8 | Selezionare la scheda **Privacy e Sicurezza** nella buca di ricerca e clicca su 9 | **Dispositivi di sicurezza**. 10 | 11 | ![description1](./images/2.png) 12 | 13 | Clicca su **Carica**, digita **CIE PKI** nel campo **Nome modulo** e seleziona 14 | il file **/usr/lib/libcie-pkcs11.so**. 15 | 16 | ![description1](./images/3.png) 17 | 18 | Clicca su **Apri** per confermare la scelta, quindi su OK per confermare il 19 | caricamento del modulo. 20 | 21 | ![description1](./images/4.png) 22 | 23 | Per autenticarti con la CIE, digita l’URL del servizio di tuo interesse e clicca 24 | sul pulsante **Entra con CIE**. 25 | 26 | ![description1](./images/5.png) 27 | 28 | Quando richiesto, procedi ad effettuare l’abilitazione della tua CIE sul 29 | computer, necessaria solo per il primo utilizzo. 30 | 31 | Ti occorrerà il codice 32 | [PIN]("https://www.cartaidentita.interno.gov.it/cosa-pin-puk-utilizzarli/") 33 | composto da 4 cifre ricevute al momento di presentazione della domanda e altre 4 34 | cifre che ti sono state recapitate a casa insieme alla nuova Carta di Identità 35 | Elettronica. 36 | 37 | **Ricorda**: dopo aver terminato l'abilitazione, ogni volta che ti sarà 38 | richiesto l'inserimento del PIN è necessario inserire solo le ultime 4 cifre del 39 | PIN. 40 | 41 | **[Clicca qui](https://www.cartaidentita.interno.gov.it/richiesta-di-ristampa/)** 42 | se hai smarrito il PIN. 43 | 44 | Terminata l’abilitazione, ti verrà richiesto di scegliere il certificato con cui 45 | accedere al servizio e di inserire la seconda metà del PIN. 46 | 47 | ![description1](./images/6.png) 48 | 49 | Inserito il PIN, clicca su OK o premi INVIO per accedere al servizio. 50 | 51 | In caso di difficoltà, contatta il servizio di assistenza per i cittadini 52 | secondo le modalità indicate all’indirizzo 53 | [https://www.cartaidentita.interno.gov.it/contatti/](https://www.cartaidentita.interno.gov.it/contatti/). 54 | 55 | Se vuoi cambiare il PIN o l’hai dimenticato e intendi cambiarlo (avrai bisogno 56 | del PUK) consulta il manuale del Software CIE per conoscere la procedura. 57 | 58 | Il manuale è disponibile all’indirizzo 59 | [https://www.cartaidentita.interno.gov.it/software-cie/](https://www.cartaidentita.interno.gov.it/software-cie/). 60 | -------------------------------------------------------------------------------- /libs/pkcs11/src/CSP/AbilitaCIE.h: -------------------------------------------------------------------------------- 1 | // 2 | // AbilitaCIE.h 3 | // cie-pkcs11 4 | // 5 | // Created by ugo chirico on 02/09/18. http://www.ugochirico.com 6 | // Copyright © 2018 IPZS. All rights reserved. 7 | // 8 | 9 | #include "PCSC/PCSC.h" 10 | #include "PKCS11/cryptoki.h" 11 | 12 | #define SCARD_ATTR_VALUE(Class, Tag) \ 13 | ((((uint32_t)(Class)) << 16) | ((uint32_t)(Tag))) 14 | #define SCARD_CLASS_ICC_STATE 9 /**< ICC State specific definitions */ 15 | #define SCARD_ATTR_ATR_STRING \ 16 | SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, \ 17 | 0x0303) /**< Answer to reset (ATR) string. */ 18 | 19 | // using namespace std 20 | 21 | /* CK_NOTIFY is an application callback that processes events */ 22 | typedef CK_CALLBACK_FUNCTION(CK_RV, PROGRESS_CALLBACK)(const int progress, 23 | const char* szMessage); 24 | 25 | typedef CK_CALLBACK_FUNCTION(CK_RV, COMPLETED_CALLBACK)(const char* szPan, 26 | const char* szName, 27 | const char* ef_seriale); 28 | 29 | typedef CK_RV (*AbilitaCIEfn)(const char* szPAN, const char* szPIN, 30 | int* attempts, PROGRESS_CALLBACK progressCallBack, 31 | COMPLETED_CALLBACK completedCallBack); 32 | 33 | typedef CK_RV (*VerificaCIEAbilitatafn)(); 34 | typedef CK_RV (*DisabilitaCIEfn)(); 35 | 36 | int TokenTransmitCallback(safeConnection* data, uint8_t* apdu, DWORD apduSize, 37 | uint8_t* resp, DWORD* respSize); 38 | -------------------------------------------------------------------------------- /libs/pkcs11/src/CSP/FirmaConCIE.h: -------------------------------------------------------------------------------- 1 | // 2 | // FirmaConCIE.hpp 3 | // cie-pkcs11 4 | // 5 | // Copyright © 2021 IPZS. All rights reserved. 6 | // 7 | 8 | #ifndef FirmaConCIE_h 9 | #define FirmaConCIE_h 10 | 11 | #include "CSP/AbilitaCIE.h" 12 | #include "PKCS11/cryptoki.h" 13 | 14 | typedef CK_CALLBACK_FUNCTION(CK_RV, SIGN_COMPLETED_CALLBACK)(const int ret); 15 | 16 | typedef CK_RV (*firmaConCIEfn)(const char* inFilePath, const char* type, 17 | const char* pin, const char* pan, int page, 18 | float x, float y, float w, float h, 19 | const char* imagePathFile, 20 | const char* outFilePath, 21 | PROGRESS_CALLBACK progressCallBack, 22 | SIGN_COMPLETED_CALLBACK completedCallBack); 23 | 24 | #endif /* FirmaConCIE_h */ 25 | -------------------------------------------------------------------------------- /libs/pkcs11/src/CSP/PINManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // PINManager.hpp 3 | // cie-pkcs11 4 | // 5 | // Created by ugo chirico on 06/10/18. http://www.ugochirico.com 6 | // Copyright © 2018 IPZS. All rights reserved. 7 | // 8 | 9 | #ifndef PINManager_h 10 | #define PINManager_h 11 | 12 | #include 13 | 14 | #include "CSP/AbilitaCIE.h" 15 | 16 | typedef CK_RV (*CambioPINfn)(const char* szCurrentPIN, const char* szNewPIN, 17 | int* attempts, PROGRESS_CALLBACK progressCallBack); 18 | 19 | typedef CK_RV (*SbloccoPINfn)(const char* szPUK, const char* szNewPIN, 20 | int* attempts, 21 | PROGRESS_CALLBACK progressCallBack); 22 | 23 | #endif /* PINManager_h */ 24 | -------------------------------------------------------------------------------- /libs/pkcs11/src/CSP/VerificaConCIE.h: -------------------------------------------------------------------------------- 1 | // 2 | // VerificaConCIE.h 3 | // cie-pkcs11 4 | // 5 | // Copyright © 2021 IPZS. All rights reserved. 6 | // 7 | 8 | #ifndef LIBS_PKCS11_SRC_CSP_VERIFICACONCIE_H_ 9 | #define LIBS_PKCS11_SRC_CSP_VERIFICACONCIE_H_ 10 | 11 | #include 12 | 13 | #include "AbilitaCIE.h" 14 | #include "Sign/CIEVerify.h" 15 | 16 | typedef CK_RV (*verificaConCIEfn)(const char* inFilePath); 17 | typedef CK_RV (*getNumberOfSignfn)(void); 18 | typedef CK_RV (*getVerifyInfofn)(int index, struct verifyInfo_t* vInfos); 19 | typedef CK_RV (*estraiP7mfn)(const char* inFilePath, const char* outFilePath); 20 | #endif // LIBS_PKCS11_SRC_CSP_VERIFICACONCIE_H_ 21 | -------------------------------------------------------------------------------- /libs/pkcs11/src/PKCS11/CardContext.cpp: -------------------------------------------------------------------------------- 1 | #include "PKCS11/CardContext.h" 2 | 3 | #include 4 | 5 | #include "Util/util.h" 6 | 7 | extern CLog Log; 8 | 9 | void CCardContext::getContext() { 10 | init_func LONG _call_ris; 11 | if ((_call_ris = (SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, 12 | &hContext))) != S_OK) { 13 | throw windows_error(_call_ris); 14 | } 15 | } 16 | 17 | CCardContext::CCardContext(void) { 18 | hContext = 0; 19 | getContext(); 20 | } 21 | 22 | CCardContext::~CCardContext(void) { 23 | if (hContext) SCardReleaseContext(hContext); 24 | } 25 | 26 | CCardContext::operator SCARDCONTEXT() { return hContext; } 27 | 28 | void CCardContext::validate() { 29 | if (hContext) 30 | if (SCardIsValidContext(hContext) != SCARD_S_SUCCESS) hContext = 0; 31 | 32 | if (hContext == 0) { 33 | getContext(); 34 | } 35 | } 36 | 37 | void CCardContext::renew() { 38 | init_func 39 | 40 | LONG ris; 41 | if (hContext) 42 | if ((ris = SCardReleaseContext(hContext)) != SCARD_S_SUCCESS) 43 | throw windows_error(ris); 44 | hContext = 0; 45 | 46 | getContext(); 47 | } 48 | -------------------------------------------------------------------------------- /libs/pkcs11/src/PKCS11/CardContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CCardContext { 7 | public: 8 | SCARDCONTEXT hContext; 9 | 10 | CCardContext(void); 11 | ~CCardContext(void); 12 | 13 | operator SCARDCONTEXT(); 14 | void validate(); 15 | void renew(); 16 | 17 | private: 18 | void getContext(); 19 | }; 20 | -------------------------------------------------------------------------------- /libs/pkcs11/src/PKCS11/P11Object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "PKCS11/Slot.h" 6 | 7 | namespace p11 { 8 | 9 | typedef std::map AttributeMap; 10 | 11 | class CSession; 12 | 13 | class CP11Object { 14 | public: 15 | bool bReadValue; 16 | static size_t P11ObjectCnt; 17 | 18 | CSlot *pSlot; 19 | void *pTemplateData; // dati specifici per il template della carta 20 | 21 | CP11Object(CK_OBJECT_CLASS objClass, void *TemplateData); 22 | CK_OBJECT_CLASS ObjClass; 23 | AttributeMap attributes; 24 | void addAttribute(CK_ATTRIBUTE_TYPE type, ByteArray data); 25 | 26 | /// nullptr come valore di ritorno sognifica che l'attibuto non fa parte della 27 | /// mappa di attributi dell'oggetto 28 | virtual ByteArray *getAttribute(CK_ATTRIBUTE_TYPE type); 29 | 30 | virtual CK_ULONG GetAttributeValue(CK_ATTRIBUTE_PTR pTemplate, 31 | CK_ULONG ulCount); 32 | virtual void SetAttributes(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount); 33 | virtual CK_ULONG GetObjectSize(); 34 | virtual ~CP11Object() = default; 35 | bool IsPrivate(); 36 | }; 37 | 38 | class CP11Certificate : public CP11Object { 39 | public: 40 | CP11Certificate(void *TemplateData); 41 | virtual ByteArray *getAttribute(CK_ATTRIBUTE_TYPE type); 42 | virtual void SetAttributes(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount); 43 | }; 44 | 45 | class CP11Data : public CP11Object { 46 | public: 47 | CP11Data(void *TemplateData); 48 | virtual ByteArray *getAttribute(CK_ATTRIBUTE_TYPE type); 49 | virtual void SetAttributes(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount); 50 | }; 51 | 52 | class CP11PublicKey : public CP11Object { 53 | public: 54 | CP11PublicKey(void *TemplateData); 55 | virtual ByteArray *getAttribute(CK_ATTRIBUTE_TYPE type); 56 | }; 57 | 58 | class CP11PrivateKey : public CP11Object { 59 | public: 60 | CP11PrivateKey(void *TemplateData); 61 | virtual ByteArray *getAttribute(CK_ATTRIBUTE_TYPE type); 62 | }; 63 | 64 | } // namespace p11 65 | -------------------------------------------------------------------------------- /libs/pkcs11/src/PKCS11/PKCS11Functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "PKCS11/cryptoki.h" 7 | 8 | #define MAXVAL 0xffffff 9 | #define MAXSESSIONS MAXVAL 10 | 11 | #define CK_ENTRY 12 | #define LIBRARY_VERSION_MAJOR 2 13 | #define LIBRARY_VERSION_MINOR 0 14 | 15 | #define PIN_LEN 8 16 | #define USER_PIN_ID 0x10 17 | 18 | #include "LOGGER/Logger.h" 19 | 20 | using namespace CieIDLogger; 21 | 22 | #define init_p11_func \ 23 | LOG_INFO("[PKCS11] %s", __FUNCTION__); \ 24 | try { 25 | #define exit_p11_func \ 26 | } \ 27 | catch (p11_error & p11Err) { \ 28 | LOG_ERROR("[PKCS11] EXC: %s", p11Err.what()); \ 29 | LOG_ERROR("[PKCS11] P11Error: %x", p11Err.getP11ErrorCode()); \ 30 | return p11Err.getP11ErrorCode(); \ 31 | } \ 32 | catch (std::exception & err) { \ 33 | LOG_ERROR("EXCLOG->"); \ 34 | LOG_ERROR("EXC: %s", err.what()); \ 35 | LOG_ERROR("<-EXCLOG"); \ 36 | return CKR_GENERAL_ERROR; \ 37 | } \ 38 | catch (...) { \ 39 | LOG_ERROR("%s, CKR_GENERAL_ERROR", __FUNCTION__); \ 40 | return CKR_GENERAL_ERROR; \ 41 | } 42 | 43 | extern "C" { 44 | CK_RV CK_ENTRY C_UpdateSlotList(); 45 | } 46 | -------------------------------------------------------------------------------- /libs/pkcs11/src/Sign/CIESign.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CSP/IAS.h" 4 | #include "Sign/disigonsdk.h" 5 | 6 | class CIESign { 7 | private: 8 | IAS* ias; 9 | 10 | public: 11 | CIESign(IAS* ias); 12 | 13 | ~CIESign(); 14 | 15 | uint16_t sign(const char* inFilePath, const char* type, const char* pin, 16 | int page, float x, float y, float w, float h, 17 | const char* imagePathFile, const char* outFilePath); 18 | }; 19 | -------------------------------------------------------------------------------- /libs/pkcs11/src/Sign/CIEVerify.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Sign/disigonsdk.h" 4 | 5 | #define MAX_INFO 20 6 | 7 | struct verifyInfo_t { 8 | char name[MAX_LEN * 2]; 9 | char surname[MAX_LEN * 2]; 10 | char cn[MAX_LEN * 2]; 11 | char signingTime[MAX_LEN * 2]; 12 | char cadn[MAX_LEN * 2]; 13 | int CertRevocStatus; 14 | bool isSignValid; 15 | bool isCertValid; 16 | }; 17 | 18 | class CIEVerify { 19 | public: 20 | CIEVerify(); 21 | ~CIEVerify(); 22 | 23 | long verify(const char* input_file, VERIFY_RESULT* verifyResult, 24 | const char* proxy_address, int proxy_port, const char* userPass); 25 | long get_file_from_p7m(const char* input_file, const char* output_file); 26 | }; 27 | -------------------------------------------------------------------------------- /libs/pkcs11/src/Util/UtilException.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Util/UtilException.h" 3 | 4 | #include "LOGGER/Logger.h" 5 | #include "Util/util.h" 6 | 7 | using namespace CieIDLogger; 8 | 9 | logged_error::logged_error(std::string message) 10 | : std::runtime_error(message.c_str()) { 11 | logged_error(message.c_str()); 12 | } 13 | 14 | logged_error::logged_error(const char *message) : std::runtime_error(message) { 15 | LOG_ERROR("%s", message); 16 | } 17 | 18 | scard_error::scard_error(StatusWord sw) 19 | : logged_error(stdPrintf("Errore smart card:%x", sw)) {} 20 | 21 | windows_error::windows_error(long ris) 22 | : logged_error(stdPrintf("Errore windows:(%08x) ", ris)) {} 23 | -------------------------------------------------------------------------------- /libs/pkcs11/src/keys.h: -------------------------------------------------------------------------------- 1 | // 2 | // keys.h 3 | // cie-pkcs11 4 | // 5 | // Created by ugo chirico on 07/01/2019. 6 | // Copyright © 2019 IPZS. All rights reserved. 7 | // 8 | 9 | #ifndef KEYS_H_ 10 | #define KEYS_H_ 11 | 12 | #define ENCRYPTION_KEY "this is a fake key" 13 | 14 | #endif // KEYS_H_ 15 | -------------------------------------------------------------------------------- /libs/shared/src/CSP/ATR.h: -------------------------------------------------------------------------------- 1 | #ifndef _CIE_ATR_H_ 2 | #define _CIE_ATR_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | enum CIE_Type { 13 | CIE_Unknown, 14 | CIE_Gemalto, 15 | CIE_Gemalto2, 16 | CIE_STM, 17 | CIE_STM2, 18 | CIE_STM3, 19 | CIE_NXP, 20 | CIE_ACTALIS, 21 | CIE_ACTALIS2, 22 | CIE_BIT4ID, 23 | CIE_BIT4ID2, 24 | CIE_BIT4ID3 25 | }; 26 | 27 | typedef struct _cie_atr { 28 | CIE_Type cie_type; 29 | string type; 30 | vector atr; 31 | } cie_atr; 32 | 33 | string get_manufacturer(vector atr); 34 | CIE_Type get_type(vector atr); 35 | 36 | #endif // _CIE_ATR_H_ 37 | -------------------------------------------------------------------------------- /libs/shared/src/CSP/ExtAuthKey.cpp: -------------------------------------------------------------------------------- 1 | #include "Sign/definitions.h" 2 | #include "Util/Array.h" 3 | 4 | BYTE ExtAuth_PrivExp[] = { 5 | 0x18, 0x6B, 0x31, 0x48, 0x8C, 0x25, 0xDC, 0xF8, 0x5D, 0x95, 0x3D, 0x36, 6 | 0x30, 0xC0, 0xD0, 0x73, 0xBA, 0x1C, 0x6A, 0xA2, 0x45, 0x81, 0xAD, 0x25, 7 | 0x4F, 0x3B, 0x67, 0x19, 0xC5, 0xD7, 0x2C, 0xCA, 0x3E, 0x5C, 0xDC, 0x5A, 8 | 0x1E, 0x53, 0x16, 0x57, 0x8D, 0x75, 0x95, 0x4F, 0xF7, 0x3B, 0x23, 0x7B, 9 | 0x53, 0x2C, 0x9F, 0x8D, 0xE4, 0xA2, 0xC4, 0xC9, 0x11, 0x38, 0x5A, 0x23, 10 | 0xE6, 0x3E, 0x33, 0xE4, 0x7E, 0xE4, 0x5E, 0x66, 0xEF, 0xD4, 0x9B, 0x18, 11 | 0xE0, 0x2C, 0xFF, 0x87, 0x59, 0x8C, 0x39, 0x10, 0x9E, 0x8F, 0x86, 0xA6, 12 | 0x6B, 0xC3, 0x30, 0x24, 0x9C, 0xE3, 0xFC, 0xAD, 0x65, 0x5D, 0xCD, 0xBF, 13 | 0x98, 0xC9, 0xC5, 0xE4, 0x79, 0x32, 0x1A, 0xF5, 0x3B, 0x51, 0x7D, 0x04, 14 | 0x10, 0x61, 0x88, 0x0A, 0x64, 0x7B, 0xBE, 0x0F, 0xF8, 0x13, 0x68, 0x34, 15 | 0x70, 0xE6, 0xC5, 0x00, 0x94, 0xCE, 0x81, 0xD0, 0x64, 0xE2, 0x04, 0xE3, 16 | 0x51, 0xBD, 0x3A, 0xE0, 0xA7, 0x94, 0x7D, 0x8E, 0x91, 0xC3, 0xFD, 0x5C, 17 | 0x0A, 0x15, 0x23, 0x3C, 0x34, 0x9A, 0x52, 0x15, 0xA4, 0xE6, 0x6E, 0x21, 18 | 0xC5, 0xD3, 0x34, 0x98, 0xE7, 0x19, 0x91, 0xEA, 0x24, 0x47, 0x3B, 0x29, 19 | 0xF1, 0x47, 0x5F, 0x6F, 0xD9, 0xBE, 0x39, 0x96, 0xE1, 0x9B, 0xD4, 0x74, 20 | 0xFA, 0xD1, 0xB4, 0x1E, 0xA0, 0xDC, 0xD2, 0xFC, 0x16, 0xC9, 0xBF, 0xFA, 21 | 0x07, 0x1B, 0xFE, 0xC1, 0xB2, 0x24, 0x15, 0x18, 0x48, 0x11, 0xC1, 0x98, 22 | 0x5F, 0xBF, 0xE3, 0xE7, 0xB4, 0xF4, 0x4A, 0x4B, 0x3C, 0x8D, 0xFA, 0xB4, 23 | 0xD9, 0x0C, 0xEC, 0xFC, 0x5E, 0x60, 0x8D, 0x67, 0x3E, 0x67, 0x62, 0xC6, 24 | 0x2C, 0xB7, 0x98, 0x34, 0x12, 0x71, 0x14, 0x9B, 0xA6, 0x88, 0x16, 0x2E, 25 | 0xC7, 0xD0, 0xE3, 0x46, 0x8F, 0x65, 0xA9, 0x4A, 0xB4, 0xAD, 0x1A, 0xB6, 26 | 0x7E, 0x37, 0xBF, 0xC1}; 27 | 28 | ByteArray baExtAuth_PrivExp(ExtAuth_PrivExp, sizeof(ExtAuth_PrivExp)); 29 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/AES.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/AES.h" 2 | 3 | extern CLog Log; 4 | 5 | ByteDynArray CAES::AES(const ByteArray &data, int encOp) { 6 | init_func 7 | 8 | ByteDynArray iv2 = iv; 9 | 10 | AES_KEY aesKey; 11 | if (encOp == AES_ENCRYPT) 12 | AES_set_encrypt_key(key.data(), (int)key.size() * 8, &aesKey); 13 | else 14 | AES_set_decrypt_key(key.data(), (int)key.size() * 8, &aesKey); 15 | size_t AppSize = data.size() - 1; 16 | ByteDynArray resp(AppSize - (AppSize % 16) + 16); 17 | AES_cbc_encrypt(data.data(), resp.data(), data.size(), &aesKey, iv2.data(), 18 | encOp); 19 | 20 | return resp; 21 | } 22 | void CAES::Init(const ByteArray &key, const ByteArray &iv) { 23 | init_func this->iv = iv; 24 | this->key = key; 25 | 26 | exit_func 27 | } 28 | 29 | CAES::CAES() {} 30 | 31 | CAES::~CAES(void) {} 32 | 33 | CAES::CAES(const ByteArray &key, const ByteArray &iv) { Init(key, iv); } 34 | 35 | ByteDynArray CAES::Encode(const ByteArray &data) { 36 | init_func return AES(ISOPad16(data), AES_ENCRYPT); 37 | } 38 | 39 | ByteDynArray CAES::RawEncode(const ByteArray &data) { 40 | init_func ER_ASSERT( 41 | (data.size() % AES_BLOCK_SIZE) == 0, 42 | "La dimensione dei dati da cifrare deve essere multipla di 16"); 43 | return AES(data, AES_ENCRYPT); 44 | } 45 | 46 | ByteDynArray CAES::Decode(const ByteArray &data) { 47 | init_func ByteDynArray result = AES(data, AES_DECRYPT); 48 | result.resize(RemoveISOPad(result), true); 49 | return result; 50 | } 51 | 52 | ByteDynArray CAES::RawDecode(const ByteArray &data) { 53 | init_func ER_ASSERT( 54 | (data.size() % AES_BLOCK_SIZE) == 0, 55 | "La dimensione dei dati da cifrare deve essere multipla di 16"); 56 | return AES(data, AES_DECRYPT); 57 | } 58 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/AES.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Util/UtilException.h" 6 | #include "Util/util.h" 7 | 8 | #define AESKEY_LENGHT 32 9 | 10 | class CAES { 11 | ByteDynArray key; 12 | ByteDynArray AES(const ByteArray &data, int encOp); 13 | ByteDynArray iv; 14 | 15 | public: 16 | CAES(); 17 | CAES(const ByteArray &key, const ByteArray &iv); 18 | ~CAES(void); 19 | 20 | void Init(const ByteArray &key, const ByteArray &iv); 21 | ByteDynArray Encode(const ByteArray &data); 22 | ByteDynArray Decode(const ByteArray &data); 23 | ByteDynArray RawEncode(const ByteArray &data); 24 | ByteDynArray RawDecode(const ByteArray &data); 25 | }; 26 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/ASNParser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Util/Array.h" 6 | 7 | size_t GetASN1DataLenght(ByteArray &data); 8 | 9 | class CASNTag; 10 | typedef std::vector> CASNTagArray; 11 | class CASNTag { 12 | public: 13 | CASNTag(void); 14 | std::vector tag; 15 | ByteDynArray content; 16 | CASNTagArray tags; 17 | bool isSequence(); 18 | void Encode(ByteArray &data, size_t &len); 19 | size_t EncodeLen(); 20 | size_t ContentLen(); 21 | void Reparse(); 22 | size_t tagInt(); 23 | 24 | CASNTag &Child(std::size_t num, uint8_t tag); 25 | void Verify(ByteArray content); 26 | CASNTag &CheckTag(uint8_t tag); 27 | 28 | size_t startPos, endPos; 29 | 30 | private: 31 | bool forcedSequence; 32 | }; 33 | 34 | class CASNParser { 35 | public: 36 | CASNParser(void); 37 | void Encode(ByteArray &data, CASNTagArray &tags); 38 | void Encode(ByteDynArray &data); 39 | void Parse(ByteArray &data); 40 | void Parse(ByteArray &data, CASNTagArray &tags, size_t startseq); 41 | CASNTagArray tags; 42 | 43 | size_t CalcLen(); 44 | }; 45 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/Base64.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/Base64.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "Sign/definitions.h" 7 | 8 | extern CLog Log; 9 | #if (CRYPTOPP_VERSION >= 600) && (__cplusplus >= 201103L) 10 | using byte = CryptoPP::byte; 11 | #else 12 | typedef unsigned char byte; 13 | #endif 14 | 15 | CBase64::CBase64() {} 16 | 17 | CBase64::~CBase64() {} 18 | 19 | std::string &CBase64::Encode(ByteArray &data, std::string &encodedData) { 20 | init_func CryptoPP::ArraySink sink; 21 | CryptoPP::Base64Encoder encoder(&sink, false); 22 | CryptoPP::StringSource(data.data(), data.size(), true, &encoder); 23 | 24 | byte *encoded = new byte[sink.AvailableSize()]; 25 | 26 | sink.Get(encoded, sink.AvailableSize()); 27 | encodedData.append((char *)encoded, sink.AvailableSize()); 28 | 29 | return encodedData; 30 | exit_func 31 | } 32 | 33 | ByteDynArray &CBase64::Decode(const char *encodedData, ByteDynArray &data) { 34 | init_func 35 | 36 | CryptoPP::ArraySink sink; 37 | CryptoPP::Base64Decoder decoder(&sink); 38 | CryptoPP::StringSource((BYTE *)encodedData, strlen(encodedData), true, 39 | &decoder); 40 | 41 | byte *decoded = new byte[sink.AvailableSize()]; 42 | 43 | sink.Get(decoded, sink.AvailableSize()); 44 | ByteArray decodedBa((BYTE *)decoded, sink.AvailableSize()); 45 | 46 | data.append(decodedBa); 47 | 48 | return data; 49 | exit_func 50 | } 51 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/Base64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Util/Array.h" 5 | 6 | class CBase64 { 7 | public: 8 | CBase64(); 9 | ~CBase64(); 10 | 11 | std::string &Encode(ByteArray &data, std::string &encodedData); 12 | ByteDynArray &Decode(const char *encodedData, ByteDynArray &data); 13 | }; 14 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/DES3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Util/UtilException.h" 6 | #include "Util/util.h" 7 | 8 | #define DESKEY_LENGHT 8 9 | 10 | class CDES3 { 11 | ByteDynArray Des3(const ByteArray &data, int encOp); 12 | DES_key_schedule k1, k2, k3; 13 | DES_cblock initVec; 14 | 15 | public: 16 | CDES3(); 17 | CDES3(const ByteArray &key, const ByteArray &iv); 18 | ~CDES3(void); 19 | 20 | void Init(const ByteArray &key, const ByteArray &iv); 21 | ByteDynArray Encode(const ByteArray &data); 22 | ByteDynArray Decode(const ByteArray &data); 23 | ByteDynArray RawEncode(const ByteArray &data); 24 | ByteDynArray RawDecode(const ByteArray &data); 25 | }; 26 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/MAC.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/MAC.h" 2 | 3 | #include 4 | 5 | extern CLog Log; 6 | 7 | void CMAC::Init(const ByteArray &key, const ByteArray &iv) { 8 | init_func long KeySize = key.size(); 9 | 10 | DES_cblock *keyVal1 = nullptr, *keyVal2 = nullptr, *keyVal3 = nullptr; 11 | CryptoPP::memcpy_s(initVec, sizeof(DES_cblock), iv.data(), 8); 12 | 13 | switch (KeySize) { 14 | case 8: 15 | throw logged_error("Errore nella cifratura DES"); 16 | break; 17 | case 16: 18 | keyVal1 = keyVal3 = (DES_cblock *)key.data(); 19 | keyVal2 = (DES_cblock *)key.mid(8).data(); 20 | break; 21 | case 24: 22 | keyVal1 = (DES_cblock *)key.data(); 23 | keyVal2 = (DES_cblock *)key.mid(8).data(); 24 | keyVal3 = (DES_cblock *)key.mid(16).data(); 25 | break; 26 | } 27 | 28 | DES_set_key(keyVal1, &k1); 29 | DES_set_key(keyVal2, &k2); 30 | DES_set_key(keyVal3, &k3); 31 | 32 | exit_func 33 | } 34 | 35 | CMAC::~CMAC(void) {} 36 | 37 | ByteDynArray CMAC::Mac(const ByteArray &data) { 38 | init_func 39 | 40 | ByteDynArray resp(8); 41 | 42 | DES_cblock iv; 43 | CryptoPP::memcpy_s(iv, sizeof(DES_cblock), initVec, sizeof(iv)); 44 | 45 | size_t ANSILen = ANSIPadLen(data.size()); 46 | if (data.size() > 8) { 47 | ByteDynArray baOutTmp(ANSILen - 8); 48 | DES_ncbc_encrypt(data.data(), baOutTmp.data(), (long)ANSILen - 8, &k1, &iv, 49 | DES_ENCRYPT); 50 | } 51 | uint8_t dest[8]; 52 | DES_ede3_cbc_encrypt(data.mid(ANSILen - 8).data(), dest, 53 | (long)(data.size() - ANSILen) + 8, &k1, &k2, &k3, &iv, 54 | DES_ENCRYPT); 55 | resp.copy(ByteArray(dest, 8)); 56 | 57 | return resp; 58 | 59 | exit_func 60 | } 61 | 62 | CMAC::CMAC() {} 63 | 64 | CMAC::CMAC(const ByteArray &key, const ByteArray &iv) { Init(key, iv); } 65 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/MAC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Util/UtilException.h" 5 | #include "Util/util.h" 6 | 7 | class CMAC { 8 | DES_key_schedule k1, k2, k3; 9 | DES_cblock initVec; 10 | 11 | public: 12 | CMAC(); 13 | CMAC(const ByteArray &key, const ByteArray &iv); 14 | ~CMAC(void); 15 | 16 | void Init(const ByteArray &key, const ByteArray &iv); 17 | ByteDynArray Mac(const ByteArray &data); 18 | }; 19 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/MD5.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/MD5.h" 2 | 3 | #include 4 | 5 | CMD5::CMD5() : isInit(false) {} 6 | 7 | CMD5::~CMD5() {} 8 | 9 | void CMD5::Init() { 10 | // throw logged_error("Un'operazione di hash � gi� in corso"); 11 | ctx = EVP_MD_CTX_new(); 12 | EVP_DigestInit_ex(ctx, EVP_md5(), NULL); 13 | isInit = true; 14 | } 15 | void CMD5::Update(ByteArray data) { 16 | if (!isInit) throw logged_error("Hash non inizializzato"); 17 | EVP_DigestUpdate(ctx, data.data(), data.size()); 18 | } 19 | ByteDynArray CMD5::Final() { 20 | if (!isInit) throw logged_error("Hash non inizializzato"); 21 | ByteDynArray resp(MD5_DIGEST_LENGTH); 22 | EVP_DigestFinal_ex(ctx, resp.data(), NULL); 23 | isInit = false; 24 | 25 | return resp; 26 | } 27 | 28 | ByteDynArray CMD5::Digest(ByteArray data) { 29 | Init(); 30 | Update(data); 31 | return Final(); 32 | } 33 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/MD5.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Util/UtilException.h" 7 | #include "Util/util.h" 8 | 9 | class CMD5 { 10 | bool isInit; 11 | EVP_MD_CTX* ctx; 12 | 13 | public: 14 | CMD5(); 15 | ~CMD5(void); 16 | 17 | ByteDynArray Digest(ByteArray data); 18 | 19 | void Init(); 20 | void Update(ByteArray data); 21 | ByteDynArray Final(); 22 | }; 23 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/RSA.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/RSA.h" 2 | 3 | #include 4 | 5 | #include "Util/funccallinfo.h" 6 | #include "Util/log.h" 7 | 8 | extern CLog Log; 9 | #if (CRYPTOPP_VERSION >= 600) && (__cplusplus >= 201103L) 10 | using byte = CryptoPP::byte; 11 | #else 12 | typedef unsigned char byte; 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | using CryptoPP::PSS; 20 | using CryptoPP::RSASS; 21 | using CryptoPP::SecByteBlock; 22 | using CryptoPP::SHA512; 23 | 24 | DWORD CRSA::GenerateKey(DWORD size, ByteDynArray &module, ByteDynArray &pubexp, 25 | ByteDynArray &privexp) { 26 | init_func throw logged_error("Non supportato"); 27 | } 28 | 29 | ByteArray modulusBa; 30 | ByteArray exponentBa; 31 | 32 | CRSA::CRSA(ByteArray &mod, ByteArray &exp) { 33 | modulusBa = mod; 34 | exponentBa = exp; 35 | 36 | CryptoPP::Integer n(mod.data(), mod.size()), e(exp.data(), exp.size()); 37 | pubKey.Initialize(n, e); 38 | } 39 | 40 | CRSA::~CRSA(void) {} 41 | 42 | ByteDynArray CRSA::RSA_PURE(ByteArray &data) { 43 | CryptoPP::Integer m((const byte *)data.data(), data.size()); 44 | CryptoPP::Integer c = pubKey.ApplyFunction(m); 45 | 46 | size_t len = c.MinEncodedSize(); 47 | if (len == 0xff) len = 0x100; 48 | 49 | ByteDynArray resp(len); 50 | 51 | c.Encode((byte *)resp.data(), resp.size(), CryptoPP::Integer::UNSIGNED); 52 | 53 | return resp; 54 | } 55 | 56 | bool CRSA::RSA_PSS(ByteArray &signatureData, ByteArray &toSign) { 57 | RSASS::Verifier verifier(pubKey); 58 | SecByteBlock signatureBlock((const byte *)signatureData.data(), 59 | signatureData.size()); 60 | 61 | return verifier.VerifyMessage((const byte *)toSign.data(), toSign.size(), 62 | signatureBlock, signatureBlock.size()); 63 | } 64 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/RSA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Sign/definitions.h" 7 | #include "Util/Array.h" 8 | 9 | class CRSA { 10 | CryptoPP::RSA::PublicKey pubKey; 11 | DWORD GenerateKey(DWORD size, ByteDynArray &module, ByteDynArray &pubexp, 12 | ByteDynArray &privexp); 13 | 14 | public: 15 | CRSA(ByteArray &mod, ByteArray &exp); 16 | ~CRSA(void); 17 | 18 | ByteDynArray RSA_PURE(ByteArray &data); 19 | bool RSA_PSS(ByteArray &signatureData, ByteArray &toSign); 20 | }; 21 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/SHA1.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/SHA1.h" 2 | 3 | #include 4 | 5 | CSHA1::CSHA1() : isInit(false) {} 6 | 7 | CSHA1::~CSHA1() {} 8 | 9 | void CSHA1::Init() { 10 | ctx = EVP_MD_CTX_new(); 11 | EVP_DigestInit_ex(ctx, EVP_sha1(), NULL); 12 | isInit = true; 13 | } 14 | void CSHA1::Update(ByteArray data) { 15 | if (!isInit) throw logged_error("Hash non inizializzato"); 16 | EVP_DigestUpdate(ctx, data.data(), data.size()); 17 | } 18 | ByteDynArray CSHA1::Final() { 19 | if (!isInit) throw logged_error("Hash non inizializzato"); 20 | ByteDynArray resp(SHA_DIGEST_LENGTH); 21 | EVP_DigestFinal_ex(ctx, resp.data(), NULL); 22 | isInit = false; 23 | 24 | return resp; 25 | } 26 | 27 | ByteDynArray CSHA1::Digest(ByteArray data) { 28 | Init(); 29 | Update(data); 30 | return Final(); 31 | } 32 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/SHA1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Util/UtilException.h" 6 | #include "Util/util.h" 7 | 8 | class CSHA1 { 9 | bool isInit; 10 | EVP_MD_CTX* ctx; 11 | 12 | public: 13 | CSHA1(); 14 | ~CSHA1(void); 15 | 16 | ByteDynArray Digest(ByteArray data); 17 | 18 | void Init(); 19 | void Update(ByteArray data); 20 | ByteDynArray Final(); 21 | }; 22 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/SHA256.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/sha256.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void CSHA256::Init() { 9 | ctx = EVP_MD_CTX_new(); 10 | EVP_DigestInit_ex(ctx, EVP_sha256(), NULL); 11 | isInit = true; 12 | } 13 | void CSHA256::Update(ByteArray data) { 14 | if (!isInit) throw logged_error("Hash non inizializzato"); 15 | EVP_DigestUpdate(ctx, data.data(), data.size()); 16 | } 17 | ByteDynArray CSHA256::Final() { 18 | if (!isInit) throw logged_error("Hash non inizializzato"); 19 | ByteDynArray resp(SHA_DIGEST_LENGTH); 20 | EVP_DigestFinal_ex(ctx, resp.data(), NULL); 21 | isInit = false; 22 | 23 | return resp; 24 | } 25 | ByteDynArray CSHA256::Digest(ByteArray& data) { 26 | const BYTE* pbData = (BYTE*)data.data(); 27 | unsigned int nDataLen = data.size(); 28 | BYTE abDigest[CryptoPP::SHA256::DIGESTSIZE]; 29 | CryptoPP::SHA256().CalculateDigest(abDigest, pbData, nDataLen); 30 | ByteArray resp(abDigest, CryptoPP::SHA256::DIGESTSIZE); 31 | 32 | return resp; 33 | } 34 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/SHA512.cpp: -------------------------------------------------------------------------------- 1 | #include "Crypto/sha512.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void CSHA512::Init() { 8 | SHA512_Init(&ctx); 9 | isInit = true; 10 | } 11 | void CSHA512::Update(ByteArray data) { 12 | if (!isInit) throw logged_error("Hash non inizializzato"); 13 | SHA512_Update(&ctx, data.data(), data.size()); 14 | } 15 | ByteDynArray CSHA512::Final() { 16 | if (!isInit) throw logged_error("Hash non inizializzato"); 17 | ByteDynArray resp(SHA_DIGEST_LENGTH); 18 | SHA512_Final(resp.data(), &ctx); 19 | isInit = false; 20 | 21 | return resp; 22 | } 23 | 24 | ByteDynArray CSHA512::Digest(ByteArray& data) { 25 | const BYTE* pbData = (BYTE*)data.data(); 26 | unsigned int nDataLen = data.size(); 27 | BYTE abDigest[CryptoPP::SHA512::DIGESTSIZE]; 28 | 29 | CryptoPP::SHA512().CalculateDigest(abDigest, pbData, nDataLen); 30 | 31 | ByteArray resp(abDigest, CryptoPP::SHA512::DIGESTSIZE); 32 | 33 | return resp; 34 | } 35 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/sha256.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "Util/Array.h" 7 | 8 | #define SHA256_DIGEST_LENGTH 32 9 | 10 | class CSHA256 { 11 | public: 12 | ByteDynArray Digest(ByteArray& data); 13 | void Init(); 14 | void Update(ByteArray data); 15 | ByteDynArray Final(); 16 | 17 | bool isInit; 18 | EVP_MD_CTX* ctx; 19 | }; 20 | -------------------------------------------------------------------------------- /libs/shared/src/Crypto/sha512.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Util/Array.h" 6 | 7 | #define SHA512_DIGEST_LENGTH 64 8 | 9 | class CSHA512 { 10 | bool isInit; 11 | SHA512_CTX ctx; 12 | void Init(); 13 | void Update(ByteArray data); 14 | ByteDynArray Final(); 15 | 16 | public: 17 | ByteDynArray Digest(ByteArray &data); 18 | }; 19 | -------------------------------------------------------------------------------- /libs/shared/src/PCSC/APDU.cpp: -------------------------------------------------------------------------------- 1 | #include "PCSC/APDU.h" 2 | 3 | #include "Crypto/DES3.h" 4 | #include "Crypto/MAC.h" 5 | #include "PCSC/Token.h" 6 | #include "Util/TLV.h" 7 | #include "Util/util.h" 8 | 9 | extern CLog Log; 10 | 11 | APDU::APDU() {} 12 | APDU::APDU(BYTE CLA, BYTE INS, BYTE P1, BYTE P2, BYTE LC, BYTE *pData, 13 | BYTE LE) { 14 | init_func if (LC > 250) throw; 15 | btINS = INS; 16 | btCLA = CLA; 17 | btP1 = P1; 18 | btP2 = P2; 19 | btLC = LC; 20 | pbtData = pData; 21 | btLE = LE; 22 | bLC = true; 23 | bLE = true; 24 | exit_func 25 | } 26 | APDU::APDU(BYTE CLA, BYTE INS, BYTE P1, BYTE P2, BYTE LC, BYTE *pData) { 27 | if (LC > 251) throw; 28 | btINS = INS; 29 | btCLA = CLA; 30 | btP1 = P1; 31 | btP2 = P2; 32 | btLC = LC; 33 | pbtData = pData; 34 | btLE = 0; 35 | bLC = true; 36 | bLE = false; 37 | } 38 | APDU::APDU(BYTE CLA, BYTE INS, BYTE P1, BYTE P2, BYTE LE) { 39 | btINS = INS; 40 | btCLA = CLA; 41 | btP1 = P1; 42 | btP2 = P2; 43 | btLE = LE; 44 | btLC = 0; 45 | bLC = false; 46 | bLE = true; 47 | } 48 | APDU::APDU(BYTE CLA, BYTE INS, BYTE P1, BYTE P2) { 49 | btINS = INS; 50 | btCLA = CLA; 51 | btP1 = P1; 52 | btP2 = P2; 53 | btLE = 0; 54 | btLC = 0; 55 | bLC = false; 56 | bLE = false; 57 | } 58 | 59 | APDU::~APDU() {} 60 | -------------------------------------------------------------------------------- /libs/shared/src/PCSC/APDU.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class CToken; 6 | class APDU { 7 | public: 8 | APDU(); 9 | APDU(uint8_t CLA, uint8_t INS, uint8_t P1, uint8_t P2, uint8_t LC, 10 | uint8_t *pData, uint8_t LE); 11 | APDU(uint8_t CLA, uint8_t INS, uint8_t P1, uint8_t P2, uint8_t LC, 12 | uint8_t *pData); 13 | APDU(uint8_t CLA, uint8_t INS, uint8_t P1, uint8_t P2, uint8_t LE); 14 | APDU(uint8_t CLA, uint8_t INS, uint8_t P1, uint8_t P2); 15 | ~APDU(); 16 | 17 | uint8_t btINS; // INS dell'APDU 18 | uint8_t btCLA; // CLA dell'APDU 19 | uint8_t btP1; // P1 dell'APDU 20 | uint8_t btP2; // P2 dell'APDU 21 | uint8_t btLC; // LC dell'APDU 22 | bool bLC; // flag: il campo dati è da includere? (caso 1 e 3) 23 | uint8_t *pbtData; // campo dati dell'APDU 24 | uint8_t btLE; // flag: LE è da includere? (caso 2 e 4) 25 | bool bLE; // LE dell'APDU 26 | }; 27 | -------------------------------------------------------------------------------- /libs/shared/src/PCSC/CardLocker.cpp: -------------------------------------------------------------------------------- 1 | #include "CardLocker.h" 2 | 3 | extern CLog Log; 4 | 5 | CCardLocker::CCardLocker(SCARDHANDLE card) { 6 | hCard = card; 7 | Lock(); 8 | } 9 | 10 | CCardLocker::~CCardLocker(void) { Unlock(); } 11 | 12 | void CCardLocker::Lock() { 13 | init_func 14 | 15 | SCardBeginTransaction(hCard); 16 | 17 | exit_func 18 | } 19 | 20 | void CCardLocker::Unlock() { 21 | init_func 22 | 23 | SCardEndTransaction(hCard, SCARD_LEAVE_CARD); 24 | 25 | exit_func 26 | } 27 | -------------------------------------------------------------------------------- /libs/shared/src/PCSC/CardLocker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "PCSC/Token.h" 6 | #include "Util/SyncroMutex.h" 7 | 8 | class CCardLocker { 9 | SCARDHANDLE hCard; 10 | 11 | public: 12 | CCardLocker(SCARDHANDLE card); 13 | ~CCardLocker(void); 14 | void Lock(); 15 | void Unlock(); 16 | }; 17 | -------------------------------------------------------------------------------- /libs/shared/src/PCSC/PCSC.h: -------------------------------------------------------------------------------- 1 | #ifndef PCSC_H 2 | #define PCSC_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "Util/Array.h" 12 | 13 | #ifndef SCARD_PROTOCOL_Tx 14 | #define SCARD_PROTOCOL_Tx SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1 15 | #endif 16 | 17 | class safeConnection { 18 | public: 19 | SCARDCONTEXT hContext; 20 | SCARDHANDLE hCard; 21 | safeConnection(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode); 22 | safeConnection(SCARDHANDLE hCard); 23 | ~safeConnection(); 24 | operator SCARDHANDLE(); 25 | }; 26 | 27 | class safeTransaction { 28 | SCARDHANDLE hCard; 29 | bool locked; 30 | DWORD dwDisposition; 31 | 32 | public: 33 | safeTransaction(safeConnection &conn, DWORD dwDisposition); 34 | void unlock(); 35 | bool isLocked(); 36 | ~safeTransaction(); 37 | }; 38 | 39 | class readerMonitor { 40 | SCARDCONTEXT hContext; 41 | std::thread Thread; 42 | void *appData; 43 | void (*readerEvent)(std::string &reader, bool insert, void *appData); 44 | bool stopMonitor; 45 | 46 | public: 47 | readerMonitor(void (*readerEvent)(std::string &reader, bool insert, 48 | void *appData), 49 | void *appData); 50 | ~readerMonitor(); 51 | }; 52 | #endif // PCSC_H 53 | -------------------------------------------------------------------------------- /libs/shared/src/PCSC/Token.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "PCSC/APDU.h" 7 | #include "Util/SyncroMutex.h" 8 | 9 | extern SCARDCONTEXT hContext; 10 | 11 | enum CardPSO { Op_PSO_DEC, Op_PSO_ENC, Op_PSO_CDS }; 12 | 13 | class CCardLocker; 14 | class CToken { 15 | public: 16 | typedef HRESULT (*TokenTransmitCallback)(void *data, uint8_t *apdu, 17 | DWORD apduSize, uint8_t *resp, 18 | DWORD *respSize); 19 | 20 | private: 21 | TokenTransmitCallback transmitCallback; 22 | void *transmitCallbackData; 23 | 24 | public: 25 | CToken(); 26 | ~CToken(); 27 | 28 | void SelectMF(); 29 | ByteDynArray BinaryRead(WORD start, BYTE size); 30 | void Reset(bool unpower = false); 31 | 32 | void setTransmitCallback(TokenTransmitCallback func, void *data); 33 | void setTransmitCallbackData(void *data); 34 | void *getTransmitCallbackData(); 35 | StatusWord Transmit(APDU &apdu, ByteDynArray *resp); 36 | StatusWord Transmit(ByteArray apdu, ByteDynArray *resp); 37 | }; 38 | -------------------------------------------------------------------------------- /libs/shared/src/PKCS11/cryptoki.h: -------------------------------------------------------------------------------- 1 | /* cryptoki.h include file for PKCS #11. */ 2 | /* $Revision: 1.4 $ */ 3 | 4 | /* License to copy and use this software is granted provided that it is 5 | * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface 6 | * (Cryptoki)" in all material mentioning or referencing this software. 7 | 8 | * License is also granted to make and use derivative works provided that 9 | * such works are identified as "derived from the RSA Security Inc. PKCS #11 10 | * Cryptographic Token Interface (Cryptoki)" in all material mentioning or 11 | * referencing the derived work. 12 | 13 | * RSA Security Inc. makes no representations concerning either the 14 | * merchantability of this software or the suitability of this software for 15 | * any particular purpose. It is provided "as is" without express or implied 16 | * warranty of any kind. 17 | */ 18 | 19 | /* This is a sample file containing the top level include directives 20 | * for building Win32 Cryptoki libraries and applications. 21 | */ 22 | 23 | #ifndef ___CRYPTOKI_H_INC___ 24 | #define ___CRYPTOKI_H_INC___ 25 | 26 | #define CK_IMPORT_SPEC 27 | #define CK_EXPORT_SPEC 28 | #define CK_CALL_SPEC 29 | 30 | #define CK_DEFINE_FUNCTION(returnType, name) \ 31 | returnType CK_EXPORT_SPEC CK_CALL_SPEC name 32 | 33 | #define CK_DECLARE_FUNCTION(returnType, name) \ 34 | returnType CK_EXPORT_SPEC CK_CALL_SPEC name 35 | 36 | #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ 37 | returnType CK_IMPORT_SPEC(CK_CALL_SPEC* name) 38 | 39 | #define CK_CALLBACK_FUNCTION(returnType, name) returnType(*name) 40 | 41 | #ifndef NULL_PTR 42 | #define NULL_PTR 0 43 | #endif 44 | 45 | #include "PKCS11/pkcs11.h" 46 | 47 | #endif /* ___CRYPTOKI_H_INC___ */ 48 | -------------------------------------------------------------------------------- /libs/shared/src/Sign/CIEEngine.h: -------------------------------------------------------------------------------- 1 | // 2 | // CIEEngine.h 3 | // CIESDK 4 | // 5 | // Created by ugo chirico on 26.02.2020. 6 | // 7 | 8 | #ifndef CIEEngine_h 9 | #define CIEEngine_h 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | typedef short (*sign)(unsigned char* tosign, size_t len, 17 | unsigned char* signature, size_t* psiglen); 18 | 19 | void engine_load_cie(sign sign_cb); 20 | 21 | #endif /* CIEEngine_h */ 22 | -------------------------------------------------------------------------------- /libs/shared/src/Util/CacheLib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | bool CacheExists(const char *PAN); 7 | void CacheGetCertificate(const char *PAN, std::vector &certificate); 8 | void CacheGetPIN(const char *PAN, std::vector &PIN); 9 | void CacheSetData(const char *PAN, uint8_t *certificate, int certificateSize, 10 | uint8_t *FirstPIN, int FirstPINSize); 11 | bool CacheRemove(const char *PAN); 12 | -------------------------------------------------------------------------------- /libs/shared/src/Util/IniSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Sign/definitions.h" 6 | #include "Util/Array.h" 7 | 8 | class IniSettings; 9 | extern std::vector _iniSettings; 10 | 11 | class IniSettings { 12 | public: 13 | int typeId; 14 | std::string section; 15 | std::string name; 16 | std::string description; 17 | 18 | IniSettings(int typeId, const char* section, const char* name, 19 | const char* description); 20 | int GetTypeId(); 21 | virtual ~IniSettings(); 22 | }; 23 | 24 | class IniSettingsInt : public IniSettings { 25 | public: 26 | int defaultVal; 27 | IniSettingsInt(const char* section, const char* name, int defaultValue, 28 | const char* description); 29 | ~IniSettingsInt(); 30 | int GetValue(const char* fileName); 31 | }; 32 | 33 | class IniSettingsString : public IniSettings { 34 | public: 35 | std::string defaultVal; 36 | IniSettingsString(const char* section, const char* name, 37 | const char* defaultValue, const char* description); 38 | ~IniSettingsString(); 39 | void GetValue(const char* fileName, std::string& value); 40 | }; 41 | 42 | class IniSettingsBool : public IniSettings { 43 | public: 44 | bool defaultVal; 45 | IniSettingsBool(const char* section, const char* name, bool defaultValue, 46 | const char* description); 47 | ~IniSettingsBool(); 48 | bool GetValue(const char* fileName); 49 | }; 50 | 51 | class IniSettingsByteArray : public IniSettings { 52 | public: 53 | ByteDynArray defaultVal; 54 | IniSettingsByteArray(const char* section, const char* name, 55 | ByteArray defaultValue, const char* description); 56 | ~IniSettingsByteArray(); 57 | void GetValue(const char* fileName, ByteDynArray& value); 58 | }; 59 | 60 | class IniSettingsB64 : public IniSettings { 61 | public: 62 | ByteDynArray defaultVal; 63 | IniSettingsB64(const char* section, const char* name, ByteArray defaultValue, 64 | const char* description); 65 | IniSettingsB64(const char* section, const char* name, 66 | const char* defaultValueB64, const char* description); 67 | ~IniSettingsB64(); 68 | void GetValue(const char* fileName, ByteDynArray& value); 69 | }; 70 | 71 | extern "C" { 72 | int GetNumIniSettings(); 73 | int GetIniSettings(int i, void* data); 74 | } 75 | -------------------------------------------------------------------------------- /libs/shared/src/Util/ModuleInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "ModuleInfo.h" 2 | 3 | #include "Util/UtilException.h" 4 | 5 | CModuleInfo::CModuleInfo() {} 6 | 7 | HANDLE CModuleInfo::getApplicationModule() { return 0; } 8 | 9 | HANDLE CModuleInfo::getModule() { return module; } 10 | 11 | void CModuleInfo::init(HANDLE module) { this->module = module; } 12 | 13 | CModuleInfo::~CModuleInfo(void) {} 14 | -------------------------------------------------------------------------------- /libs/shared/src/Util/ModuleInfo.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Util/util.h" 4 | 5 | class CModuleInfo { 6 | HANDLE module; 7 | 8 | public: 9 | std::string szModuleFullPath; 10 | std::string szModulePath; 11 | std::string szModuleName; 12 | 13 | CModuleInfo(void); 14 | virtual ~CModuleInfo(void); 15 | static HANDLE getApplicationModule(); 16 | HANDLE getModule(); 17 | void init(HANDLE module); 18 | }; 19 | -------------------------------------------------------------------------------- /libs/shared/src/Util/SyncroEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "SyncroEvent.h" 2 | 3 | void auto_reset_event::set() { 4 | { 5 | std::unique_lock lock(m_); 6 | signaled_ = true; 7 | } 8 | 9 | cv_.notify_one(); 10 | } 11 | 12 | void auto_reset_event::wait() { 13 | std::unique_lock lock(m_); 14 | while (!signaled_) cv_.wait(lock); 15 | signaled_ = false; 16 | } 17 | -------------------------------------------------------------------------------- /libs/shared/src/Util/SyncroEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class auto_reset_event { 7 | public: 8 | auto_reset_event(bool signaled = false) : signaled_(signaled) {} 9 | 10 | void set(); 11 | void wait(); 12 | 13 | private: 14 | std::mutex m_; 15 | std::condition_variable cv_; 16 | bool signaled_; 17 | }; 18 | -------------------------------------------------------------------------------- /libs/shared/src/Util/SyncroMutex.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "SyncroMutex.h" 3 | 4 | #include "Util/util.h" 5 | 6 | CSyncroMutex::CSyncroMutex(void) { hMutex = NULL; } 7 | 8 | void CSyncroMutex::Create(void) {} 9 | 10 | void CSyncroMutex::Create(const char *szName) {} 11 | 12 | CSyncroMutex::~CSyncroMutex(void) {} 13 | 14 | void CSyncroMutex::Lock() {} 15 | 16 | void CSyncroMutex::Unlock() {} 17 | 18 | CSyncroLocker::CSyncroLocker(CSyncroMutex &mutex) {} 19 | 20 | CSyncroLocker::~CSyncroLocker() {} 21 | -------------------------------------------------------------------------------- /libs/shared/src/Util/SyncroMutex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Util/UtilException.h" 3 | #include "Util/util.h" 4 | 5 | class CSyncroMutex { 6 | HANDLE hMutex; 7 | 8 | public: 9 | void Create(void); 10 | 11 | CSyncroMutex(void); 12 | void Create(const char *name); 13 | ~CSyncroMutex(void); 14 | 15 | void Lock(); 16 | void Unlock(); 17 | }; 18 | 19 | class CSyncroLocker { 20 | public: 21 | CSyncroLocker(CSyncroMutex &mutex); 22 | ~CSyncroLocker(); 23 | }; 24 | -------------------------------------------------------------------------------- /libs/shared/src/Util/TLV.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Util/Array.h" 5 | 6 | typedef std::map tlvMap; 7 | typedef std::map tlvCreateMap; 8 | 9 | class CTLV { 10 | tlvMap map; 11 | 12 | public: 13 | CTLV(ByteArray &data); 14 | ~CTLV(); 15 | ByteArray getValue(uint8_t Tag); 16 | ByteArray *getTAG(uint8_t Tag); 17 | }; 18 | 19 | class CTLVCreate { 20 | public: 21 | tlvCreateMap map; 22 | 23 | CTLVCreate(); 24 | ~CTLVCreate(); 25 | ByteDynArray *addValue(uint8_t Tag); 26 | ByteDynArray *getValue(uint8_t Tag); 27 | void setValue(uint8_t Tag, ByteArray &Value); 28 | ByteDynArray getBuffer(); 29 | }; 30 | -------------------------------------------------------------------------------- /libs/shared/src/Util/UUCByteArray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2018 by Ugo Chirico - http://www.ugochirico.com 3 | * All Rights Reserved 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #pragma once 21 | #include "Sign/definitions.h" 22 | 23 | #define ERR_INDEX_OUT_OF_BOUND 0xC0001001L 24 | 25 | class UUCByteArray { 26 | public: 27 | UUCByteArray(const BYTE* pbtContent, const unsigned long unLen); 28 | UUCByteArray(const UUCByteArray& blob); 29 | UUCByteArray(const char* szHexString); 30 | UUCByteArray(const unsigned long nLen); 31 | UUCByteArray(); 32 | 33 | long load(const char* szHexString); 34 | 35 | virtual ~UUCByteArray(); 36 | 37 | const BYTE* getContent() const; 38 | unsigned long getLength() const; 39 | 40 | long reverse(); 41 | long append(const BYTE btVal); 42 | long append(const BYTE* pbtVal, const unsigned long nLen); 43 | long append(const UUCByteArray& val); 44 | long append(const char* szHexString); 45 | BYTE get(const unsigned int index) const; // throw(long); 46 | void set(const unsigned int index, const BYTE btVal); // throw (long); 47 | BYTE operator[](const unsigned int index) const; // throw(long); 48 | void remove(const unsigned int index); // throw(long); 49 | void removeAll(); 50 | // void toHexString(char* szHex) const; 51 | const char* toHexString(); 52 | const char* toHexString(int nSize); 53 | 54 | private: 55 | BYTE* m_pbtContent; 56 | unsigned long m_unLen; 57 | unsigned long m_nCapacity; 58 | char* m_szHex; 59 | }; 60 | -------------------------------------------------------------------------------- /libs/shared/src/Util/UUCProperties.h: -------------------------------------------------------------------------------- 1 | /* UUCProperties.h: interface for the UUCProperties class. 2 | * 3 | * Copyright (c) 2000-2018 by Ugo Chirico - http://www.ugochirico.com 4 | * All Rights Reserved 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined( \ 22 | AFX_UUCPROPERTIES_H__715BAE3B_069E_4D31_9FBF_54EA38AAEFEC__INCLUDED_) 23 | #define AFX_UUCPROPERTIES_H__715BAE3B_069E_4D31_9FBF_54EA38AAEFEC__INCLUDED_ 24 | 25 | #include 26 | 27 | #include "UUCStringTable.h" 28 | #include "Util/UUCByteArray.h" 29 | 30 | class UUCProperties { 31 | public: 32 | UUCProperties(); 33 | UUCProperties(const UUCProperties& defaults); 34 | 35 | virtual ~UUCProperties(); 36 | 37 | long load(const char* szFilePath); 38 | long load(const UUCByteArray& props); 39 | void putProperty(const char* szName, const char* szValue); 40 | const char* getProperty(const char* szName, 41 | const char* szDefaultValue = NULL) const; 42 | int getIntProperty(const char* szName, int nDefaultValue = 0) const; 43 | 44 | void remove(const char* szName); 45 | void removeAll(); 46 | 47 | UUCStringTable* getPropertyTable() const; 48 | 49 | bool contains(const char* szName) const; 50 | 51 | int size() const; 52 | 53 | protected: 54 | UUCStringTable* m_pStringTable; 55 | 56 | bool m_bAllocated; 57 | }; 58 | 59 | #endif // !defined(AFX_UUCPROPERTIES_H__715BAE3B_069E_4D31_9FBF_54EA38AAEFEC__INCLUDED_) 60 | -------------------------------------------------------------------------------- /libs/shared/src/Util/UUCStringTable.h: -------------------------------------------------------------------------------- 1 | /* UUCStringTable.h: interface for the UUCStringTable class. 2 | * 3 | * Copyright (c) 2000-2018 by Ugo Chirico - http://www.ugochirico.com 4 | * All Rights Reserved 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined( \ 22 | AFX_UUCSTRINGTABLE_H__4392B6C2_89AA_436D_8291_A3D22CFF877B__INCLUDED_) 23 | #define AFX_UUCSTRINGTABLE_H__4392B6C2_89AA_436D_8291_A3D22CFF877B__INCLUDED_ 24 | 25 | #include "UUCHashtable.hpp" 26 | 27 | class UUCStringTable : public UUCHashtable { 28 | public: 29 | void remove(); 30 | // contructors 31 | UUCStringTable(); 32 | UUCStringTable(int initialCapacity, float loadFactor); 33 | UUCStringTable(int initialCapacity); 34 | 35 | virtual void put(char* const& szKey, char* const& szValue); 36 | virtual bool remove(char* const& szKey); 37 | 38 | static unsigned long getHash(const char* szKey); 39 | 40 | // destructor 41 | virtual ~UUCStringTable(); 42 | 43 | protected: 44 | // virtual unsigned long getHashValue(unsigned long szKey); 45 | virtual unsigned long getHashValue(char* const& szKey) const; 46 | virtual bool equal(char* const& szKey1, char* const& szKey2) const; 47 | 48 | // virtual UINT getHashValue(const char*& szKey); 49 | }; 50 | 51 | #endif // !defined(AFX_UUCSTRINGTABLE_H__4392B6C2_89AA_436D_8291_A3D22CFF877B__INCLUDED_) 52 | -------------------------------------------------------------------------------- /libs/shared/src/Util/UUCTextFileReader.h: -------------------------------------------------------------------------------- 1 | /* UUCTextFile.h: interface for the UUCTextFile class. 2 | * Copyright (c) 2000-2018 by Ugo Chirico - http://www.ugochirico.com 3 | * All Rights Reserved 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #if !defined(AFX_UUCTEXTFILE_H__CD3660A5_B4C5_4CD4_99AC_69AC96D1460F__INCLUDED_) 21 | #define AFX_UUCTEXTFILE_H__CD3660A5_B4C5_4CD4_99AC_69AC96D1460F__INCLUDED_ 22 | 23 | #include 24 | 25 | #include "Util/UUCByteArray.h" 26 | 27 | class UUCTextFileReader { 28 | public: 29 | UUCTextFileReader(const char* szFilePath); 30 | virtual ~UUCTextFileReader(); 31 | 32 | long readLine(char* szLine, unsigned long nLen); // throw (long); 33 | long readLine(UUCByteArray& line); 34 | 35 | private: 36 | FILE* m_pf; 37 | }; 38 | 39 | #endif // !defined(AFX_UUCTEXTFILE_H__CD3660A5_B4C5_4CD4_99AC_69AC96D1460F__INCLUDED_) 40 | -------------------------------------------------------------------------------- /libs/shared/src/Util/UtilException.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "defines.h" 7 | 8 | class logged_error : public std::runtime_error { 9 | public: 10 | logged_error(std::string message); 11 | logged_error(const char *message); 12 | }; 13 | 14 | class scard_error : public logged_error { 15 | public: 16 | StatusWord sw; 17 | scard_error(StatusWord sw); 18 | }; 19 | 20 | class windows_error : logged_error { 21 | public: 22 | windows_error(long ris); 23 | }; 24 | -------------------------------------------------------------------------------- /libs/shared/src/Util/funccallinfo.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Util/funccallinfo.h" 3 | 4 | #include 5 | 6 | thread_local size_t tlsCallDepth = 0; 7 | thread_local std::unique_ptr callQueue = nullptr; 8 | extern bool FunctionLog; 9 | extern unsigned int GlobalDepth; 10 | extern bool GlobalParam; 11 | char szEmpty[] = {'\0'}; 12 | 13 | CFuncCallInfo::CFuncCallInfo(const char *name, CLog &logInfo) : log(logInfo) { 14 | fName = name; 15 | if (FunctionLog) { 16 | if (tlsCallDepth < GlobalDepth) { 17 | LogNum = 18 | logInfo.write("%*sIN -> %s", (DWORD)tlsCallDepth, szEmpty, fName); 19 | } 20 | } 21 | 22 | tlsCallDepth = tlsCallDepth + 1; 23 | } 24 | 25 | CFuncCallInfo::~CFuncCallInfo() { 26 | tlsCallDepth = tlsCallDepth - 1; 27 | if (fName) 28 | log.write("%*sOUT -> %s (%u)", (DWORD)tlsCallDepth, szEmpty, fName, 29 | LogNum - 1); 30 | } 31 | 32 | const char *CFuncCallInfo::FunctionName() { return fName; } 33 | -------------------------------------------------------------------------------- /libs/shared/src/Util/funccallinfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Util/log.h" 6 | 7 | class CFuncCallInfo { 8 | const char *fName; 9 | unsigned int LogNum; 10 | CLog &log; 11 | 12 | public: 13 | CFuncCallInfo(const char *name, CLog &logInfo); 14 | ~CFuncCallInfo(); 15 | 16 | const char *FunctionName(); 17 | }; 18 | 19 | class CFuncCallInfoList { 20 | public: 21 | CFuncCallInfoList(CFuncCallInfo *info) : info(info) {} 22 | CFuncCallInfo *info; 23 | std::unique_ptr next = nullptr; 24 | }; 25 | -------------------------------------------------------------------------------- /libs/shared/src/Util/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #ifndef OutputDebugString 10 | #define OutputDebugString printf 11 | #endif 12 | 13 | class CLog { 14 | public: 15 | unsigned int LogCount; 16 | bool Initialized; 17 | bool Enabled; 18 | bool FunctionLog; 19 | bool LogParam; 20 | unsigned int ModuleNum; 21 | std::string logDir; 22 | std::string logPath; 23 | std::string logName; 24 | std::string logFileName; 25 | std::string::iterator threadPos; 26 | std::string logVersion; 27 | bool FirstLog; 28 | 29 | bool _stack_logged; 30 | 31 | CLog(void); 32 | ~CLog(void); 33 | DWORD write(const char *format, ...); 34 | void writePure(const char *format, ...); 35 | void writeBinData(uint8_t *data, size_t datalen); 36 | void init(); 37 | void dumpErr(); 38 | }; 39 | 40 | void initLog(const char *moduleName, const char *iniFile, const char *version); 41 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/Base64.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006-2007, Philip Busch 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 17 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | * POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | /** 27 | * @file 28 | * Base64 header. 29 | * @ingroup base64 30 | */ 31 | 32 | #ifndef _BASE64_H 33 | #define _BASE64_H 34 | 35 | void base64_encode_block(unsigned char out[4], const unsigned char in[3], 36 | int len); 37 | int base64_decode_block(unsigned char out[3], const unsigned char in[4]); 38 | int base64_encoded_size(int len); 39 | int base64_decoded_size(int len); 40 | void base64_encode_binary(char *out, const unsigned char *in, int len); 41 | int base64_decode_binary(unsigned char *out, const char *in); 42 | char *base64_encode(const char *in, int size); 43 | char *base64_decode(const char *in); 44 | 45 | #endif /* ! _BASE64_H */ 46 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/BaseSigner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ASN1/Certificate.h" 4 | 5 | class CBaseSigner { 6 | public: 7 | virtual ~CBaseSigner() {}; // make destructor virtual 8 | 9 | virtual long GetCertificate(const char* alias, CCertificate** ppCertificate, 10 | UUCByteArray& id) = 0; 11 | 12 | virtual long Sign(UUCByteArray& data, UUCByteArray& id, int algo, 13 | UUCByteArray& signature) = 0; 14 | 15 | virtual long Close() = 0; 16 | }; 17 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/BigIntegerAlgorithms.h: -------------------------------------------------------------------------------- 1 | #ifndef BIGINTEGERALGORITHMS_H 2 | #define BIGINTEGERALGORITHMS_H 3 | 4 | #include "BigInteger.h" 5 | 6 | /* Some mathematical algorithms for big integers. 7 | * This code is new and, as such, experimental. */ 8 | 9 | // Returns the greatest common divisor of a and b. 10 | BigUnsigned gcd(BigUnsigned a, BigUnsigned b); 11 | 12 | /* Extended Euclidean algorithm. 13 | * Given m and n, finds gcd g and numbers r, s such that r*m + s*n == g. */ 14 | void extendedEuclidean(BigInteger m, BigInteger n, BigInteger &g, BigInteger &r, 15 | BigInteger &s); 16 | 17 | /* Returns the multiplicative inverse of x modulo n, or throws an exception if 18 | * they have a common factor. */ 19 | BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n); 20 | 21 | // Returns (base ^ exponent) % modulus. 22 | BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent, 23 | const BigUnsigned &modulus); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/BigIntegerLibrary.h: -------------------------------------------------------------------------------- 1 | // This header file includes all of the library header files. 2 | 3 | #include "BigInteger.h" 4 | #include "BigIntegerAlgorithms.h" 5 | #include "BigIntegerUtils.h" 6 | #include "BigUnsigned.h" 7 | #include "BigUnsignedInABase.h" 8 | #include "NumberlikeArray.h" 9 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/CIEEngineHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // CIEEngineHelper.h 3 | // CIESDK 4 | // 5 | // Created by ugo chirico on 26.02.2020. 6 | // 7 | 8 | #ifndef CIEEngineHelper_h 9 | #define CIEEngineHelper_h 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | void alloc_rsa_ex_index(void); 16 | void free_rsa_ex_index(void); 17 | RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); 18 | int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); 19 | int RSA_meth_set_flags(RSA_METHOD *meth, int flags); 20 | int RSA_meth_set_priv_enc(RSA_METHOD *meth, 21 | int (*priv_enc)(int flen, const unsigned char *from, 22 | unsigned char *to, RSA *rsa, 23 | int padding)); 24 | int RSA_meth_set_priv_dec(RSA_METHOD *meth, 25 | int (*priv_dec)(int flen, const unsigned char *from, 26 | unsigned char *to, RSA *rsa, 27 | int padding)); 28 | 29 | int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa)); 30 | 31 | #endif /* CIEEngineHelper_h */ 32 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/CIESigner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ASN1/Certificate.h" 4 | #include "ASN1/RSAPrivateKey.h" 5 | #include "BaseSigner.h" 6 | #include "CSP/IAS.h" 7 | 8 | class CCIESigner : public CBaseSigner { 9 | public: 10 | CCIESigner(IAS* pIAS); 11 | virtual ~CCIESigner(void); 12 | 13 | long Init(const char* szPIN); 14 | 15 | virtual long GetCertificate(const char* alias, CCertificate** ppCertificate, 16 | UUCByteArray& id); 17 | 18 | virtual long Sign(UUCByteArray& data, UUCByteArray& id, int algo, 19 | UUCByteArray& signature); 20 | 21 | virtual long Close(); 22 | 23 | private: 24 | IAS* m_pIAS; 25 | char m_szPIN[9]; 26 | CCertificate* m_pCertificate; 27 | }; 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/CertStore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "ASN1/Certificate.h" 6 | 7 | using namespace std; 8 | 9 | class CCertStore { 10 | public: 11 | static void AddCertificate(CCertificate& caCertificate); 12 | 13 | static CCertificate* GetCertificate(CCertificate& certificate); 14 | 15 | static void CleanUp(); 16 | 17 | private: 18 | static map m_certMap; 19 | }; 20 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/CounterSignatureGenerator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CounterSignatureGenerator.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 13/07/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | // #include "ASN1/utiltypes.h" 11 | #include "SignedDocument.h" 12 | #include "SignerInfoGenerator.h" 13 | #include "Util/UUCByteArray.h" 14 | 15 | class CounterSignatureGenerator { 16 | public: 17 | CounterSignatureGenerator(CSignedDocument& signedDoc, int signerInfoIndex); 18 | 19 | virtual ~CounterSignatureGenerator(); 20 | 21 | void getContent(UUCByteArray& content); 22 | 23 | void setContentHash(const BYTE* hash, int hashlen); 24 | 25 | void setSigningCertificate(const BYTE* certificate, int certlen, 26 | const BYTE* certHash, int certHashLen); 27 | 28 | void setSignature(const BYTE* signature, int siglen); 29 | 30 | void setTimestampToken(const BYTE* timestampToken, int tstlen); 31 | 32 | void getSignedAttributes(UUCByteArray& signedAttribute); 33 | 34 | void toByteArray(UUCByteArray& signedDoc); 35 | 36 | private: 37 | CSignedDocument m_signedDoc; 38 | CSignerInfo m_signerInfo; 39 | int m_signerInfoIndex; 40 | 41 | UUCByteArray m_signingCertificate; 42 | CASN1SetOf m_signerInfos; // = new DerSet(signerInfos); 43 | CASN1SetOf m_certificates; // = new DerSet(certificates); 44 | CASN1SetOf m_digestAlgos; // = new DerSet(certificates); 45 | 46 | CSignerInfoGenerator m_signerInfoGenerator; 47 | }; 48 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/LdapCrl.h: -------------------------------------------------------------------------------- 1 | // 2 | // LdapCrl.h 3 | // iDigitalSApp 4 | // 5 | // Created by svp on 02/04/12. 6 | // Copyright 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | long getCRLFromLDAP(char* url, UUCByteArray& data); 10 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/M7MParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * M7MParser.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 05/09/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #ifndef _M7MPARSER_H_ 11 | #define _M7MPARSER_H_ 12 | 13 | #include 14 | 15 | #include "Util/UUCByteArray.h" 16 | 17 | using namespace std; 18 | 19 | class M7MParser { 20 | public: 21 | M7MParser(); 22 | 23 | int Load(const char* m7m, int m7mlen); 24 | 25 | int GetP7M(UUCByteArray& p7m); 26 | 27 | int GetTSR(UUCByteArray& tsr); 28 | 29 | private: 30 | UUCByteArray m_p7m; 31 | UUCByteArray m_tsr; 32 | }; 33 | 34 | #endif //_M7MPARSER_H_ 35 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/PdfVerifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PdfVerifier.h 3 | * SignPoDoFo 4 | * 5 | * Created by svp on 26/05/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #ifndef _PDFVERIFIER_H_ 11 | #define _PDFVERIFIER_H_ 12 | 13 | #include 14 | #if PODOFO_VERSION_MAJOR < 1 15 | #if PODOFO_VERSION_MINOR < 10 16 | #include 17 | #include 18 | #endif 19 | #else 20 | #error PoDoFo version not supported (yet) 21 | #endif 22 | #include "Sign/disigonsdk.h" 23 | #include "Util/UUCByteArray.h" 24 | 25 | using namespace PoDoFo; 26 | using namespace std; 27 | 28 | typedef struct _SignatureAppearanceInfo { 29 | int left; 30 | int bottom; 31 | int width; 32 | int heigth; 33 | } SignatureAppearanceInfo; 34 | 35 | class PDFVerifier { 36 | public: 37 | PDFVerifier(); 38 | 39 | virtual ~PDFVerifier(); 40 | 41 | int Load(const char* pdf, int len); 42 | int Load(const char* szFilePath); 43 | 44 | int GetNumberOfSignatures(); 45 | 46 | int VerifySignature(size_t index, const char* szDate, char* signatureType, 47 | REVOCATION_INFO* pRevocationInfo); 48 | 49 | int GetSignature(size_t index, UUCByteArray& signedDocument, 50 | SignatureAppearanceInfo& appearanceInfo); 51 | 52 | static int GetNumberOfSignatures(PdfMemDocument* pPdfDocument); 53 | static int GetNumberOfSignatures(const char* szFilePath); 54 | 55 | private: 56 | UUCByteArray m_data; 57 | static bool IsSignatureField(const PdfMemDocument* pDoc, 58 | const PdfObject* const pObj); 59 | 60 | int VerifySignature(const PdfMemDocument* pDoc, const PdfObject* const pObj, 61 | const char* szDate, char* signatureType, 62 | REVOCATION_INFO* pRevocationInfo); 63 | 64 | int GetSignature(const PdfMemDocument* pDoc, const PdfObject* const pObj, 65 | UUCByteArray& signedDocument, 66 | SignatureAppearanceInfo& appearanceInfo); 67 | 68 | PdfMemDocument* m_pPdfMemDocument; 69 | 70 | int m_actualLen; 71 | 72 | char* m_szDocBuffer; 73 | }; 74 | 75 | #endif //_PDFVERIFIER_H 76 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/SignatureGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ASN1/SignerInfo.h" 4 | #include "BaseSigner.h" 5 | #include "PKCS11/cryptoki.h" 6 | #include "Sign/definitions.h" 7 | #include "SignedDocument.h" 8 | #include "SignerInfoGenerator.h" 9 | #include "TSAClient.h" 10 | 11 | #define ALGO_SHA1 1 12 | #define ALGO_SHA256 2 13 | 14 | class CSignatureGeneratorBase { 15 | protected: 16 | CSignatureGeneratorBase(CBaseSigner* pCryptoki); 17 | CSignatureGeneratorBase(CSignatureGeneratorBase* pGenerator); 18 | virtual ~CSignatureGeneratorBase(void); 19 | 20 | public: 21 | virtual void SetData(const UUCByteArray& data); 22 | 23 | virtual void SetAlias(char* alias); 24 | 25 | virtual void SetHashAlgo(int hashAlgo); 26 | 27 | virtual void SetTSA(char* szUrl, char* szUsername, char* szPassword); 28 | virtual void SetTSAUsername(char* szUsername); 29 | virtual void SetTSAPassword(char* szPassword); 30 | 31 | virtual long Generate(UUCByteArray& pkcs7SignedData, BOOL bDetached = FALSE, 32 | BOOL bVerifyRevocation = FALSE) = 0; 33 | 34 | protected: 35 | CBaseSigner* m_pSigner; 36 | UUCByteArray m_data; 37 | int m_nHashAlgo; 38 | char m_szAlias[MAX_PATH]; 39 | CTSAClient* m_pTSAClient; 40 | }; 41 | 42 | class CSignatureGenerator : public CSignatureGeneratorBase { 43 | public: 44 | CSignatureGenerator(CBaseSigner* pSigner, bool bRemote = false); 45 | virtual ~CSignatureGenerator(void); 46 | 47 | void SetPKCS7Data(const UUCByteArray& pkcs7Data); 48 | 49 | void SetCAdES(bool cades); 50 | bool GetCAdES(); 51 | 52 | long GetCertificate(CCertificate** ppCertificate); 53 | virtual long Generate(UUCByteArray& pkcs7SignedData, BOOL bDetached = FALSE, 54 | BOOL bVerifyRevocation = FALSE); 55 | 56 | private: 57 | bool m_bCAdES; 58 | bool m_bRemote; 59 | 60 | CASN1SetOf m_signerInfos; // = new DerSet(signerInfos); 61 | CASN1SetOf m_certificates; // = new DerSet(certificates); 62 | CASN1SetOf m_digestAlgos; // = new DerSet(certificates); 63 | 64 | CSignerInfoGenerator m_signerInfoGenerator; 65 | }; 66 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/SignedDataGeneratorEx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SignedDataGenerator.h 3 | * iDigitalS 4 | * 5 | * Created by svp on 05/07/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | // #include "ASN1/utiltypes.h" 11 | #include 12 | 13 | #include "ASN1/ASN1Setof.h" 14 | #include "ASN1/SignerInfo.h" 15 | #include "ASN1/TimeStampResponse.h" 16 | #include "SignedDocument.h" 17 | #include "Util/UUCByteArray.h" 18 | 19 | class SignedDataGeneratorEx { 20 | public: 21 | SignedDataGeneratorEx(CSignedDocument& sd); 22 | 23 | virtual ~SignedDataGeneratorEx(); 24 | 25 | bool isDetached(); 26 | 27 | void setContent(const BYTE* content, int len); 28 | 29 | void addSigners(CSignedDocument& sd); 30 | 31 | void addCounterSignature(CSignerInfo& signerInfoRef, 32 | CSignedDocument& countersignature); 33 | 34 | void addCounterSignature(CSignerInfo& signerInfoRef, 35 | CSignedDocument& counterSignature, 36 | CTimeStampResponse& tsr); 37 | 38 | void setTimestamp(CTimeStampResponse& tsr, int signerInfoIndex); 39 | 40 | void toByteArray(UUCByteArray& pkcs7SignedData); 41 | 42 | private: 43 | UUCByteArray m_content; 44 | 45 | CASN1SetOf m_signerInfos; 46 | CASN1SetOf m_certificates; 47 | CASN1SetOf m_digestAlgos; 48 | 49 | bool addCounterSignature(CSignerInfo& signerInfo, CSignerInfo& signerInfoRef, 50 | CSignerInfo& counterSignature); 51 | }; 52 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/SignedDocument.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SignedDocument.h 3 | * iDigitalS 4 | * 5 | * Created by svp on 05/07/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #include 11 | 12 | #include "ASN1/ContentInfo.h" 13 | #include "ASN1/SignedData.h" 14 | #include "ASN1/SignerInfo.h" 15 | #include "Sign/definitions.h" 16 | #include "Sign/disigonsdk.h" 17 | #include "Util/UUCByteArray.h" 18 | 19 | class CSignedDocument { 20 | public: 21 | CSignedDocument(const BYTE* content, int len); 22 | CSignedDocument(const CSignedDocument& signedDocument); 23 | 24 | virtual ~CSignedDocument(); 25 | 26 | int verify(); 27 | int verify(const char* dateTime); 28 | int verify(int index, REVOCATION_INFO* pRevocationInfo); 29 | int verify(int index, const char* dateTime, REVOCATION_INFO* pRevocationInfo); 30 | 31 | int getSignerCount(); 32 | CASN1SetOf getSignerInfos(); 33 | CASN1SetOf getCertificates(); 34 | CASN1SetOf getDigestAlgos(); 35 | 36 | CSignerInfo getSignerInfo(int index); 37 | CCertificate getSignerCertificate(int index); 38 | void getContent(UUCByteArray& content); 39 | 40 | // static void init(map certMap); 41 | 42 | void makeDetached(); 43 | 44 | void toByteArray(UUCByteArray& signedData); 45 | 46 | CSignedData getSignedData(); 47 | 48 | bool isDetached(); 49 | void setContent(UUCByteArray& content); 50 | 51 | // 0 successivo al 30 Giugno 2011, 1 successivo al 30 agosto 2010, 2 52 | // precedente al 30 agosto 2010 53 | static int get452009Range(char* szDateTime); 54 | 55 | private: 56 | CContentInfo* m_pCMSSignedData; 57 | CSignedData* m_pSignedData; 58 | CASN1SetOf m_signerInfos; 59 | CASN1SetOf m_certificates; 60 | }; 61 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/SignerInfoGenerator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SignerInfoGenerator.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 11/07/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "ASN1/IssuerAndSerialNumber.h" 13 | #include "ASN1/SignerInfo.h" 14 | #include "Sign/definitions.h" 15 | #include "Util/UUCByteArray.h" 16 | 17 | class CSignerInfoGenerator { 18 | public: 19 | CSignerInfoGenerator(); 20 | 21 | virtual ~CSignerInfoGenerator(); 22 | 23 | void setContent(const BYTE* content, int len); 24 | 25 | void setContentHash(const BYTE* hash, int hashlen); 26 | 27 | void setSigningCertificate(const BYTE* certificate, int certlen, 28 | const BYTE* certHash, int certHashLen); 29 | 30 | void setSignature(const BYTE* signature, int siglen); 31 | 32 | void setTimestampToken(const BYTE* timestampToken, int tstlen); 33 | 34 | void setTimestampToken(const CTimeStampToken* pTimestampToken); 35 | 36 | void getSignedAttributes(UUCByteArray& signedAttribute, bool countersignature, 37 | bool signingTime); 38 | 39 | void toByteArray(UUCByteArray& signerInfo); 40 | 41 | CSignerInfo getSignerInfo(); 42 | 43 | private: 44 | UUCByteArray m_content; 45 | UUCByteArray m_contentHash; 46 | UUCByteArray m_signingCertificate; 47 | UUCByteArray m_signature; 48 | UUCByteArray m_signedAttributes; 49 | CASN1SetOf m_unsignedAttributes; 50 | UUCByteArray m_certificateHash; 51 | UUCByteArray m_timeStampToken; 52 | CASN1SetOf m_counterSignatures; 53 | void buildUnsignedAttributes(); 54 | CName* m_pIssuer; 55 | CASN1Integer* m_pSerialNumber; 56 | }; 57 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/TSAClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ASN1/TimeStampToken.h" 4 | 5 | class CTSAClient { 6 | public: 7 | CTSAClient(void); 8 | virtual ~CTSAClient(void); 9 | 10 | void SetTSAUrl(const char* szUrl); 11 | void SetCredential(const char* szUsername, const char* szPassword); 12 | void SetUsername(const char* szUsername); 13 | void SetPassword(const char* szPassword); 14 | long GetTimeStampToken(UUCByteArray& digest, const char* szPolicyID, 15 | CTimeStampToken** ppTimeStampToken); 16 | 17 | private: 18 | char m_szTSAUrl[256]; 19 | char m_szTSAUsername[256]; 20 | char m_szTSAPassword[256]; 21 | }; 22 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/UUCLogger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Sign/disigonsdk.h" 6 | 7 | #define MAX_LOG_SIZE 5000 8 | 9 | #define LOG_TYPE_ERROR 1 10 | #define LOG_TYPE_WARNING 2 11 | #define LOG_TYPE_MESSAGE 3 12 | #define LOG_TYPE_DEBUG 4 13 | 14 | #define DECLARE_LOG 15 | #define USE_LOG 16 | #define SET_LOG_FILE(file) 17 | #define SET_LOG_LEVEL(level) 18 | 19 | #define LOG_MSG(params) 20 | #define LOG_ERR(params) 21 | #define LOG_WAR(params) 22 | #define LOG_DBG(params) 23 | 24 | //- ------------- DA VERIFICARE, CONTIENTE MOLTI BUG 25 | 26 | // macro 27 | #if 0 28 | #define DECLARE_LOG UUCLogger g_log 29 | #define USE_LOG extern UUCLogger g_log 30 | #define SET_LOG_FILE(file) g_log.setLogFile(file) 31 | #define SET_LOG_LEVEL(level) g_log.setLogLevel(level) 32 | 33 | #define LOG_MSG(params) g_log.logMessage params 34 | #define LOG_ERR(params) g_log.logError params 35 | #define LOG_WAR(params) g_log.logWarning params 36 | #define LOG_DBG(params) g_log.logDebug params 37 | #endif 38 | 39 | class UUCLogger { 40 | public: 41 | UUCLogger(void); 42 | UUCLogger(const char* szLogFileName); 43 | virtual ~UUCLogger(void); 44 | 45 | virtual void logMessage(const unsigned int nID, const char* szModuleName, 46 | const char* szMsg, ...); 47 | virtual void logWarning(const unsigned int nID, const char* szModuleName, 48 | const char* szMsg, ...); 49 | virtual void logError(const unsigned int nID, const char* szModuleName, 50 | const char* szMsg, ...); 51 | virtual void logDebug(const unsigned int nID, const char* szModuleName, 52 | const char* szMsg, ...); 53 | 54 | virtual void setLogFile(const char* szLogFileName); 55 | virtual void setLogLevel(int logLevel); 56 | 57 | private: 58 | void log(const unsigned int nType, const char* szMsg, const unsigned int nID, 59 | const char* szModuleName); 60 | void log(const unsigned int nType, const char* szMsg, const unsigned int nID, 61 | const char* szModuleName, va_list args); 62 | 63 | char m_szLogFileName[MAX_PATH]; 64 | int m_nLogLevel; 65 | char m_szBuffer[MAX_LOG_SIZE]; 66 | }; 67 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/UUCProperties.h: -------------------------------------------------------------------------------- 1 | // UUCProperties.h: interface for the UUCProperties class. 2 | // 3 | 4 | #if !defined( \ 5 | AFX_UUCPROPERTIES_H__715BAE3B_069E_4D31_9FBF_54EA38AAEFEC__INCLUDED_) 6 | #define AFX_UUCPROPERTIES_H__715BAE3B_069E_4D31_9FBF_54EA38AAEFEC__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | #include 12 | 13 | #include "UUCStringTable.h" 14 | #include "Util/UUCByteArray.h" 15 | 16 | class UUCProperties { 17 | public: 18 | UUCProperties(); 19 | UUCProperties(const UUCProperties& defaults); 20 | 21 | virtual ~UUCProperties(); 22 | 23 | long load(const char* szFilePath); 24 | long load(const UUCByteArray& props); 25 | long save(const char* szFilePath, const char* szHeader) const; 26 | long save(UUCByteArray& props, const char* szHeader) const; 27 | void putProperty(const char* szName, const char* szValue); 28 | // void putProperty(char* szName, char* szValue); 29 | const char* getProperty(const char* szName, 30 | const char* szDefaultValue = NULL) const; 31 | void remove(const char* szName); 32 | void removeAll(); 33 | 34 | UUCStringTable* getPropertyTable() const; 35 | 36 | bool contains(const char* szName) const; 37 | 38 | int size() const; 39 | 40 | protected: 41 | UUCStringTable* m_pStringTable; 42 | 43 | bool m_bAllocated; 44 | }; 45 | 46 | #endif // !defined(AFX_UUCPROPERTIES_H__715BAE3B_069E_4D31_9FBF_54EA38AAEFEC__INCLUDED_) 47 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/UUCStringTable.h: -------------------------------------------------------------------------------- 1 | // UUCStringTable.h: interface for the UUCStringTable class. 2 | // 3 | 4 | #if !defined( \ 5 | AFX_UUCSTRINGTABLE_H__4392B6C2_89AA_436D_8291_A3D22CFF877B__INCLUDED_) 6 | #define AFX_UUCSTRINGTABLE_H__4392B6C2_89AA_436D_8291_A3D22CFF877B__INCLUDED_ 7 | 8 | #pragma once 9 | 10 | #include "UUCHashtable.h" 11 | 12 | class UUCStringTable : public UUCHashtable { 13 | public: 14 | void remove(); 15 | // contructors 16 | UUCStringTable(); 17 | UUCStringTable(int initialCapacity, float loadFactor); 18 | UUCStringTable(int initialCapacity); 19 | 20 | virtual void put(char* const& szKey, char* const& szValue); 21 | virtual bool remove(char* const& szKey); 22 | 23 | static unsigned long getHash(const char* szKey); 24 | 25 | // destructor 26 | virtual ~UUCStringTable(); 27 | 28 | protected: 29 | // virtual unsigned long getHashValue(unsigned long szKey); 30 | virtual unsigned long getHashValue(char* const& szKey) const; 31 | virtual bool equal(char* const& szKey1, char* const& szKey2) const; 32 | 33 | // virtual UINT getHashValue(const char*& szKey); 34 | }; 35 | 36 | #endif // !defined(AFX_UUCSTRINGTABLE_H__4392B6C2_89AA_436D_8291_A3D22CFF877B__INCLUDED_) 37 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/UUCTextFileReader.h: -------------------------------------------------------------------------------- 1 | // UUCTextFile.h: interface for the UUCTextFile class. 2 | // 3 | 4 | #if !defined(AFX_UUCTEXTFILE_H__CD3660A5_B4C5_4CD4_99AC_69AC96D1460F__INCLUDED_) 5 | #define AFX_UUCTEXTFILE_H__CD3660A5_B4C5_4CD4_99AC_69AC96D1460F__INCLUDED_ 6 | 7 | #if _MSC_VER > 1000 8 | #pragma once 9 | #endif // _MSC_VER > 1000 10 | 11 | #include 12 | 13 | #include "Util/UUCByteArray.h" 14 | 15 | class UUCTextFileReader { 16 | public: 17 | UUCTextFileReader(const char* szFilePath); 18 | virtual ~UUCTextFileReader(); 19 | 20 | long readLine(char* szLine, unsigned long nLen); // throw (long); 21 | long readLine(UUCByteArray& line); 22 | 23 | private: 24 | FILE* m_pf; 25 | }; 26 | 27 | #endif // !defined(AFX_UUCTEXTFILE_H__CD3660A5_B4C5_4CD4_99AC_69AC96D1460F__INCLUDED_) 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/UUCTextFileWriter.h: -------------------------------------------------------------------------------- 1 | // UUCTextFileWriter.h: interface for the UUCTextFileWriter class. 2 | // 3 | 4 | #if !defined( \ 5 | AFX_UUCTEXTFILEWRITER_H__F64974CA_4F95_4200_B7AE_4A53FB004B75__INCLUDED_) 6 | #define AFX_UUCTEXTFILEWRITER_H__F64974CA_4F95_4200_B7AE_4A53FB004B75__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | #include 12 | 13 | #include "Util/UUCByteArray.h" 14 | 15 | class UUCTextFileWriter { 16 | public: 17 | UUCTextFileWriter(const char* szFilePath, bool bAppend = false); 18 | virtual ~UUCTextFileWriter(); 19 | 20 | long writeLine(const char* szLine); 21 | long writeLine(const UUCByteArray& byteArray); 22 | 23 | private: 24 | FILE* m_pf; 25 | }; 26 | 27 | #endif // !defined(AFX_UUCTEXTFILEWRITER_H__F64974CA_4F95_4200_B7AE_4A53FB004B75__INCLUDED_) 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/XAdESGenerator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "SignatureGenerator.h" 11 | 12 | /* 13 | typedef struct 14 | { 15 | int nType; 16 | union 17 | { 18 | UUCByteArray content; 19 | char* szURI; 20 | } reference; 21 | } Reference; 22 | */ 23 | 24 | class CXAdESGenerator : public CSignatureGeneratorBase { 25 | public: 26 | CXAdESGenerator(CBaseSigner* pCryptoki); 27 | CXAdESGenerator(CSignatureGeneratorBase* pGenerator); 28 | 29 | virtual ~CXAdESGenerator(void); 30 | 31 | void SetXAdES(bool xades); 32 | 33 | void SetFileName(char* szFileName); 34 | 35 | virtual long Generate(UUCByteArray& xadesData, BOOL bDetached, 36 | BOOL bVerifyRevocation); 37 | /* 38 | void AddContent(UUCByteArray& content); 39 | 40 | void AddReference(char* szURI); 41 | */ 42 | private: 43 | bool m_bXAdES; 44 | 45 | xmlDocPtr CreateSignedInfo(xmlDocPtr pDocument, 46 | string& strQualifyingPropertiesB64Hash, 47 | bool bDetached, char* szFileName); 48 | xmlDocPtr CreateQualifyingProperties(xmlDocPtr pDocument, 49 | CCertificate* pCertificate); 50 | 51 | void CanonicalizeAndHashBase64(xmlDocPtr pDoc, string& strDocHashB64, 52 | string& strCanonical); 53 | 54 | // vector m_refecenceVect; 55 | 56 | char m_szID[100]; 57 | char m_szFileName[MAX_PATH]; 58 | }; 59 | -------------------------------------------------------------------------------- /libs/sign-sdk/include/keys.h: -------------------------------------------------------------------------------- 1 | // 2 | // keys.h 3 | // cie-pkcs11 4 | // 5 | // Created by ugo chirico on 07/01/2019. 6 | // Copyright © 2019 IPZS. All rights reserved. 7 | // 8 | 9 | #ifndef keys_h 10 | #define keys_h 11 | 12 | #define ENCRYPTION_KEY "this is a fake key" 13 | 14 | #endif /* keys_h */ 15 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1BitString.cpp: -------------------------------------------------------------------------------- 1 | // ASN1BitString.cpp: implementation of the CASN1BitString class. 2 | // 3 | 4 | #include "ASN1BitString.h" 5 | 6 | // Construction/Destruction 7 | 8 | const BYTE CASN1BitString::TAG = 0x03; 9 | 10 | CASN1BitString::~CASN1BitString() {} 11 | 12 | CASN1BitString::CASN1BitString(UUCBufferedReader& reader) 13 | : CASN1Object(reader) {} 14 | 15 | CASN1BitString::CASN1BitString(const CASN1Object& obj) : CASN1Object(obj) {} 16 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1BitString.h: -------------------------------------------------------------------------------- 1 | // ASN1BitString.h: interface for the CASN1BitString class. 2 | // 3 | 4 | #if !defined( \ 5 | AFX_ASN1BITSTRING_H__C1B0BC02_DBEF_4919_902C_5C6C91AE9D25__INCLUDED_) 6 | #define AFX_ASN1BITSTRING_H__C1B0BC02_DBEF_4919_902C_5C6C91AE9D25__INCLUDED_ 7 | 8 | #include "ASN1Object.h" 9 | 10 | class CASN1BitString : public CASN1Object { 11 | public: 12 | // Costruttori 13 | CASN1BitString(UUCBufferedReader& reader); 14 | 15 | CASN1BitString(const CASN1Object& obj); 16 | 17 | // Distruttore 18 | virtual ~CASN1BitString(); 19 | 20 | private: 21 | static const BYTE TAG; 22 | }; 23 | 24 | #endif // !defined(AFX_ASN1BITSTRING_H__C1B0BC02_DBEF_4919_902C_5C6C91AE9D25__INCLUDED_) 25 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Boolean.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1Boolean.h" 2 | 3 | const BYTE CASN1Boolean::TAG = 0x01; 4 | 5 | // Distruttori 6 | CASN1Boolean::~CASN1Boolean() {} 7 | 8 | // Costruttori 9 | CASN1Boolean::CASN1Boolean(UUCBufferedReader& reader) : CASN1Object(reader) {} 10 | 11 | CASN1Boolean::CASN1Boolean(bool b) { 12 | setTag(TAG); 13 | UUCByteArray val; 14 | val.append((BYTE)(b ? 0xFF : 0)); 15 | setValue(val); 16 | } 17 | 18 | CASN1Boolean::CASN1Boolean(const CASN1Object& obj) : CASN1Object(obj) { 19 | setTag(TAG); 20 | } 21 | 22 | bool CASN1Boolean::getBoolValue() const { 23 | return getValue()->getContent()[0] == 1; 24 | } 25 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Boolean.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1BOOLEAN_H 2 | #define _ASN1BOOLEAN_H 3 | 4 | #include "ASN1/ASN1Object.h" 5 | #include "ASN1/UUCBufferedReader.h" 6 | class CASN1Boolean : public CASN1Object { 7 | private: 8 | static const BYTE TAG; 9 | 10 | public: 11 | // costruttori 12 | 13 | CASN1Boolean(bool val); 14 | 15 | CASN1Boolean(const CASN1Object&); 16 | 17 | CASN1Boolean(UUCBufferedReader& reader); 18 | // distruttori 19 | 20 | ~CASN1Boolean(); 21 | 22 | bool getBoolValue() const; 23 | }; 24 | 25 | #endif // ASN1BOOLEAN 26 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2006 by Ugo Chirico - http://www.ugosweb.com 3 | * All Rights Reserved 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | #ifndef _ASN1EXCEPTION_H 21 | #define _ASN1EXCEPTION_H 22 | 23 | #include 24 | 25 | #include "Sign/definitions.h" 26 | class CASN1Exception { 27 | public: 28 | CASN1Exception(const char* lpszMsg) : m_lpszMsg(lpszMsg) {} 29 | 30 | virtual ~CASN1Exception() {} 31 | 32 | virtual bool GetErrorMessage(char* lpszError, UINT nMaxError) { 33 | if (nMaxError < strlen(m_lpszMsg)) return false; 34 | 35 | strcpy(lpszError, m_lpszMsg); 36 | 37 | return true; 38 | } 39 | 40 | public: 41 | const char* m_lpszMsg; 42 | }; 43 | 44 | class CASN1ParsingException : public CASN1Exception { 45 | public: 46 | CASN1ParsingException() : CASN1Exception("Bad ASN1Object parsed") {} 47 | 48 | virtual ~CASN1ParsingException() {} 49 | }; 50 | 51 | class CASN1ObjectNotFoundException : public CASN1Exception { 52 | public: 53 | CASN1ObjectNotFoundException(const char* lpszClass) 54 | : CASN1Exception(lpszClass) {} 55 | 56 | virtual ~CASN1ObjectNotFoundException() {} 57 | }; 58 | 59 | class CASN1BadObjectIdException : public CASN1Exception { 60 | public: 61 | CASN1BadObjectIdException(const char* strClass) : CASN1Exception(strClass) {} 62 | 63 | virtual ~CASN1BadObjectIdException() {} 64 | }; 65 | 66 | class CBadContentTypeException : public CASN1Exception { 67 | public: 68 | CBadContentTypeException() : CASN1Exception("Bad Content Type") {} 69 | 70 | virtual ~CBadContentTypeException() {} 71 | }; 72 | 73 | #endif //_ASN1EXCEPTION_H 74 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1GenericSequence.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1GENERICSEQUENCE_H 2 | #define _ASN1GENERICSEQUENCE_H 3 | 4 | #include "ASN1Object.h" 5 | #define MAXSIZE 100 6 | 7 | class CASN1GenericSequence : public CASN1Object { 8 | public: 9 | CASN1GenericSequence(BYTE btTag); 10 | CASN1GenericSequence(UUCBufferedReader& reader); 11 | CASN1GenericSequence(const UUCByteArray& content); 12 | CASN1GenericSequence(const CASN1Object& obj); 13 | CASN1GenericSequence(const CASN1GenericSequence& obj); 14 | CASN1GenericSequence(const BYTE* value, long len); 15 | 16 | virtual ~CASN1GenericSequence(); 17 | 18 | CASN1GenericSequence& operator=(const CASN1GenericSequence&); 19 | 20 | void addElement(const CASN1Object& obj); 21 | void addElementAt(const CASN1Object& pObj, int nPos); 22 | CASN1Object elementAt(int nPos); 23 | CASN1Object nextElement(); 24 | CASN1Object elementAtOpt(int nPos); 25 | CASN1Object nextElementOpt(); 26 | void setElementAt(const CASN1Object& obj, int nPos); 27 | void removeElementAt(int nPos); 28 | void removeAll(); 29 | bool isPresent(int nPos) const; 30 | unsigned int size() const; 31 | void fromByteArray(const UUCByteArray& content); 32 | 33 | protected: 34 | private: 35 | unsigned int m_nextOffset; 36 | 37 | unsigned int* m_pnOffsets; 38 | unsigned int m_nOffsetsMax; 39 | int m_nSize; 40 | 41 | int makeOffset(); 42 | }; 43 | 44 | #endif // _ASN1GENERICSEQUENCE_H 45 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Integer.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1/ASN1Integer.h" 2 | 3 | const BYTE CASN1Integer::TAG = 0x02; 4 | 5 | CASN1Integer::CASN1Integer(const CASN1Object& obj) : CASN1Object(obj) { 6 | setTag(TAG); 7 | } 8 | 9 | CASN1Integer::~CASN1Integer() {} 10 | 11 | CASN1Integer::CASN1Integer(unsigned long nVal) { 12 | UUCByteArray val; 13 | 14 | // first digit 15 | BYTE btDigit = (BYTE)(nVal & 0x000000FF); 16 | if (btDigit == 0x80) { 17 | val.append((BYTE)0x00); 18 | val.append((BYTE)0x80); 19 | } else { 20 | val.append(btDigit); 21 | } 22 | 23 | nVal = nVal / 256; 24 | 25 | int i = 1; 26 | while (nVal > 0) { 27 | btDigit = (BYTE)(nVal >> (256 * i)); 28 | val.append(btDigit); 29 | nVal = nVal / 256; 30 | } 31 | 32 | val.reverse(); 33 | setValue(val); 34 | setTag(TAG); 35 | } 36 | 37 | CASN1Integer::CASN1Integer(const BYTE* pbtVal, unsigned int nLen) { 38 | setValue(UUCByteArray(pbtVal, nLen)); 39 | setTag(TAG); 40 | } 41 | 42 | int CASN1Integer::getIntValue() const { return getLongValue(); } 43 | 44 | unsigned long CASN1Integer::getLongValue() const { 45 | long nValue = 0; 46 | const BYTE* btBuffer = getValue()->getContent(); 47 | unsigned long nLen = getLength(); 48 | 49 | if (nLen == 1) { 50 | nValue = btBuffer[0]; 51 | } else { 52 | for (unsigned int i = 0; i < nLen; i++) { 53 | BYTE btVal = (BYTE)(btBuffer[nLen - i - 1]); 54 | 55 | nValue += btVal << (8 * i); 56 | } 57 | } 58 | return nValue; 59 | } 60 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Integer.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1INTEGER_H 2 | #define _ASN1INTEGER_H 3 | 4 | #include "ASN1Object.h" 5 | 6 | class CASN1Integer : public CASN1Object { 7 | private: 8 | static const BYTE TAG; 9 | 10 | public: 11 | // Costruttori 12 | 13 | CASN1Integer(unsigned long); 14 | 15 | CASN1Integer(const CASN1Object& obj); 16 | 17 | CASN1Integer(const BYTE* pbtVal, unsigned int nLen); 18 | 19 | // Distruttore 20 | virtual ~CASN1Integer(); 21 | 22 | int getIntValue() const; 23 | 24 | unsigned long getLongValue() const; 25 | }; 26 | 27 | #endif // ASN1INTEGER 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Null.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1Null.h" 2 | 3 | const BYTE CASN1Null::TAG = 0x05; 4 | 5 | // Distruttori 6 | CASN1Null::~CASN1Null() {} 7 | 8 | // Costruttori 9 | CASN1Null::CASN1Null(UUCBufferedReader& reader) : CASN1Object(reader) {} 10 | 11 | CASN1Null::CASN1Null() : CASN1Object(TAG) {} 12 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Null.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1NULL_H 2 | #define _ASN1NULL_H 3 | #include "ASN1Object.h" 4 | 5 | class CASN1Null : public CASN1Object { 6 | private: 7 | static const BYTE TAG; 8 | 9 | public: 10 | // costruttori 11 | CASN1Null(UUCBufferedReader& reader); 12 | 13 | CASN1Null(); 14 | 15 | // distruttori 16 | 17 | ~CASN1Null(); 18 | }; 19 | 20 | #endif // ASN1BOOLEAN 21 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Object.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1OBJECT_ 2 | #define _ASN1OBJECT_ 3 | 4 | #include "Sign/definitions.h" 5 | #include "UUCBufferedReader.h" 6 | #include "Util/UUCByteArray.h" 7 | 8 | class CASN1Object { 9 | public: 10 | // Constructors 11 | CASN1Object(); 12 | CASN1Object(const CASN1Object& obj); 13 | CASN1Object(BYTE btTag, const UUCByteArray& value); 14 | CASN1Object(BYTE btTag); 15 | CASN1Object(UUCBufferedReader& reader); 16 | CASN1Object(const UUCByteArray& content); 17 | CASN1Object(const BYTE* value, long len); 18 | 19 | virtual ~CASN1Object(); 20 | 21 | virtual BYTE getTag() const; 22 | UINT getLength() const; 23 | 24 | const UUCByteArray* getValue() const; 25 | void setValue(const UUCByteArray& value); 26 | void setValue(const BYTE* value, long len); 27 | 28 | void setTag(BYTE tag); 29 | 30 | int getSerializedLength(); 31 | static int getSerializedLength(int nLen, bool indefiniteLen); 32 | 33 | void toByteArray(UUCByteArray& byteArray) const; 34 | void fromByteArray(const UUCByteArray& content); 35 | void fromByteArray(const BYTE* pContent, int iLen); 36 | static int parseLen(UUCBufferedReader& reader, BYTE* pbtTag, 37 | UUCByteArray* pValue, BYTE* pbtLenRead, 38 | bool* pbIndefiniteLen); 39 | void fromReader(UUCBufferedReader& reader); 40 | 41 | CASN1Object operator=(const CASN1Object& obj); 42 | 43 | bool operator==(const CASN1Object& obj) const; 44 | bool operator!=(const CASN1Object& obj) const; 45 | 46 | const char* toHexString(); 47 | 48 | BYTE getOrigLenLen() const; // number of bytes to represent len 49 | 50 | protected: 51 | BYTE m_btTag; 52 | UUCByteArray m_value; 53 | 54 | static int parseBER(UUCBufferedReader& reader, UUCByteArray& buffer); 55 | 56 | bool m_indefiniteLen; 57 | BYTE m_btLenRead; 58 | UUCByteArray m_der; 59 | }; 60 | 61 | #endif //_ASN1OBJECT_ 62 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1ObjectIdentifier.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1OBJECTIDENTIFIER_H 2 | #define _ASN1OBJECTIDENTIFIER_H 3 | 4 | #include 5 | 6 | #include "ASN1Object.h" 7 | 8 | using namespace std; 9 | 10 | class CASN1ObjectIdentifier : public CASN1Object { 11 | private: 12 | const static BYTE TAG; 13 | 14 | public: 15 | CASN1ObjectIdentifier(UUCBufferedReader& reader); 16 | 17 | CASN1ObjectIdentifier(const CASN1Object&); 18 | 19 | CASN1ObjectIdentifier(const char* szObjId); 20 | 21 | // distruttore 22 | ~CASN1ObjectIdentifier(); 23 | 24 | void ToOidString(UUCByteArray& objId); 25 | 26 | bool equals(const CASN1ObjectIdentifier& objid); 27 | }; 28 | 29 | #endif // _ASN1OBJECTIDENTIFIER_H 30 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Octetstring.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1Octetstring.h" 2 | 3 | const BYTE CASN1OctetString::TAG = 0x04; 4 | 5 | // distruttori 6 | CASN1OctetString::~CASN1OctetString() {} 7 | 8 | // costruttori 9 | CASN1OctetString::CASN1OctetString(UUCBufferedReader& reader) 10 | : CASN1Object(reader) {} 11 | 12 | CASN1OctetString::CASN1OctetString(const char* szOctetString) 13 | : CASN1Object(TAG) { 14 | UUCByteArray octetString((BYTE*)szOctetString, strlen(szOctetString)); 15 | setValue(octetString); 16 | } 17 | 18 | CASN1OctetString::CASN1OctetString(const UUCByteArray& octetString) 19 | : CASN1Object(TAG) { 20 | setValue(octetString); 21 | } 22 | 23 | CASN1OctetString::CASN1OctetString(const BYTE* value, long len) 24 | : CASN1Object(TAG) { 25 | setValue(value, len); 26 | } 27 | 28 | CASN1OctetString::CASN1OctetString(const CASN1Object& octetString) 29 | : CASN1Object(octetString) {} 30 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Octetstring.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1OCTECTSTRING_H 2 | #define _ASN1OCTECTSTRING_H 3 | 4 | #include "ASN1Object.h" 5 | 6 | class CASN1OctetString : public CASN1Object { 7 | private: 8 | const static BYTE TAG; 9 | 10 | public: 11 | // Costruttore 12 | CASN1OctetString(UUCBufferedReader& reader); 13 | 14 | CASN1OctetString(const UUCByteArray& bOctetString); 15 | 16 | CASN1OctetString(const char* szOctetString); 17 | 18 | CASN1OctetString(const CASN1Object& octetString); 19 | 20 | CASN1OctetString(const BYTE* value, long len); 21 | 22 | // Distruttore 23 | ~CASN1OctetString(); 24 | }; 25 | 26 | #endif // ASN1OCTECTSTRING 27 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1OptionalField.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1OptionalField.h" 2 | 3 | const BYTE CASN1OptionalField::TAG = 0xA0; 4 | 5 | CASN1OptionalField::CASN1OptionalField(const CASN1Object& asn1Obj, 6 | const BYTE& btClass) 7 | : CASN1Object(asn1Obj), m_btClass(btClass) {} 8 | 9 | CASN1OptionalField::CASN1OptionalField(const CASN1Object& opt) 10 | : CASN1Object(opt) {} 11 | 12 | CASN1OptionalField::CASN1OptionalField(UUCBufferedReader& reader) 13 | : CASN1Object(reader) {} 14 | 15 | CASN1OptionalField::~CASN1OptionalField() {} 16 | 17 | BYTE CASN1OptionalField::getTag() const { return (BYTE)(TAG | m_btClass); } 18 | 19 | /* 20 | BOOL CASN1OptionalField::isOptionaField(const BYTE& btClass, CBufferedReader& 21 | reader) 22 | { 23 | reader.mark(); 24 | try 25 | { 26 | TL* pTl = getTL(reader); 27 | if (pTl->getTag() == (TAG | btClass)) 28 | { 29 | //reader.mark(0); 30 | //reader.reset(); 31 | delete pTl; 32 | return true; 33 | } 34 | delete pTl; 35 | } 36 | catch(CASN1Exception* ex) 37 | { 38 | } 39 | 40 | reader.reset(); 41 | 42 | 43 | 44 | return false; 45 | } 46 | */ 47 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1OptionalField.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1OPTIONALFIELD_H 2 | #define _ASN1OPTIONALFIELD_H 3 | 4 | #include "ASN1Object.h" 5 | 6 | class CASN1OptionalField : public CASN1Object { 7 | public: 8 | CASN1OptionalField(UUCBufferedReader& reader); 9 | 10 | CASN1OptionalField(const CASN1Object& pAsn1Obj, const BYTE& btClass); 11 | 12 | CASN1OptionalField(const CASN1Object& opt); 13 | 14 | ~CASN1OptionalField(); 15 | 16 | BYTE getTag() const; 17 | 18 | private: 19 | static const BYTE TAG; 20 | BYTE m_btClass; 21 | }; 22 | 23 | #endif //_ASN1OPTIONALFIELD_H 24 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Sequence.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1/ASN1Sequence.h" 2 | 3 | const BYTE CASN1Sequence::TAG = 0x30; 4 | 5 | CASN1Sequence::CASN1Sequence() : CASN1GenericSequence(TAG) {} 6 | 7 | CASN1Sequence::CASN1Sequence(UUCBufferedReader& reader) 8 | : CASN1GenericSequence(reader) { 9 | setTag(TAG); 10 | } 11 | 12 | CASN1Sequence::CASN1Sequence(const CASN1Object& obj) 13 | : CASN1GenericSequence(obj) { 14 | setTag(TAG); 15 | } 16 | 17 | CASN1Sequence::CASN1Sequence(const BYTE* value, long len) 18 | : CASN1GenericSequence(value, len) {} 19 | 20 | CASN1Sequence::CASN1Sequence(const UUCByteArray& content) 21 | : CASN1GenericSequence(content) {} 22 | 23 | CASN1Sequence::~CASN1Sequence() { 24 | // NSLog(@"~CASN1Sequence()"); 25 | } 26 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Sequence.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1SEQUENCE_H 2 | #define _ASN1SEQUENCE_H 3 | 4 | #include "ASN1GenericSequence.h" 5 | 6 | class CASN1Sequence : public CASN1GenericSequence { 7 | public: 8 | ~CASN1Sequence(); 9 | 10 | CASN1Sequence(); 11 | 12 | CASN1Sequence(const UUCByteArray& content); 13 | 14 | CASN1Sequence(UUCBufferedReader& reader); 15 | 16 | CASN1Sequence(const CASN1Object& obj); 17 | 18 | CASN1Sequence(const BYTE* value, long len); 19 | 20 | private: 21 | static const BYTE TAG; 22 | }; 23 | 24 | #endif // _ASN1SEQUENCE_H 25 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Setof.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1Setof.h" 2 | 3 | const BYTE CASN1SetOf::TAG = 0x31; 4 | 5 | CASN1SetOf::CASN1SetOf() : CASN1GenericSequence(TAG) {} 6 | 7 | CASN1SetOf::CASN1SetOf(const CASN1Object& obj) : CASN1GenericSequence(obj) { 8 | setTag(TAG); 9 | } 10 | 11 | CASN1SetOf::~CASN1SetOf() {} 12 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1Setof.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASN1SETOF_H 2 | #define _ASN1SETOF_H 3 | 4 | #include "ASN1GenericSequence.h" 5 | #include "ASN1Object.h" 6 | #define MAX_OBJ 10 7 | 8 | class CASN1SetOf : public CASN1GenericSequence { 9 | public: 10 | ~CASN1SetOf(); 11 | 12 | CASN1SetOf(); 13 | 14 | CASN1SetOf(const CASN1Object&); 15 | 16 | private: 17 | static const BYTE TAG; 18 | }; 19 | 20 | #endif // _ASN1SETOF_H 21 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1UTCTime.cpp: -------------------------------------------------------------------------------- 1 | // ASN1UTCTime.cpp: implementation of the CASN1UTCTime class. 2 | // 3 | #include "ASN1/ASN1UTCTime.h" 4 | 5 | // Construction/Destruction 6 | 7 | const BYTE CASN1UTCTime::TAG = 0x17; 8 | 9 | // distruttori 10 | CASN1UTCTime::~CASN1UTCTime() {} 11 | 12 | // costruttori 13 | CASN1UTCTime::CASN1UTCTime(UUCBufferedReader& reader) : CASN1Object(reader) {} 14 | 15 | CASN1UTCTime::CASN1UTCTime(const char* szUTCTime) : CASN1Object(TAG) { 16 | UUCByteArray utcTime((BYTE*)szUTCTime, strlen(szUTCTime)); 17 | setValue(utcTime); 18 | } 19 | 20 | CASN1UTCTime::CASN1UTCTime(const CASN1Object& utcTime) : CASN1Object(utcTime) {} 21 | 22 | void CASN1UTCTime::getUTCTime(char* szTime) { 23 | strncpy(szTime, (char*)m_value.getContent(), m_value.getLength()); 24 | szTime[m_value.getLength()] = 0; 25 | } 26 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ASN1UTCTime.h: -------------------------------------------------------------------------------- 1 | // ASN1UTCTime.h: interface for the CASN1UTCTime class. 2 | // 3 | 4 | #if !defined(AFX_ASN1UTCTIME_H__794C3E2C_270F_44D5_8A0F_40E56ED13484__INCLUDED_) 5 | #define AFX_ASN1UTCTIME_H__794C3E2C_270F_44D5_8A0F_40E56ED13484__INCLUDED_ 6 | 7 | #pragma once 8 | 9 | #include "ASN1Object.h" 10 | 11 | class CASN1UTCTime : public CASN1Object { 12 | public: 13 | private: 14 | static const BYTE TAG; 15 | 16 | public: 17 | // Costruttori 18 | CASN1UTCTime(UUCBufferedReader& reader); 19 | 20 | CASN1UTCTime(const char* szUTCTime); 21 | 22 | CASN1UTCTime(const CASN1Object& obj); 23 | 24 | // Distruttore 25 | virtual ~CASN1UTCTime(); 26 | 27 | void getUTCTime(char* szTime); 28 | }; 29 | 30 | #endif // !defined(AFX_ASN1UTCTIME_H__794C3E2C_270F_44D5_8A0F_40E56ED13484__INCLUDED_) 31 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/AlgorithmIdentifier.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1/AlgorithmIdentifier.h" 2 | 3 | #include "ASN1Null.h" 4 | 5 | CAlgorithmIdentifier::CAlgorithmIdentifier(const CASN1Object& algoId) 6 | : CASN1Sequence(algoId) {} 7 | 8 | CAlgorithmIdentifier::CAlgorithmIdentifier(const char* lpszObjId) { 9 | addElement(CASN1ObjectIdentifier(lpszObjId)); 10 | addElement(CASN1Null()); 11 | } 12 | 13 | CAlgorithmIdentifier::CAlgorithmIdentifier(UUCBufferedReader& reader) 14 | : CASN1Sequence(reader) {} 15 | 16 | CASN1ObjectIdentifier CAlgorithmIdentifier::getOID() { 17 | return (CASN1ObjectIdentifier)elementAt(0); 18 | } 19 | 20 | CASN1Object CAlgorithmIdentifier::getParameters() { 21 | return (CASN1Object)elementAt(1); 22 | } 23 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/AlgorithmIdentifier.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALGORITHMIDENTIFIER_H 2 | #define _ALGORITHMIDENTIFIER_H 3 | 4 | #include "ASN1/ASN1Sequence.h" 5 | #include "ASN1ObjectIdentifier.h" 6 | 7 | class CAlgorithmIdentifier : public CASN1Sequence { 8 | public: 9 | CAlgorithmIdentifier(const CASN1Object& algoId); 10 | 11 | CAlgorithmIdentifier(UUCBufferedReader& reader); 12 | 13 | CAlgorithmIdentifier(const char* szObjId); 14 | 15 | CAlgorithmIdentifier(const CASN1ObjectIdentifier& objId); 16 | 17 | CASN1ObjectIdentifier getOID(); 18 | 19 | CASN1Object getParameters(); 20 | }; 21 | 22 | #endif // _ALGORITHMIDENTIFIER_H 23 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/Certificate.h: -------------------------------------------------------------------------------- 1 | // Certificate.h: interface for the CCertificate class. 2 | // 3 | 4 | #if !defined(AFX_CERTIFICATE_H__2DF2B808_9398_479F_9FD2_9A229517EF9D__INCLUDED_) 5 | #define AFX_CERTIFICATE_H__2DF2B808_9398_479F_9FD2_9A229517EF9D__INCLUDED_ 6 | 7 | #include "ASN1/ASN1Sequence.h" 8 | #include "ASN1/ASN1UTCTime.h" 9 | #include "ASN1/AlgorithmIdentifier.h" 10 | #include "ASN1Octetstring.h" 11 | #include "CertificateInfo.h" 12 | #include "Sign/disigonsdk.h" 13 | 14 | class CCertificate : public CASN1Sequence { 15 | public: 16 | CCertificate(UUCBufferedReader& reader); 17 | 18 | CCertificate(const BYTE* value, long len); 19 | 20 | CCertificate(const CASN1Object& cert); 21 | 22 | virtual ~CCertificate(); 23 | 24 | CCertificateInfo getCertificateInfo(); 25 | 26 | CAlgorithmIdentifier getAlgorithmIdentifier(); 27 | 28 | CASN1OctetString getAuthorithyKeyIdentifier(); 29 | CASN1OctetString getSubjectKeyIdentifier(); 30 | 31 | CASN1Sequence getCertificatePolicies(); 32 | 33 | CASN1Sequence getQCStatements(); 34 | 35 | bool isNonRepudiation(); 36 | 37 | int verifyStatus(REVOCATION_INFO* pRevocationInfo); 38 | int verifyStatus(const char* szTime, REVOCATION_INFO* pRevocationInfo); 39 | bool verifySignature(CCertificate& cert); 40 | int verify(); 41 | 42 | CName getIssuer(); 43 | CASN1Integer getSerialNumber(); 44 | CName getSubject(); 45 | 46 | CASN1UTCTime getExpiration(); 47 | CASN1UTCTime getFrom(); 48 | 49 | CASN1Sequence getExtensions(); 50 | 51 | bool isQualified(); 52 | bool isValid(); 53 | bool isValid(const char* szDateTime); 54 | bool isSHA256(); 55 | CASN1Sequence getExtension(const CASN1ObjectIdentifier& oid); 56 | 57 | static CCertificate* createCertificate(UUCByteArray& contentArray); 58 | }; 59 | 60 | #endif // !defined(AFX_CERTIFICATE_H__2DF2B808_9398_479F_9FD2_9A229517EF9D__INCLUDED_) 61 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/CertificateInfo.cpp: -------------------------------------------------------------------------------- 1 | // CertificateInfo.cpp: implementation of the CCertificateInfo class. 2 | #include "CertificateInfo.h" 3 | 4 | // Construction/Destruction 5 | 6 | CCertificateInfo::CCertificateInfo(UUCBufferedReader& reader) 7 | : CASN1Sequence(reader) {} 8 | 9 | CCertificateInfo::CCertificateInfo(const CASN1Object& certInfo) 10 | : CASN1Sequence(certInfo) {} 11 | 12 | CCertificateInfo::~CCertificateInfo() {} 13 | 14 | CASN1Integer CCertificateInfo::getSerialNumber() { 15 | return (CASN1Integer)elementAt(1); 16 | } 17 | 18 | CAlgorithmIdentifier CCertificateInfo::getSignatureAlgo() { 19 | return (CAlgorithmIdentifier)elementAt(2); 20 | } 21 | 22 | CName CCertificateInfo::getIssuer() { return (CName)elementAt(3); } 23 | 24 | CASN1UTCTime CCertificateInfo::getExpiration() { 25 | return CASN1Sequence(elementAt(4)).elementAt(1); 26 | } 27 | 28 | CASN1UTCTime CCertificateInfo::getFrom() { 29 | return CASN1Sequence(elementAt(4)).elementAt(0); 30 | } 31 | 32 | CASN1Integer CCertificateInfo::getVersion() { 33 | return CASN1Sequence(elementAt(0)).elementAt(0); 34 | } 35 | 36 | CName CCertificateInfo::getSubject() { return (CName)elementAt(5); } 37 | 38 | CSubjectPublicKeyInfo CCertificateInfo::getSubjectPublicKeyInfo() { 39 | return elementAt(6); 40 | } 41 | 42 | CASN1Sequence CCertificateInfo::getExtensions() { 43 | int count = size(); 44 | return elementAt(count - 1); 45 | } 46 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/CertificateInfo.h: -------------------------------------------------------------------------------- 1 | // CertificateInfo.h: interface for the CCertificateInfo class. 2 | 3 | #if !defined( \ 4 | AFX_CERTIFICATEINFO_H__BC0C3782_D000_44C9_B3CE_532326CA26F6__INCLUDED_) 5 | #define AFX_CERTIFICATEINFO_H__BC0C3782_D000_44C9_B3CE_532326CA26F6__INCLUDED_ 6 | 7 | #include "ASN1/ASN1Integer.h" 8 | #include "ASN1/ASN1Sequence.h" 9 | #include "ASN1/ASN1UTCTime.h" 10 | #include "ASN1/AlgorithmIdentifier.h" 11 | #include "Name.h" 12 | #include "SubjectPublicKeyInfo.h" 13 | 14 | class CCertificateInfo : public CASN1Sequence { 15 | public: 16 | CCertificateInfo(UUCBufferedReader& reader); 17 | 18 | CCertificateInfo(const CASN1Object& cert); 19 | 20 | virtual ~CCertificateInfo(); 21 | 22 | CASN1Integer getVersion(); 23 | 24 | CASN1Integer getSerialNumber(); 25 | 26 | CAlgorithmIdentifier getSignatureAlgo(); 27 | 28 | CName getIssuer(); 29 | 30 | CASN1UTCTime getExpiration(); 31 | CASN1UTCTime getFrom(); 32 | 33 | CName getSubject(); 34 | 35 | CSubjectPublicKeyInfo getSubjectPublicKeyInfo(); 36 | 37 | CASN1Sequence getExtensions(); 38 | }; 39 | 40 | #endif // !defined(AFX_CERTIFICATEINFO_H__BC0C3782_D000_44C9_B3CE_532326CA26F6__INCLUDED_) 41 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ContentInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1/ContentInfo.h" 2 | 3 | #include "ASN1OptionalField.h" 4 | 5 | CContentInfo::~CContentInfo() {} 6 | 7 | CContentInfo::CContentInfo(const CASN1Object& contentInfo) 8 | : CASN1Sequence(contentInfo) {} 9 | 10 | CContentInfo::CContentInfo(UUCBufferedReader& reader) : CASN1Sequence(reader) {} 11 | 12 | CContentInfo::CContentInfo(const CContentType& contentType) { 13 | addElement(contentType); 14 | } 15 | 16 | CContentInfo::CContentInfo(const CContentType& contentType, 17 | const CASN1Object& content) { 18 | addElement(contentType); 19 | 20 | CASN1Sequence innerContent; 21 | innerContent.addElement(content); 22 | addElement(CASN1OptionalField(innerContent, 0)); 23 | } 24 | 25 | void CContentInfo::setContent(const CASN1Object& content) { 26 | CASN1Sequence innerContent; 27 | innerContent.addElement(content); 28 | if (size() < 2) 29 | addElement(CASN1OptionalField(innerContent, 0)); 30 | else { 31 | setElementAt(CASN1OptionalField(innerContent, 0), 1); 32 | } 33 | } 34 | 35 | CContentType CContentInfo::getContentType() { 36 | return CContentType(elementAt(0)); 37 | } 38 | 39 | CASN1Object CContentInfo::getContent() { 40 | // il getValue è necessario perchè il content è dichiarato explicit [0] 41 | return CASN1Object(*elementAt(1).getValue()); 42 | } 43 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ContentInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONTENTINFO_H 2 | #define _CONTENTINFO_H 3 | 4 | #include "ASN1/ASN1Sequence.h" 5 | #include "ContentType.h" 6 | 7 | class CContentInfo : public CASN1Sequence { 8 | // Defined as 9 | // ContentInfo ::= SEQUENCE { 10 | // contentType ContentType, 11 | // content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL} 12 | 13 | public: 14 | CContentInfo(const CContentType& contentType, const CASN1Object& content); 15 | 16 | CContentInfo(const CContentType& contentType); 17 | 18 | CContentInfo(UUCBufferedReader& reader); 19 | 20 | CContentInfo(const CASN1Object& contentInfo); 21 | 22 | virtual ~CContentInfo(); 23 | 24 | void setContent(const CASN1Object& content); 25 | 26 | CContentType getContentType(); 27 | 28 | CASN1Object getContent(); 29 | }; 30 | 31 | #endif //_CONTENTINFO_H 32 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ContentType.cpp: -------------------------------------------------------------------------------- 1 | #include "ContentType.h" 2 | 3 | const char* CContentType::OID_TYPE_DATA = "1.2.840.113549.1.7.1"; 4 | const char* CContentType::OID_TYPE_SIGNED = "1.2.840.113549.1.7.2"; 5 | const char* CContentType::OID_TYPE_ENVELOPED = "1.2.840.113549.1.7.3"; 6 | const char* CContentType::OID_TYPE_SIGNED_ENVELOPED = "1.2.840.113549.1.7.4"; 7 | const char* CContentType::OID_TYPE_DIGEST = "1.2.840.113549.1.7.5"; 8 | const char* CContentType::OID_TYPE_ENCRYPTED = "1.2.840.113549.1.7.6"; 9 | const char* CContentType::OID_TYPE_TSTINFO = "1.2.840.113549.1.9.16.1.4"; 10 | 11 | CContentType::CContentType(const CASN1ObjectIdentifier& algoId) 12 | : CASN1ObjectIdentifier(algoId) {} 13 | 14 | CContentType::CContentType(char* lpszOId) : CASN1ObjectIdentifier(lpszOId) {} 15 | 16 | CContentType::CContentType(const char* timeStampDataOID) 17 | : CASN1ObjectIdentifier(timeStampDataOID) {} 18 | 19 | CContentType::CContentType(UUCBufferedReader& reader) 20 | : CASN1ObjectIdentifier(reader) {} 21 | 22 | CContentType::CContentType(const CASN1Object& contentType) 23 | : CASN1ObjectIdentifier(contentType) {} 24 | 25 | CContentType::~CContentType() {} 26 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/ContentType.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONTENTTYPE_H 2 | #define _CONTENTTYPE_H 3 | 4 | #include "ASN1ObjectIdentifier.h" 5 | 6 | class CContentType : public CASN1ObjectIdentifier { 7 | public: 8 | static const char* OID_TYPE_DATA; 9 | static const char* OID_TYPE_SIGNED; 10 | static const char* OID_TYPE_ENVELOPED; 11 | static const char* OID_TYPE_SIGNED_ENVELOPED; 12 | static const char* OID_TYPE_DIGEST; 13 | static const char* OID_TYPE_ENCRYPTED; 14 | static const char* OID_TYPE_TSTINFO; 15 | 16 | CContentType(UUCBufferedReader& reader); 17 | 18 | CContentType(const CASN1Object& contentType); 19 | 20 | CContentType(char* lpszOId); 21 | CContentType(const char* timeStampDataOID); 22 | 23 | CContentType(const CASN1ObjectIdentifier& algoId); 24 | 25 | virtual ~CContentType(); 26 | }; 27 | 28 | #endif //_CONTENTTYPE_H 29 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/Crl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CCrl.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 15/07/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #ifndef _CRL_H 11 | #define _CRL_H 12 | 13 | #include "ASN1/ASN1Integer.h" 14 | #include "ASN1/ASN1Sequence.h" 15 | #include "Sign/disigonsdk.h" 16 | 17 | class CCrl : public CASN1Sequence { 18 | public: 19 | CCrl(UUCBufferedReader& reader); 20 | 21 | CCrl(const CASN1Object& contentInfo); 22 | 23 | bool isRevoked(const CASN1Integer& serialNumber, const char* szDateTime, 24 | int* pReason, REVOCATION_INFO* pRevocationInfo); 25 | }; 26 | 27 | #endif //_CRL_H 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/DigestInfo.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "DigestInfo.h" 4 | 5 | CDigestInfo::CDigestInfo(UUCBufferedReader& reader) : CASN1Sequence(reader) {} 6 | 7 | CDigestInfo::CDigestInfo(const CAlgorithmIdentifier& algoId, 8 | const CASN1OctetString& digest) { 9 | addElement(algoId); 10 | addElement(digest); 11 | } 12 | 13 | CDigestInfo::CDigestInfo(const CASN1Object& digestInfo) 14 | : CASN1Sequence(digestInfo) {} 15 | 16 | CAlgorithmIdentifier CDigestInfo::getDigestAlgorithm() { return elementAt(0); } 17 | 18 | CASN1OctetString CDigestInfo::getDigest() { return elementAt(1); } 19 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/DigestInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef _DIGESTINFO_H 2 | #define _DIGESTINFO_H 3 | 4 | #include "ASN1/ASN1Sequence.h" 5 | #include "ASN1/AlgorithmIdentifier.h" 6 | #include "ASN1Octetstring.h" 7 | 8 | class CDigestInfo : public CASN1Sequence { 9 | // Defined as 10 | // DigestInfo ::= SEQUENCE { 11 | // digestAlgorithm DigestAlgorithmIdentifier, 12 | // digest Digest} 13 | 14 | public: 15 | CDigestInfo(UUCBufferedReader& reader); 16 | 17 | CDigestInfo(const CAlgorithmIdentifier& algoId, 18 | const CASN1OctetString& digest); 19 | 20 | CDigestInfo(const CASN1Object& digestInfo); 21 | 22 | CAlgorithmIdentifier getDigestAlgorithm(); 23 | 24 | CASN1OctetString getDigest(); 25 | }; 26 | 27 | #endif //_DIGESTINFO_H 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/IssuerAndSerialNumber.cpp: -------------------------------------------------------------------------------- 1 | // IssuerAndSerialNumber.cpp: implementation of the CIssuerAndSerialNumber 2 | // class. 3 | // 4 | 5 | #include "ASN1/IssuerAndSerialNumber.h" 6 | 7 | #include "ASN1OptionalField.h" 8 | 9 | // Construction/Destruction 10 | 11 | CIssuerAndSerialNumber::CIssuerAndSerialNumber(UUCBufferedReader& reader) 12 | : CASN1Sequence(reader) {} 13 | 14 | CIssuerAndSerialNumber::CIssuerAndSerialNumber( 15 | const CASN1Object& issuerAndSerNum) 16 | : CASN1Sequence(issuerAndSerNum) {} 17 | 18 | CIssuerAndSerialNumber::CIssuerAndSerialNumber(const CName& issuer, 19 | const CASN1Integer& serNum, 20 | bool contextSpecific) { 21 | if (contextSpecific) { 22 | CASN1Sequence issuerField; 23 | issuerField.addElement(issuer); 24 | 25 | CASN1Sequence innerSequence; 26 | innerSequence.addElement(CASN1OptionalField(issuerField, 0x04)); 27 | 28 | addElement(innerSequence); 29 | addElement(serNum); 30 | } else { 31 | addElement(issuer); 32 | addElement(serNum); 33 | } 34 | } 35 | 36 | CIssuerAndSerialNumber::~CIssuerAndSerialNumber() {} 37 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/IssuerAndSerialNumber.h: -------------------------------------------------------------------------------- 1 | // IssuerAndSerialNumber.h: interface for the CIssuerAndSerialNumber class. 2 | // 3 | 4 | #if !defined( \ 5 | AFX_ISSUERANDSERIALNUMBER_H__0AE18C2B_4100_4D86_98D3_167D05277E42__INCLUDED_) 6 | #define AFX_ISSUERANDSERIALNUMBER_H__0AE18C2B_4100_4D86_98D3_167D05277E42__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "ASN1/ASN1Integer.h" 13 | #include "ASN1/ASN1Sequence.h" 14 | #include "Name.h" 15 | 16 | class CIssuerAndSerialNumber : public CASN1Sequence { 17 | public: 18 | CIssuerAndSerialNumber(UUCBufferedReader& reader); 19 | 20 | CIssuerAndSerialNumber(const CASN1Object& issuerAndSerNum); 21 | 22 | CIssuerAndSerialNumber(const CName& issuer, const CASN1Integer& serNum, 23 | bool contextSpecific); 24 | 25 | virtual ~CIssuerAndSerialNumber(); 26 | }; 27 | 28 | #endif // !defined(AFX_ISSUERANDSERIALNUMBER_H__0AE18C2B_4100_4D86_98D3_167D05277E42__INCLUDED_) 29 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/Name.h: -------------------------------------------------------------------------------- 1 | // Name.h: interface for the CName class. 2 | // 3 | 4 | #if !defined(AFX_NAME_H__554A2FC6_1A7E_4639_8E45_487603ACB583__INCLUDED_) 5 | #define AFX_NAME_H__554A2FC6_1A7E_4639_8E45_487603ACB583__INCLUDED_ 6 | 7 | #if _MSC_VER > 1000 8 | #pragma once 9 | #endif // _MSC_VER > 1000 10 | 11 | #include 12 | 13 | #include "ASN1/ASN1Sequence.h" 14 | 15 | #define OID_EMAIL_ADDRESS "1.2.840.113549.1.9.1" 16 | #define OID_UNSTRUCTURED_NAME "1.2.840.113549.1.9.2" 17 | #define OID_CONTENT_TYPE "1.2.840.113549.1.9.3" 18 | #define OID_MESSAGE_DIGEST "1.2.840.113549.1.9.4" 19 | #define OID_SIGNING_TIME "1.2.840.113549.1.9.5" 20 | #define OID_COUNTERSIGNATURE "1.2.840.113549.1.9.6" 21 | #define OID_CHALLENGE_PASSWORD "1.2.840.113549.1.9.7" 22 | #define OID_UNSTRUCTURED_ADDRESS "1.2.840.113549.1.9.8" 23 | #define OID_EXTENDED_CERTIFICATE_ATTRIBUTES "2.5.4.3" 24 | #define OID_COMMON_NAME "2.5.4.3" 25 | #define OID_SURNAME "2.5.4.4" 26 | #define OID_COUNTRY_NAME "2.5.4.6" 27 | #define OID_LOCALITY_NAME "2.5.4.7" 28 | #define OID_STATE_OR_PROVINCE_NAME "2.5.4.8" 29 | #define OID_ORGANIZATION_NAME "2.5.4.10" 30 | #define OID_ORGANIZATIONAL_UNIT_NAME "2.5.4.11" 31 | #define OID_TITLE "2.5.4.12" 32 | #define OID_NAME "2.5.4.41" 33 | #define OID_GIVEN_NAME "2.5.4.42" 34 | #define OID_INITIALS "2.5.4.43" 35 | #define OID_GENERATION_QUALIFIER "2.5.4.44" 36 | #define OID_DN_QUALIFIER "2.5.4.46" 37 | #define OID_SERIALNUMBER "2.5.4.5" 38 | 39 | using namespace std; 40 | 41 | class CName : public CASN1Sequence { 42 | public: 43 | CName(UUCBufferedReader& reader); 44 | 45 | CName(const CASN1Object& name); 46 | 47 | string getField(const char* fieldOID); 48 | 49 | void getNameAsString(UUCByteArray& objId); 50 | 51 | virtual ~CName(); 52 | }; 53 | 54 | #endif // !defined(AFX_NAME_H__554A2FC6_1A7E_4639_8E45_487603ACB583__INCLUDED_) 55 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/OCSPRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OCSPRequest.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 14/10/11. 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | /* 10 | OCSPRequest ::= SEQUENCE { 11 | tbsRequest TBSRequest, 12 | optionalSignature [0] EXPLICIT Signature OPTIONAL } 13 | 14 | TBSRequest ::= SEQUENCE { 15 | version [0] EXPLICIT Version DEFAULT v1, 16 | requestorName [1] EXPLICIT GeneralName OPTIONAL, 17 | requestList SEQUENCE OF Request, 18 | requestExtensions [2] EXPLICIT Extensions OPTIONAL } 19 | 20 | Signature ::= SEQUENCE { 21 | signatureAlgorithm AlgorithmIdentifier, 22 | signature BIT STRING, 23 | certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } 24 | 25 | Version ::= INTEGER { v1(0) } 26 | 27 | Request ::= SEQUENCE { 28 | reqCert CertID, 29 | singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } 30 | 31 | CertID ::= SEQUENCE { 32 | hashAlgorithm AlgorithmIdentifier, 33 | issuerNameHash OCTET STRING, -- Hash of Issuer's DN 34 | issuerKeyHash OCTET STRING, -- Hash of Issuers public key 35 | serialNumber CertificateSerialNumber } 36 | */ 37 | 38 | #ifndef _OCSPRequest_H 39 | #define _OCSPRequest_H 40 | 41 | #include "ASN1/ASN1Sequence.h" 42 | #include "ASN1/Certificate.h" 43 | 44 | class COCSPRequest : public CASN1Sequence { 45 | public: 46 | COCSPRequest(UUCBufferedReader& reader); 47 | 48 | COCSPRequest(const CASN1Object& contentInfo); 49 | 50 | COCSPRequest(CCertificate& certificate); 51 | }; 52 | 53 | #endif //_OCSPRequest 54 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/PKIStatusInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * PKIStatusInfo.cpp 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 19/03/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "PKIStatusInfo.h" 11 | 12 | // Construction/Destruction 13 | 14 | CPKIStatusInfo::CPKIStatusInfo(UUCBufferedReader& reader) 15 | : CASN1Sequence(reader) {} 16 | 17 | CPKIStatusInfo::CPKIStatusInfo(const CASN1Object& pkiStatusInfo) 18 | : CASN1Sequence(pkiStatusInfo) {} 19 | 20 | CPKIStatusInfo::~CPKIStatusInfo() {} 21 | 22 | CASN1Integer CPKIStatusInfo::getStatus() { return elementAt(0); } 23 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/PKIStatusInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKIStatusInfo.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 19/03/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #ifndef _PKISTATUSINFO_H 11 | #define _PKISTATUSINFO_H 12 | 13 | #include "ASN1/ASN1Integer.h" 14 | #include "ASN1/ASN1Object.h" 15 | #include "ASN1/ASN1Sequence.h" 16 | #include "ASN1/UUCBufferedReader.h" 17 | class CPKIStatusInfo : public CASN1Sequence { 18 | public: 19 | CPKIStatusInfo(UUCBufferedReader& reader); 20 | 21 | CPKIStatusInfo(const CASN1Object& PKIStatusInfo); 22 | 23 | virtual ~CPKIStatusInfo(); 24 | 25 | CASN1Integer getStatus(); 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/RSAPrivateKey.cpp: -------------------------------------------------------------------------------- 1 | #include "ASN1/RSAPrivateKey.h" 2 | 3 | // RSAPrivateKey :: = SEQUENCE{ 4 | // version Version, 5 | // modulus INTEGER, --n 6 | // publicExponent INTEGER, --e 7 | // privateExponent INTEGER, --d 8 | // prime1 INTEGER, --p 9 | // prime2 INTEGER, --q 10 | // exponent1 INTEGER, --d mod(p - 1) 11 | // exponent2 INTEGER, --d mod(q - 1) 12 | // coefficient INTEGER, --(inverse of q) mod p 13 | // otherPrimeInfos OtherPrimeInfos OPTIONAL 14 | // } 15 | 16 | // Macro per trasformazione da little-endian a big-endian e viceversa 17 | #define REVERSE(in, out, len) \ 18 | { \ 19 | for (int i = 0; i < len; i++) { \ 20 | out[i] = in[len - i - 1]; \ 21 | } \ 22 | } 23 | 24 | CRSAPrivateKey::CRSAPrivateKey(UUCBufferedReader& reader) 25 | : CASN1Sequence(reader) {} 26 | 27 | CRSAPrivateKey::CRSAPrivateKey(const CASN1Object& obj) : CASN1Sequence(obj) {} 28 | 29 | CRSAPrivateKey::CRSAPrivateKey(const UUCByteArray& content) 30 | : CASN1Sequence(content) {} 31 | 32 | CRSAPrivateKey::CRSAPrivateKey(const CASN1Integer& modulus, 33 | const CASN1Integer& pubExp, 34 | const CASN1Integer& priExp) { 35 | addElement(modulus); 36 | addElement(pubExp); 37 | addElement(priExp); 38 | } 39 | 40 | CRSAPrivateKey::~CRSAPrivateKey(void) {} 41 | 42 | CASN1Integer CRSAPrivateKey::getModulus() { return CASN1Integer(elementAt(1)); } 43 | 44 | CASN1Integer CRSAPrivateKey::getPublicExponent() { 45 | return CASN1Integer(elementAt(2)); 46 | } 47 | 48 | CASN1Integer CRSAPrivateKey::getPrivateExponent() { 49 | return CASN1Integer(elementAt(3)); 50 | } 51 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/RSAPrivateKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ASN1/ASN1Integer.h" 3 | #include "ASN1/ASN1Sequence.h" 4 | #include "ASN1Object.h" 5 | 6 | // RSAPrivateKey :: = SEQUENCE{ 7 | // version Version, 8 | // modulus INTEGER, --n 9 | // publicExponent INTEGER, --e 10 | // privateExponent INTEGER, --d 11 | // prime1 INTEGER, --p 12 | // prime2 INTEGER, --q 13 | // exponent1 INTEGER, --d mod(p - 1) 14 | // exponent2 INTEGER, --d mod(q - 1) 15 | // coefficient INTEGER, --(inverse of q) mod p 16 | // otherPrimeInfos OtherPrimeInfos OPTIONAL 17 | // } 18 | 19 | class CRSAPrivateKey : public CASN1Sequence { 20 | public: 21 | // Costruttori 22 | CRSAPrivateKey(UUCBufferedReader& reader); 23 | 24 | CRSAPrivateKey(const CASN1Object& obj); 25 | 26 | CRSAPrivateKey(const UUCByteArray& content); 27 | 28 | CRSAPrivateKey(const CASN1Integer& modulus, const CASN1Integer& pubExp, 29 | const CASN1Integer& priExp); 30 | 31 | CRSAPrivateKey(const BYTE* pbtRSAKey_MS, const DWORD dwLen); 32 | 33 | virtual ~CRSAPrivateKey(); 34 | 35 | CASN1Integer getModulus(); 36 | 37 | CASN1Integer getPublicExponent(); 38 | 39 | CASN1Integer getPrivateExponent(); 40 | }; 41 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/RSAPublicKey.cpp: -------------------------------------------------------------------------------- 1 | #include "RSAPublicKey.h" 2 | 3 | CRSAPublicKey::CRSAPublicKey(UUCBufferedReader& reader) 4 | : CASN1Sequence(reader) {} 5 | 6 | CRSAPublicKey::CRSAPublicKey(const CASN1Object& obj) : CASN1Sequence(obj) {} 7 | 8 | CRSAPublicKey::CRSAPublicKey(const CASN1Integer& modulus, 9 | const CASN1Integer& exponent) { 10 | addElement(modulus); 11 | addElement(exponent); 12 | } 13 | 14 | CRSAPublicKey::~CRSAPublicKey(void) {} 15 | 16 | CASN1Integer CRSAPublicKey::getModulus() { return CASN1Integer(elementAt(0)); } 17 | 18 | CASN1Integer CRSAPublicKey::getExponent() { return CASN1Integer(elementAt(1)); } 19 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/RSAPublicKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ASN1/ASN1Integer.h" 3 | #include "ASN1/ASN1Sequence.h" 4 | #include "ASN1Object.h" 5 | 6 | class CRSAPublicKey : public CASN1Sequence { 7 | public: 8 | // Costruttori 9 | CRSAPublicKey(UUCBufferedReader& reader); 10 | 11 | CRSAPublicKey(const CASN1Object& obj); 12 | 13 | CRSAPublicKey(const CASN1Integer& modulus, const CASN1Integer& exponent); 14 | 15 | virtual ~CRSAPublicKey(); 16 | 17 | CASN1Integer getModulus(); 18 | 19 | CASN1Integer getExponent(); 20 | 21 | private: 22 | }; 23 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/RelativeDistinguishedName.cpp: -------------------------------------------------------------------------------- 1 | // RelativeDistinguishedName.cpp: implementation of the 2 | // CRelativeDistinguishedName class. 3 | // 4 | 5 | #include "RelativeDistinguishedName.h" 6 | // #include "ASN1Exception.h" 7 | 8 | // Construction/Destruction 9 | 10 | CRelativeDistinguishedName::CRelativeDistinguishedName() {} 11 | 12 | CRelativeDistinguishedName::CRelativeDistinguishedName( 13 | UUCBufferedReader& reader) 14 | : CASN1SetOf(reader) {} 15 | 16 | CRelativeDistinguishedName::CRelativeDistinguishedName(const CASN1Object& name) 17 | : CASN1SetOf(name) {} 18 | 19 | /* 20 | void CRelativeDistinguishedName::addAttributeValue(const 21 | CAttributeValueAssertion& value) 22 | { 23 | addElement(new CAttributeValueAssertion(value)); 24 | } 25 | */ 26 | 27 | CRelativeDistinguishedName::~CRelativeDistinguishedName() {} 28 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/RelativeDistinguishedName.h: -------------------------------------------------------------------------------- 1 | // RelativeDistinguishedName.h: interface for the CRelativeDistinguishedName 2 | // class. 3 | // 4 | 5 | #if !defined( \ 6 | AFX_RELATIVEDISTINGUISHEDNAME_H__6344EC52_BE52_4C57_AA1D_3D2790EDDD7E__INCLUDED_) 7 | #define AFX_RELATIVEDISTINGUISHEDNAME_H__6344EC52_BE52_4C57_AA1D_3D2790EDDD7E__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #include "ASN1Setof.h" 14 | // #include "AttributeValueAssertion.h" 15 | 16 | class CRelativeDistinguishedName : public CASN1SetOf { 17 | public: 18 | CRelativeDistinguishedName(UUCBufferedReader& reader); 19 | 20 | CRelativeDistinguishedName(); 21 | 22 | CRelativeDistinguishedName(const CASN1Object& rname); 23 | 24 | // void addAttributeValue(const CAttributeValueAssertion& algos); 25 | 26 | virtual ~CRelativeDistinguishedName(); 27 | }; 28 | 29 | #endif // !defined(AFX_RELATIVEDISTINGUISHEDNAME_H__6344EC52_BE52_4C57_AA1D_3D2790EDDD7E__INCLUDED_) 30 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/SignedData.h: -------------------------------------------------------------------------------- 1 | // SignedData.h: interface for the CSignedData class. 2 | // 3 | 4 | #include "ASN1/ASN1Setof.h" 5 | #if !defined(AFX_SIGNEDDATA_H__C408FDA9_5C26_4F85_8073_EA7278527011__INCLUDED_) 6 | #define AFX_SIGNEDDATA_H__C408FDA9_5C26_4F85_8073_EA7278527011__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "ASN1/ASN1Sequence.h" 13 | #include "ASN1/Certificate.h" 14 | #include "ASN1/ContentInfo.h" 15 | #include "Sign/disigonsdk.h" 16 | 17 | class CSignedData : public CASN1Sequence { 18 | public: 19 | CSignedData(UUCBufferedReader& reader); 20 | 21 | CSignedData(const CASN1Object& signedData); 22 | 23 | CSignedData(const CASN1SetOf& algos, const CContentInfo& contentInfo, 24 | const CASN1SetOf& signerInfos, const CASN1SetOf& certificates); 25 | 26 | virtual ~CSignedData(); 27 | 28 | CASN1SetOf getDigestAlgorithmIdentifiers(); 29 | 30 | CContentInfo getContentInfo(); 31 | 32 | CASN1SetOf getSignerInfos(); 33 | 34 | CASN1SetOf getCertificates(); 35 | 36 | CCertificate getSignerCertificate(int index); 37 | 38 | void makeDetached(); 39 | 40 | void setContent(UUCByteArray& content); 41 | 42 | int verify(int i); 43 | 44 | int verify(int i, const char* dateTime, REVOCATION_INFO* pRevocationInfo); 45 | }; 46 | 47 | #endif // !defined(AFX_SIGNEDDATA_H__C408FDA9_5C26_4F85_8073_EA7278527011__INCLUDED_) 48 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/SubjectPublicKeyInfo.cpp: -------------------------------------------------------------------------------- 1 | // SubjectPublicKeyInfo.cpp: implementation of the CSubjectPublicKeyInfo class. 2 | // 3 | 4 | #include "SubjectPublicKeyInfo.h" 5 | 6 | // Construction/Destruction 7 | 8 | CSubjectPublicKeyInfo::CSubjectPublicKeyInfo(UUCBufferedReader& reader) 9 | : CASN1Sequence(reader) {} 10 | 11 | CSubjectPublicKeyInfo::CSubjectPublicKeyInfo(const CASN1Object& subPubKey) 12 | : CASN1Sequence(subPubKey) {} 13 | 14 | CSubjectPublicKeyInfo::~CSubjectPublicKeyInfo() {} 15 | 16 | CAlgorithmIdentifier CSubjectPublicKeyInfo::getAlgorithmIdentifier() { 17 | return elementAt(0); 18 | } 19 | 20 | CASN1BitString CSubjectPublicKeyInfo::getPublicKey() { return elementAt(1); } 21 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/SubjectPublicKeyInfo.h: -------------------------------------------------------------------------------- 1 | // SubjectPublicKeyInfo.h: interface for the CSubjectPublicKeyInfo class. 2 | // 3 | 4 | #if !defined( \ 5 | AFX_SUBJECTPUBLICKEYINFO_H__93E2619B_704A_49A2_8DEA_DCCC521605CE__INCLUDED_) 6 | #define AFX_SUBJECTPUBLICKEYINFO_H__93E2619B_704A_49A2_8DEA_DCCC521605CE__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "ASN1/ASN1Sequence.h" 13 | #include "ASN1/AlgorithmIdentifier.h" 14 | #include "ASN1BitString.h" 15 | 16 | class CSubjectPublicKeyInfo : public CASN1Sequence { 17 | public: 18 | CSubjectPublicKeyInfo(UUCBufferedReader& reader); 19 | 20 | CSubjectPublicKeyInfo(const CASN1Object& obj); 21 | 22 | virtual ~CSubjectPublicKeyInfo(); 23 | 24 | CAlgorithmIdentifier getAlgorithmIdentifier(); 25 | 26 | CASN1BitString getPublicKey(); 27 | }; 28 | 29 | #endif // !defined(AFX_SUBJECTPUBLICKEYINFO_H__93E2619B_704A_49A2_8DEA_DCCC521605CE__INCLUDED_) 30 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TSTInfo.cpp: -------------------------------------------------------------------------------- 1 | // TSTInfo.cpp: implementation of the CTSTInfo class. 2 | // 3 | 4 | #include "TSTInfo.h" 5 | 6 | #include "ASN1/ASN1UTCTime.h" 7 | 8 | // Construction/Destruction 9 | 10 | CTSTInfo::CTSTInfo(UUCBufferedReader& reader) : CASN1Sequence(reader) {} 11 | 12 | CTSTInfo::CTSTInfo(const CASN1Object& tstInfo) : CASN1Sequence(tstInfo) {} 13 | 14 | CTSTInfo::~CTSTInfo() {} 15 | 16 | CASN1Sequence CTSTInfo::getMessageImprint() { return elementAt(2); } 17 | 18 | CASN1UTCTime CTSTInfo::getUTCTime() { return elementAt(4); } 19 | 20 | CAlgorithmIdentifier CTSTInfo::getDigestAlgorithn() { 21 | CASN1Sequence messageImprint(elementAt(2)); 22 | return (CAlgorithmIdentifier)messageImprint.elementAt(0); 23 | } 24 | 25 | CASN1Integer CTSTInfo::getSerialNumber() { return elementAt(3); } 26 | 27 | CName CTSTInfo::getTSAName() { 28 | int siz = size(); 29 | for (int i = 1; i < siz; i++) { 30 | CASN1Object obj = elementAt(i); 31 | if (obj.getTag() == 0xA0) { 32 | CASN1Sequence val(obj); 33 | CASN1Sequence val1(val.elementAt(0)); 34 | return val1.elementAt(0); 35 | } 36 | } 37 | 38 | throw -1; 39 | } 40 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TSTInfo.h: -------------------------------------------------------------------------------- 1 | // TSTInfo.h: interface for the CTSTInfo class. 2 | // 3 | #ifndef _TSTINFO_H 4 | #define _TSTINFO_H 5 | 6 | #if !defined(AFX_TSTINFO_H__7B1086C5_9AEE_4973_8D52_FBB757D01E2A__INCLUDED_) 7 | #define AFX_TSTINFO_H__7B1086C5_9AEE_4973_8D52_FBB757D01E2A__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #include "ASN1/ASN1Integer.h" 14 | #include "ASN1/ASN1Sequence.h" 15 | #include "ASN1/ASN1UTCTime.h" 16 | #include "ASN1/AlgorithmIdentifier.h" 17 | #include "Name.h" 18 | 19 | class CTSTInfo : public CASN1Sequence { 20 | public: 21 | CTSTInfo(UUCBufferedReader& reader); 22 | 23 | CTSTInfo(const CASN1Object& tstInfo); 24 | 25 | virtual ~CTSTInfo(); 26 | 27 | CASN1UTCTime getUTCTime(); 28 | 29 | CASN1Integer getSerialNumber(); 30 | 31 | CAlgorithmIdentifier getDigestAlgorithn(); 32 | 33 | CASN1Sequence getMessageImprint(); 34 | 35 | // N.B. il campo TSAName è opzionale. se non presente nel tstoken torna 36 | // eccezione 37 | CName getTSAName(); 38 | }; 39 | 40 | #endif // !defined(AFX_TSTINFO_H__7B1086C5_9AEE_4973_8D52_FBB757D01E2A__INCLUDED_) 41 | #endif //_TSTINFO_H 42 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TimeStampRequest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeStampRequest.cpp 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 22/03/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "TimeStampRequest.h" 11 | 12 | #include "ASN1/ASN1Octetstring.h" 13 | #include "ASN1Boolean.h" 14 | 15 | // Construction/Destruction 16 | CTimeStampRequest::CTimeStampRequest(UUCBufferedReader& reader) 17 | : CASN1Sequence(reader) {} 18 | 19 | CTimeStampRequest::CTimeStampRequest(const CASN1Object& timeStampToken) 20 | : CASN1Sequence(timeStampToken) {} 21 | 22 | CTimeStampRequest::CTimeStampRequest(const char* szHashAlgoOID, 23 | UUCByteArray& digest, 24 | const char* szPolicyOID, 25 | CASN1Integer& nounce) 26 | : CASN1Sequence() { 27 | addElement(CASN1Integer(1)); 28 | CASN1Sequence messageImprint; 29 | 30 | messageImprint.addElement(CAlgorithmIdentifier(szHashAlgoOID)); 31 | messageImprint.addElement(CASN1OctetString(digest)); 32 | addElement(messageImprint); 33 | 34 | if (szPolicyOID != NULL && strlen(szPolicyOID) > 0) { 35 | CASN1ObjectIdentifier policyOid(szPolicyOID); //"1.3.6.1.4.1.29741.1.1.6"); 36 | addElement(policyOid); 37 | } 38 | 39 | addElement(nounce); 40 | addElement(CASN1Boolean(true)); // certReq 41 | } 42 | 43 | CTimeStampRequest::~CTimeStampRequest() {} 44 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TimeStampRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeStampRequest.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 22/03/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "ASN1/TimeStampToken.h" 11 | 12 | class CTimeStampRequest : public CASN1Sequence { 13 | public: 14 | CTimeStampRequest(UUCBufferedReader& reader); 15 | 16 | CTimeStampRequest(const CASN1Object& timeStampToken); 17 | 18 | CTimeStampRequest(const char* szHashAlgoOID, UUCByteArray& digest, 19 | const char* szPolicyOID, CASN1Integer& nounce); 20 | 21 | virtual ~CTimeStampRequest(); 22 | }; 23 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TimeStampResponse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeStampResponse.cpp 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 19/03/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "TimeStampResponse.h" 11 | 12 | #include "ASN1/TimeStampToken.h" 13 | 14 | // Construction/Destruction 15 | 16 | CTimeStampResponse::CTimeStampResponse(UUCBufferedReader& reader) 17 | : CASN1Sequence(reader) {} 18 | 19 | CTimeStampResponse::CTimeStampResponse(const CASN1Object& timeStampresponse) 20 | : CASN1Sequence(timeStampresponse) {} 21 | 22 | CTimeStampResponse::CTimeStampResponse(const BYTE* content, int length) 23 | : CASN1Sequence(content, length) {} 24 | 25 | CTimeStampResponse::~CTimeStampResponse() {} 26 | 27 | CTimeStampToken CTimeStampResponse::getTimeStampToken() { return elementAt(1); } 28 | 29 | CPKIStatusInfo CTimeStampResponse::getPKIStatusInfo() { return elementAt(0); } 30 | 31 | int CTimeStampResponse::verify() { return verify(NULL); } 32 | 33 | int CTimeStampResponse::verify(const char* szDateTime) { 34 | CTimeStampToken tst(elementAt(1)); 35 | return tst.verify(szDateTime, NULL); 36 | } 37 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TimeStampResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TimeStampResponse.h 3 | * iDigitalSApp 4 | * 5 | * Created by svp on 19/03/12. 6 | * Copyright 2012 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "ASN1/TimeStampToken.h" 11 | #include "PKIStatusInfo.h" 12 | 13 | class CTimeStampResponse : public CASN1Sequence { 14 | public: 15 | CTimeStampResponse(UUCBufferedReader& reader); 16 | 17 | CTimeStampResponse(const CASN1Object& timeStampresponse); 18 | 19 | CTimeStampResponse(const BYTE* content, int length); 20 | 21 | virtual ~CTimeStampResponse(); 22 | 23 | CTimeStampToken getTimeStampToken(); 24 | 25 | CPKIStatusInfo getPKIStatusInfo(); 26 | 27 | int verify(const char* szDateTime); 28 | 29 | int verify(); 30 | }; 31 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TimeStampToken.cpp: -------------------------------------------------------------------------------- 1 | // TimeStampToken.cpp: implementation of the CTimeStampToken class. 2 | #include "ASN1/TimeStampToken.h" 3 | 4 | #include "ASN1/ContentInfo.h" 5 | #include "ASN1Octetstring.h" 6 | #include "SignedData.h" 7 | 8 | // Construction/Destruction 9 | CTimeStampToken::CTimeStampToken(UUCBufferedReader& reader) 10 | : CContentInfo(reader) {} 11 | 12 | CTimeStampToken::CTimeStampToken(const CASN1Object& timeStampToken) 13 | : CContentInfo(timeStampToken) {} 14 | 15 | CTimeStampToken::~CTimeStampToken() {} 16 | 17 | CTSTInfo CTimeStampToken::getTSTInfo() { 18 | CSignedData signedData(getContent()); 19 | 20 | CContentInfo contentInfo(signedData.getContentInfo()); 21 | 22 | CASN1OctetString tst(contentInfo.getContent()); 23 | 24 | UUCBufferedReader reader(*tst.getValue()); 25 | return CTSTInfo(reader); 26 | } 27 | 28 | int CTimeStampToken::verify(REVOCATION_INFO* pRevocationInfo) { 29 | CSignedData signedData(getContent()); 30 | 31 | return signedData.verify(0, NULL, pRevocationInfo); 32 | } 33 | 34 | int CTimeStampToken::verify(const char* szDateTime, 35 | REVOCATION_INFO* pRevocationInfo) { 36 | CSignedData signedData(getContent()); 37 | 38 | return signedData.verify(0, szDateTime, pRevocationInfo); 39 | } 40 | 41 | CASN1SetOf CTimeStampToken::getCertificates() { 42 | CSignedData signedData(getContent()); 43 | 44 | return signedData.getCertificates(); 45 | } 46 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/TimeStampToken.h: -------------------------------------------------------------------------------- 1 | // TimeStampToken.h: interface for the CTimeStampToken class. 2 | // 3 | #ifndef _TIMESTAMPTOKEN_H 4 | #define _TIMESTAMPTOKEN_H 5 | 6 | #include "ASN1/ASN1Setof.h" 7 | #include "Sign/disigonsdk.h" 8 | #if !defined( \ 9 | AFX_TIMESTAMPTOKEN_H__2D568B92_6258_4EBE_B1CA_17F3746F3801__INCLUDED_) 10 | #define AFX_TIMESTAMPTOKEN_H__2D568B92_6258_4EBE_B1CA_17F3746F3801__INCLUDED_ 11 | 12 | #if _MSC_VER > 1000 13 | #pragma once 14 | #endif // _MSC_VER > 1000 15 | 16 | #include "ASN1/ContentInfo.h" 17 | #include "TSTInfo.h" 18 | 19 | class CTimeStampToken : public CContentInfo { 20 | public: 21 | CTimeStampToken(UUCBufferedReader& reader); 22 | 23 | CTimeStampToken(const CASN1Object& timeStampToken); 24 | 25 | CTSTInfo getTSTInfo(); 26 | 27 | virtual ~CTimeStampToken(); 28 | 29 | int verify(REVOCATION_INFO* pRevocationInfo); 30 | int verify(const char* szDateTime, REVOCATION_INFO* pRevocationInfo); 31 | 32 | CASN1SetOf getCertificates(); 33 | }; 34 | 35 | #endif // !defined(AFX_TIMESTAMPTOKEN_H__2D568B92_6258_4EBE_B1CA_17F3746F3801__INCLUDED_) 36 | #endif // TIMESTAMPTOKEN 37 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/ASN1/UUCBufferedReader.h: -------------------------------------------------------------------------------- 1 | /* BufferedReader.h: interface for the CBufferedReader class. 2 | * 3 | * Copyright (c) 2000-2006 by Ugo Chirico - http://www.ugosweb.com 4 | * All Rights Reserved 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "Util/UUCByteArray.h" 24 | 25 | class UUCBufferedReader { 26 | public: 27 | unsigned int getPosition(); 28 | void setPosition(unsigned int index); 29 | // UUCBufferedReader(const char* szFilePath); 30 | UUCBufferedReader(const UUCByteArray& buffer); 31 | UUCBufferedReader(const BYTE* pbtBuffer, int len); 32 | 33 | virtual ~UUCBufferedReader(); 34 | 35 | unsigned int read(BYTE* pbtBuffer, unsigned int nLen); 36 | unsigned int read(UUCByteArray& byteArray); 37 | 38 | void mark(); 39 | void reset(); 40 | void releaseMark(); 41 | 42 | private: 43 | // unsigned int readNext(); 44 | 45 | // FILE* m_pf; 46 | BYTE* m_pbtBuffer; 47 | // UUCByteArray* m_pByteArray; 48 | unsigned int m_nBufPos; 49 | unsigned int m_nBufLen; 50 | unsigned int m_nIndex; 51 | bool m_bEOF; 52 | 53 | unsigned int* m_pnStack; 54 | unsigned int m_nStackSize; 55 | unsigned int m_nTop; 56 | }; 57 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/BigIntegerAlgorithms.cpp: -------------------------------------------------------------------------------- 1 | #include "BigIntegerAlgorithms.h" 2 | 3 | BigUnsigned gcd(BigUnsigned a, BigUnsigned b) { 4 | BigUnsigned trash; 5 | // Neat in-place alternating technique. 6 | for (;;) { 7 | if (b.isZero()) return a; 8 | a.divideWithRemainder(b, trash); 9 | if (a.isZero()) return b; 10 | b.divideWithRemainder(a, trash); 11 | } 12 | } 13 | 14 | void extendedEuclidean(BigInteger m, BigInteger n, BigInteger &g, BigInteger &r, 15 | BigInteger &s) { 16 | if (&g == &r || &g == &s || &r == &s) 17 | throw "BigInteger extendedEuclidean: Outputs are aliased"; 18 | BigInteger r1(1), s1(0), r2(0), s2(1), q; 19 | /* Invariants: 20 | * r1*m(orig) + s1*n(orig) == m(current) 21 | * r2*m(orig) + s2*n(orig) == n(current) */ 22 | for (;;) { 23 | if (n.isZero()) { 24 | r = r1; 25 | s = s1; 26 | g = m; 27 | return; 28 | } 29 | // Subtract q times the second invariant from the first invariant. 30 | m.divideWithRemainder(n, q); 31 | r1 -= q * r2; 32 | s1 -= q * s2; 33 | 34 | if (m.isZero()) { 35 | r = r2; 36 | s = s2; 37 | g = n; 38 | return; 39 | } 40 | // Subtract q times the first invariant from the second invariant. 41 | n.divideWithRemainder(m, q); 42 | r2 -= q * r1; 43 | s2 -= q * s1; 44 | } 45 | } 46 | 47 | BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n) { 48 | BigInteger g, r, s; 49 | extendedEuclidean(x, n, g, r, s); 50 | if (g == 1) 51 | // r*x + s*n == 1, so r*x === 1 (mod n), so r is the answer. 52 | return (r % n).getMagnitude(); // (r % n) will be nonnegative 53 | else 54 | throw "BigInteger modinv: x and n have a common factor"; 55 | } 56 | 57 | BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent, 58 | const BigUnsigned &modulus) { 59 | BigUnsigned ans = 1, base2 = (base % modulus).getMagnitude(); 60 | BigUnsigned::Index i = exponent.bitLength(); 61 | // For each bit of the exponent, most to least significant... 62 | while (i > 0) { 63 | i--; 64 | // Square. 65 | ans *= ans; 66 | ans %= modulus; 67 | // And multiply if the bit is a 1. 68 | if (exponent.getBit(i)) { 69 | ans *= base2; 70 | ans %= modulus; 71 | } 72 | } 73 | return ans; 74 | } 75 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/BigIntegerUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "BigIntegerUtils.h" 2 | 3 | #include "BigUnsignedInABase.h" 4 | 5 | std::string bigUnsignedToString(const BigUnsigned &x) { 6 | return std::string(BigUnsignedInABase(x, 10)); 7 | } 8 | 9 | std::string bigIntegerToString(const BigInteger &x) { 10 | return (x.getSign() == BigInteger::negative) 11 | ? (std::string("-") + bigUnsignedToString(x.getMagnitude())) 12 | : (bigUnsignedToString(x.getMagnitude())); 13 | } 14 | 15 | BigUnsigned stringToBigUnsigned(const std::string &s) { 16 | return BigUnsigned(BigUnsignedInABase(s, 10)); 17 | } 18 | 19 | BigInteger stringToBigInteger(const std::string &s) { 20 | // Recognize a sign followed by a BigUnsigned. 21 | return (s[0] == '-') 22 | ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1)), 23 | BigInteger::negative) 24 | : (s[0] == '+') 25 | ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1))) 26 | : BigInteger(stringToBigUnsigned(s)); 27 | } 28 | 29 | std::ostream &operator<<(std::ostream &os, const BigUnsigned &x) { 30 | BigUnsignedInABase::Base base; 31 | long osFlags = os.flags(); 32 | if (osFlags & os.dec) 33 | base = 10; 34 | else if (osFlags & os.hex) { 35 | base = 16; 36 | if (osFlags & os.showbase) os << "0x"; 37 | } else if (osFlags & os.oct) { 38 | base = 8; 39 | if (osFlags & os.showbase) os << '0'; 40 | } else 41 | throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags"; 42 | std::string s = std::string(BigUnsignedInABase(x, base)); 43 | os << s; 44 | return os; 45 | } 46 | 47 | std::ostream &operator<<(std::ostream &os, const BigInteger &x) { 48 | if (x.getSign() == BigInteger::negative) os << '-'; 49 | os << x.getMagnitude(); 50 | return os; 51 | } 52 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/UUCStringTable.cpp: -------------------------------------------------------------------------------- 1 | // UUCStringTable.cpp: implementation of the UUCStringTable class. 2 | #include "UUCStringTable.h" 3 | 4 | // Construction/Destruction 5 | UUCStringTable::UUCStringTable(int initialCapacity, float loadFactor) 6 | : UUCHashtable(initialCapacity, loadFactor) {} 7 | 8 | UUCStringTable::UUCStringTable(int initialCapacity) 9 | : UUCHashtable(initialCapacity) {} 10 | 11 | UUCStringTable::UUCStringTable() {} 12 | 13 | UUCStringTable::~UUCStringTable() { removeAll(); } 14 | 15 | void UUCStringTable::put(char* const& szKey, char* const& szValue) { 16 | char* szOldValue = NULL; 17 | char* szOldKey = szKey; 18 | 19 | char* szNewValue; 20 | char* szNewKey; 21 | 22 | if (containsKey(szKey)) { 23 | get(szOldKey, szOldValue); 24 | } else { 25 | szOldKey = NULL; 26 | } 27 | 28 | szNewValue = new char[strlen(szValue) + 1]; 29 | strcpy(szNewValue, szValue); 30 | 31 | szNewKey = new char[strlen(szKey) + 1]; 32 | strcpy(szNewKey, szKey); 33 | 34 | UUCHashtable::put(szNewKey, szNewValue); 35 | 36 | if (szOldKey) delete szOldKey; 37 | if (szOldValue) delete szOldValue; 38 | } 39 | 40 | unsigned long UUCStringTable::getHashValue(char* const& szKey) const { 41 | return UUCStringTable::getHash((const char*)szKey); 42 | } 43 | 44 | unsigned long UUCStringTable::getHash(const char* szKey) { 45 | int h = 0; 46 | int off = 0; 47 | char* val = (char*)szKey; 48 | int len = strlen((char*)szKey); 49 | 50 | if (len < 16) { 51 | for (int i = len; i > 0; i--) { 52 | h = (h * 37) + val[off++]; 53 | } 54 | } else { 55 | // only sample some characters 56 | int skip = len / 8; 57 | for (int i = len; i > 0; i -= skip, off += skip) { 58 | h = (h * 39) + val[off]; 59 | } 60 | } 61 | 62 | return h; 63 | } 64 | 65 | bool UUCStringTable::equal(char* const& szKey1, char* const& szKey2) const { 66 | return strcmp(szKey1, szKey2) == 0; 67 | } 68 | 69 | bool UUCStringTable::remove(char* const& szKey) { 70 | char* szNewValue; 71 | 72 | char* szNewKey = szKey; 73 | ; 74 | 75 | if (containsKey(szKey)) { 76 | get(szNewKey, szNewValue); 77 | 78 | UUCHashtable::remove(szNewKey); 79 | 80 | delete szNewKey; 81 | delete szNewValue; 82 | return true; 83 | } 84 | 85 | return false; 86 | } 87 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/UUCTextFileReader.cpp: -------------------------------------------------------------------------------- 1 | // UUCTextFile.cpp: implementation of the UUCTextFile class. 2 | #include "UUCTextFileReader.h" 3 | 4 | #include "UUCLogger.h" 5 | USE_LOG; 6 | 7 | // Construction/Destruction 8 | UUCTextFileReader::UUCTextFileReader(const char* szFilePath) { 9 | m_pf = fopen(szFilePath, "rt"); 10 | if (!m_pf) { 11 | throw (long)ERROR_FILE_NOT_FOUND; 12 | } 13 | } 14 | 15 | UUCTextFileReader::~UUCTextFileReader() { fclose(m_pf); } 16 | 17 | long UUCTextFileReader::readLine(UUCByteArray& line) { 18 | char szLine[2]; 19 | unsigned int i = 0; 20 | while ((fread(szLine, 1, 1, m_pf) > 0) && (szLine[0] != '\n')) { 21 | i++; 22 | line.append(szLine[0]); 23 | } 24 | 25 | if (i > 0) { 26 | line.append((BYTE)0); 27 | return 0; 28 | } else if ((i == 0) && szLine[0] == '\n') { 29 | return readLine(line); 30 | } else { 31 | return -1; 32 | } 33 | } 34 | 35 | long UUCTextFileReader::readLine(char* szLine, unsigned long nLen) { 36 | unsigned int i = 0; 37 | while ((fread(szLine + i, 1, 1, m_pf) > 0) && (szLine[i] != '\n')) { 38 | i++; 39 | if (i == nLen) { 40 | throw (long)ERROR_MORE_DATA; 41 | } 42 | } 43 | 44 | if (i > 0) { 45 | szLine[i] = 0; 46 | return 0; 47 | } else if ((i == 0) && szLine[i] == '\n') { 48 | return readLine(szLine, nLen); 49 | } else { 50 | return -1; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/UUCTextFileWriter.cpp: -------------------------------------------------------------------------------- 1 | // UUCTextFileWriter.cpp: implementation of the UUCTextFileWriter class. 2 | #include "UUCTextFileWriter.h" 3 | 4 | // Construction/Destruction 5 | UUCTextFileWriter::UUCTextFileWriter(const char* szFilePath, 6 | bool bAppend /*= false*/) { 7 | if (bAppend) 8 | m_pf = fopen(szFilePath, "a+t"); 9 | else 10 | m_pf = fopen(szFilePath, "wt"); 11 | 12 | if (!m_pf) throw (long)ERROR_FILE_NOT_FOUND; 13 | } 14 | 15 | UUCTextFileWriter::~UUCTextFileWriter() { fclose(m_pf); } 16 | 17 | long UUCTextFileWriter::writeLine(const char* szLine) { 18 | if (fprintf(m_pf, "%s\n", szLine) < 0) return -1; 19 | 20 | fflush(m_pf); 21 | 22 | return 0; 23 | } 24 | 25 | long UUCTextFileWriter::writeLine(const UUCByteArray& byteArray) { 26 | char* pszLine = new char[byteArray.getLength() + 1]; 27 | memcpy(pszLine, byteArray.getContent(), byteArray.getLength()); 28 | 29 | if (fprintf(m_pf, "%s\n", pszLine) < 0) { 30 | delete[] pszLine; 31 | return -1; 32 | } 33 | 34 | delete[] pszLine; 35 | fflush(m_pf); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/Util/UtilException.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Util/UtilException.h" 3 | 4 | #include "Util/util.h" 5 | 6 | logged_error::logged_error(std::string message) 7 | : std::runtime_error(message.c_str()) { 8 | logged_error(message.c_str()); 9 | } 10 | 11 | logged_error::logged_error(const char *message) : std::runtime_error(message) { 12 | OutputDebugString("%s", what()); 13 | } 14 | 15 | scard_error::scard_error(StatusWord sw) 16 | : logged_error(stdPrintf("Errore smart card:%x", sw)) {} 17 | 18 | windows_error::windows_error(long ris) 19 | : logged_error(stdPrintf("Errore windows:(%08x) ", ris)) {} 20 | -------------------------------------------------------------------------------- /libs/sign-sdk/src/definitions.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Sign/definitions.h" 3 | 4 | // static unsigned long g_nErr; 5 | using namespace std; 6 | 7 | int atox(const char* szVal) { 8 | int nVal = 0; 9 | 10 | if (szVal[1] >= '0' && szVal[1] <= '9') { 11 | nVal = szVal[1] - '0'; 12 | } else if (szVal[1] >= 'a' && szVal[1] <= 'f') { 13 | nVal = szVal[1] - 'a' + 10; 14 | } else if (szVal[1] >= 'A' && szVal[1] <= 'F') { 15 | nVal = szVal[1] - 'A' + 10; 16 | } else { 17 | throw(-1); 18 | } 19 | 20 | if (szVal[0] >= '0' && szVal[0] <= '9') { 21 | nVal += (szVal[0] - '0') * 16; 22 | } else if (szVal[0] >= 'a' && szVal[0] <= 'f') { 23 | nVal += (szVal[0] - 'a' + 10) * 16; 24 | } else if (szVal[0] >= 'A' && szVal[0] <= 'F') { 25 | nVal += (szVal[0] - 'A' + 10) * 16; 26 | } else { 27 | throw(-1); 28 | } 29 | 30 | return nVal; 31 | } 32 | -------------------------------------------------------------------------------- /packages/yap.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cie-middleware", 3 | "Description": "CIE middleware", 4 | "buildDir": "/tmp/", 5 | "output": "artifacts", 6 | "Projects": [ 7 | { 8 | "name": "cie-middleware" 9 | } 10 | ] 11 | } --------------------------------------------------------------------------------