diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3f6f5d6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + name: Build and Test + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + jdk: [1.8, 9, 11, 15] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.jdk }} + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Maven Build + run: mvn -V -B -DskipTests=true install + - name: Maven Test + run: mvn -B verify +# - name: Maven Code Coverage +# if: ${{ github.ref == 'refs/heads/main' && matrix.jdk == '1.8' && matrix.os == 'ubuntu-latest' }} +# run: mvn -B jacoco:report coveralls:report -DrepoToken=${{ secrets.COVERALLS_TOKEN }} diff --git a/.gitignore b/.gitignore index b878ed4..f06ffbd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ target/ +.DS_Store *.iml .idea/ .classpath diff --git a/README.md b/README.md index 9eaf2af..659e2e2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![CI](https://github.com/eXist-db/crypto-exist-java-lib/workflows/CI/badge.svg)](https://github.com/eXist-db/crypto-exist-java-lib/actions?query=workflow%3ACI) + # eXist-db implementation for EXPath Cryptographic Module This is an eXist-db implementation of the [EXPath HTTP Crypto Module specification](http://expath.org/spec/crypto). @@ -35,12 +37,12 @@ For the latest version of the specification for this module see [http://expath.o The implementation follows this specification. -### Examples of usage - -For examples of usage, see [this folder in github](src/test/java/org/expath/exist/crypto/xquery/) or [this collection](/apps/expath-crypto/tests/unit-tests) when this library is installed in eXist. - ### Unit Tests -Unit Tests can be found in [this folder in github](src/test/java/org/expath/exist/crypto/xquery/) or in [this collection](/apps/expath-crypto/tests/unit-tests) when this library is installed in eXist. +Unit Tests use [XQSuite](https://exist-db.org/exist/apps/doc/xqsuite) and can be found in the [src/test/xquery/crypto folder](src/test/xquery/crypto/). -When this library is installed in eXist, to get a simple test runner, showing description and status (passed / failed) for each unit test, go [here](/apps/expath-crypto/tests/test-plan.xq). +To run tests: + +```bash +$ mvn validate +``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5442993..27ed924 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,7 @@ 1.8.0 5.3.0 http://expath.org/ns/crypto + org.expath.exist.crypto.ExistExpathCryptoModule crypto ${crypto.module.ns} @@ -113,6 +114,17 @@ + + + src/test/resources + false + + + src/test/resources-filtered + true + + + org.apache.maven.plugins @@ -137,6 +149,19 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M5 + + + + integration-test + verify + + + + com.ruleoftech markdown-page-generator-plugin diff --git a/src/test/java/org/expath/exist/crypto/test-plan.xml b/src/test/java/org/expath/exist/crypto/test-plan.xml deleted file mode 100644 index 092965f..0000000 --- a/src/test/java/org/expath/exist/crypto/test-plan.xml +++ /dev/null @@ -1,946 +0,0 @@ - - - - Test plan for EXPath Cryptographic Module - 0.6 - - - Passed - Failed - Unfound - Undefined result token - - Partial - Unknown - Deprecated - Timeout - - - Claudius Teodorescu - Generate enveloped digital signature - 0.3 - - Generate an enveloped digital signature for an XML document by using the following parameters: - 'SHA1' canonicalization algorithm, 'DSA_SHA1' signature algorithm, - 'dsig' signature - namespace prefix, and an X509 - certificate. - - unit-tests/generateEnvelopedDigitalSignature.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/generateEnvelopedDigitalSignature.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Validate enveloped digital signature - 0.3 - - Validate an enveloped digital signature, which is generated by using the following parameters: - 'SHA1' canonicalization algorithm, 'DSA_SHA1' signature algorithm, - 'dsig' signature - namespace prefix, and an X509 - certificate. - - unit-tests/validateEnvelopedDigitalSignature.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/validateEnvelopedDigitalSignature.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric encryption of string, AES/CBC/PKCS5Padding - 0.4 - Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, and 128 bytes key. - unit-tests/encryptStringWithAesSymmetricKeyCbcMode.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/encryptStringWithAesSymmetricKeyCbcMode.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric encryption of string, AES/CBC/PKCS5Padding, default provider - 0.1 - Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, 128 bytes key, and default provider. - unit-tests/encryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/encryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric encryption of string, AES - 0.1 - Symmetric encryption of a string with AES transformation (implicit ECB mode), and 128 bytes key. - unit-tests/encryptStringWithAesSymmetricKeyEcbMode.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/encryptStringWithAesSymmetricKeyEcbMode.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric encryption of string, AES/CBC/PKCS5Padding, wrong key - 0.1 - Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, and wrong key. - unit-tests/encryptStringWithAesWrongSymmetricKeyCbcMode.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/encryptStringWithAesWrongSymmetricKeyCbcMode.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric encryption of string, AES/CBC/PKCS5Padding, wrong key, default provider - 0.1 - Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, wrong key, and default provider. - unit-tests/encryptStringWithAesWrongSymmetricKeyCbcModeDefaultProvider.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/encryptStringWithAesWrongSymmetricKeyCbcModeDefaultProvider.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric decryption of string, AES/CBC/PKCS5Padding - 0.4 - Symmetric decryption of a string with AES/CBC/PKCS5Padding transformation, and 128 bytes key. - unit-tests/decryptStringWithAesSymmetricKeyCbcMode.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/decryptStringWithAesSymmetricKeyCbcMode.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric decryption of string, AES/CBC/PKCS5Padding, default provider - 0.1 - Symmetric decryption of a string with AES/CBC/PKCS5Padding transformation, 128 bytes key, and default provider. - unit-tests/decryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/decryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Symmetric decryption of string, AES - 0.1 - Symmetric decryption of a string with AES transformation (implicit ECB mode), and 128 bytes key. - - unit-tests/decryptStringWithAesSymmetricKeyEcbMode.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/decryptStringWithAesSymmetricKeyEcbMode.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Error message for symmetric encryption of string - 0.3 - - Symmetric encryption of string ' - Test! - ' with AES algorithm and 136 key (testing with a wrong key, to see the error message). - - unit-tests/encryptStringWithAesWrongSymmetricKeyCbcMode.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/encryptStringWithAesWrongSymmetricKeyCbcMode.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-512' HMAC for string - 0.3 - HMAC for a string by using 'SHA-512' algorithm. - unit-tests/hmacStringWithSha512.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha512.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-512' HMAC for string, default format - 0.3 - HMAC for a string by using 'SHA-512' algorithm and the default format. - unit-tests/hmacStringWithSha512AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha512AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' hashing for string - 0.3 - Hashing a string by using 'MD5' algorithm. - unit-tests/hashStringWithMd5.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithMd5.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' hashing for string, default format - 0.1 - Hashing a string by using 'MD5' algorithm and the default format. - unit-tests/hashStringWithMd5AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithMd5AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-1' hashing for string - 0.3 - Hashing a string by using 'SHA-1' algorithm. - unit-tests/hashStringWithSha1.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha1.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-1' hashing for string, default format - 0.1 - Hashing a string by using 'SHA-1' algorithm and the default format. - unit-tests/hashStringWithSha1AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha1AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' HMAC for string - 0.3 - HMAC for a string by using 'MD5' algorithm. - unit-tests/hmacStringWithMd5.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithMd5.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' HMAC for string, default format - 0.1 - HMAC for a string by using 'MD5' algorithm and the default format. - unit-tests/hmacStringWithMd5AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithMd5AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-1' HMAC for string - 0.3 - HMAC for a string by using 'SHA-1' algorithm. - unit-tests/hmacStringWithSha1.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha1.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-1' HMAC for string, default format - 0.1 - HMAC for a string by using 'SHA-1' algorithm and the default format. - unit-tests/hmacStringWithSha1AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha1AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-256' HMAC for string - 0.3 - HMAC for a string by using 'SHA-256' algorithm. - unit-tests/hmacStringWithSha256.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha256.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-256' HMAC for string, default format - 0.1 - HMAC for a string by using 'SHA-256' algorithm and the default format. - unit-tests/hmacStringWithSha256AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha256AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-384' HMAC for string - 0.3 - HMAC for a string by using 'SHA-384' algorithm. - unit-tests/hmacStringWithSha384.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha384.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-384' HMAC for string, default format - 0.1 - HMAC for a string by using 'SHA-384' algorithm and the default format. - unit-tests/hmacStringWithSha384AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hmacStringWithSha384AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Joe Wicentowski - AWS REST request - 0.3 - Authenticating a REST Request as needed by S3 Amazon Web Service. - unit-tests/AwsRestRequest.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/AwsRestRequest.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - AWS REST request, default format - 0.1 - Authenticating a REST Request as needed by S3 Amazon Web Service with default format. - unit-tests/AwsRestRequestWithDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/AwsRestRequestWithDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-256' hashing for string - 0.1 - Hashing a string by using 'SHA-256' algorithm. - unit-tests/hashStringWithSha256.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha256.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-256' hashing for string, default format - 0.1 - Hashing a string by using 'SHA-256' algorithm and the default format. - unit-tests/hashStringWithSha256AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha256AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-384' hashing for string - 0.1 - Hashing a string by using 'SHA-384' algorithm. - unit-tests/hashStringWithSha384.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha384.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-384' hashing for string, default format - 0.1 - Hashing a string by using 'SHA-384' algorithm and the default format. - unit-tests/hashStringWithSha384AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha384AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-512' hashing for string - 0.1 - Hashing a string by using 'SHA-512' algorithm. - unit-tests/hashStringWithSha512.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha512.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-512' hashing for string, default format - 0.1 - Hashing a string by using 'SHA-512' algorithm and the default format. - unit-tests/hashStringWithSha512AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashStringWithSha512AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' hashing for binary - 0.1 - Hashing a binary by using 'MD5' algorithm. - unit-tests/hashBinaryWithMd5.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithMd5.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' hashing for binary, default format - 0.1 - Hashing a binary by using 'MD5' algorithm and the default format. - unit-tests/hashBinaryWithMd5AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithMd5AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-1' hashing for binary - 0.1 - Hashing a binary by using 'SHA-1' algorithm. - unit-tests/hashBinaryWithSha1.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha1.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-1' hashing for binary, default format - 0.1 - Hashing a binary by using 'SHA-1' algorithm and the default format. - unit-tests/hashBinaryWithSha1AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha1AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-256' hashing for binary - 0.1 - Hashing a binary by using 'SHA-256' algorithm. - unit-tests/hashBinaryWithSha256.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha256.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-256' hashing for binary, default format - 0.1 - Hashing a binary by using 'SHA-256' algorithm and the default format. - unit-tests/hashBinaryWithSha256AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha256AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-384' hashing for binary - 0.1 - Hashing a binary by using 'SHA-384' algorithm. - unit-tests/hashBinaryWithSha384.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha384.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-384' hashing for binary, default format - 0.1 - Hashing a string by using 'SHA-384' algorithm and the default format. - unit-tests/hashBinaryWithSha384AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha384AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-512' hashing for binary - 0.1 - Hashing a binary by using 'SHA-512' algorithm. - unit-tests/hashBinaryWithSha512.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha512.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'SHA-512' hashing for binary, default format - 0.1 - Hashing a binary by using 'SHA-512' algorithm and the default format. - unit-tests/hashBinaryWithSha512AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithSha512AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Hash binary with wrong algorithm - 0.1 - Hashing a binary with a wrong algorithm. Test will pass if the correct error is thrown. - - unit-tests/hashBinaryWithWrongAlgorithm.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithWrongAlgorithm.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - Hash binary with wrong algorithm, default format - 0.1 - Hashing a binary with a wrong algorithm and the default format. Test will pass if the correct - error is thrown. - - unit-tests/hashBinaryWithWrongAlgorithmAndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashBinaryWithWrongAlgorithmAndDefaultFormat.xq - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' hashing for XML file - 0.1 - Hashing an XML file with 'MD5' algorithm. - unit-tests/hashXmlWithMd5.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashXmlWithMd5.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - Claudius Teodorescu - 'MD5' hashing for XML file, default format - 0.1 - Hashing an XML file with 'MD5' algorithm and the default format. - unit-tests/hashXmlWithMd5AndDefaultFormat.xq - http://127.0.0.1:8080/utils/kert-new/services/source.xq?url=/tests/crypto/unit-tests/hashXmlWithMd5AndDefaultFormat.xq - - /result/result-token - - - - - - - unattended - assert-xml - - - -
    -
  • Generate enveloped digital signature
  • -
  • Validate enveloped digital signature
  • -
  • Symmetric encryption of string, AES/CBC/PKCS5Padding
  • -
  • Symmetric encryption of string, AES/CBC/PKCS5Padding, default provider
  • -
  • Symmetric encryption of string, AES
  • -
  • Symmetric encryption of string, AES/CBC/PKCS5Padding, wrong key
  • -
  • Symmetric encryption of string, AES/CBC/PKCS5Padding, wrong key, default provider
  • -
  • Symmetric decryption of string, AES/CBC/PKCS5Padding
  • -
  • Symmetric decryption of string, AES/CBC/PKCS5Padding, default provider
  • -
  • Symmetric decryption of string, AES
  • -
  • Error message for symmetric encryption of string
  • -
  • 'MD5' HMAC for string
  • -
  • 'MD5' HMAC for string, default format
  • -
  • 'SHA-1' HMAC for string
  • -
  • 'SHA-1' HMAC for string, default format
  • -
  • 'SHA-256' HMAC for string
  • -
  • 'SHA-256' HMAC for string, default format
  • -
  • 'SHA-384' HMAC for string
  • -
  • 'SHA-384' HMAC for string, default format
  • -
  • 'SHA-512' HMAC for string
  • -
  • 'SHA-512' HMAC for string, default format
  • -
  • 'MD5' hashing for string
  • -
  • 'MD5' hashing for string, default provider
  • -
  • 'SHA-1' hashing for string
  • -
  • 'SHA-1' hashing for string, default provider
  • -
  • 'SHA-256' hashing for string
  • -
  • 'SHA-256' hashing for string, default provider
  • -
  • 'SHA-384' hashing for string
  • -
  • 'SHA-384' hashing for string, default provider
  • -
  • 'SHA-512' hashing for string
  • -
  • 'SHA-512' hashing for string, default provider
  • -
  • 'MD5' hashing for binary
  • -
  • 'MD5' hashing for binary, default provider
  • -
  • 'SHA-1' hashing for binary
  • -
  • 'SHA-1' hashing for binary, default provider
  • -
  • 'SHA-256' hashing for binary
  • -
  • 'SHA-256' hashing for binary, default provider
  • -
  • 'SHA-384' hashing for binary
  • -
  • 'SHA-384' hashing for binary, default provider
  • -
  • 'SHA-512' hashing for binary
  • -
  • 'SHA-512' hashing for binary, default format
  • -
  • AWS REST request
  • -
  • AWS REST request, default format
  • -
  • Hash binary with wrong algorithm
  • -
  • Hash binary with wrong algorithm, default format
  • -
  • 'MD5' hashing for XML file
  • -
  • 'MD5' hashing for XML file, default format
  • -
-
-
\ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/AwsRestRequest.xq b/src/test/java/org/expath/exist/crypto/xquery/AwsRestRequest.xq deleted file mode 100644 index 2af30b2..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/AwsRestRequest.xq +++ /dev/null @@ -1,51 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $string-to-hash := 'PUT -c8fdb181845a4ca6b8fec737b3581d76 -text/html -Thu, 17 Nov 2005 18:49:58 GMT -x-amz-magic:password -x-amz-meta-author:foo@bar.com -/quotes/nelson' -let $expected-result := - jZNOcbfWmD/A/f3hSvVzXZjM2HU= -let $private-key :='OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV' -let $actual-result := - - {crypto:hmac($string-to-hash, $private-key, "HMAC-SHA-1", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/AwsRestRequestWithDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/AwsRestRequestWithDefaultFormat.xq deleted file mode 100644 index 0d01980..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/AwsRestRequestWithDefaultFormat.xq +++ /dev/null @@ -1,51 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $string-to-hash := 'PUT -c8fdb181845a4ca6b8fec737b3581d76 -text/html -Thu, 17 Nov 2005 18:49:58 GMT -x-amz-magic:abracadabra -x-amz-meta-author:foo@bar.com -/quotes/nelson' -let $expected-result := - jZNOcbfWmD/A/f3hSvVzXZjM2HU= -let $private-key :='OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV' -let $actual-result := - - {crypto:hmac($string-to-hash, $private-key, "HMAC-SHA-1")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyCbcMode.xq b/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyCbcMode.xq deleted file mode 100644 index f068f0a..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyCbcMode.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := Short string for tests. -let $iv := crypto:hash("initialization vector", "MD5", "base64") -let $actual-result := - - { - crypto:decrypt("51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, "SunJCE") - } - -let $condition := util:parse-html($expected-result) = util:parse-html($actual-result) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq b/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq deleted file mode 100644 index 169340f..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := Short string for tests. -let $iv := crypto:hash("initialization vector", "MD5", "base64") -let $actual-result := - - { - crypto:decrypt("51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, ()) - } - -let $condition := util:parse-html($expected-result) = util:parse-html($actual-result) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyEcbMode.xq b/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyEcbMode.xq deleted file mode 100644 index 61263be..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/decryptStringWithAesSymmetricKeyEcbMode.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := Short string for tests. -let $actual-result := - - { - crypto:decrypt("222-157-20-54-132-99-46-30-73-43-253-148-61-155-86-141-51-56-40-42-31-168-189-56-236-102-58-237-175-171-9-87", "symmetric", "1234567890123456", "AES", (), "SunJCE") - } - -let $condition := util:parse-html($expected-result) = util:parse-html($actual-result) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/encryptAbdDecryptStringWithAesSymmetricKeyCbcMode.xql b/src/test/java/org/expath/exist/crypto/xquery/encryptAbdDecryptStringWithAesSymmetricKeyCbcMode.xql deleted file mode 100644 index 5262fb8..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/encryptAbdDecryptStringWithAesSymmetricKeyCbcMode.xql +++ /dev/null @@ -1,51 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.1"; - -import module namespace crypto="http://expath.org/ns/crypto"; - -let $text := "String for tests. String for tests. String for tests." -let $type := 'symmetric' -let $key := '1234567890123456' -let $algorithm := 'AES/CBC/PKCS5Padding' -let $iv := crypto:hash("initialization vector", "MD5", "base64") - -let $expected-result := $text -let $iv := crypto:hash("initialization vector", "MD5", "base64") -let $actual-result := - let $encrypted := crypto:encrypt($text, $type, $key, $algorithm, $iv, "SunJCE") - let $decrypted := crypto:decrypt($encrypted, $type, $key, $algorithm, $iv, "SunJCE") - - return $decrypted -let $condition := normalize-space($expected-result) = normalize-space($actual-result) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyCbcMode.xq b/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyCbcMode.xq deleted file mode 100644 index a3447e2..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyCbcMode.xq +++ /dev/null @@ -1,46 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - 51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54 -let $iv := crypto:hash("initialization vector", "MD5", "base64") -let $actual-result := - - { - crypto:encrypt("Short string for tests.", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, "SunJCE") - } - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq b/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq deleted file mode 100644 index 8b39b76..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyCbcModeDefaultProvider.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := 51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54 -let $iv := crypto:hash("initialization vector", "MD5", "base64") -let $actual-result := - - { - crypto:encrypt("Short string for tests.", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, "") - } - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyEcbMode.xq b/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyEcbMode.xq deleted file mode 100644 index d9fafc7..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesSymmetricKeyEcbMode.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - 222-157-20-54-132-99-46-30-73-43-253-148-61-155-86-141-51-56-40-42-31-168-189-56-236-102-58-237-175-171-9-87 -let $actual-result := - - { - crypto:encrypt("Short string for tests.", "symmetric", "1234567890123456", "AES", (), "SunJCE") - } - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesWrongSymmetricKeyCbcMode.xq b/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesWrongSymmetricKeyCbcMode.xq deleted file mode 100644 index f985470..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesWrongSymmetricKeyCbcMode.xq +++ /dev/null @@ -1,50 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := err:CX19: The secret key is invalid -let $iv := crypto:hash("initialization vector", "MD5", "") -let $actual-result := - - { - try { - crypto:encrypt("Short string for tests.", "symmetric", "12345678901234567", "AES/CBC/PKCS5Padding", $iv, "SunJCE") - } - catch * { - {$err:description} - } - } - -let $condition := contains(normalize-space($actual-result/element()/text()), normalize-space($expected-result/element()/text())) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - diff --git a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesWrongSymmetricKeyCbcModeDefaultProvider.xq b/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesWrongSymmetricKeyCbcModeDefaultProvider.xq deleted file mode 100644 index facad1a..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/encryptStringWithAesWrongSymmetricKeyCbcModeDefaultProvider.xq +++ /dev/null @@ -1,51 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := err:CX19: The secret key is invalid -let $iv := crypto:hash("initialization vector", "MD5", "") -let $actual-result := - - { - try { - crypto:encrypt("Short string for tests.", "symmetric", "12345678901234567", "AES/CBC/PKCS5Padding", $iv, ()) - } - catch * { - {$err:description} - } - } - -let $condition := contains(normalize-space($actual-result/element()/text()), normalize-space($expected-result/element()/text())) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/generateEnvelopedDigitalSignature.xq b/src/test/java/org/expath/exist/crypto/xquery/generateEnvelopedDigitalSignature.xq deleted file mode 100644 index 14a7caa..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/generateEnvelopedDigitalSignature.xq +++ /dev/null @@ -1,57 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - /KaCzo4Syrom78z3EQ5SbbB4sF7ey80etKII864WF64B81uRpH5t9jQTxeEu0ImbzRMqzVDZkVG9 - xD7nN1kuFw== - -let $sample-doc := doc('../resources/doc-1.xml') -let $certificate-details := - - JKS - ab987c - eXist - kpi135 - {concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))} - -let $actual-result := - - { - let $signed-doc := crypto:generate-signature($sample-doc, "inclusive", "SHA1", "DSA_SHA1", "dsig", "enveloped") - return $signed-doc//*[local-name() = 'P']/text() - } - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithMd5.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithMd5.xq deleted file mode 100644 index 3a23aec..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithMd5.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - UI/aOJodA6gtJPitQ6xcJA== -let $actual-result := - - {crypto:hash($input, "MD5", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithMd5AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithMd5AndDefaultFormat.xq deleted file mode 100644 index 671c0d8..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithMd5AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - UI/aOJodA6gtJPitQ6xcJA== -let $actual-result := - - {crypto:hash($input, "MD5", ())} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha1.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha1.xq deleted file mode 100644 index 82e899e..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha1.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - GyscHvnJKxInsBLgSg/FRAmQXYU= -let $actual-result := - - {crypto:hash($input, "SHA-1", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha1AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha1AndDefaultFormat.xq deleted file mode 100644 index fc09901..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha1AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - GyscHvnJKxInsBLgSg/FRAmQXYU= -let $actual-result := - - {crypto:hash($input, "SHA-1", ())} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha256.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha256.xq deleted file mode 100644 index d8d6339..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha256.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - 37JiNBym250ye3aUJ04RaZg3SFSP03qJ8FR/I1JckVI= -let $actual-result := - - {crypto:hash($input, "SHA-256", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha256AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha256AndDefaultFormat.xq deleted file mode 100644 index 33c13a1..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha256AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - 37JiNBym250ye3aUJ04RaZg3SFSP03qJ8FR/I1JckVI= -let $actual-result := - - {crypto:hash($input, "SHA-256", ())} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha384.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha384.xq deleted file mode 100644 index 57755c7..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha384.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - DcQ3caBftiQCIQn96Pr8PC2vzs17Re0tZ8/CZnOoucu/N+818uqAXxR7l9oxYgoW -let $actual-result := - - {crypto:hash($input, "SHA-384", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha384AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha384AndDefaultFormat.xq deleted file mode 100644 index 6c73e73..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha384AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - DcQ3caBftiQCIQn96Pr8PC2vzs17Re0tZ8/CZnOoucu/N+818uqAXxR7l9oxYgoW -let $actual-result := - - {crypto:hash($input, "SHA-384", ())} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha512.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha512.xq deleted file mode 100644 index 838058b..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha512.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - Be+hlGy9TNibbaE+6DA2gu6kNj2GS+7b4egFcJDMzQSFQiGgFtTh/mD61ta4pDvc+jqHFlqOyJLH - irkROd86Mw== -let $actual-result := - - {crypto:hash($input, "SHA-512", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha512AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha512AndDefaultFormat.xq deleted file mode 100644 index 158d253..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithSha512AndDefaultFormat.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - Be+hlGy9TNibbaE+6DA2gu6kNj2GS+7b4egFcJDMzQSFQiGgFtTh/mD61ta4pDvc+jqHFlqOyJLH - irkROd86Mw== -let $actual-result := - - {crypto:hash($input, "SHA-512", ())} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithWrongAlgorithm.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithWrongAlgorithm.xq deleted file mode 100644 index 33ae643..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithWrongAlgorithm.xq +++ /dev/null @@ -1,51 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - err:CX21: The algorithm is not supported. -let $actual-result := - - { - try { - crypto:hash($input, "SHA-17", "base64") - } - catch * { - {$err:description} - } - } - -let $condition := contains(normalize-space($actual-result/element()/text()), normalize-space($expected-result/element()/text())) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithWrongAlgorithmAndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithWrongAlgorithmAndDefaultFormat.xq deleted file mode 100644 index 2da9d19..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashBinaryWithWrongAlgorithmAndDefaultFormat.xq +++ /dev/null @@ -1,51 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := util:binary-doc(concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))) -let $expected-result := - err:CX21: The algorithm is not supported. -let $actual-result := - - { - try { - crypto:hash($input, "SHA-17", ()) - } - catch * { - {$err:description} - } - } - -let $condition := contains(normalize-space($actual-result/element()/text()), normalize-space($expected-result/element()/text())) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithMd5.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithMd5.xq deleted file mode 100644 index 6a417a3..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithMd5.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - use1oAoe8vIgnFgygz2OKw== -, $actual-result := - - {crypto:hash("Short string for tests.", "MD5", "base64")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithMd5AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithMd5AndDefaultFormat.xq deleted file mode 100644 index 9f373d1..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithMd5AndDefaultFormat.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - use1oAoe8vIgnFgygz2OKw== -, $actual-result := - - {crypto:hash("Short string for tests.", "MD5")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha1.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha1.xq deleted file mode 100644 index 0400648..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha1.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - cV2wx17vo8eH2TaFRvCIIvJjNqU= -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-1", "base64")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha1AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha1AndDefaultFormat.xq deleted file mode 100644 index c0ecaa9..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha1AndDefaultFormat.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - cV2wx17vo8eH2TaFRvCIIvJjNqU= -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-1")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha256.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha256.xq deleted file mode 100644 index 51b58ea..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha256.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - E+B0JzLRgxm2+1rB8qIZoQ2Qn+JLxwJCWORv46fKhMM= -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-256", "base64")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha256AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha256AndDefaultFormat.xq deleted file mode 100644 index b35a4ff..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha256AndDefaultFormat.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - E+B0JzLRgxm2+1rB8qIZoQ2Qn+JLxwJCWORv46fKhMM= -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-256")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha384.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha384.xq deleted file mode 100644 index 489d232..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha384.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - F4CFDSBHm+Bm400bOgH2q2IbIUj8XRUBWf0inx7lrN0T8IHz9scGVmJoGZ2+s1La -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-384", "base64")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha384AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha384AndDefaultFormat.xq deleted file mode 100644 index ceabb3f..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha384AndDefaultFormat.xq +++ /dev/null @@ -1,43 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - F4CFDSBHm+Bm400bOgH2q2IbIUj8XRUBWf0inx7lrN0T8IHz9scGVmJoGZ2+s1La -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-384")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha512.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha512.xq deleted file mode 100644 index 6a66dfb..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha512.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - +YpeZRBrctlL1xr6plZOScp/6ArUw3GihjtKys1e3qQ6/aWLFjoOFEfuiUJA3uLIkebH1OG+rDdM - FZ0+/JFK2g== -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-512", "base64")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha512AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha512AndDefaultFormat.xq deleted file mode 100644 index 9dc3b62..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashStringWithSha512AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := - +YpeZRBrctlL1xr6plZOScp/6ArUw3GihjtKys1e3qQ6/aWLFjoOFEfuiUJA3uLIkebH1OG+rDdM - FZ0+/JFK2g== -, $actual-result := - - {crypto:hash("Short string for tests.", "SHA-512")} - -, $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashXmlWithMd5.xq b/src/test/java/org/expath/exist/crypto/xquery/hashXmlWithMd5.xq deleted file mode 100644 index cf7fcc6..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashXmlWithMd5.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := doc('../resources/doc-1.xml') -let $expected-result := - xMpCOKC5I4INzFCab3WEmw== -let $actual-result := - - {crypto:hash($input/*/*[1], "MD5", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hashXmlWithMd5AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hashXmlWithMd5AndDefaultFormat.xq deleted file mode 100644 index a03aaf9..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hashXmlWithMd5AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $input := doc('../resources/doc-1.xml') -let $expected-result := - xMpCOKC5I4INzFCab3WEmw== -let $actual-result := - - {crypto:hash($input/*/*[1], "MD5")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithMd5.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithMd5.xq deleted file mode 100644 index 38935b4..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithMd5.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - l4MY6Yosjo7W60VJeXB/PQ== -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-MD5", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithMd5AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithMd5AndDefaultFormat.xq deleted file mode 100644 index d96a9fa..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithMd5AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - l4MY6Yosjo7W60VJeXB/PQ== -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-MD5")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha1.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha1.xq deleted file mode 100644 index 24d1798..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha1.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - 55LyDq7GFnqijauK4CQWR4AqyZk= -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HmacSha1", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha1AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha1AndDefaultFormat.xq deleted file mode 100644 index aaec815..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha1AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - 55LyDq7GFnqijauK4CQWR4AqyZk= -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-1")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha256.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha256.xq deleted file mode 100644 index 0f30f94..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha256.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - FfZidcLEUg4oJLIZfw6xHlPMz8KPHxo2liaBKgLfcOE= -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HmacSha256", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha256AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha256AndDefaultFormat.xq deleted file mode 100644 index 5c8e9e4..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha256AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - FfZidcLEUg4oJLIZfw6xHlPMz8KPHxo2liaBKgLfcOE= -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-256")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha384.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha384.xq deleted file mode 100644 index 0ba3b72..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha384.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - RRirKZTmx+cG8EXvgrRnpYFPEPYXaZBirY+LFmiUBAK61LCryDsL4clFRG5/BcBr -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-384", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha384AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha384AndDefaultFormat.xq deleted file mode 100644 index 7334645..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha384AndDefaultFormat.xq +++ /dev/null @@ -1,44 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - RRirKZTmx+cG8EXvgrRnpYFPEPYXaZBirY+LFmiUBAK61LCryDsL4clFRG5/BcBr -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-384")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha512.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha512.xq deleted file mode 100644 index 1193ba2..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha512.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - z9MtEpBXxO5bKmsXJWfKsZ4v+RduKU89Y95H2HMGQEwHGefWmewNNQ7urZVuWEU5aeRRdO7G7j0Q - lcLYv1pkrg== -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-512", "base64")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha512AndDefaultFormat.xq b/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha512AndDefaultFormat.xq deleted file mode 100644 index 6a10c76..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/hmacStringWithSha512AndDefaultFormat.xq +++ /dev/null @@ -1,45 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $private-key := util:binary-to-string(util:binary-doc(concat('xmldb:', resolve-uri('../resources/private-key.pem', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/'))))) -let $expected-result := - z9MtEpBXxO5bKmsXJWfKsZ4v+RduKU89Y95H2HMGQEwHGefWmewNNQ7urZVuWEU5aeRRdO7G7j0Q - lcLYv1pkrg== -let $actual-result := - - {crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-512")} - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/org/expath/exist/crypto/xquery/validateEnvelopedDigitalSignature.xq b/src/test/java/org/expath/exist/crypto/xquery/validateEnvelopedDigitalSignature.xq deleted file mode 100644 index 2cc459c..0000000 --- a/src/test/java/org/expath/exist/crypto/xquery/validateEnvelopedDigitalSignature.xq +++ /dev/null @@ -1,54 +0,0 @@ -(: - : eXist-db EXPath Cryptographic library - : eXist-db wrapper for EXPath Cryptographic Java library - : Copyright (C) 2016 Claudius Teodorescu - : - : This library is free software; you can redistribute it and/or - : modify it under the terms of the GNU Lesser General Public License - : as published by the Free Software Foundation; either version 2.1 - : of the License, or (at your option) any later version. - : - : This library is distributed in the hope that it will be useful, - : but WITHOUT ANY WARRANTY; without even the implied warranty of - : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - : GNU Lesser General Public License for more details. - : - : You should have received a copy of the GNU Lesser General Public License - : along with this library; if not, write to the Free Software Foundation, - : Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - :) -xquery version "3.0"; - -import module "http://expath.org/ns/crypto"; - -let $expected-result := true -let $input := doc('../resources/doc-1.xml') -let $certificate-details := - - JKS - ab987c - eXist - kpi135 - {concat('xmldb:', resolve-uri('../resources/keystore.ks', concat(substring-after(system:get-module-load-path(), 'xmldb:'), '/')))} - -let $signed-doc := crypto:generate-signature($input, "inclusive", "SHA1", "DSA_SHA1", "dsig", "enveloped") -let $actual-result := - - { - crypto:validate-signature($signed-doc) - } - -let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text()) - - -return - - { - ( - if ($condition) - then passed - else failed - , $actual-result - ) - } - \ No newline at end of file diff --git a/src/test/java/xquery/crypto/CryptoIT.java b/src/test/java/xquery/crypto/CryptoIT.java new file mode 100644 index 0000000..2f267b4 --- /dev/null +++ b/src/test/java/xquery/crypto/CryptoIT.java @@ -0,0 +1,32 @@ +/* + * eXist-db Open Source Native XML Database + * Copyright (C) 2001 The eXist-db Authors + * + * info@exist-db.org + * http://www.exist-db.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package xquery.maps; + +import org.exist.test.runner.XSuite; +import org.junit.runner.RunWith; + +@RunWith(XSuite.class) +@XSuite.XSuiteFiles({ + "src/test/xquery/crypto" +}) +public class CryptoIT { +} diff --git a/src/test/resources-filtered/conf.xml b/src/test/resources-filtered/conf.xml new file mode 100644 index 0000000..f1e92ac --- /dev/null +++ b/src/test/resources-filtered/conf.xml @@ -0,0 +1,921 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/org/expath/exist/crypto/digital-certificate-base64.txt b/src/test/resources/org/expath/exist/crypto/digital-certificate-base64.txt deleted file mode 100644 index c9b0740..0000000 --- a/src/test/resources/org/expath/exist/crypto/digital-certificate-base64.txt +++ /dev/null @@ -1,6 +0,0 @@ -PGRpZ2l0YWwtY2VydGlmaWNhdGU+DQogIDxrZXlzdG9yZS10eXBlPkpLUzwva2V5c3RvcmUtdHlw -ZT4NCiAgPGtleXN0b3JlLXBhc3N3b3JkPmFiOTg3Yzwva2V5c3RvcmUtcGFzc3dvcmQ+DQogIDxr -ZXktYWxpYXM+ZVhpc3Q8L2tleS1hbGlhcz4NCiAgPHByaXZhdGUta2V5LXBhc3N3b3JkPmtwaTEz -NTwvcHJpdmF0ZS1rZXktcGFzc3dvcmQ+DQogIDxrZXlzdG9yZS11cmk+L3diPWUvdGVzdHMvZXhw -YXRoLWNyeXB0by9yZXNvdXJjZXMva2V5c3RvcmU8L2tleXN0b3JlLXVyaT4NCjwvZGlnaXRhbC1j -ZXJ0aWZpY2F0ZT4= \ No newline at end of file diff --git a/src/test/resources/org/expath/exist/crypto/digital-certificate.xml b/src/test/resources/org/expath/exist/crypto/digital-certificate.xml deleted file mode 100644 index a5bc4b7..0000000 --- a/src/test/resources/org/expath/exist/crypto/digital-certificate.xml +++ /dev/null @@ -1,7 +0,0 @@ - - JKS - ab987c - eXist - kpi135 - /wb=e/tests/expath-crypto/resources/keystore - \ No newline at end of file diff --git a/src/test/resources/org/expath/exist/crypto/doc-1.xml b/src/test/resources/org/expath/exist/crypto/doc-1.xml deleted file mode 100644 index e8cb69e..0000000 --- a/src/test/resources/org/expath/exist/crypto/doc-1.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - 1 - 7 - - - \ No newline at end of file diff --git a/src/test/resources/org/expath/exist/crypto/mycert.cer b/src/test/resources/org/expath/exist/crypto/mycert.cer deleted file mode 100644 index 533f7a3..0000000 --- a/src/test/resources/org/expath/exist/crypto/mycert.cer +++ /dev/null @@ -1,10 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIBqjCCARMCBgEteaBAlzANBgkqhkiG9w0BAQsFADAbMRkwFwYDVQQDExBUZXN0IENlcnRpZmlj -YXRlMB4XDTExMDExMjA5NDczMVoXDTExMDExMjA5NDkxMVowGzEZMBcGA1UEAxMQVGVzdCBDZXJ0 -aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAnCl2ubpT4A7eebwvjHJWJUSBsVg7 -zJA2GH9NxY5jVS7rQmEF3uPIzEIR1yhwg8WKqiEZ9hK6TFw3SyQ+u18K4AYZOtKwXmF3Gd3c9Lc9 -X8/djRENZ6u2rLEIW9uZGjWxYlTxif2aBoLjJkBnF3z4/IPO7Q92W9St0WIh8ggK428CAwEAATAN -BgkqhkiG9w0BAQsFAAOBgQAV2TNxFE3XJElZxtp09KLZAGkXyXWtzYdO/MAJebClBXmoL/6S5eRT -JZlrOlr4U/LFq9G+HxI/vNtzEpQed1cF9r3XjrcZHq1YN2wHTBt04STVSnKCavY0MV8Rjy/+Rah5 -tod8T9vPR0YkHJUPMaYp5EMTnG5U0qdlgbSvrZc4Dg== ------END CERTIFICATE----- diff --git a/src/test/resources/org/expath/exist/crypto/private-key.pem b/src/test/resources/org/expath/exist/crypto/private-key.pem deleted file mode 100644 index bffc6c9..0000000 --- a/src/test/resources/org/expath/exist/crypto/private-key.pem +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAhPxBGln4YOcOGOxmRYEN8nzYHYvQx+PP8GnbJ+kW4f6HvH8WMAUa2lTB6gib -LzJGezhqkMy8NT8ogVz8xbra3AyK/IBDzXpWtPhSxVOCo6hJfTjj7wX3E2AVN9CTUOYrS/3iSu1q -/6MoB6MDIj8wV0HO1ujXqEip45UgVl+xRVtU+1wiJQ7Gc8GEEyHVtK/X4joiyCEebJhFsI42Z9e4 -aETI/XOaLszyEQeipMRlyznpRL2x0chz+yj7KuwiMqBZmPYyeWBsbldW8xREwnHEyko5GWc6wkEi -vgFwzKaZWo2ct3pmZ9vwXKecAxbeJbyJQl/PDfSnqcwyhL6pOaSAuQIDAQABAoIBAHo5hnR7wIb/ -lbteetjitjjqeY8eU/OD9DfYcu6Jkth/Ia4jd/cGmhmU0O0Sn96O7KyPu5H+OfUOaWIMXt400LZy -aMON98NA77RAj4KBMI7OO0z2Hrgu2Vlbc+TqtJskESM04ulOsIroIAB02Ip/XSS1fS+UrbEjp9Fd -3GzGYp2E6IF/YtTXMiqgdrZVAoDPtxiMR/1KXuETiBkeMxPvXfgePXLi/rYBDcecmfsCEzDX8RZV -xLoPKFxuLaIrzdVhGVHwp88fB57OufLytmuvro71FNrFzcIO88NyDpEQVnsBadm9Ir0mb5uhYq9j -YV444b2Gra0/onJm7e/zRUSSJGkCgYEA67Q8gBSADrkc0UCypjnFV8WWCQJBPspb9Vnf2MJi5aYM -U5Sa/2H+tNoY+fJoa/eDSu1jeAn71TDcXZizihj3IT8gVdoXSncbcTulxEnaOi85Q2uKfSia16rX -d+MufjJ4UDC7vR/Ve+zIQOxpzBmcFO5cMnLS3mJdpWSdS7DyQpMCgYEAkG+6udsQ02GEKaJZl2mi -XBqe4Rh187sDCwiqSO5ItS4jUg1xF1cn1PuF2nvjztZyEsaKKYdiqekEQv3jA6gRsWFvRi/abFN3 -zau/5M42v7H1cgU7m+FsDywhN5IRAmGfEyL/2wpKuZ6lD2qqhGkXmxqyEqgmEClyIwxJKHWiAwMC -gYBCJK8Bpj8VYp8SnZxEh1u4uMrUtlxG2ZSasmDdvBbyqPk2jzI7zm0ipT1zDrJ88dVXNmy+Z9bS -ycZdQZfIfh8DpmpVjUER9YCu8vUeszbZMx1XrRsM6lMhiGC01PzcDx+yKSrV9NP81cKQbYd27gzd -1tHqmkxQebwbyLNXZU1mnwKBgDpuiPsBbdgmHkJ9pIMFwCJEvrvPmoBEyuFe2wzwIUfy52UdfP/1 -SW73ZlpSPoIB7Vo9Kc3NMJQOaaP0dC+Zgbbh9RNO7q1eQxxYfCRDbJC2nNZI2amhU4b70mBZ3jm5 -ZpJmWV2y1zIqxRnsjBlPLraX4Sx9DBEDw2H8aWhN1oIjAoGBANc0gizRHGfOK2UASXskuO5Ueias -6z0V7J/m93E7wK8IQHcZXGloy8S9QSX6uAqe48ZDVCZGPxqq7TppT+P9WsdqkXqxR7M/KLa+7Y6C -s1tkDtD9uOJN6CsLuVjfuo4ZT5SwC7pq842aQrqJveKWKdzEorQjWKeN8OM2wzEMs0P1 ------END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/src/test/resources/org/expath/exist/crypto/keystore.ks b/src/test/resources/xquery/crypto/keystore.ks similarity index 100% rename from src/test/resources/org/expath/exist/crypto/keystore.ks rename to src/test/resources/xquery/crypto/keystore.ks diff --git a/src/test/xquery/crypto/crypto-tests.xqm b/src/test/xquery/crypto/crypto-tests.xqm new file mode 100644 index 0000000..ab8712c --- /dev/null +++ b/src/test/xquery/crypto/crypto-tests.xqm @@ -0,0 +1,538 @@ +xquery version "3.1"; + +(: An xqsuite edition of the original java tests in crypto-exist-java-lib :) + +module namespace ct = "http://expath.org/ns/crypto/test"; + +import module "http://expath.org/ns/crypto"; + +declare namespace test="http://exist-db.org/xquery/xqsuite"; + +declare variable $ct:doc-1 := document { + + 1 + 7 + + + +}; + +declare variable $ct:private-key-pem := "-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAhPxBGln4YOcOGOxmRYEN8nzYHYvQx+PP8GnbJ+kW4f6HvH8WMAUa2lTB6gib +LzJGezhqkMy8NT8ogVz8xbra3AyK/IBDzXpWtPhSxVOCo6hJfTjj7wX3E2AVN9CTUOYrS/3iSu1q +/6MoB6MDIj8wV0HO1ujXqEip45UgVl+xRVtU+1wiJQ7Gc8GEEyHVtK/X4joiyCEebJhFsI42Z9e4 +aETI/XOaLszyEQeipMRlyznpRL2x0chz+yj7KuwiMqBZmPYyeWBsbldW8xREwnHEyko5GWc6wkEi +vgFwzKaZWo2ct3pmZ9vwXKecAxbeJbyJQl/PDfSnqcwyhL6pOaSAuQIDAQABAoIBAHo5hnR7wIb/ +lbteetjitjjqeY8eU/OD9DfYcu6Jkth/Ia4jd/cGmhmU0O0Sn96O7KyPu5H+OfUOaWIMXt400LZy +aMON98NA77RAj4KBMI7OO0z2Hrgu2Vlbc+TqtJskESM04ulOsIroIAB02Ip/XSS1fS+UrbEjp9Fd +3GzGYp2E6IF/YtTXMiqgdrZVAoDPtxiMR/1KXuETiBkeMxPvXfgePXLi/rYBDcecmfsCEzDX8RZV +xLoPKFxuLaIrzdVhGVHwp88fB57OufLytmuvro71FNrFzcIO88NyDpEQVnsBadm9Ir0mb5uhYq9j +YV444b2Gra0/onJm7e/zRUSSJGkCgYEA67Q8gBSADrkc0UCypjnFV8WWCQJBPspb9Vnf2MJi5aYM +U5Sa/2H+tNoY+fJoa/eDSu1jeAn71TDcXZizihj3IT8gVdoXSncbcTulxEnaOi85Q2uKfSia16rX +d+MufjJ4UDC7vR/Ve+zIQOxpzBmcFO5cMnLS3mJdpWSdS7DyQpMCgYEAkG+6udsQ02GEKaJZl2mi +XBqe4Rh187sDCwiqSO5ItS4jUg1xF1cn1PuF2nvjztZyEsaKKYdiqekEQv3jA6gRsWFvRi/abFN3 +zau/5M42v7H1cgU7m+FsDywhN5IRAmGfEyL/2wpKuZ6lD2qqhGkXmxqyEqgmEClyIwxJKHWiAwMC +gYBCJK8Bpj8VYp8SnZxEh1u4uMrUtlxG2ZSasmDdvBbyqPk2jzI7zm0ipT1zDrJ88dVXNmy+Z9bS +ycZdQZfIfh8DpmpVjUER9YCu8vUeszbZMx1XrRsM6lMhiGC01PzcDx+yKSrV9NP81cKQbYd27gzd +1tHqmkxQebwbyLNXZU1mnwKBgDpuiPsBbdgmHkJ9pIMFwCJEvrvPmoBEyuFe2wzwIUfy52UdfP/1 +SW73ZlpSPoIB7Vo9Kc3NMJQOaaP0dC+Zgbbh9RNO7q1eQxxYfCRDbJC2nNZI2amhU4b70mBZ3jm5 +ZpJmWV2y1zIqxRnsjBlPLraX4Sx9DBEDw2H8aWhN1oIjAoGBANc0gizRHGfOK2UASXskuO5Ueias +6z0V7J/m93E7wK8IQHcZXGloy8S9QSX6uAqe48ZDVCZGPxqq7TppT+P9WsdqkXqxR7M/KLa+7Y6C +s1tkDtD9uOJN6CsLuVjfuo4ZT5SwC7pq842aQrqJveKWKdzEorQjWKeN8OM2wzEMs0P1 +-----END RSA PRIVATE KEY-----"; + +declare + %test:setUp +function ct:setup() { + let $testCol := xmldb:create-collection("/db", "test") + return + ( + xmldb:store("/db/test", "doc-1.xml", $ct:doc-1), + + let $keystore := fn:unparsed-text("resource:xquery/crypto/keystore.ks") + return + xmldb:store-as-binary("/db/test", "keystore.ks", $keystore) + ) +}; + +declare + %test:tearDown +function ct:tear-down() { + xmldb:remove("/db/test") +}; + +(:~ Authenticating a REST Request as needed by S3 Amazon Web Service. :) +declare + %test:name("AWS REST request") + %test:assertEquals("jZNOcbfWmD/A/f3hSvVzXZjM2HU=") +function ct:aws-rest-request() { + let $string-to-hash := "PUT +c8fdb181845a4ca6b8fec737b3581d76 +text/html +Thu, 17 Nov 2005 18:49:58 GMT +x-amz-magic:password +x-amz-meta-author:foo@bar.com +/quotes/nelson" + let $private-key := "OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV" + return + crypto:hmac($string-to-hash, $private-key, "HMAC-SHA-1", "base64") +}; + +(:~ Authenticating a REST Request as needed by S3 Amazon Web Service with default format. :) +declare + %test:name("AWS REST request, default format") + %test:assertEquals("jZNOcbfWmD/A/f3hSvVzXZjM2HU=") +function ct:aws-rest-request-with-default-format() { + let $string-to-hash := "PUT +c8fdb181845a4ca6b8fec737b3581d76 +text/html +Thu, 17 Nov 2005 18:49:58 GMT +x-amz-magic:abracadabra +x-amz-meta-author:foo@bar.com +/quotes/nelson" + let $private-key := "OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV" + return + crypto:hmac($string-to-hash, $private-key, "HMAC-SHA-1") +}; + +(:~ Symmetric decryption of a string with AES/CBC/PKCS5Padding transformation, and 128 bytes key. :) +declare + %test:name("Symmetric decryption of string, AES/CBC/PKCS5Padding") + %test:assertEquals("Short string for tests.") +function ct:decrypt-string-with-aes-symmetric-key-cbc-mode() { + let $iv := crypto:hash("initialization vector", "MD5", "base64") + return + crypto:decrypt("51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, "SunJCE") +}; + +(:~ Symmetric decryption of a string with AES/CBC/PKCS5Padding transformation, 128 bytes key, and default provider. :) +declare + %test:name("Symmetric decryption of string, AES/CBC/PKCS5Padding, default provider") + %test:assertEquals("Short string for tests.") +function ct:decrypt-string-with-aes-symmetric-key-cbc-mode-default-provider() { + let $iv := crypto:hash("initialization vector", "MD5", "base64") + return + crypto:decrypt("51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, ()) +}; + +(:~ Symmetric decryption of a string with AES transformation (implicit ECB mode), and 128 bytes key. :) +declare + %test:name("Symmetric decryption of string, AES") + %test:assertEquals("Short string for tests.") +function ct:decrypt-string-with-aes-symmetric-key-ecb-mode() { + crypto:decrypt("222-157-20-54-132-99-46-30-73-43-253-148-61-155-86-141-51-56-40-42-31-168-189-56-236-102-58-237-175-171-9-87", "symmetric", "1234567890123456", "AES", (), "SunJCE") +}; + +(:~ Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, and 128 bytes key. :) +declare + %test:name("Symmetric encryption of string, AES/CBC/PKCS5Padding") + %test:assertEquals("51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54") +function ct:encrypt-string-with-aes-symmetric-key-cbc-mode() { + let $iv := crypto:hash("initialization vector", "MD5", "base64") + return + crypto:encrypt("Short string for tests.", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, "SunJCE") +}; + +(:~ Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, 128 bytes key, and default provider. :) +declare + %test:name("Symmetric encryption of string, AES/CBC/PKCS5Padding, default provider") + %test:assertEquals("51-143-171-200-187-20-34-252-231-243-254-42-36-13-9-123-191-251-243-42-3-238-193-13-155-168-139-67-135-3-143-54") +function ct:encrypt-string-with-aes-symmetric-key-cbc-mode-default-provider() { + let $iv := crypto:hash("initialization vector", "MD5", "base64") + return + crypto:encrypt("Short string for tests.", "symmetric", "1234567890123456", "AES/CBC/PKCS5Padding", $iv, "") +}; + +(:~ Symmetric encryption of a string with AES transformation (implicit ECB mode), and 128 bytes key. :) +declare + %test:name("Symmetric encryption of string, AES") + %test:assertEquals("222-157-20-54-132-99-46-30-73-43-253-148-61-155-86-141-51-56-40-42-31-168-189-56-236-102-58-237-175-171-9-87") +function ct:encrypt-string-with-aes-symmetric-key-ecb-mode() { + crypto:encrypt("Short string for tests.", "symmetric", "1234567890123456", "AES", (), "SunJCE") +}; + +(:~ Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, and wrong key. :) +declare + %test:name("Symmetric encryption of string, AES/CBC/PKCS5Padding, wrong key") + %test:assertError("err:CX19: The secret key is invalid") +function ct:encrypt-string-with-aes-wrong-symmetric-key-cbc-Mode() { + let $iv := crypto:hash("initialization vector", "MD5", "") + return + crypto:encrypt("Short string for tests.", "symmetric", "12345678901234567", "AES/CBC/PKCS5Padding", $iv, "SunJCE") +}; + +(:~ Symmetric encryption of a string with AES/CBC/PKCS5Padding transformation, wrong key, and default provider. :) +declare + %test:name("Symmetric encryption of string, AES/CBC/PKCS5Padding, wrong key, default provider") + %test:assertEquals("err:CX19: The secret key is invalid") +function ct:encrypt-string-with-aes-wrong-symmetric-key-cbc-mode-default-provider() { + let $iv := crypto:hash("initialization vector", "MD5", "") + return + crypto:encrypt("Short string for tests.", "symmetric", "12345678901234567", "AES/CBC/PKCS5Padding", $iv, ()) +}; + +(:~ Generate an enveloped digital signature for an XML document by using the following parameters: + : 'SHA1' canonicalization algorithm, + : 'DSA_SHA1' signature algorithm, + : 'dsig' signature namespace prefix, + : and an X509 certificate. :) +declare + %test:name("Generate enveloped digital signature") + %test:assertEquals("/KaCzo4Syrom78z3EQ5SbbB4sF7ey80etKII864WF64B81uRpH5t9jQTxeEu0ImbzRMqzVDZkVG9xD7nN1kuFw==") +function ct:generate-enveloped-digital-signature() { + let $sample-doc := $ct:doc-1 + let $certificate-details := + + JKS + ab987c + eXist + kpi135 + xmldb:///db/test/keystore.ks + + let $signed-doc := crypto:generate-signature($sample-doc, "inclusive", "SHA1", "DSA_SHA1", "dsig", "enveloped") + return + $signed-doc//*[local-name() = 'P']/text() +}; + +(:~ Hashing a binary by using 'MD5' algorithm. :) +declare + %test:name("'MD5' hashing for binary") + %test:assertEquals("UI/aOJodA6gtJPitQ6xcJA==") +function ct:hash-binary-with-md5() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "MD5", "base64") +}; + +(:~ Hashing a binary by using 'MD5' algorithm and the default format. :) +declare + %test:name("'MD5' hashing for binary, default format") + %test:assertEquals("UI/aOJodA6gtJPitQ6xcJA==") +function ct:hash-binary-with-md5-and-default-format() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "MD5", ()) +}; + +(:~ Hashing a binary by using 'SHA-1' algorithm. :) +declare + %test:name("'SHA-1' hashing for binary") + %test:assertEquals("GyscHvnJKxInsBLgSg/FRAmQXYU=") +function ct:hash-binary-with-sha1() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-1", "base64") +}; + +(:~ Hashing a binary by using 'SHA-1' algorithm and the default format. :) +declare + %test:name("'SHA-1' hashing for binary, default format") + %test:assertEquals("GyscHvnJKxInsBLgSg/FRAmQXYU=") +function ct:hash-binary-with-sha1-and-default-format() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-1", ()) +}; + +(:~ Hashing a binary by using 'SHA-256' algorithm. :) +declare + %test:name("'SHA-256' hashing for binary") + %test:assertEquals("37JiNBym250ye3aUJ04RaZg3SFSP03qJ8FR/I1JckVI=") +function ct:hash-binary-with-sha256() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-256", "base64") +}; + +(:~ Hashing a binary by using 'SHA-256' algorithm and the default format. :) +declare + %test:name("'SHA-256' hashing for binary, default format") + %test:assertEquals("37JiNBym250ye3aUJ04RaZg3SFSP03qJ8FR/I1JckVI=") +function ct:hash-binary-with-sha256-and-default-format() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-256", ()) +}; + +(:~ Hashing a binary by using 'SHA-384' algorithm. :) +declare + %test:name("'SHA-384' hashing for binary") + %test:assertEquals("DcQ3caBftiQCIQn96Pr8PC2vzs17Re0tZ8/CZnOoucu/N+818uqAXxR7l9oxYgoW") +function ct:hash-binary-with-sha384() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-384", "base64") +}; + +(:~ Hashing a string by using 'SHA-384' algorithm and the default format. :) +declare + %test:name("'SHA-384' hashing for binary, default format") + %test:assertEquals("DcQ3caBftiQCIQn96Pr8PC2vzs17Re0tZ8/CZnOoucu/N+818uqAXxR7l9oxYgoW") +function ct:hash-binary-with-sha384-and-default-format() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-384", ()) +}; + +(:~ Hashing a binary by using 'SHA-512' algorithm. :) +declare + %test:name("'SHA-512' hashing for binary") + %test:assertEquals("Be+hlGy9TNibbaE+6DA2gu6kNj2GS+7b4egFcJDMzQSFQiGgFtTh/mD61ta4pDvc+jqHFlqOyJLHirkROd86Mw==") +function ct:hash-binary-with-sha512() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-512", "base64") +}; + +(:~ Hashing a binary by using 'SHA-512' algorithm and the default format. :) +declare + %test:name("'SHA-512' hashing for binary, default format") + %test:assertEquals("Be+hlGy9TNibbaE+6DA2gu6kNj2GS+7b4egFcJDMzQSFQiGgFtTh/mD61ta4pDvc+jqHFlqOyJLHirkROd86Mw==") +function ct:hash-binary-with-sha512-and-default-format() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-512", ()) +}; + +(:~ Hashing a binary with a wrong algorithm. Test will pass if the correct error is thrown. :) +declare + %test:name("Hash binary with wrong algorithm") + %test:assertError("err:CX21: The algorithm is not supported.") +function ct:hash-binary-with-wrong-algorithm() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-17", "base64") +}; + +(:~ Hashing a binary with a wrong algorithm and the default format. Test will pass if the correct error is thrown. :) +declare + %test:name("Hash binary with wrong algorithm, default format") + %test:assertError("err:CX21: The algorithm is not supported.") +function ct:hash-binary-with-wrong-algorithm-and-default-format() { + let $input := util:binary-doc("/db/test/keystore.ks") + return + crypto:hash($input, "SHA-17", ()) +}; + +(:~ Hashing an XML file with 'MD5' algorithm. :) +declare + %test:name("'MD5' hashing for string") + %test:assertEquals("use1oAoe8vIgnFgygz2OKw==") +function ct:hash-string-with-md5() { + crypto:hash("Short string for tests.", "MD5", "base64") +}; + +(:~ Hashing an XML file with 'MD5' algorithm and the default format. :) +declare + %test:name("'MD5' hashing for string, default format") + %test:assertEquals("use1oAoe8vIgnFgygz2OKw==") +function ct:hash-string-with-md5-and-default-format() { + crypto:hash("Short string for tests.", "MD5") +}; + +(:~ Hashing a string by using 'SHA-1' algorithm. :) +declare + %test:name("'SHA-1' hashing for string") + %test:assertEquals("cV2wx17vo8eH2TaFRvCIIvJjNqU=") +function ct:hash-string-with-sha1() { + crypto:hash("Short string for tests.", "SHA-1", "base64") +}; + +(:~ Hashing a string by using 'SHA-1' algorithm and the default format. :) +declare + %test:name("'SHA-1' hashing for string, default format") + %test:assertEquals("cV2wx17vo8eH2TaFRvCIIvJjNqU=") +function ct:hash-string-with-sha1-and-default-format() { + crypto:hash("Short string for tests.", "SHA-1") +}; + +(:~ Hashing a string by using 'SHA-256' algorithm. :) +declare + %test:name("'SHA-256' hashing for string") + %test:assertEquals("E+B0JzLRgxm2+1rB8qIZoQ2Qn+JLxwJCWORv46fKhMM=") +function ct:hash-string-with-sha256() { + crypto:hash("Short string for tests.", "SHA-256", "base64") +}; + +(:~ Hashing a string by using 'SHA-256' algorithm and the default format. :) +declare + %test:name("'SHA-256' hashing for string, default format") + %test:assertEquals("E+B0JzLRgxm2+1rB8qIZoQ2Qn+JLxwJCWORv46fKhMM=") +function ct:hash-string-with-sha256-and-default-format() { + crypto:hash("Short string for tests.", "SHA-256") +}; + +(:~ Hashing a string by using 'SHA-384' algorithm. :) +declare + %test:assertEquals("F4CFDSBHm+Bm400bOgH2q2IbIUj8XRUBWf0inx7lrN0T8IHz9scGVmJoGZ2+s1La") + %test:name("'SHA-384' hashing for string") +function ct:hash-string-with-sha384() { + crypto:hash("Short string for tests.", "SHA-384", "base64") +}; + +(:~ Hashing a string by using 'SHA-384' algorithm and the default format. :) +declare + %test:assertEquals("F4CFDSBHm+Bm400bOgH2q2IbIUj8XRUBWf0inx7lrN0T8IHz9scGVmJoGZ2+s1La") + %test:name("'SHA-384' hashing for string, default format") +function ct:hash-string-with-sha384-and-default-format() { + crypto:hash("Short string for tests.", "SHA-384") +}; + +(:~ Hashing a string by using 'SHA-512' algorithm. :) +declare + %test:assertEquals("+YpeZRBrctlL1xr6plZOScp/6ArUw3GihjtKys1e3qQ6/aWLFjoOFEfuiUJA3uLIkebH1OG+rDdMFZ0+/JFK2g==") + %test:name("'SHA-512' hashing for string") +function ct:hash-string-with-sha512() { + crypto:hash("Short string for tests.", "SHA-512", "base64") +}; + +(:~ Hashing a string by using 'SHA-512' algorithm and the default format. :) +declare + %test:name("'SHA-512' hashing for string, default format") + %test:assertEquals("+YpeZRBrctlL1xr6plZOScp/6ArUw3GihjtKys1e3qQ6/aWLFjoOFEfuiUJA3uLIkebH1OG+rDdMFZ0+/JFK2g==") +function ct:hash-string-with-sha512-and-default-format() { + crypto:hash("Short string for tests.", "SHA-512") +}; + +(:~ Hashing an XML file with 'MD5' algorithm. :) +declare + %test:name("'MD5' hashing for XML file") + %test:assertEquals("xMpCOKC5I4INzFCab3WEmw==") +function ct:hash-xml-with-md5() { + let $input := $ct:doc-1 + return + crypto:hash($input/*/*[1], "MD5", "base64") +}; + +(:~ Hashing an XML file with 'MD5' algorithm and the default format. :) +declare + %test:name("'MD5' hashing for XML file, default format") + %test:assertEquals("xMpCOKC5I4INzFCab3WEmw==") +function ct:hash-xml-with-md5-and-default-format() { + let $input := $ct:doc-1 + return + crypto:hash($input/*/*[1], "MD5") +}; + +(:~ HMAC for a string by using 'MD5' algorithm. :) +declare + %test:name("'MD5' HMAC for string") + %test:assertEquals("l4MY6Yosjo7W60VJeXB/PQ==") +function ct:hmac-string-with-md5() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-MD5", "base64") +}; + +(:~ HMAC for a string by using 'MD5' algorithm and the default format. :) +declare + %test:name("'MD5' HMAC for string, default format") + %test:assertEquals("l4MY6Yosjo7W60VJeXB/PQ==") +function ct:hmac-string-with-md5-and-default-format() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-MD5") +}; + +(:~ HMAC for a string by using 'SHA-1' algorithm. :) +declare + %test:name("'SHA-1' HMAC for string") + %test:assertEquals("55LyDq7GFnqijauK4CQWR4AqyZk=") +function ct:hmac-string-with-sha1() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HmacSha1", "base64") +}; + +(:~ HMAC for a string by using 'SHA-1' algorithm and the default format. :) +declare + %test:name("'SHA-1' HMAC for string, default format") + %test:assertEquals("55LyDq7GFnqijauK4CQWR4AqyZk=") +function ct:hmac-string-with-sha1-and-default-format() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-1") +}; + +(:~ HMAC for a string by using 'SHA-256' algorithm. :) +declare + %test:name("'SHA-256' HMAC for string") + %test:assertEquals("FfZidcLEUg4oJLIZfw6xHlPMz8KPHxo2liaBKgLfcOE=") +function ct:hmac-string-with-sha256() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HmacSha256", "base64") +}; + +(:~ HMAC for a string by using 'SHA-256' algorithm and the default format. :) +declare + %test:name("'SHA-256' HMAC for string, default format") + %test:assertEquals("FfZidcLEUg4oJLIZfw6xHlPMz8KPHxo2liaBKgLfcOE=") +function ct:hmac-string-with-sha256-and-default-format() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-256") +}; + +(:~ HMAC for a string by using 'SHA-384' algorithm. :) +declare + %test:name("'SHA-384' HMAC for string") + %test:assertEquals("RRirKZTmx+cG8EXvgrRnpYFPEPYXaZBirY+LFmiUBAK61LCryDsL4clFRG5/BcBr") +function ct:hmac-string-with-sha384() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-384", "base64") +}; + +(:~ HMAC for a string by using 'SHA-384' algorithm and the default format. :) +declare + %test:name("'SHA-384' HMAC for string, default format") + %test:assertEquals("RRirKZTmx+cG8EXvgrRnpYFPEPYXaZBirY+LFmiUBAK61LCryDsL4clFRG5/BcBr") +function ct:hmac-string-with-sha-384-and-default-format() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-384") +}; + +(:~ Authenticating a REST Request as needed by S3 Amazon Web Service. :) +declare + %test:name("'SHA-512' HMAC for string") + %test:assertEquals("z9MtEpBXxO5bKmsXJWfKsZ4v+RduKU89Y95H2HMGQEwHGefWmewNNQ7urZVuWEU5aeRRdO7G7j0QlcLYv1pkrg==") +function ct:hmac-string-with-sha-512() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-512", "base64") +}; + +(:~ Authenticating a REST Request as needed by S3 Amazon Web Service with default format. :) +declare + %test:name("'SHA-512' HMAC for string, default format") + %test:assertEquals("z9MtEpBXxO5bKmsXJWfKsZ4v+RduKU89Y95H2HMGQEwHGefWmewNNQ7urZVuWEU5aeRRdO7G7j0QlcLYv1pkrg==") +function ct:hmac-string-with-sha512-and-default-format() { + let $private-key := $ct:private-key-pem + return + crypto:hmac("Short string for tests.", $private-key, "HMAC-SHA-512") +}; + +(:~ Validate an enveloped digital signature, which is generated by using the following parameters: + : 'SHA1' canonicalization algorithm, + : 'DSA_SHA1' signature algorithm, + : 'dsig' signature namespace prefix, + : and an X509 certificate. :) +declare + %test:name("Validate enveloped digital signature") + %test:assertTrue +function ct:validate-enveloped-digital-signature() { + let $input := $ct:doc-1 + let $certificate-details := + + JKS + ab987c + eXist + kpi135 + xmldb:///db/test/keystore.ks + + let $signed-doc := crypto:generate-signature($input, "inclusive", "SHA1", "DSA_SHA1", "dsig", "enveloped") + return + crypto:validate-signature($signed-doc) +}; diff --git a/xar-assembly.xml b/xar-assembly.xml index 9203c5a..61f7cf8 100644 --- a/xar-assembly.xml +++ b/xar-assembly.xml @@ -31,7 +31,7 @@ ${crypto.module.ns} - urn:java:class:org.expath.exist.crypto.ExistExpathCryptoModule + urn:java:class:${crypto.module.java.class}