pax_global_header 0000666 0000000 0000000 00000000064 14125500636 0014514 g ustar 00root root 0000000 0000000 52 comment=21af2aaec9e8948019e5189fa3fa5d2417f9eafa
jss-5.0.0/ 0000775 0000000 0000000 00000000000 14125500636 0012315 5 ustar 00root root 0000000 0000000 jss-5.0.0/.classpath 0000664 0000000 0000000 00000001532 14125500636 0014301 0 ustar 00root root 0000000 0000000
jss-5.0.0/.copr/ 0000775 0000000 0000000 00000000000 14125500636 0013336 5 ustar 00root root 0000000 0000000 jss-5.0.0/.copr/Makefile 0000664 0000000 0000000 00000000244 14125500636 0014776 0 ustar 00root root 0000000 0000000 srpm:
dnf install -y git
./build.sh --with-timestamp --with-commit-id srpm
if [[ "${outdir}" != "" ]]; then \
mv ${HOME}/build/jss/SRPMS/* ${outdir}; \
fi
jss-5.0.0/.github/ 0000775 0000000 0000000 00000000000 14125500636 0013655 5 ustar 00root root 0000000 0000000 jss-5.0.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14125500636 0015712 5 ustar 00root root 0000000 0000000 jss-5.0.0/.github/workflows/build-tests.yml 0000664 0000000 0000000 00000003676 14125500636 0020710 0 ustar 00root root 0000000 0000000 name: Build Tests
on: [push, pull_request]
jobs:
build-test:
name: Build Test
runs-on: ubuntu-latest
strategy:
matrix:
os:
- 'fedora:latest'
- 'debian:testing'
- 'ubuntu:rolling'
# Disable CentOS due to missing dependencies
# - 'centos:7'
# - 'centos:8'
container: ${{ matrix.os }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Install Fedora/CentOS dependencies
if: ${{ startsWith(matrix.os, 'fedora:') || startsWith(matrix.os, 'centos:') }}
run: |
dnf install -y dnf-plugins-core rpm-build
dnf builddep -y --spec jss.spec
- name: Install Debian/Ubuntu dependencies
if: ${{ startsWith(matrix.os, 'debian:') || startsWith(matrix.os, 'ubuntu:') }}
run: |
apt-get update
apt-get install -y \
cmake zip unzip \
g++ libnss3-dev libnss3-tools \
openjdk-11-jdk libcommons-lang3-java libslf4j-java junit4
- name: Build JSS binaries, Javadoc, and run tests
run: ./build.sh
# Compare JNI symbols in the code and in the version script.
# If there are JNI symbols in the code but not in the version script -> fail.
symbol-test:
name: Symbol Test
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Get JNI symbols in the code
run: |
grep -iroh '^Java_org_mozilla[^(;]*' src/main/java/ | sort -u > /tmp/functions.txt
cat /tmp/functions.txt
- name: Get JNI symbols in the version script
run: |
grep -iroh '^Java_org_mozilla[^(;]*' lib/ | sort -u > /tmp/version.txt
cat /tmp/version.txt
- name: Compare JNI symbols
run: |
diff /tmp/functions.txt /tmp/version.txt || true
comm -23 --check-order /tmp/functions.txt /tmp/version.txt > /tmp/diff.txt
test ! -s /tmp/diff.txt
jss-5.0.0/.github/workflows/code-analysis.yml 0000664 0000000 0000000 00000002227 14125500636 0021173 0 ustar 00root root 0000000 0000000 name: Code Analysis
on: [push, pull_request]
jobs:
build:
name: Code analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
-Dsonar.c.file.suffixes= -Dsonar.cpp.file.suffixes=- -Dsonar.objc.file.suffixes=-
jss-5.0.0/.github/workflows/known_failures.yml 0000664 0000000 0000000 00000000651 14125500636 0021465 0 ustar 00root root 0000000 0000000 name: Known Failing Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
image:
- 'fedora_rawhide'
- 'fedora_sandbox'
steps:
- name: Clone the repository
uses: actions/checkout@v2
- name: Build and Run the Docker Image
run: bash tools/run_container.sh "${{ matrix.image }}" || echo "::warning ::Job exited with status $?"
jss-5.0.0/.github/workflows/maven-tests.yml 0000664 0000000 0000000 00000000724 14125500636 0020706 0 ustar 00root root 0000000 0000000 name: Maven Tests
on: [push, pull_request]
jobs:
build:
name: Building JSS
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Build JSS
run: mvn install
- name: Build examples
run: mvn compile
working-directory: examples
# TODO: Run examples
jss-5.0.0/.github/workflows/pkcs11-tests.yml 0000664 0000000 0000000 00000006105 14125500636 0020701 0 ustar 00root root 0000000 0000000 name: PKCS11 Tests
on: [push, pull_request]
jobs:
init:
name: Initializing Workflow
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.init.outputs.matrix }}
repo: ${{ steps.init.outputs.repo }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Initialize workflow
id: init
env:
BASE64_MATRIX: ${{ secrets.BASE64_MATRIX }}
BASE64_REPO: ${{ secrets.BASE64_REPO }}
run: |
tests/bin/init-workflow.sh
build:
name: Building JSS
needs: init
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build runner image
uses: docker/build-push-action@v2
with:
context: .
build-args: |
OS_VERSION=${{ matrix.os }}
COPR_REPO=${{ needs.init.outputs.repo }}
BUILD_OPTS=--with-timestamp --with-commit-id
tags: jss-runner
target: jss-runner
outputs: type=docker,dest=/tmp/jss-runner.tar
- name: Upload runner image
uses: actions/cache@v2
with:
key: jss-runner-${{ matrix.os }}
path: /tmp/jss-runner.tar
pkcs11-constants-test:
name: Testing PKCS11 Constants
needs: [init, build]
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/jss
strategy:
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Download runner image
uses: actions/cache@v2
with:
key: jss-runner-${{ matrix.os }}
path: /tmp/jss-runner.tar
- name: Load runner image
run: docker load --input /tmp/jss-runner.tar
- name: Run container
run: |
IMAGE=jss-runner \
NAME=jss \
HOSTNAME=jss.example.com \
tests/bin/runner-init.sh
- name: Install dependencies
run: docker exec jss dnf install -y nss-util-devel python2 python3 java-devel
- name: Generate PKCS11 constants with Python 2
run: |
docker exec jss python2 $SHARED/tools/build_pkcs11_constants.py \
--pkcs11t /usr/include/nss3/pkcs11t.h \
--pkcs11n /usr/include/nss3/pkcs11n.h \
-o PKCS11Constants-py2.java \
--verbose
docker exec jss diff PKCS11Constants-py2.java $SHARED/src/main/java/org/mozilla/jss/pkcs11/PKCS11Constants.java
- name: Generate PKCS11 constants with Python 3
run: |
docker exec jss python3 $SHARED/tools/build_pkcs11_constants.py \
--pkcs11t /usr/include/nss3/pkcs11t.h \
--pkcs11n /usr/include/nss3/pkcs11n.h \
-o PKCS11Constants-py3.java \
--verbose
docker exec jss diff PKCS11Constants-py3.java $SHARED/src/main/java/org/mozilla/jss/pkcs11/PKCS11Constants.java
jss-5.0.0/.github/workflows/pki-tests.yml 0000664 0000000 0000000 00000013504 14125500636 0020363 0 ustar 00root root 0000000 0000000 name: PKI Tests
on: [push, pull_request]
jobs:
init:
name: Initializing Workflow
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.init.outputs.matrix }}
repo: ${{ steps.init.outputs.repo }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Initialize workflow
id: init
env:
BASE64_MATRIX: ${{ secrets.BASE64_MATRIX }}
BASE64_REPO: ${{ secrets.BASE64_REPO }}
run: |
tests/bin/init-workflow.sh
build:
name: Building JSS
needs: init
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build runner image
uses: docker/build-push-action@v2
with:
context: .
build-args: |
OS_VERSION=${{ matrix.os }}
COPR_REPO=${{ needs.init.outputs.repo }}
BUILD_OPTS=--with-timestamp --with-commit-id
tags: jss-runner
target: jss-runner
outputs: type=docker,dest=/tmp/jss-runner.tar
- name: Upload runner image
uses: actions/upload-artifact@v2
with:
name: jss-runner-${{ matrix.os }}
path: /tmp/jss-runner.tar
pki-build-test:
name: Building PKI
needs: [init, build]
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/jss
strategy:
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Download runner image
uses: actions/download-artifact@v2
with:
name: jss-runner-${{ matrix.os }}
path: /tmp
- name: Load runner image
run: docker load --input /tmp/jss-runner.tar
- name: Run container
run: |
IMAGE=jss-runner \
NAME=pki \
HOSTNAME=pki.example.com \
tests/bin/runner-init.sh
- name: Build PKI
run: |
docker exec pki dnf install -y git rpm-build
docker exec pki git clone https://github.com/dogtagpki/pki
docker exec pki dnf build-dep -y --spec pki/pki.spec
docker exec pki pki/build.sh --with-timestamp --with-commit-id rpm
docker exec pki bash -c "dnf install -y /root/build/pki/RPMS/*.rpm"
ca-test:
name: Installing CA
needs: [init, build]
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/jss
strategy:
matrix: ${{ fromJSON(needs.init.outputs.matrix) }}
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Download runner image
uses: actions/download-artifact@v2
with:
name: jss-runner-${{ matrix.os }}
path: /tmp
- name: Load runner image
run: docker load --input /tmp/jss-runner.tar
- name: Run container
run: |
IMAGE=jss-runner \
NAME=pki \
HOSTNAME=pki.example.com \
tests/bin/runner-init.sh
- name: Install DS and PKI packages
run: docker exec pki dnf install -y 389-ds-base pki-ca pki-tests
- name: Install DS
run: docker exec pki ${SHARED}/tests/bin/ds-create.sh
- name: Install CA
run: |
docker exec pki pkispawn -f /usr/share/pki/server/examples/installation/ca.cfg -s CA -v
# set buffer size to 0 so that revocation takes effect immediately
docker exec pki pki-server ca-config-set auths.revocationChecking.bufferSize 0
# enable signed audit log
docker exec pki pki-server ca-config-set log.instance.SignedAudit.logSigning true
# restart PKI server
docker exec pki pki-server restart --wait
- name: Run PKI healthcheck
run: docker exec pki pki-healthcheck --debug
- name: Initialize PKI client
run: |
docker exec pki pki-server cert-export ca_signing --cert-file ca_signing.crt
docker exec pki pki client-cert-import ca_signing --ca-cert ca_signing.crt
docker exec pki pki info
- name: Test CA certs
run: |
docker exec pki /usr/share/pki/tests/ca/bin/test-ca-signing-cert.sh
docker exec pki /usr/share/pki/tests/ca/bin/test-subsystem-cert.sh
docker exec pki /usr/share/pki/tests/ca/bin/test-ca-certs.sh
- name: Test CA admin
run: |
docker exec pki pki client-cert-import \
--pkcs12 /root/.dogtag/pki-tomcat/ca_admin_cert.p12 \
--pkcs12-password-file /root/.dogtag/pki-tomcat/ca/pkcs12_password.conf
docker exec pki pki -n caadmin ca-user-show caadmin
- name: Test CA agent
run: |
docker exec pki /usr/share/pki/tests/ca/bin/ca-agent-create.sh
docker exec pki /usr/share/pki/tests/ca/bin/ca-agent-cert-create.sh
docker exec pki /usr/share/pki/tests/ca/bin/ca-agent-cert-revoke.sh
docker exec pki /usr/share/pki/tests/ca/bin/ca-agent-cert-unrevoke.sh
- name: Test CA auditor
run: |
docker exec pki /usr/share/pki/tests/ca/bin/test-ca-auditor-create.sh
docker exec pki /usr/share/pki/tests/ca/bin/test-ca-auditor-cert.sh
docker exec pki /usr/share/pki/tests/ca/bin/test-ca-auditor-logs.sh
- name: Gather artifacts
if: always()
run: |
tests/bin/ds-artifacts-save.sh pki
tests/bin/pki-artifacts-save.sh pki
- name: Remove CA
run: docker exec pki pkidestroy -i pki-tomcat -s CA -v
- name: Remove DS
run: docker exec pki ${SHARED}/tests/bin/ds-remove.sh
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: ca-${{ matrix.os }}
path: |
/tmp/artifacts/pki
jss-5.0.0/.gitignore 0000664 0000000 0000000 00000000452 14125500636 0014306 0 ustar 00root root 0000000 0000000 # Ignore build directories and artifacts
/bin
*.OBJ/
build/
src/*.a
src/*.o
target/
# These files are automatically generated from their .in equivalents
org/mozilla/jss/util/jssver.h
org/mozilla/jss/jssconfig.h
src/main/java/org/mozilla/jss/util/jssver.h
src/main/java/org/mozilla/jss/jssconfig.h
jss-5.0.0/.gitlab-ci.yml 0000664 0000000 0000000 00000001232 14125500636 0014747 0 ustar 00root root 0000000 0000000 image: fedora
sync:
script:
- echo "Synchronizing $CI_COMMIT_BRANCH branch from $UPSTREAM_URL to $CI_PROJECT_URL"
- dnf install -y git
- git remote set-url origin https://sync:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git
- git remote remove upstream || true
- git remote add upstream $UPSTREAM_URL
- git remote -v
- git fetch upstream $CI_COMMIT_BRANCH
- git checkout upstream/$CI_COMMIT_BRANCH
- git log origin/$CI_COMMIT_BRANCH..upstream/$CI_COMMIT_BRANCH --oneline
- GIT_SSL_NO_VERIFY=true git push origin HEAD:$CI_COMMIT_BRANCH
rules:
- if: $SYNC == "true"
tags:
# Use shared runners.
- shared
jss-5.0.0/.hgignore 0000664 0000000 0000000 00000000062 14125500636 0014116 0 ustar 00root root 0000000 0000000 syntax: glob
*~
*OPT.OBJ/*
*DBG.OBJ/*
*DBG.OBJD/*
jss-5.0.0/.project 0000664 0000000 0000000 00000000552 14125500636 0013766 0 ustar 00root root 0000000 0000000
jss
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
jss-5.0.0/.settings/ 0000775 0000000 0000000 00000000000 14125500636 0014233 5 ustar 00root root 0000000 0000000 jss-5.0.0/.settings/org.eclipse.jdt.core.prefs 0000664 0000000 0000000 00000056123 14125500636 0021224 0 ustar 00root root 0000000 0000000 eclipse.preferences.version=1
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=false
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
org.eclipse.jdt.core.formatter.comment.line_length=120
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=8
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=false
org.eclipse.jdt.core.formatter.join_wrapped_lines=false
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=120
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
jss-5.0.0/.settings/org.eclipse.jdt.ui.prefs 0000664 0000000 0000000 00000005256 14125500636 0020712 0 ustar 00root root 0000000 0000000 eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_PKI Project Profile
formatter_settings_version=12
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=false
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=false
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=true
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
jss-5.0.0/CMakeLists.txt 0000664 0000000 0000000 00000007157 14125500636 0015067 0 ustar 00root root 0000000 0000000 # This is the CMakeLists.txt for the JSS Project.
project(jss)
# Required cmake version; set a 3.14.2 since we need LINK_OPTIONS in
# try_compile.
cmake_minimum_required(VERSION 3.14.0)
# Source our custom CMake modules; this includes NSS and NSPR modules from
# PKI and the JSSConfig and JSSCommon modules.
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Define optional variables and conditionals.
if (DEFINED ENV{CHECK_DEPRECATION})
set(CHECK_DEPRECATION_ENV TRUE)
endif()
option(CHECK_DEPRECATION "When enabled, utilize the deprecation checking functionality of the java compiler." ${CHECK_DEPRECATION_ENV})
if (CHECK_DEPRECATION)
list(APPEND JSS_JAVAC_FLAGS "-Xlint:deprecation")
endif()
if (DEFINED ENV{FIPS_ENABLED})
set(FIPS_ENABLED_ENV TRUE)
endif()
option(FIPS_ENABLED "When enabled, disable certain tests which don't work in FIPS mode. This should only be specified when the host system is in FIPS mode." ${FIPS_ENABLED_ENV})
if (DEFINED ENV{SANDBOX})
set(SANDBOX_ENV TRUE)
endif()
option(SANDBOX "When enabled, expect to find nss and nspr from the parent (sandbox) directory instead of using the system-installed versions of the libraries." ${SANDBOX_ENV})
if (DEFINED ENV{TEST_VALGRIND})
set(TEST_VALGRIND_ENV TRUE)
endif()
option(TEST_VALGRIND "When enabled, run the entire test suite under Valgrind. This will be noisy as JSS can't clean up NSS initialization and the JVM itself leaks." ${TEST_VALGRIND_ENV})
# Build a debug build by default when no type is specified on the command line
if(NOT (DEFINED CMAKE_BUILD_TYPE))
set(CMAKE_BUILD_TYPE "Debug")
endif()
if (DEFINED ENV{WITH_INTERNET})
set(TEST_WITH_INTERNET_ENV TRUE)
endif()
option(TEST_WITH_INTERNET "When enabled, runs various tests which require an internet connection. " ${TEST_WITH_INTERNET_ENV})
option(WITH_JAVADOC "Build Javadoc package." TRUE)
# Find NSPR and NSS Libraries.
find_package(NSPR REQUIRED)
find_package(NSS REQUIRED)
# Find Java and JNI packages; this sets CMake wariables like
# Java_JAVAC_EXECUTABLE.
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
# Shims for older CMake versions without useful features.
include(Shims)
# Since we found Java, include UseJava to provide the find_jar function.
include(UseJava)
# These includes are required for the macro check_symbol_exists and
# check_struct_has_member in jss_config().
include(CheckSymbolExists)
include(CheckStructHasMember)
# Load JSSConfig module; this defines the jss_config() macro which defines
# JSS-specific configuration values.
include(JSSConfig)
# Load JSSCommon module; this defines the jss_build() macros which defines
# the JSS build procedure.
include(JSSCommon)
# Load JSSTests module; this defines the jss_tests() macro which defines the
# JSS test procedure.
include(JSSTests)
jss_config()
jss_build()
jss_tests()
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/jss.jar
DESTINATION
${JAVA_LIB_INSTALL_DIR}
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/libjss.so
DESTINATION
${JSS_LIB_INSTALL_DIR}
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
install(
CODE "execute_process(
COMMAND ln -sf ${JAVA_LIB_INSTALL_DIR}/jss.jar \$ENV{DESTDIR}${JSS_LIB_INSTALL_DIR}/jss.jar
)"
)
if(WITH_JAVADOC)
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/docs/
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/javadoc/jss
)
install(
FILES
jss.html MPL-1.1.txt gpl.txt lgpl.txt
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/javadoc/jss
)
endif(WITH_JAVADOC)
jss-5.0.0/Dockerfile 0000664 0000000 0000000 00000002237 14125500636 0014313 0 ustar 00root root 0000000 0000000 #
# Copyright Red Hat, Inc.
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
ARG OS_VERSION="latest"
ARG COPR_REPO="@pki/master"
################################################################################
FROM registry.fedoraproject.org/fedora:$OS_VERSION AS jss-builder
ARG COPR_REPO
ARG BUILD_OPTS
# Enable COPR repo if specified
RUN if [ -n "$COPR_REPO" ]; then dnf install -y dnf-plugins-core; dnf copr enable -y $COPR_REPO; fi
# Import source
COPY . /tmp/src/
WORKDIR /tmp/src
# Build packages
RUN dnf install -y git rpm-build
RUN dnf builddep -y --spec jss.spec
RUN ./build.sh $BUILD_OPTS --work-dir=../build rpm
################################################################################
FROM registry.fedoraproject.org/fedora:$OS_VERSION AS jss-runner
ARG COPR_REPO
EXPOSE 389 8080 8443
# Enable COPR repo if specified
RUN if [ -n "$COPR_REPO" ]; then dnf install -y dnf-plugins-core; dnf copr enable -y $COPR_REPO; fi
# Import packages
COPY --from=jss-builder /tmp/build/RPMS /tmp/RPMS/
# Install packages
RUN dnf localinstall -y /tmp/RPMS/*; rm -rf /tmp/RPMS
# Install systemd to run the container
RUN dnf install -y systemd
CMD [ "/usr/sbin/init" ]
jss-5.0.0/MPL-1.1.txt 0000664 0000000 0000000 00000062233 14125500636 0014011 0 ustar 00root root 0000000 0000000 MOZILLA PUBLIC LICENSE
Version 1.1
---------------
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the
Covered Code available to a third party.
1.1. "Contributor" means each entity that creates or contributes to
the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. "Covered Code" means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. "Electronic Distribution Mechanism" means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. "Executable" means Covered Code in any form other than Source
Code.
1.6. "Initial Developer" means the individual or entity identified
as the Initial Developer in the Source Code notice required by Exhibit
A.
1.7. "Larger Work" means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. "License" means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed herein.
1.9. "Modifications" means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. "Original Code" means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this
License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method, process,
and apparatus claims, in any patent Licensable by grantor.
1.11. "Source Code" means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus
any associated interface definition files, scripts used to control
compilation and installation of an Executable, or source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You" includes any entity which controls, is
controlled by, or is under common control with You. For purposes of
this definition, "control" means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer to use, reproduce,
modify, display, perform, sublicense and distribute the Original
Code (or portions thereof) with or without Modifications, and/or
as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or
selling of Original Code, to make, have made, use, practice,
sell, and offer for sale, and/or otherwise dispose of the
Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are
effective on the date Initial Developer first distributes
Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: 1) for code that You delete from the Original Code; 2)
separate from the Original Code; or 3) for infringements caused
by: i) the modification of the Original Code or ii) the
combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor
hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor, to use, reproduce, modify,
display, perform, sublicense and distribute the Modifications
created by such Contributor (or portions thereof) either on an
unmodified basis, with other Modifications, as Covered Code
and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either alone
and/or in combination with its Contributor Version (or portions
of such combination), to make, use, sell, offer for sale, have
made, and/or otherwise dispose of: 1) Modifications made by that
Contributor (or portions thereof); and 2) the combination of
Modifications made by that Contributor with its Contributor
Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first makes Commercial Use of
the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: 1) for any code that Contributor has deleted from the
Contributor Version; 2) separate from the Contributor Version;
3) for infringements caused by: i) third party modifications of
Contributor Version or ii) the combination of Modifications made
by that Contributor with other software (except as part of the
Contributor Version) or other devices; or 4) under Patent Claims
infringed by Covered Code in the absence of Modifications made by
that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be
distributed only under the terms of this License or a future version
of this License released under Section 6.1, and You must include a
copy of this License with every copy of the Source Code You
distribute. You may not offer or impose any terms on any Source Code
version that alters or restricts the applicable version of this
License or the recipients' rights hereunder. However, You may include
an additional document offering the additional rights described in
Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that
the Modification is derived, directly or indirectly, from Original
Code provided by the Initial Developer and including the name of the
Initial Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's
intellectual property rights is required to exercise the rights
granted by such Contributor under Sections 2.1 or 2.2,
Contributor must include a text file with the Source Code
distribution titled "LEGAL" which describes the claim and the
party making the claim in sufficient detail that a recipient will
know whom to contact. If Contributor obtains such knowledge after
the Modification is made available as described in Section 3.2,
Contributor shall promptly modify the LEGAL file in all copies
Contributor makes available thereafter and shall take other steps
(such as notifying appropriate mailing lists or newsgroups)
reasonably calculated to inform those who received the Covered
Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming
interface and Contributor has knowledge of patent licenses which
are reasonably necessary to implement that API, Contributor must
also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to
Section 3.4(a) above, Contributor believes that Contributor's
Modifications are Contributor's original creation(s) and/or
Contributor has sufficient rights to grant the rights conveyed by
this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code. If it is not possible to put such notice in a particular Source
Code file due to its structure, then You must include such notice in a
location (such as a relevant directory) where a user would be likely
to look for such a notice. If You created one or more Modification(s)
You may add your name as a Contributor to the notice described in
Exhibit A. You must also duplicate this License in any documentation
for the Source Code where You describe recipients' rights or ownership
rights relating to Covered Code. You may choose to offer, and to
charge a fee for, warranty, support, indemnity or liability
obligations to one or more recipients of Covered Code. However, You
may do so only on Your own behalf, and not on behalf of the Initial
Developer or any Contributor. You must make it absolutely clear than
any such warranty, support, indemnity or liability obligation is
offered by You alone, and You hereby agree to indemnify the Initial
Developer and every Contributor for any liability incurred by the
Initial Developer or such Contributor as a result of warranty,
support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of
the Covered Code is available under the terms of this License,
including a description of how and where You have fulfilled the
obligations of Section 3.2. The notice must be conspicuously included
in any notice in an Executable version, related documentation or
collateral in which You describe recipients' rights relating to the
Covered Code. You may distribute the Executable version of Covered
Code or ownership rights under a license of Your choice, which may
contain terms different from this License, provided that You are in
compliance with the terms of this License and that the license for the
Executable version does not attempt to limit or alter the recipient's
rights in the Source Code version from the rights set forth in this
License. If You distribute the Executable version under a different
license You must make it absolutely clear that any terms which differ
from this License are offered by You alone, not by the Initial
Developer or any Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred by
the Initial Developer or such Contributor as a result of any such
terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description
must be included in the LEGAL file described in Section 3.4 and must
be included with all distributions of the Source Code. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation ("Netscape") may publish revised
and/or new versions of the License from time to time. Each version
will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), You must (a) rename Your license so that
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
"MPL", "NPL" or any confusingly similar phrase do not appear in your
license (except to note that your license differs from this License)
and (b) otherwise make it clear that Your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial
Developer, Original Code or Contributor in the notice described in
Exhibit A shall not of themselves be deemed to be modifications of
this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
8.2. If You initiate litigation by asserting a patent infringement
claim (excluding declatory judgment actions) against Initial Developer
or a Contributor (the Initial Developer or Contributor against whom
You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly
infringes any patent, then any and all rights granted by such
Participant to You under Sections 2.1 and/or 2.2 of this License
shall, upon 60 days notice from Participant terminate prospectively,
unless if within 60 days after receipt of notice You either: (i)
agree in writing to pay Participant a mutually agreeable reasonable
royalty for Your past and future use of Modifications made by such
Participant, or (ii) withdraw Your litigation claim with respect to
the Contributor Version against such Participant. If within 60 days
of notice, a reasonable royalty and payment arrangement are not
mutually agreed upon in writing by the parties or the litigation claim
is not withdrawn, the rights granted by Participant to You under
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's
Contributor Version, directly or indirectly infringes any patent, then
any rights granted to You by such Participant under Sections 2.1(b)
and 2.2(b) are revoked effective as of the date You first made, used,
sold, distributed, or had made, Modifications made by that
Participant.
8.3. If You assert a patent infringement claim against Participant
alleging that such Participant's Contributor Version directly or
indirectly infringes any patent where such claim is resolved (such as
by license or settlement) prior to the initiation of patent
infringement litigation, then the reasonable value of the licenses
granted by such Participant under Sections 2.1 or 2.2 shall be taken
into account in determining the amount or value of any payment or
license.
8.4. In the event of termination under Sections 8.1 or 8.2 above,
all end user license agreements (excluding distributors and resellers)
which have been validly granted by You or any distributor hereunder
prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a "commercial item," as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
software" and "commercial computer software documentation," as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if
any, provides otherwise), excluding its conflict-of-law provisions.
With respect to disputes in which at least one party is a citizen of,
or an entity chartered or registered to do business in the United
States of America, any litigation relating to this License shall be
subject to the jurisdiction of the Federal Courts of the Northern
District of California, with venue lying in Santa Clara County,
California, with the losing party responsible for costs, including
without limitation, court costs and reasonable attorneys' fees and
expenses. The application of the United Nations Convention on
Contracts for the International Sale of Goods is expressly excluded.
Any law or regulation which provides that the language of a contract
shall be construed against the drafter shall not apply to this
License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or indirectly,
out of its utilization of rights under this License and You agree to
work with Initial Developer and Contributors to distribute such
responsibility on an equitable basis. Nothing herein is intended or
shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
Developer permits you to utilize portions of the Covered Code under
Your choice of the NPL or the alternative licenses, if any, specified
by the Initial Developer in the file described in Exhibit A.
EXHIBIT A -Mozilla Public License.
``The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
The Original Code is ______________________________________.
The Initial Developer of the Original Code is ________________________.
Portions created by ______________________ are Copyright (C) ______
_______________________. All Rights Reserved.
Contributor(s): ______________________________________.
Alternatively, the contents of this file may be used under the terms
of the _____ license (the "[___] License"), in which case the
provisions of [______] License are applicable instead of those
above. If you wish to allow use of your version of this file only
under the terms of the [____] License and not to allow others to use
your version of this file under the MPL, indicate your decision by
deleting the provisions above and replace them with the notice and
other provisions required by the [___] License. If you do not delete
the provisions above, a recipient may use your version of this file
under either the MPL or the [___] License."
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. You should
use the text of this Exhibit A rather than the text found in the
Original Code Source Code for Your Modifications.]
jss-5.0.0/README.md 0000664 0000000 0000000 00000005305 14125500636 0013577 0 ustar 00root root 0000000 0000000 Network Security Services for Java (JSS)
========================================
Overview
--------
**Network Security Services for Java** is a Java interface to [NSS](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS).
JSS supports most of the security standards and encryption technologies supported by NSS.
JSS also provides a pure Java interface for ASN.1 types and BER/DER encoding.
* Website: http://www.dogtagpki.org/wiki/JSS
* Issues: https://github.com/dogtagpki/jss/issues
* Archive: https://github.com/dogtagpki/jss-archive
* Javadocs: https://dogtagpki.github.io/jss
**NOTICE:** As of JSS version 4.5.1, the legacy build instructions will not
work; the build system has been completely replaced with CMake.
Dependencies
------------
This project has the following dependencies:
- [NSPR](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR)
- [NSS](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS)
- Minimum version: 3.44
- Recommended version: 3.48 and above
- A c and c++ compiler such as [gcc](ttps://gcc.gnu.org/)
- [zlib](https://zlib.net/)
- [OpenJDK 1.8.0 or newer](https://openjdk.java.net/)
- [CMake](https://cmake.org/)
- [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/)
- [SLF4J](https://www.slf4j.org/)
- [JUnit 4](https://junit.org/junit4/)
To install these dependencies on Fedora, execute the following:
sudo dnf install apache-commons-lang gcc-c++ java-devel jpackage-utils \
slf4j zlib-devel nss-tools nss-devel \
cmake junit
To install these dependencies on Debian, execute the following:
sudo apt-get install build-essential libcommons-lang-java libnss3-dev \
libslf4j-java default-jdk pkg-config zlib1g-dev \
libnss3-tools cmake zip unzip \
junit4
Building
--------
To build JSS and make a best effort to detect environment variables:
git clone https://github.com/dogtagpki/jss
cd jss/build && cmake ..
make all test
Alternatively, to build a RPM distribution of JSS:
git clone https://github.com/dogtagpki/jss
cd jss
./build.sh rpm
To view more detailed instructions for building JSS, please refer to
the build documentation: [`docs/building.md`](docs/building.md).
In Distributions
----------------
JSS is currently shipped in Fedora-based distributions under the package
name `jss`; to install issue `sudo dnf install jss`.
JSS is also shipped in Debian-based distributions under the package
name `libjss-java`; to install, issue `sudo apt-get install libjss-java`.
Contact Us
----------
See [Contact Us](https://github.com/dogtagpki/pki/wiki/Contact-Us).
jss-5.0.0/azure-pipelines.yml 0000664 0000000 0000000 00000004652 14125500636 0016163 0 ustar 00root root 0000000 0000000 # Workaround to install sudo
# https://github.com/Microsoft/azure-pipelines-agent/issues/2043#issuecomment-687983301
resources:
containers:
- container: debian_testing
image: debian:testing
options: '--name ci-container -v /usr/bin/docker:/tmp/docker:ro'
- container: ubuntu_rolling
image: ubuntu:rolling
options: '--name ci-container -v /usr/bin/docker:/tmp/docker:ro'
jobs:
- job: BuildTest
pool:
vmImage: ubuntu-latest
strategy:
matrix:
fedora_latest:
image: fedora:latest
debian_testing:
image: debian_testing
ubuntu_rolling:
image: ubuntu_rolling
# Disable CentOS due to missing dependencies
# centos_7:
# image: centos:7
# centos_8:
# image: centos:8
container: $[variables['image']]
steps:
- script: |
sudo dnf install -y dnf-plugins-core rpm-build
sudo dnf builddep -y --spec jss.spec
condition: or(startsWith(variables.image, 'fedora:'), startsWith(variables.image, 'centos:'))
displayName: Install Fedora/CentOS dependencies
- script: |
# Workaround to install sudo
# https://github.com/Microsoft/azure-pipelines-agent/issues/2043#issuecomment-687983301
/tmp/docker exec -t -u 0 ci-container \
apt-get update
/tmp/docker exec -t -u 0 -e DEBIAN_FRONTEND=noninteractive ci-container \
apt-get -o Dpkg::Options::="--force-confold" -y install sudo
sudo apt-get install -y \
cmake zip unzip \
g++ libnss3-dev libnss3-tools \
openjdk-11-jdk libcommons-lang3-java libslf4j-java junit4
condition: or(startsWith(variables.image, 'debian_'), startsWith(variables.image, 'ubuntu_'))
displayName: Install Debian/Ubuntu dependencies
- script: ./build.sh
displayName: Build JSS binaries, Javadoc, and run tests
- job: SymbolTest
pool:
vmImage: ubuntu-latest
steps:
- script: |
grep -iroh '^Java_org_mozilla[^(;]*' src/main/java/ | sort -u > /tmp/functions.txt
cat /tmp/functions.txt
displayName: Get JNI symbols in the code
- script: |
grep -iroh '^Java_org_mozilla[^(;]*' lib/ | sort -u > /tmp/version.txt
cat /tmp/version.txt
displayName: Get JNI symbols in the version script
- script: |
diff /tmp/functions.txt /tmp/version.txt || true
comm -23 --check-order /tmp/functions.txt /tmp/version.txt > /tmp/diff.txt
test ! -s /tmp/diff.txt
displayName: Compare JNI symbols
jss-5.0.0/build.sh 0000775 0000000 0000000 00000030736 14125500636 0013764 0 ustar 00root root 0000000 0000000 #!/bin/bash -e
# BEGIN COPYRIGHT BLOCK
# (C) 2018 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
SCRIPT_PATH="$(readlink -f "$0")"
SCRIPT_NAME="$(basename "$SCRIPT_PATH")"
SRC_DIR="$(dirname "$SCRIPT_PATH")"
NAME=jss
WORK_DIR="$HOME/build/$NAME"
JAVA_LIB_DIR="/usr/lib/java"
if [ "$HOSTTYPE" = "x86_64" ]; then
JSS_LIB_DIR="/usr/lib64/jss"
else
JSS_LIB_DIR="/usr/lib/jss"
fi
INSTALL_DIR=
SOURCE_TAG=
SPEC_TEMPLATE=
VERSION=
RELEASE=
WITH_TIMESTAMP=
WITH_COMMIT_ID=
DIST=
WITHOUT_JAVADOC=
WITHOUT_TEST=
VERBOSE=
DEBUG=
usage() {
echo "Usage: $SCRIPT_NAME [OPTIONS] "
echo
echo "Options:"
echo " --work-dir= Working directory (default: $WORK_DIR)."
echo " --java-lib-dir= Java library directory (default: $JAVA_LIB_DIR)."
echo " --jss-lib-dir= JSS library directory (default: $JSS_LIB_DIR)."
echo " --install-dir= Installation directory."
echo " --source-tag= Generate RPM sources from a source tag."
echo " --spec= Use the specified RPM spec."
echo " --version= Use the specified version."
echo " --release= Use the specified release."
echo " --with-timestamp Append timestamp to release number."
echo " --with-commit-id Append commit ID to release number."
echo " --dist= Distribution name (e.g. fc28)."
echo " --without-javadoc Do not build Javadoc package."
echo " --without-test Do not run unit tests."
echo " -v,--verbose Run in verbose mode."
echo " --debug Run in debug mode."
echo " --help Show help message."
echo
echo "Target:"
echo " dist Build JSS binaries (default)."
echo " install Install JSS binaries."
echo " src Generate RPM sources."
echo " spec Generate RPM spec."
echo " srpm Build SRPM package."
echo " rpm Build RPM packages."
}
generate_rpm_sources() {
TARBALL="$NAME-$VERSION${_PHASE}.tar.gz"
if [ "$SOURCE_TAG" != "" ] ; then
if [ "$VERBOSE" = true ] ; then
echo "Generating $TARBALL from $SOURCE_TAG tag"
fi
git -C "$SRC_DIR" \
archive \
--format=tar.gz \
--prefix "$NAME-$VERSION${_PHASE}/" \
-o "$WORK_DIR/SOURCES/$TARBALL" \
$SOURCE_TAG
if [ "$SOURCE_TAG" != "HEAD" ] ; then
TAG_ID="$(git -C "$SRC_DIR" rev-parse $SOURCE_TAG)"
HEAD_ID="$(git -C "$SRC_DIR" rev-parse HEAD)"
if [ "$TAG_ID" != "$HEAD_ID" ] ; then
generate_patch
fi
fi
return
fi
if [ "$VERBOSE" = true ] ; then
echo "Generating $TARBALL"
fi
tar czf "$WORK_DIR/SOURCES/$TARBALL" \
--transform "s,^./,$NAME-$VERSION${_PHASE}/," \
--exclude .git \
--exclude bin \
-C "$SRC_DIR" \
.
}
generate_patch() {
PATCH="$NAME-$VERSION-$RELEASE.patch"
if [ "$VERBOSE" = true ] ; then
echo "Generating $PATCH for all changes since $SOURCE_TAG tag"
fi
git -C "$SRC_DIR" \
format-patch \
--stdout \
$SOURCE_TAG \
> "$WORK_DIR/SOURCES/$PATCH"
}
generate_rpm_spec() {
RPM_SPEC="$NAME.spec"
if [ "$VERBOSE" = true ] ; then
echo "Generating $RPM_SPEC"
fi
# hard-code timestamp
commands="s/%{?_timestamp}/${_TIMESTAMP}/g"
# hard-code commit ID
commands="${commands}; s/%{?_commit_id}/${_COMMIT_ID}/g"
# hard-code phase
commands="${commands}; s/%{?_phase}/${_PHASE}/g"
# hard-code patch
if [ "$PATCH" != "" ] ; then
commands="${commands}; s/# Patch: jss-VERSION-RELEASE.patch/Patch: $PATCH/g"
fi
# hard-code Javadoc option
if [ "$WITHOUT_JAVADOC" = true ] ; then
# convert bcond_without into bcond_with such that Javadoc package is not built by default
commands="${commands}; s/%\(bcond_without *javadoc\)\$/# \1\n%bcond_with javadoc/g"
fi
# hard-code test option
if [ "$WITHOUT_TEST" = true ] ; then
# convert bcond_without into bcond_with such that unit tests do not run by default
commands="${commands}; s/%\(bcond_without *test\)\$/# \1\n%bcond_with test/g"
fi
sed "$commands" "$SPEC_TEMPLATE" > "$WORK_DIR/SPECS/$RPM_SPEC"
# rpmlint "$WORK_DIR/SPECS/$RPM_SPEC"
}
while getopts v-: arg ; do
case $arg in
v)
VERBOSE=true
;;
-)
LONG_OPTARG="${OPTARG#*=}"
case $OPTARG in
work-dir=?*)
WORK_DIR="$(readlink -f "$LONG_OPTARG")"
;;
java-lib-dir=?*)
JAVA_LIB_DIR="$(readlink -f "$LONG_OPTARG")"
;;
jss-lib-dir=?*)
JSS_LIB_DIR="$(readlink -f "$LONG_OPTARG")"
;;
install-dir=?*)
INSTALL_DIR="$(readlink -f "$LONG_OPTARG")"
;;
source-tag=?*)
SOURCE_TAG="$LONG_OPTARG"
;;
spec=?*)
SPEC_TEMPLATE="$LONG_OPTARG"
;;
version=?*)
VERSION="$LONG_OPTARG"
;;
release=?*)
RELEASE="$LONG_OPTARG"
;;
with-timestamp)
WITH_TIMESTAMP=true
;;
with-commit-id)
WITH_COMMIT_ID=true
;;
dist=?*)
DIST="$LONG_OPTARG"
;;
without-javadoc)
WITHOUT_JAVADOC=true
;;
without-test)
WITHOUT_TEST=true
;;
verbose)
VERBOSE=true
;;
debug)
VERBOSE=true
DEBUG=true
;;
help)
usage
exit
;;
'')
break # "--" terminates argument processing
;;
work-dir* | java-lib-dir* | jss-lib-dir* | install-dir* | source-tag* | spec* | version* | release* | dist*)
echo "ERROR: Missing argument for --$OPTARG option" >&2
exit 1
;;
*)
echo "ERROR: Illegal option --$OPTARG" >&2
exit 1
;;
esac
;;
\?)
exit 1 # getopts already reported the illegal option
;;
esac
done
# remove parsed options and args from $@ list
shift $((OPTIND-1))
if [ "$#" -lt 1 ] ; then
BUILD_TARGET=dist
else
BUILD_TARGET=$1
fi
if [ "$DEBUG" = true ] ; then
echo "WORK_DIR: $WORK_DIR"
echo "JAVA_LIB_DIR: $JAVA_LIB_DIR"
echo "JSS_LIB_DIR: $JSS_LIB_DIR"
echo "INSTALL_DIR: $INSTALL_DIR"
echo "BUILD_TARGET: $BUILD_TARGET"
fi
if [ "$BUILD_TARGET" != "dist" ] &&
[ "$BUILD_TARGET" != "install" ] &&
[ "$BUILD_TARGET" != "src" ] &&
[ "$BUILD_TARGET" != "spec" ] &&
[ "$BUILD_TARGET" != "srpm" ] &&
[ "$BUILD_TARGET" != "rpm" ] ; then
echo "ERROR: Invalid build target: $BUILD_TARGET" >&2
exit 1
fi
mkdir -p "$WORK_DIR"
cd "$WORK_DIR"
if [ "$BUILD_TARGET" = "dist" ] ; then
if [ "$VERBOSE" = true ] ; then
echo "Building $NAME"
fi
OPTIONS=()
OPTIONS+=(-DVERSION=$VERSION)
if [ "$JAVA_HOME" != "" ] ; then
OPTIONS+=(-DJAVA_HOME=$JAVA_HOME)
fi
OPTIONS+=(-DCMAKE_INSTALL_PREFIX=/usr)
OPTIONS+=(-DJAVA_LIB_INSTALL_DIR=$JAVA_LIB_DIR )
OPTIONS+=(-DJSS_LIB_INSTALL_DIR=$JSS_LIB_DIR)
if [ "$WITHOUT_JAVADOC" = true ] ; then
OPTIONS+=(-DWITH_JAVADOC=FALSE)
fi
OPTIONS+=(-S $SRC_DIR)
OPTIONS+=(-B .)
cmake "${OPTIONS[@]}"
OPTIONS=()
if [ "$VERBOSE" = true ] ; then
OPTIONS+=(VERBOSE=1)
fi
OPTIONS+=(CMAKE_NO_VERBOSE=1)
OPTIONS+=(--no-print-directory)
make "${OPTIONS[@]}" all
if [ "$WITHOUT_JAVADOC" != true ] ; then
make "${OPTIONS[@]}" javadoc
fi
if [ "$WITHOUT_TEST" != true ] ; then
ctest --output-on-failure
fi
echo
echo "Build artifacts:"
echo "- Java archive: $WORK_DIR/jss.jar"
echo "- shared library: $WORK_DIR/libjss.so"
echo "- documentation: $WORK_DIR/docs"
echo
echo "To install the build: $0 install"
echo "To create RPM packages: $0 rpm"
echo
exit
fi
if [ "$BUILD_TARGET" = "install" ] ; then
if [ "$VERBOSE" = true ] ; then
echo "Installing $NAME"
fi
OPTIONS=()
if [ "$VERBOSE" = true ] ; then
OPTIONS+=(VERBOSE=1)
fi
OPTIONS+=(CMAKE_NO_VERBOSE=1)
OPTIONS+=(DESTDIR=$INSTALL_DIR)
OPTIONS+=(INSTALL="install -p")
OPTIONS+=(--no-print-directory)
make "${OPTIONS[@]}" install
exit
fi
################################################################################
# Prepare RPM build
################################################################################
if [ "$SPEC_TEMPLATE" = "" ] ; then
SPEC_TEMPLATE="$SRC_DIR/$NAME.spec"
fi
if [ "$VERSION" = "" ] ; then
# if version not specified, get from spec template
VERSION="$(rpmspec -P "$SPEC_TEMPLATE" | grep "^Version:" | awk '{print $2;}')"
fi
if [ "$DEBUG" = true ] ; then
echo "VERSION: $VERSION"
fi
if [ "$RELEASE" = "" ] ; then
# if release not specified, get from spec template
RELEASE="$(rpmspec -P "$SPEC_TEMPLATE" --undefine dist | grep "^Release:" | awk '{print $2;}')"
fi
if [ "$DEBUG" = true ] ; then
echo "RELEASE: $RELEASE"
fi
spec=$(<"$SPEC_TEMPLATE")
regex=$'%global *_phase *([^\n]+)'
if [[ $spec =~ $regex ]] ; then
_PHASE="${BASH_REMATCH[1]}"
fi
if [ "$DEBUG" = true ] ; then
echo "PHASE: ${_PHASE}"
fi
if [ "$WITH_TIMESTAMP" = true ] ; then
TIMESTAMP="$(date -u +"%Y%m%d%H%M%S%Z")"
_TIMESTAMP=".$TIMESTAMP"
fi
if [ "$DEBUG" = true ] ; then
echo "TIMESTAMP: $TIMESTAMP"
fi
if [ "$WITH_COMMIT_ID" = true ]; then
COMMIT_ID="$(git -C "$SRC_DIR" rev-parse --short=8 HEAD)"
_COMMIT_ID=".$COMMIT_ID"
fi
if [ "$DEBUG" = true ] ; then
echo "COMMIT_ID: $COMMIT_ID"
fi
echo "Building $NAME-$VERSION-$RELEASE${_TIMESTAMP}${_COMMIT_ID}"
rm -rf BUILD
rm -rf RPMS
rm -rf SOURCES
rm -rf SPECS
rm -rf SRPMS
mkdir BUILD
mkdir RPMS
mkdir SOURCES
mkdir SPECS
mkdir SRPMS
################################################################################
# Generate RPM sources
################################################################################
generate_rpm_sources
echo "RPM sources:"
find "$WORK_DIR/SOURCES" -type f -printf " %p\\n"
if [ "$BUILD_TARGET" = "src" ] ; then
exit
fi
################################################################################
# Generate RPM spec
################################################################################
generate_rpm_spec
echo "RPM spec:"
find "$WORK_DIR/SPECS" -type f -printf " %p\\n"
if [ "$BUILD_TARGET" = "spec" ] ; then
exit
fi
################################################################################
# Build source package
################################################################################
OPTIONS=()
OPTIONS+=(--quiet)
OPTIONS+=(--define "_topdir ${WORK_DIR}")
if [ "$WITH_TIMESTAMP" = true ] ; then
OPTIONS+=(--define "_timestamp ${_TIMESTAMP}")
fi
if [ "$WITH_COMMIT_ID" = true ] ; then
OPTIONS+=(--define "_commit_id ${_COMMIT_ID}")
fi
if [ "$DIST" != "" ] ; then
OPTIONS+=(--define "dist .$DIST")
fi
if [ "$DEBUG" = true ] ; then
echo rpmbuild -bs "${OPTIONS[@]}" "$WORK_DIR/SPECS/$RPM_SPEC"
fi
# build SRPM with user-provided options
rpmbuild -bs "${OPTIONS[@]}" "$WORK_DIR/SPECS/$RPM_SPEC"
rc=$?
if [ $rc != 0 ]; then
echo "ERROR: Unable to build SRPM package"
exit 1
fi
SRPM="$(find "$WORK_DIR/SRPMS" -type f)"
echo "SRPM package:"
echo " $SRPM"
if [ "$BUILD_TARGET" = "srpm" ] ; then
exit
fi
################################################################################
# Build binary packages
################################################################################
OPTIONS=()
if [ "$VERBOSE" = true ] ; then
OPTIONS+=(--define "_verbose 1")
fi
OPTIONS+=(--define "_topdir ${WORK_DIR}")
if [ "$DEBUG" = true ] ; then
echo rpmbuild --rebuild "${OPTIONS[@]}" "$SRPM"
fi
# rebuild RPM with hard-coded options in SRPM
rpmbuild --rebuild "${OPTIONS[@]}" "$SRPM"
rc=$?
if [ $rc != 0 ]; then
echo "ERROR: Unable to build RPM packages"
exit 1
fi
# install SRPM to restore sources and spec file removed during rebuild
rpm -i --define "_topdir $WORK_DIR" "$SRPM"
# flatten folder
find "$WORK_DIR/RPMS" -mindepth 2 -type f -exec mv -i '{}' "$WORK_DIR/RPMS" ';'
# remove empty subfolders
find "$WORK_DIR/RPMS" -mindepth 1 -type d -delete
echo "RPM packages:"
find "$WORK_DIR/RPMS" -type f -printf " %p\\n"
jss-5.0.0/build/ 0000775 0000000 0000000 00000000000 14125500636 0013414 5 ustar 00root root 0000000 0000000 jss-5.0.0/build/.gitkeep 0000664 0000000 0000000 00000000000 14125500636 0015033 0 ustar 00root root 0000000 0000000 jss-5.0.0/cmake/ 0000775 0000000 0000000 00000000000 14125500636 0013375 5 ustar 00root root 0000000 0000000 jss-5.0.0/cmake/FindNSPR.cmake 0000664 0000000 0000000 00000005674 14125500636 0015776 0 ustar 00root root 0000000 0000000 # - Try to find NSPR
# Once done this will define
#
# NSPR_FOUND - system has NSPR
# NSPR_INCLUDE_DIRS - the NSPR include directory
# NSPR_LIBRARIES - Link these to use NSPR
# NSPR_DEFINITIONS - Compiler switches required for using NSPR
#
# Copyright (c) 2010 Andreas Schneider
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (SANDBOX)
# Bypass the cache: we want to use files from the directory above.
set(NSS_FOUND TRUE)
# Read the internal build directory from the dist directory
set(DIST_DIR "${CMAKE_SOURCE_DIR}/../dist")
file(READ "${DIST_DIR}/latest" LATEST_BUILD)
string(STRIP "${LATEST_BUILD}" LATEST_BUILD)
message(STATUS "NSS sandbox build directory: ${LATEST_BUILD}")
# Directly set the NSS include and library directories
set(NSPR_INCLUDE_DIRS "${DIST_DIR}/${LATEST_BUILD}/include/nspr")
set(NSPR_LIBRARIES "${DIST_DIR}/${LATEST_BUILD}/lib")
list(APPEND JSS_LD_FLAGS "-L${DIST_DIR}/${LATEST_BUILD}/lib")
list(APPEND JSS_LD_FLAGS "-Wl,-rpath,${DIST_DIR}/${LATEST_BUILD}/lib")
elseif (NSPR_LIBRARIES AND NSPR_INCLUDE_DIRS)
# in cache already
set(NSPR_FOUND TRUE)
else (NSPR_LIBRARIES AND NSPR_INCLUDE_DIRS)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_NSPR nspr)
endif (PKG_CONFIG_FOUND)
find_path(NSPR_INCLUDE_DIR
NAMES
nspr.h
PATHS
${_NSPR_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
nspr4
nspr
)
find_library(PLDS4_LIBRARY
NAMES
plds4
PATHS
${_NSPR_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
find_library(PLC4_LIBRARY
NAMES
plc4
PATHS
${_NSPR_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
find_library(NSPR4_LIBRARY
NAMES
nspr4
PATHS
${_NSPR_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(NSPR_INCLUDE_DIRS
${NSPR_INCLUDE_DIR}
)
if(PLDS4_LIBRARY)
get_filename_component(PLDS4_LIBRARY "${PLDS4_LIBRARY}" DIRECTORY)
set(NSPR_LIBRARIES
${NSPR_LIBRARIES}
${PLDS4_LIBRARY}
)
endif()
if(PLC4_LIBRARY)
get_filename_component(PLC4_LIBRARY "${PLC4_LIBRARY}" DIRECTORY)
set(NSPR_LIBRARIES
${NSPR_LIBRARIES}
${PLC4_LIBRARY}
)
endif()
if(NSPR4_LIBRARY)
get_filename_component(NSPR4_LIBRARY "${NSPR4_LIBRARY}" DIRECTORY)
set(NSPR_LIBRARIES
${NSPR_LIBRARIES}
${NSPR4_LIBRARY}
)
endif()
list(REMOVE_DUPLICATES NSPR_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NSPR DEFAULT_MSG NSPR_LIBRARIES NSPR_INCLUDE_DIRS)
# show the NSPR_INCLUDE_DIRS and NSPR_LIBRARIES variables only in the advanced view
mark_as_advanced(NSPR_INCLUDE_DIRS NSPR_LIBRARIES)
endif()
jss-5.0.0/cmake/FindNSS.cmake 0000664 0000000 0000000 00000006344 14125500636 0015652 0 ustar 00root root 0000000 0000000 # - Try to find NSS
# Once done this will define
#
# NSS_FOUND - system has NSS
# NSS_INCLUDE_DIRS - the NSS include directory
# NSS_LIBRARIES - Link these to use NSS
# NSS_DEFINITIONS - Compiler switches required for using NSS
#
# Copyright (c) 2010 Andreas Schneider
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (SANDBOX)
# Bypass the cache: we want to use files from the directory above.
set(NSS_FOUND TRUE)
# Read the internal build directory from the dist directory
set(DIST_DIR "${CMAKE_SOURCE_DIR}/../dist")
file(READ "${DIST_DIR}/latest" LATEST_BUILD)
string(STRIP "${LATEST_BUILD}" LATEST_BUILD)
message(STATUS "NSS sandbox build directory: ${LATEST_BUILD}")
# Directly set the NSS include and library directories
set(NSS_INCLUDE_DIRS "${DIST_DIR}/public/nss")
set(NSS_LIBRARIES "${DIST_DIR}/${LATEST_BUILD}/lib")
list(APPEND JSS_LD_FLAGS "-L${DIST_DIR}/${LATEST_BUILD}/lib")
list(APPEND JSS_LD_FLAGS "-Wl,-rpath,${DIST_DIR}/${LATEST_BUILD}/lib")
elseif (NSS_LIBRARIES AND NSS_INCLUDE_DIRS)
# in cache already
set(NSS_FOUND TRUE)
else (NSS_LIBRARIES AND NSS_INCLUDE_DIRS)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_NSS nss)
endif (PKG_CONFIG_FOUND)
find_path(NSS_INCLUDE_DIR
NAMES
nss.h
PATHS
${_NSS_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
nss3
nss
)
find_library(SSL3_LIBRARY
NAMES
ssl3
PATHS
${_NSS_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
find_library(SMIME3_LIBRARY
NAMES
smime3
PATHS
${_NSS_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
find_library(NSS3_LIBRARY
NAMES
nss3
PATHS
${_NSS_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
find_library(NSSUTIL3_LIBRARY
NAMES
nssutil3
PATHS
${_NSS_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(NSS_INCLUDE_DIRS
${NSS_INCLUDE_DIR}
)
if(SSL3_LIBRARY)
get_filename_component(SSL3_LIBRARY "${SSL3_LIBRARY}" DIRECTORY)
set(NSS_LIBRARIES
${NSS_LIBRARIES}
${SSL3_LIBRARY}
)
endif()
if(SMIME3_LIBRARY)
get_filename_component(SMIME3_LIBRARY "${SMIME3_LIBRARY}" DIRECTORY)
set(NSS_LIBRARIES
${NSS_LIBRARIES}
${SMIME3_LIBRARY}
)
endif()
if(NSS3_LIBRARY)
get_filename_component(NSS3_LIBRARY "${NSS3_LIBRARY}" DIRECTORY)
set(NSS_LIBRARIES
${NSS_LIBRARIES}
${NSS3_LIBRARY}
)
endif()
if(NSSUTIL3_LIBRARY)
get_filename_component(NSSUTIL3_LIBRARY "${NSSUTIL3_LIBRARY}" DIRECTORY)
set(NSS_LIBRARIES
${NSS_LIBRARIES}
${NSSUTIL3_LIBRARY}
)
endif()
list(REMOVE_DUPLICATES NSS_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NSS DEFAULT_MSG NSS_LIBRARIES NSS_INCLUDE_DIRS)
# show the NSS_INCLUDE_DIRS and NSS_LIBRARIES variables only in the advanced view
mark_as_advanced(NSS_INCLUDE_DIRS NSS_LIBRARIES)
endif()
jss-5.0.0/cmake/JSSCommon.cmake 0000664 0000000 0000000 00000022070 14125500636 0016210 0 ustar 00root root 0000000 0000000 # Core of JSS building
# Build JSS; high level flow
macro(jss_build)
# "set(..)" in CMake defines a globally-scoped variable (or more
# precisely, a variable that exists in all scopes _after_ this one)
# by default. These are three helpful globs of files for dependencies:
# all java, headers, and c source files. Note that src/main/java/*.java differs
# from the bash-style glob in that it matches all files which begin with
# "src/main/java/" and end with ".java". This includes, e.g.,
# "src/main/java/org/mozilla/jss/CryptoManager.java". Because these globs are computed
# at cmake time (prior to the make step) incremental builds are not
# possible; each time the build directory should be removed and recreated
# prior to building again.
jss_build_globs()
# To build JSS, we need:
# 1. To build the Java files.
# 2. To copy the headers for compilation.
# 3. To build the library.
# 4. To build the jar.
# 5. To build the javadocs.
jss_build_java()
jss_build_includes()
jss_build_c()
jss_build_jars()
jss_build_javadocs()
endmacro()
macro(jss_build_globs)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(GLOB_RECURSE JAVA_TEST_SOURCES src/test/java/*.java)
# Write the Java sources to a file to reduce the size of the javac
# command line.
list(SORT JAVA_SOURCES)
list(SORT JAVA_TEST_SOURCES)
jss_list_join(JAVA_SOURCES "\n" JAVA_SOURCES_CONTENTS)
jss_list_join(JAVA_TEST_SOURCES "\n" JAVA_TEST_SOURCES_CONTENTS)
file(WRITE "${JAVA_SOURCES_FILE}" "${JAVA_SOURCES_CONTENTS}")
file(WRITE "${JAVA_TEST_SOURCES_FILE}" "${JAVA_TEST_SOURCES_CONTENTS}")
file(GLOB_RECURSE _C_HEADERS src/main/java/*.h)
foreach(_C_HEADER ${_C_HEADERS})
if(${_C_HEADER} MATCHES "mozilla/jss/tests/")
list(APPEND C_TEST_HEADERS "${_C_HEADER}")
else()
list(APPEND C_HEADERS "${_C_HEADER}")
endif()
endforeach()
# We exclude any C files in the tests directory because they shouldn't
# contribute to our library. They should instead be built as part of the
# test suite and probably be built as stand alone binaries which link
# against libjss.so (at most).
file(GLOB_RECURSE C_SOURCES src/main/java/*.c)
file(GLOB_RECURSE C_TEST_SOURCES src/test/java/*.c)
endmacro()
# Build all Java sources into classes and generate JNI headers
macro(jss_build_java)
# Create a fake, pseudo-target for generate_java -- we have to have some
# status for when the build finishes for the add_custom_target to depend
# on, but it also must be the last-thing created; thus, we touch
# ${JNI_OUTPUTS} after the javac command finishes.
set(JNI_OUTPUTS "${TARGETS_OUTPUT_DIR}/finished_generate_java")
set(TESTS_JNI_OUTPUTS "${TARGETS_OUTPUT_DIR}/finished_tests_generate_java")
# We frequently use the add_custom_command + add_custom_target wrapper due
# to a quirk of CMake. This is documented more extensively in the
# following links:
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory
add_custom_command(
OUTPUT "${JNI_OUTPUTS}"
COMMAND ${Java_JAVAC_EXECUTABLE} ${JSS_JAVAC_FLAGS} -d ${CLASSES_OUTPUT_DIR} -h ${JNI_OUTPUT_DIR} @${JAVA_SOURCES_FILE}
COMMAND touch "${JNI_OUTPUTS}"
DEPENDS ${JAVA_SOURCES}
)
add_custom_command(
OUTPUT "${TESTS_JNI_OUTPUTS}"
COMMAND ${Java_JAVAC_EXECUTABLE} ${JSS_TEST_JAVAC_FLAGS} -d ${TESTS_CLASSES_OUTPUT_DIR} -h ${TESTS_JNI_OUTPUT_DIR} @${JAVA_TEST_SOURCES_FILE}
COMMAND touch "${TESTS_JNI_OUTPUTS}"
DEPENDS ${JAVA_TEST_SOURCES}
)
add_custom_target(
generate_java ALL
DEPENDS ${JNI_OUTPUTS} ${TESTS_JNI_OUTPUTS}
)
endmacro()
# "Build" all includes by copying them to a common directory
macro(jss_build_includes)
# Note that file(COPY ...) operations are performed at "CMake" run time,
# (equivalent to configure time), so CMake needs to be reconfigured every
# time a new header file is added. This is most easily done by removing
# the build directory and recreating it. This also applies to all other
# build steps as the globs are computed at configure time as well.
foreach(C_HEADER ${C_HEADERS})
file(COPY "${C_HEADER}" DESTINATION ${INCLUDE_OUTPUT_DIR})
endforeach()
foreach(C_TEST_HEADER ${C_TEST_HEADERS})
file(COPY "${C_TEST_HEADER}" DESTINATION ${TESTS_INCLUDE_OUTPUT_DIR})
endforeach()
add_custom_target(
generate_includes
)
endmacro()
# Compile a single C file
macro(jss_build_c_file C_FILE C_OUTPUT C_TARGET C_DIR)
# C files can be built in parallel. This macro builds each file wrapped in
# add_custom_command+add_custom_target so parallel builds work. Note that
# each build depends on generate_java and generate_includes to have
# finished, else many headers wouldn't exist.
add_custom_command(
OUTPUT "${C_OUTPUT}"
COMMAND ${CMAKE_C_COMPILER} -fPIC ${JSS_C_FLAGS} -o ${C_OUTPUT} -c ${C_FILE}
WORKING_DIRECTORY ${C_DIR}
DEPENDS ${C_FILE}
DEPENDS generate_java
DEPENDS generate_includes
)
add_custom_target(
"generate_c_${C_TARGET}"
DEPENDS "${C_OUTPUT}" ${C_HEADERS}
)
endmacro()
# Compile all C source files and build libjss library
macro(jss_build_c)
foreach(C_SOURCE ${C_SOURCES})
get_filename_component(C_TARGET ${C_SOURCE} NAME_WE)
get_filename_component(C_DIR ${C_SOURCE} DIRECTORY)
set(C_OUTPUT "${LIB_OUTPUT_DIR}/${C_TARGET}.o")
jss_build_c_file("${C_SOURCE}" "${C_OUTPUT}" "${C_TARGET}" "${C_DIR}")
list(APPEND C_OUTPUTS "${C_OUTPUT}")
endforeach()
# Combine all C targets here into a single pseudo-target for parallel
# builds.
add_custom_target(
generate_c ALL
DEPENDS ${C_OUTPUTS}
)
# We generate two libraries: build/lib/libjss.so and build/libjss.so:
# the former is for testing and is unversioned, so all symbols are public
# and can thus be tested; the latter is for releases and is versioned,
# limiting which symbols are made public. We only need to make the JNI
# symbols public as libjss.so should only be used from Java in conjunction
# with jss.jar.
add_custom_command(
OUTPUT "${JSS_SO_PATH}" "${JSS_TESTS_SO_PATH}"
COMMAND ${CMAKE_C_COMPILER} -o ${JSS_TESTS_SO_PATH} ${LIB_OUTPUT_DIR}/*.o ${JSS_LD_FLAGS} ${JSS_LIBRARY_FLAGS}
COMMAND ${CMAKE_C_COMPILER} -o ${JSS_SO_PATH} ${LIB_OUTPUT_DIR}/*.o ${JSS_LD_FLAGS} ${JSS_VERSION_SCRIPT} ${JSS_LIBRARY_FLAGS}
DEPENDS generate_c
)
# Add a target for anything depending on the library existing.
add_custom_target(
generate_so ALL
DEPENDS ${JSS_SO_PATH} ${JSS_TESTS_SO_PATH}
)
endmacro()
# Build the jar by combining the java classes from generate_java step
macro(jss_build_jars)
# Note that build/MANIFEST.MF is generated by JSSConfig.cmake's
# jss_config_version macro. Further, this doesn't yet build a reproducible
# JAR.
add_custom_command(
OUTPUT "${JSS_BUILD_JAR_PATH}"
COMMAND "${Java_JAR_EXECUTABLE}" cmf "${CMAKE_BINARY_DIR}/MANIFEST.MF" "${JSS_BUILD_JAR_PATH}" -C "${CLASSES_OUTPUT_DIR}" org -C "${CLASSES_OUTPUT_DIR}" META-INF
DEPENDS generate_java
)
add_custom_command(
OUTPUT "${JSS_TESTS_JAR_PATH}"
COMMAND "${Java_JAR_EXECUTABLE}" cmf "${CMAKE_BINARY_DIR}/MANIFEST.MF" ${JSS_TESTS_JAR_PATH} -C "${TESTS_CLASSES_OUTPUT_DIR}" org
DEPENDS generate_java
)
add_custom_target(
generate_build_jar
DEPENDS "${JSS_BUILD_JAR_PATH}"
)
add_custom_command(
OUTPUT "${JSS_JAR_PATH}"
COMMAND "${PROJECT_SOURCE_DIR}/tools/reproducible_jar.sh" "${JSS_BUILD_JAR_PATH}" "${REPRODUCIBLE_TEMP_DIR}" "${JSS_JAR_PATH}"
DEPENDS generate_build_jar
)
add_custom_target(
generate_jar ALL
DEPENDS "${JSS_JAR_PATH}" "${JSS_TESTS_JAR_PATH}"
)
endmacro()
# Build javadocs from the source files
macro(jss_build_javadocs)
# Add another pseudo-target here as well -- javadocs create a lot of
# output, but anything which depends on the javadocs existing should
# depend on the javadoc target.
set(JAVADOCS_OUTPUTS "${TARGETS_OUTPUT_DIR}/finished_generate_javadocs")
add_custom_command(
OUTPUT ${JAVADOCS_OUTPUTS}
COMMAND "${Java_JAVADOC_EXECUTABLE}" -overview "${PROJECT_SOURCE_DIR}/tools/javadoc/overview.html" -windowtitle "${JSS_WINDOW_TITLE}" -notimestamp -breakiterator -classpath ${JAVAC_CLASSPATH} -sourcepath ${PROJECT_SOURCE_DIR} -d ${DOCS_OUTPUT_DIR} @${JAVA_SOURCES_FILE}
COMMAND touch "${JAVADOCS_OUTPUTS}"
DEPENDS ${JAVA_SOURCES}
)
add_custom_target(
javadoc
DEPENDS ${JAVADOCS_OUTPUTS}
)
# For compliance with GNU Make standard targets
add_custom_target(
html
DEPENDS javadoc
)
endmacro()
jss-5.0.0/cmake/JSSConfig.cmake 0000664 0000000 0000000 00000043605 14125500636 0016174 0 ustar 00root root 0000000 0000000 macro(jss_config)
# Set the current JSS release number. Arguments are:
# MAJOR MINOR PATCH BETA
# When BETA is 1, it is a pre-release (it enables some tests).
# When BETA is 0, it is a final release.
jss_config_version(5 0 0 0)
# Configure output directories
jss_config_outputs()
# Configure flags for compiling and linking
jss_config_cflags()
jss_config_ldflags()
# Configure java-related flags
jss_config_java()
# Configure test variables
jss_config_tests()
# Check symbols to see what tests we run
jss_config_symbols()
# Template auto-generated files
jss_config_template()
endmacro()
macro(jss_config_version MAJOR MINOR PATCH BETA)
# This sets the JSS Version for use in CMake and propagates it to the
# necessary source locations. These are:
#
# src/main/java/org/mozilla/jss/util/jssver.h{.in,}
# lib/MANIFEST.MF.in -> build/MANIFEST.MF
#
# On a build, these automatically get generated with the correct versions
# included. Note that all "sets" are of global scope, so these variables
# can be used anywhere that is necessary. Some uses are for setting the
# version number in the library and jar file, etc.
# Define variables from passed arguments
set(JSS_VERSION_MAJOR "${MAJOR}")
set(JSS_VERSION_MINOR "${MINOR}")
set(JSS_VERSION_PATCH "${PATCH}")
set(JSS_VERSION_BETA "${BETA}")
set(JSS_VERSION "${JSS_VERSION_MAJOR}.${JSS_VERSION_MINOR}.${JSS_VERSION_PATCH}")
set(JSS_VERSION_MANIFEST "${JSS_VERSION_MAJOR}.${JSS_VERSION_MINOR}")
set(JSS_VERSION_STR "JSS_${JSS_VERSION_MAJOR}_${JSS_VERSION_MINOR}")
if(${PATCH} GREATER 0)
set(JSS_VERSION_MANIFEST "${JSS_VERSION_MANIFEST}.${JSS_VERSION_PATCH}")
set(JSS_VERSION_STR "${JSS_VERSION_STR}_${JSS_VERSION_PATCH}")
endif()
if(${BETA} GREATER 0)
set(JSS_VERSION "${JSS_VERSION} beta ${JSS_VERSION_BETA}")
set(JSS_VERSION_STR "${JSS_VERSION_STR}_b${JSS_VERSION_BETA}")
endif()
endmacro()
macro(jss_config_outputs)
# Global variables representing various output files; note that these
# directories are created at the end of this macro.
set(CLASSES_OUTPUT_DIR "${CMAKE_BINARY_DIR}/classes/jss")
set(CONFIG_OUTPUT_DIR "${CMAKE_BINARY_DIR}/config")
set(DOCS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/docs")
set(LIB_OUTPUT_DIR "${CMAKE_BINARY_DIR}/lib")
set(BIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/include/jss")
set(JNI_OUTPUT_DIR "${CMAKE_BINARY_DIR}/include/jss/_jni")
if (NOT DEFINED JAVA_LIB_INSTALL_DIR)
set(JAVA_LIB_INSTALL_DIR "/usr/lib/java")
endif(NOT DEFINED JAVA_LIB_INSTALL_DIR)
if (NOT DEFINED JSS_LIB_INSTALL_DIR)
set(JSS_LIB_INSTALL_DIR "/usr/lib/jss")
endif(NOT DEFINED JSS_LIB_INSTALL_DIR)
# This folder is for pseudo-locations for CMake targets
set(TARGETS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/.targets")
set(JAVA_SOURCES_FILE "${TARGETS_OUTPUT_DIR}/java.sources")
set(JAVA_TEST_SOURCES_FILE "${TARGETS_OUTPUT_DIR}/java-test.sources")
# These folders are for the NSS DBs created during testing
set(RESULTS_DATA_OUTPUT_DIR "${CMAKE_BINARY_DIR}/results/data")
set(RESULTS_NSSDB_OUTPUT_DIR "${CMAKE_BINARY_DIR}/results/nssdb")
set(RESULTS_NSSDB_FIPS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/results/fips")
set(RESULTS_NSSDB_INTERNET_OUTPUT_DIR "${CMAKE_BINARY_DIR}/results/internet")
# This is a temporary location for building the reproducible jar
set(REPRODUCIBLE_TEMP_DIR "${CMAKE_BINARY_DIR}/reproducible")
set(JSS_BUILD_JAR "staging.jar")
set(JSS_JAR "jss.jar")
set(JSS_SO "libjss.so")
set(JSS_BUILD_JAR_PATH "${CMAKE_BINARY_DIR}/${JSS_BUILD_JAR}")
set(JSS_JAR_PATH "${CMAKE_BINARY_DIR}/${JSS_JAR}")
set(JSS_SO_PATH "${CMAKE_BINARY_DIR}/${JSS_SO}")
# These options are for the test suite and mirror their non-tests
# counterparts. Note that JSS_TESTS_SO is the same as JSS_SO, but
# JSS_TESTS_SO_PATH differs -- one is "unversioned" and lacks a
# version script so we can test internal methods.
set(TESTS_CLASSES_OUTPUT_DIR "${CMAKE_BINARY_DIR}/classes/tests")
set(TESTS_INCLUDE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/include/tests")
set(TESTS_JNI_OUTPUT_DIR "${CMAKE_BINARY_DIR}/include/jss/_jni")
set(JSS_TESTS_JAR "tests-jss.jar")
set(JSS_TESTS_SO "${JSS_SO}")
set(JSS_TESTS_JAR_PATH "${CMAKE_BINARY_DIR}/${JSS_TESTS_JAR}")
set(JSS_TESTS_SO_PATH "${LIB_OUTPUT_DIR}/${JSS_TESTS_SO}")
# Create the *_OUTPUT_DIR locations.
file(MAKE_DIRECTORY "${CLASSES_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${CONFIG_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${DOCS_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${LIB_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${BIN_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${INCLUDE_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${JNI_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${TARGETS_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${TESTS_CLASSES_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${TESTS_INCLUDE_OUTPUT_DIR}")
file(MAKE_DIRECTORY "${TESTS_JNI_OUTPUT_DIR}")
endmacro()
macro(jss_config_cflags)
# We check that the C compiler can handle each of the C flags below
include(CheckCCompilerFlag)
# This list of C flags was taken from the original build scripts for
# debug and release builds.
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND JSS_RAW_C_FLAGS "-Og")
list(APPEND JSS_RAW_C_FLAGS "-ggdb")
list(APPEND JSS_RAW_C_FLAGS "-DDEBUG")
list(APPEND JSS_RAW_C_FLAGS "-DFORCE_PR_ASSERT")
else()
list(APPEND JSS_RAW_C_FLAGS "-O2")
endif()
list(APPEND JSS_RAW_C_FLAGS "-Wall")
list(APPEND JSS_RAW_C_FLAGS "-std=gnu99")
list(APPEND JSS_RAW_C_FLAGS "-Wno-cast-function-type")
list(APPEND JSS_RAW_C_FLAGS "-Wno-unused-parameter")
list(APPEND JSS_RAW_C_FLAGS "-Wno-unknown-warning-option")
list(APPEND JSS_RAW_C_FLAGS "-Wno-unused-but-set-variable")
list(APPEND JSS_RAW_C_FLAGS "-Werror-implicit-function-declaration")
list(APPEND JSS_RAW_C_FLAGS "-Wno-switch")
list(APPEND JSS_RAW_C_FLAGS "-I${INCLUDE_OUTPUT_DIR}")
foreach(JNI_INCLUDE_DIR ${JNI_INCLUDE_DIRS})
list(APPEND JSS_RAW_C_FLAGS "-I${JNI_INCLUDE_DIR}")
endforeach()
foreach(NSPR_INCLUDE_DIR ${NSPR_INCLUDE_DIRS})
list(APPEND JSS_RAW_C_FLAGS "-I${NSPR_INCLUDE_DIR}")
endforeach()
foreach(NSS_INCLUDE_DIR ${NSS_INCLUDE_DIRS})
list(APPEND JSS_RAW_C_FLAGS "-I${NSS_INCLUDE_DIR}")
endforeach()
foreach(NSPR_LIBRARY ${NSPR_LIBRARIES})
list(APPEND JSS_RAW_C_FLAGS "-L${NSPR_LIBRARY}")
endforeach()
foreach(NSS_LIBRARY ${NSS_LIBRARIES})
list(APPEND JSS_RAW_C_FLAGS "-L${NSS_LIBRARY}")
endforeach()
foreach(JSS_RAW_C_FLAG ${JSS_RAW_C_FLAGS})
# Validate that each of our desired CFLAGS is supported by the
# compiler, or well, at least the compiler doesn't immediately
# error on it. :)
check_c_compiler_flag(${JSS_RAW_C_FLAG} HAVE_C_FLAG)
if(${HAVE_C_FLAG})
list(APPEND JSS_C_FLAGS "${JSS_RAW_C_FLAG}")
endif()
endforeach()
# Handle passed-in C flags as well; assume they are valid.
separate_arguments(PASSED_C_FLAGS UNIX_COMMAND "${CMAKE_C_FLAGS}")
foreach(PASSED_C_FLAG ${PASSED_C_FLAGS})
list(INSERT JSS_C_FLAGS 0 "${PASSED_C_FLAG}")
endforeach()
message(STATUS "JSS C FLAGS: ${JSS_C_FLAGS}")
endmacro()
macro(jss_config_ldflags)
# This list of C linker flags was taken from the original build scripts
# for debug and release builds. We lack a "check_c_linker_flag" macro,
# so no effort is made to validate these flags.
list(APPEND JSS_LD_FLAGS "-lsmime3")
list(APPEND JSS_LD_FLAGS "-lssl3")
list(APPEND JSS_LD_FLAGS "-lnss3")
list(APPEND JSS_LD_FLAGS "-lnssutil3")
list(APPEND JSS_LD_FLAGS "-lplc4")
list(APPEND JSS_LD_FLAGS "-lplds4")
list(APPEND JSS_LD_FLAGS "-lnspr4")
list(APPEND JSS_LD_FLAGS "-lpthread")
list(APPEND JSS_LD_FLAGS "-ldl")
separate_arguments(PASSED_LD_FLAGS UNIX_COMMAND "${CMAKE_SHARED_LINKER_FLAGS}")
foreach(PASSED_LD_FLAG ${PASSED_LD_FLAGS})
list(INSERT JSS_LD_FLAGS 0 "${PASSED_LD_FLAG}")
endforeach()
# This set of flags is specific to building the libjss library.
list(APPEND JSS_LIBRARY_FLAGS "-shared")
list(APPEND JSS_LIBRARY_FLAGS "-Wl,-z,defs")
list(APPEND JSS_LIBRARY_FLAGS "-Wl,-soname")
list(APPEND JSS_LIBRARY_FLAGS "-Wl,${JSS_SO}")
set(JSS_VERSION_SCRIPT "-Wl,--version-script,${PROJECT_SOURCE_DIR}/lib/jss.map")
message(STATUS "JSS LD FLAGS: ${JSS_LD_FLAGS}")
message(STATUS "JSS LIBRARY FLAGS: ${JSS_LIBRARY_FLAGS}")
endmacro()
macro(jss_config_java)
# Find various JARs required by JSS build and test suite
find_jar(
SLF4J_API_JAR
NAMES api slf4j/api slf4j-api
)
find_jar(
LANG_JAR
NAMES apache-commons-lang3 commons-lang3
)
find_jar(
SLF4J_JDK14_JAR
NAMES jdk14 slf4j/jdk14 slf4j-jdk14
)
find_jar(
JUNIT4_JAR
NAMES junit4 junit
)
find_jar(
HAMCREST_JAR
NAMES hamcrest/core hamcrest-core hamcrest/hamcrest
)
# Validate that we've found the required JARs
if(SLF4J_API_JAR STREQUAL "SLF4J_API_JAR-NOTFOUND")
message(FATAL_ERROR "Required dependency sfl4j-api.jar not found by find_jar!")
endif()
if(LANG_JAR STREQUAL "LANG_JAR-NOTFOUND")
message(FATAL_ERROR "Required dependency apache-commons-lang.jar not found by find_jar!")
endif()
if(SLF4J_JDK14_JAR STREQUAL "SLF4J_JDK14_JAR-NOTFOUND")
message(WARNING "Test dependency sfl4j-jdk14.jar not found by find_jar! Tests might not run properly.")
endif()
if(JUNIT4_JAR STREQUAL "JUNIT4_JAR-NOTFOUND")
message(FATAL_ERROR "Test dependency junit4.jar not found by find_jar! Tests will not compile.")
endif()
if(HAMCREST_JAR STREQUAL "HAMCREST_JAR-NOTFOUND")
message(WARNING "Test dependency hamcrest/core.jar not found by find_jar! Tests might not run properly.")
endif()
# Set class paths
set(JAVAC_CLASSPATH "${SLF4J_API_JAR}:${LANG_JAR}")
set(TEST_CLASSPATH "${JSS_JAR_PATH}:${JSS_TESTS_JAR_PATH}:${JAVAC_CLASSPATH}:${SLF4J_JDK14_JAR}:${JUNIT4_JAR}:${HAMCREST_JAR}")
message(STATUS "javac classpath: ${JAVAC_CLASSPATH}")
message(STATUS "tests classpath: ${TEST_CLASSPATH}")
# Set compile flags for JSS
list(APPEND JSS_JAVAC_FLAGS "-classpath")
list(APPEND JSS_JAVAC_FLAGS "${JAVAC_CLASSPATH}")
list(APPEND JSS_JAVAC_FLAGS "-sourcepath")
list(APPEND JSS_JAVAC_FLAGS "${PROJECT_SOURCE_DIR}/src/main/java")
# Ensure we're compatible with JDK 8
list(APPEND JSS_JAVAC_FLAGS "-target")
list(APPEND JSS_JAVAC_FLAGS "1.8")
list(APPEND JSS_JAVAC_FLAGS "-source")
list(APPEND JSS_JAVAC_FLAGS "1.8")
# Handle passed-in javac flags as well; assume they are valid.
separate_arguments(PASSED_JAVAC_FLAGS UNIX_COMMAND "$ENV{JAVACFLAGS}")
foreach(PASSED_JAVAC_FLAG ${PASSED_JAVAC_FLAGS})
list(APPEND JSS_JAVAC_FLAGS "${PASSED_JAVAC_FLAG}")
endforeach()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND JSS_JAVAC_FLAGS "-g")
list(APPEND JSS_JAVAC_FLAGS "-Xlint:unchecked")
else()
list(APPEND JSS_JAVAC_FLAGS "-O")
endif()
# Set compile flags for JSS test suite
list(APPEND JSS_TEST_JAVAC_FLAGS "-classpath")
list(APPEND JSS_TEST_JAVAC_FLAGS "${JAVAC_CLASSPATH}:${JUNIT4_JAR}:${CLASSES_OUTPUT_DIR}")
list(APPEND JSS_TEST_JAVAC_FLAGS "-sourcepath")
list(APPEND JSS_TEST_JAVAC_FLAGS "${PROJECT_SOURCE_DIR}/src/main/java")
# Ensure we're compatible with JDK 8
list(APPEND JSS_TEST_JAVAC_FLAGS "-target")
list(APPEND JSS_TEST_JAVAC_FLAGS "1.8")
list(APPEND JSS_TEST_JAVAC_FLAGS "-source")
list(APPEND JSS_TEST_JAVAC_FLAGS "1.8")
# Handle passed-in javac flags as well; assume they are valid.
separate_arguments(PASSED_JAVAC_FLAGS UNIX_COMMAND "$ENV{JAVACFLAGS}")
foreach(PASSED_JAVAC_FLAG ${PASSED_JAVAC_FLAGS})
list(APPEND JSS_TEST_JAVAC_FLAGS "${PASSED_JAVAC_FLAG}")
endforeach()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND JSS_TEST_JAVAC_FLAGS "-g")
else()
list(APPEND JSS_TEST_JAVAC_FLAGS "-O")
endif()
message(STATUS "JSS JAVAC FLAGS: ${JSS_JAVAC_FLAGS}")
message(STATUS "JSS TEST JAVAC FLAGS: ${JSS_TEST_JAVAC_FLAGS}")
# Variables for javadoc building.
set(JSS_WINDOW_TITLE "JSS: Java Security Services")
set(JSS_BASE_PORT 2876)
math(EXPR JSS_TEST_PORT_CLIENTAUTH ${JSS_BASE_PORT}+0)
math(EXPR JSS_TEST_PORT_CLIENTAUTH_FIPS ${JSS_BASE_PORT}+1)
# Create META-INF directory for provider
file(MAKE_DIRECTORY "${CLASSES_OUTPUT_DIR}/META-INF/services")
endmacro()
macro(jss_config_template)
# Template files
configure_file(
"${PROJECT_SOURCE_DIR}/src/main/java/org/mozilla/jss/jssconfig.h.in"
"${PROJECT_SOURCE_DIR}/src/main/java/org/mozilla/jss/jssconfig.h"
)
configure_file(
"${PROJECT_SOURCE_DIR}/src/main/java/org/mozilla/jss/util/jssver.h.in"
"${PROJECT_SOURCE_DIR}/src/main/java/org/mozilla/jss/util/jssver.h"
)
configure_file(
"${PROJECT_SOURCE_DIR}/lib/MANIFEST.MF.in"
"${CMAKE_BINARY_DIR}/MANIFEST.MF"
)
configure_file(
"${PROJECT_SOURCE_DIR}/lib/java.security.Provider.in"
"${CLASSES_OUTPUT_DIR}/META-INF/services/java.security.Provider"
)
configure_file(
"${PROJECT_SOURCE_DIR}/tools/run_test.sh.in"
"${CMAKE_BINARY_DIR}/run_test.sh"
)
set(JSS_CFG_PATH "${CONFIG_OUTPUT_DIR}/jss.cfg")
configure_file(
"${PROJECT_SOURCE_DIR}/tools/java.security.in"
"${CONFIG_OUTPUT_DIR}/java.security"
@ONLY
)
set(NSS_DB_PATH "${RESULTS_NSSDB_OUTPUT_DIR}")
configure_file(
"${PROJECT_SOURCE_DIR}/tools/jss.cfg.in"
"${JSS_CFG_PATH}"
)
set(JSS_CFG_PATH "${CONFIG_OUTPUT_DIR}/jss-fips.cfg")
configure_file(
"${PROJECT_SOURCE_DIR}/tools/java.security.in"
"${CONFIG_OUTPUT_DIR}/fips.security"
@ONLY
)
set(NSS_DB_PATH "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}")
configure_file(
"${PROJECT_SOURCE_DIR}/tools/jss.cfg.in"
"${JSS_CFG_PATH}"
)
set(JSS_CFG_PATH "${CONFIG_OUTPUT_DIR}/jss-internet.cfg")
configure_file(
"${PROJECT_SOURCE_DIR}/tools/java.security.in"
"${CONFIG_OUTPUT_DIR}/internet.security"
@ONLY
)
set(NSS_DB_PATH "${RESULTS_NSSDB_INTERNET_OUTPUT_DIR}")
configure_file(
"${PROJECT_SOURCE_DIR}/tools/jss.cfg.in"
"${JSS_CFG_PATH}"
)
unset(JSS_CFG_PATH)
unset(NSS_DB_PATH)
endmacro()
macro(jss_config_symbols)
list(APPEND CMAKE_REQUIRED_INCLUDES ${NSPR_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${NSS_INCLUDE_DIRS})
jss_list_join(JSS_C_FLAGS " " CMAKE_REQUIRED_FLAGS)
check_symbol_exists("CKM_AES_CMAC" "nspr.h;nss.h;pkcs11t.h" HAVE_NSS_CMAC)
if(NOT HAVE_NSS_CMAC)
message(WARNING "Your NSS version doesn't support CMAC; some features of JSS won't work.")
endif()
check_symbol_exists("CKM_SP800_108_COUNTER_KDF" "nspr.h;nss.h;pkcs11t.h" HAVE_NSS_KBKDF)
if(NOT HAVE_NSS_KBKDF)
message(WARNING "Your NSS version doesn't support NIST SP800-108 KBKDF; some features of JSS won't work.")
endif()
try_compile(CK_HAVE_COMPILING_OAEP
${CMAKE_BINARY_DIR}/results
${CMAKE_SOURCE_DIR}/tools/tests/oaep.c
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}"
"-DREQUIRED_FLAGS=${CMAKE_REQUIRED_FLAGS}"
LINK_OPTIONS ${JSS_LD_FLAGS}
OUTPUT_VARIABLE COMP_OUT)
if (CK_HAVE_COMPILING_OAEP)
set(HAVE_NSS_OAEP TRUE)
else()
message(WARNING "Your NSS version doesn't support RSA-OAEP key wra/unwrap; some features of JSS won't work.")
message(WARNING "Compile output: ${COMP_OUT}")
endif()
if(HAVE_NSS_CMAC)
try_run(CK_HAVE_WORKING_CMAC
CK_HAVE_COMPILING_CMAC
${CMAKE_BINARY_DIR}/results
${CMAKE_SOURCE_DIR}/tools/tests/cmac.c
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}"
"-DREQUIRED_FLAGS=${CMAKE_REQUIRED_FLAGS}"
COMPILE_OUTPUT_VARIABLE COMP_OUT
RUN_OUTPUT_VARIABLE RUN_OUT)
if (NOT CK_HAVE_WORKING_CMAC STREQUAL "0" OR NOT CK_HAVE_COMPILING_CMAC)
set(HAVE_NSS_CMAC FALSE)
set(HAVE_NSS_KBKDF FALSE)
message(WARNING "Your NSS version is broken: between NSS v3.47 and v3.50, the values of CKM_AES_CMAC and CKM_AES_CMAC_GENERAL were swapped. Disabling CMAC and KBKDF support.")
message(WARNING "Compile output: ${COMP_OUT}")
message(WARNING "Run output: ${RUN_OUT}")
endif()
endif()
# Added in NSS v3.43
check_struct_has_member(
SSLCipherSuiteInfo
kdfHash
ssl.h
HAVE_NSS_CIPHER_SUITE_INFO_KDFHASH
)
# Added in NSS v3.34
check_struct_has_member(
SSLChannelInfo
originalKeaGroup
ssl.h
HAVE_NSS_CHANNEL_INFO_ORIGINAL_KEA_GROUP
)
# Added in NSS v3.45
check_struct_has_member(
SSLChannelInfo
peerDelegCred
ssl.h
HAVE_NSS_CHANNEL_INFO_PEER_DELEG_CRED
)
# Added in NSS v3.43
check_struct_has_member(
SSLPreliminaryChannelInfo
zeroRttCipherSuite
ssl.h
HAVE_NSS_PRELIMINARY_CHANNEL_INFO_ZERO_RTT_CIPHER_SUITE
)
# Added in NSS v3.48
check_struct_has_member(
SSLPreliminaryChannelInfo
peerDelegCred
ssl.h
HAVE_NSS_PRELIMINARY_CHANNEL_INFO_PEER_DELEG_CRED
)
endmacro()
macro(jss_config_tests)
# Common variables used as arguments to several tests
set(JSS_TEST_DIR "${PROJECT_SOURCE_DIR}/src/test/java/org/mozilla/jss/tests")
set(PASSWORD_FILE "${JSS_TEST_DIR}/passwords")
set(DB_PWD "m1oZilla")
endmacro()
jss-5.0.0/cmake/JSSTests.cmake 0000664 0000000 0000000 00000053436 14125500636 0016074 0 ustar 00root root 0000000 0000000 macro(jss_tests)
enable_testing()
jss_tests_compile()
# Create directories for test cases:
# - results/data
# - results/nssdb
# - results/fips
jss_test_exec(
NAME "Clean_Data_Dir"
COMMAND "cmake" "-E" "remove_directory" "${RESULTS_DATA_OUTPUT_DIR}"
)
jss_test_exec(
NAME "Create_Data_Dir"
COMMAND "cmake" "-E" "make_directory" "${RESULTS_DATA_OUTPUT_DIR}"
DEPENDS "Clean_Data_Dir"
)
# Rather than creating our results directories earlier in JSSConfig,
# create them here so that the test suite can be rerun multiple times.
jss_test_exec(
NAME "Clean_Setup_DBs"
COMMAND "cmake" "-E" "remove_directory" "${RESULTS_NSSDB_OUTPUT_DIR}"
)
jss_test_exec(
NAME "Create_Setup_DBs"
COMMAND "cmake" "-E" "make_directory" "${RESULTS_NSSDB_OUTPUT_DIR}"
DEPENDS "Clean_Setup_DBs"
)
jss_test_java(
NAME "Setup_DBs"
COMMAND "org.mozilla.jss.tests.SetupDBs" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Create_Setup_DBs"
MODE "NONE"
)
# Various FIPS related tests depend on FIPS being enabled; since this
# affects the entire NSS DB, create a separate database for them.
jss_test_exec(
NAME "Clean_FIPS_Setup_DBs"
COMMAND "cmake" "-E" "remove_directory" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}"
)
jss_test_exec(
NAME "Create_FIPS_Setup_DBs"
COMMAND "cmake" "-E" "make_directory" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}"
DEPENDS "Clean_FIPS_Setup_DBs"
)
jss_test_java(
NAME "Setup_FIPS_DBs"
COMMAND "org.mozilla.jss.tests.SetupDBs" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Create_FIPS_Setup_DBs"
MODE "NONE"
)
# NSS DB for internet connected tests; imports global root CA certs.
if(TEST_WITH_INTERNET)
jss_test_exec(
NAME "Clean_Internet_Setup_DBs"
COMMAND "cmake" "-E" "remove_directory" "${RESULTS_NSSDB_INTERNET_OUTPUT_DIR}"
)
jss_test_exec(
NAME "Import_Internet_Certs"
COMMAND "${CMAKE_SOURCE_DIR}/tools/common_roots.sh" "${RESULTS_NSSDB_INTERNET_OUTPUT_DIR}"
DEPENDS "Clean_Internet_Setup_DBs"
)
endif()
jss_test_exec(
NAME "TestBufferPRFD"
COMMAND "${BIN_OUTPUT_DIR}/TestBufferPRFD"
)
jss_test_java(
NAME "Test_UTF-8_Converter"
COMMAND "org.mozilla.jss.tests.UTF8ConverterTest"
)
jss_test_java(
NAME "Test_Base64_Parsing"
COMMAND "org.mozilla.jss.tests.Base64Parsing"
)
jss_test_java(
NAME "JSS_DER_Encoding_of_Enumeration_regression_test"
COMMAND "org.mozilla.jss.tests.EnumerationZeroTest"
)
jss_test_java(
NAME "JSS_Test_DER_Encoding_Functionality"
COMMAND "org.mozilla.jss.tests.DEROutputStreamTests"
)
jss_test_java(
NAME "JSS_Test_Empty_DER_Value"
COMMAND "org.mozilla.jss.tests.EmptyDerValue"
)
jss_test_java(
NAME "BigObjectIdentifier"
COMMAND "org.mozilla.jss.tests.BigObjectIdentifier"
)
jss_test_java(
NAME "JSS_Test_PR_FileDesc"
COMMAND "org.mozilla.jss.tests.TestPRFD"
)
jss_test_java(
NAME "JSS_Test_Raw_SSL"
COMMAND "org.mozilla.jss.tests.TestRawSSL" "${RESULTS_NSSDB_OUTPUT_DIR}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "JSS_Test_Buffer"
COMMAND "org.mozilla.jss.tests.TestBuffer"
)
jss_test_java(
NAME "JSS_Test_GlobalRefProxy"
COMMAND "org.mozilla.jss.tests.TestGlobalReference"
MODE "NONE"
)
if ((${Java_VERSION_MAJOR} EQUAL 1) AND (${Java_VERSION_MINOR} LESS 9) AND (${JSS_VERSION_BETA} EQUAL 1))
jss_test_java(
NAME "Test_PKCS11Constants.java_for_Sun_compatibility"
COMMAND "org.mozilla.jss.tests.TestPKCS11Constants"
)
endif()
jss_test_java(
NAME "JUnit_BMPStringTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.BMPStringTest"
)
jss_test_java(
NAME "JUnit_IA5StringTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.IA5StringTest"
)
jss_test_java(
NAME "JUnit_PrintableStringTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.PrintableStringTest"
)
jss_test_java(
NAME "JUnit_TeletexStringTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.TeletexStringTest"
)
jss_test_java(
NAME "JUnit_UniversalStringTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.UniversalStringTest"
)
jss_test_java(
NAME "JUnit_UTF8StringTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.UTF8StringTest"
)
jss_test_exec(
NAME "buffer_size_1"
COMMAND "${BIN_OUTPUT_DIR}/buffer_size_1"
DEPENDS "generate_c_buffer_size_1"
)
jss_test_exec(
NAME "buffer_size_4"
COMMAND "${BIN_OUTPUT_DIR}/buffer_size_4"
DEPENDS "generate_c_buffer_size_4"
)
jss_test_java(
NAME "JUnit_CertificateChainTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.CertificateChainTest"
)
jss_test_java(
NAME "JUnit_ChainSortingTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.ChainSortingTest"
)
jss_test_java(
NAME "Generate_known_RSA_cert_pair"
COMMAND "org.mozilla.jss.tests.GenerateTestCert" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" "20" "localhost" "SHA-256/RSA" "CA_RSA" "Server_RSA" "Client_RSA"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Generate_known_ECDSA_cert_pair"
COMMAND "org.mozilla.jss.tests.GenerateTestCert" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" "30" "localhost" "SHA-256/EC" "CA_ECDSA" "Server_ECDSA" "Client_ECDSA"
DEPENDS "Generate_known_RSA_cert_pair"
)
jss_test_exec(
NAME "Create_PKCS11_cert_to_PKCS12_rsa.pfx"
COMMAND "pk12util" "-o" "${RESULTS_NSSDB_OUTPUT_DIR}/rsa.pfx" "-n" "CA_RSA" "-d" "${RESULTS_NSSDB_OUTPUT_DIR}" "-K" "${DB_PWD}" "-W" "${DB_PWD}"
DEPENDS "Generate_known_RSA_cert_pair"
)
jss_test_exec(
NAME "Create_PKCS11_cert_to_PKCS12_ecdsa.pfx"
COMMAND "pk12util" "-o" "${RESULTS_NSSDB_OUTPUT_DIR}/ecdsa.pfx" "-n" "CA_ECDSA" "-d" "${RESULTS_NSSDB_OUTPUT_DIR}" "-K" "${DB_PWD}" "-W" "${DB_PWD}"
DEPENDS "Generate_known_ECDSA_cert_pair"
)
jss_test_java(
NAME "List_CA_certs"
COMMAND "org.mozilla.jss.tests.ListCACerts" "${RESULTS_NSSDB_OUTPUT_DIR}" "Verbose"
DEPENDS "Generate_known_ECDSA_cert_pair"
)
jss_test_java(
NAME "SSLClientAuth"
COMMAND "org.mozilla.jss.tests.SSLClientAuth" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" "${JSS_TEST_PORT_CLIENTAUTH}" "50"
DEPENDS "List_CA_certs"
)
jss_test_java(
NAME "Key_Generation"
COMMAND "org.mozilla.jss.tests.TestKeyGen" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Digest"
COMMAND "org.mozilla.jss.tests.DigestTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "HMAC"
COMMAND "org.mozilla.jss.tests.CrossHMACTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "KeyWrapping"
COMMAND "org.mozilla.jss.tests.JCAKeyWrap" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
if(HAVE_NSS_OAEP)
jss_test_java(
NAME "JSS-KeyWrapping"
COMMAND "org.mozilla.jss.tests.KeyWrapping" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
endif()
jss_test_java(
NAME "Mozilla_JSS_JCA_Signature"
COMMAND "org.mozilla.jss.tests.JCASigTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Mozilla_JSS_NSS_Signature"
COMMAND "org.mozilla.jss.tests.SigTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "JSS_Signature_test"
COMMAND "org.mozilla.jss.tests.SigTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Secret_Decoder_Ring"
COMMAND "org.mozilla.jss.tests.TestSDR" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "List_cert_by_certnick"
COMMAND "org.mozilla.jss.tests.ListCerts" "${RESULTS_NSSDB_OUTPUT_DIR}" "Server_RSA"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Verify_cert_by_certnick"
COMMAND "org.mozilla.jss.tests.VerifyCert" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" "Server_RSA"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Secret_Key_Generation"
COMMAND "org.mozilla.jss.tests.SymKeyGen" "${RESULTS_NSSDB_OUTPUT_DIR}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "Symmetric_Key_Deriving"
COMMAND "org.mozilla.jss.tests.SymKeyDeriving" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "X509CertTest"
COMMAND "org.mozilla.jss.tests.X509CertTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "List_CA_certs"
)
jss_test_java(
NAME "KeyStoreTest"
COMMAND "org.mozilla.jss.tests.KeyStoreTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" getAliases
DEPENDS "List_CA_certs" "X509CertTest" "Secret_Key_Generation" "Symmetric_Key_Deriving" "SSLClientAuth"
)
jss_test_java(
NAME "JSSProvider"
COMMAND "org.mozilla.jss.tests.JSSProvider" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "List_CA_certs" "X509CertTest" "Secret_Key_Generation" "Symmetric_Key_Deriving" "SSLClientAuth"
)
jss_test_java(
NAME "SSLEngine_RSA"
COMMAND "org.mozilla.jss.tests.TestSSLEngine" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" "Client_RSA" "Server_RSA"
DEPENDS "List_CA_certs"
)
jss_test_java(
NAME "SSLEngine_ECDSA"
COMMAND "org.mozilla.jss.tests.TestSSLEngine" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}" "Client_ECDSA" "Server_ECDSA"
DEPENDS "SSLEngine_RSA"
)
if(NOT FIPS_ENABLED)
jss_test_java(
NAME "Key_Factory"
COMMAND "org.mozilla.jss.tests.KeyFactoryTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
jss_test_java(
NAME "HMAC_Unwrap"
COMMAND "org.mozilla.jss.tests.HmacTest" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
if(HAVE_NSS_CMAC)
jss_test_java(
NAME "CMAC_Test"
COMMAND "org.mozilla.jss.tests.TestCmac" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
endif()
if(HAVE_NSS_KBKDF)
jss_test_java(
NAME "KBKDF_Test"
COMMAND "org.mozilla.jss.tests.TestKBKDF" "${RESULTS_NSSDB_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Setup_DBs"
)
endif()
jss_test_java(
NAME "Mozilla_JSS_Secret_Key_Generation"
COMMAND "org.mozilla.jss.tests.JCASymKeyGen" "${RESULTS_NSSDB_OUTPUT_DIR}"
DEPENDS "Setup_DBs"
)
# SSL Engine related tests
jss_test_exec(
NAME "TestBufferPRFDSSL_RSA"
COMMAND "${BIN_OUTPUT_DIR}/TestBufferPRFDSSL" "${RESULTS_NSSDB_OUTPUT_DIR}" "${DB_PWD}" "Server_RSA"
DEPENDS "List_CA_certs" "generate_c_TestBufferPRFDSSL"
)
jss_test_exec(
NAME "TestBufferPRFDSSL_ECDSA"
COMMAND "${BIN_OUTPUT_DIR}/TestBufferPRFDSSL" "${RESULTS_NSSDB_OUTPUT_DIR}" "${DB_PWD}" "Server_ECDSA"
DEPENDS "List_CA_certs" "generate_c_TestBufferPRFDSSL"
)
jss_test_java(
NAME "JSS_Test_BufferPRFD"
COMMAND "org.mozilla.jss.tests.TestBufferPRFD" "${RESULTS_NSSDB_OUTPUT_DIR}" "${DB_PWD}"
DEPENDS "List_CA_certs"
)
# FIPS-related tests
jss_test_java(
NAME "Generate_FIPS_known_RSA_cert_pair"
COMMAND "org.mozilla.jss.tests.GenerateTestCert" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}" "70" "localhost" "SHA-256/RSA" "CA_RSA" "Server_RSA" "Client_RSA"
DEPENDS "Setup_FIPS_DBs"
MODE "FIPS"
)
jss_test_java(
NAME "Generate_FIPS_known_ECDSA_cert_pair"
COMMAND "org.mozilla.jss.tests.GenerateTestCert" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}" "80" "localhost" "SHA-256/EC" "CA_ECDSA" "Server_ECDSA" "Client_ECDSA"
DEPENDS "Generate_FIPS_known_RSA_cert_pair"
MODE "FIPS"
)
jss_test_java(
NAME "Enable_FipsMODE"
COMMAND "org.mozilla.jss.tests.FipsTest" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "enable"
DEPENDS "Generate_FIPS_known_ECDSA_cert_pair"
MODE "NONE"
)
jss_test_java(
NAME "check_FipsMODE"
COMMAND "org.mozilla.jss.tests.FipsTest" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "chkfips"
DEPENDS "Enable_FipsMODE"
MODE "NONE"
)
# The current version of NSS features partial support for TLS 1.3 in
# FIPS mode.
if (NOT SANDBOX)
jss_test_java(
NAME "SSLClientAuth_FIPSMODE"
COMMAND "org.mozilla.jss.tests.SSLClientAuth" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}" "${JSS_TEST_PORT_CLIENTAUTH_FIPS}" "60"
DEPENDS "Enable_FipsMODE"
MODE "FIPS"
)
else()
jss_test_java(
NAME "SSLClientAuth_FIPSMODE"
COMMAND "org.mozilla.jss.tests.JSSProvider"
DEPENDS "Enable_FipsMODE"
MODE "FIPS"
)
endif()
jss_test_java(
NAME "HMAC_FIPSMODE"
COMMAND "org.mozilla.jss.tests.CrossHMACTest" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Enable_FipsMODE"
MODE "FIPS"
)
jss_test_java(
NAME "KeyWrapping_FIPSMODE"
COMMAND "org.mozilla.jss.tests.JCAKeyWrap" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Enable_FipsMODE"
MODE "FIPS"
)
jss_test_java(
NAME "Mozilla_JSS_JCA_Signature_FIPSMODE"
COMMAND "org.mozilla.jss.tests.JCASigTest" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Enable_FipsMODE"
MODE "FIPS"
)
jss_test_java(
NAME "JSS_Signature_test_FipsMODE"
COMMAND "org.mozilla.jss.tests.SigTest" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}"
DEPENDS "Enable_FipsMODE"
MODE "FIPS"
)
jss_test_java(
NAME "SSLEngine_RSA_FIPSMODE"
COMMAND "org.mozilla.jss.tests.TestSSLEngine" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}" "Client_RSA" "Server_RSA"
DEPENDS "Enable_FipsMODE" "SSLEngine_ECDSA"
MODE "FIPS"
)
jss_test_java(
NAME "SSLEngine_ECDSA_FIPSMODE"
COMMAND "org.mozilla.jss.tests.TestSSLEngine" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "${PASSWORD_FILE}" "Client_ECDSA" "Server_ECDSA"
DEPENDS "SSLEngine_RSA_FIPSMODE" "SSLEngine_ECDSA"
MODE "FIPS"
)
# Since we need to disable FIPS mode _after_ all FIPS-mode tests have
# run, we have to add a strict dependency from Disable_FipsMODE onto all
# FIPS-related checks.
jss_test_java(
NAME "Disable_FipsMODE"
COMMAND "org.mozilla.jss.tests.FipsTest" "${RESULTS_NSSDB_FIPS_OUTPUT_DIR}" "disable"
DEPENDS "check_FipsMODE" "SSLClientAuth_FIPSMODE" "HMAC_FIPSMODE" "KeyWrapping_FIPSMODE" "Mozilla_JSS_JCA_Signature_FIPSMODE" "JSS_Signature_test_FipsMODE" "SSLEngine_RSA_FIPSMODE" "SSLEngine_ECDSA_FIPSMODE"
MODE "NONE"
)
endif()
jss_test_java(
NAME "JUnit_GenericValueConverterTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.GenericValueConverterTest"
)
jss_test_java(
NAME "JUnit_IA5StringConverterTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.IA5StringConverterTest"
)
jss_test_java(
NAME "JUnit_PrintableConverterTest"
COMMAND "org.junit.runner.JUnitCore" "org.mozilla.jss.tests.PrintableConverterTest"
)
if(TEST_WITH_INTERNET)
jss_test_java(
NAME "BadSSL"
COMMAND "org.mozilla.jss.tests.BadSSL" "${RESULTS_NSSDB_INTERNET_OUTPUT_DIR}"
DEPENDS "Import_Internet_Certs"
MODE "INTERNET"
)
jss_test_java(
NAME "BadSSL_Leaf_And_Chain"
COMMAND "org.mozilla.jss.tests.BadSSL" "${RESULTS_NSSDB_INTERNET_OUTPUT_DIR}" "LEAF_AND_CHAIN"
DEPENDS "Import_Internet_Certs"
MODE "INTERNET"
)
endif()
# For compliance with several existing clients
add_custom_target(
check
DEPENDS test
)
endmacro()
macro(jss_tests_compile)
jss_tests_compile_c("${PROJECT_SOURCE_DIR}/src/test/java/org/mozilla/jss/tests/buffer_size_1.c" "${BIN_OUTPUT_DIR}/buffer_size_1" "buffer_size_1")
jss_tests_compile_c("${PROJECT_SOURCE_DIR}/src/test/java/org/mozilla/jss/tests/buffer_size_4.c" "${BIN_OUTPUT_DIR}/buffer_size_4" "buffer_size_4")
jss_tests_compile_c("${PROJECT_SOURCE_DIR}/src/test/java/org/mozilla/jss/tests/TestBufferPRFD.c" "${BIN_OUTPUT_DIR}/TestBufferPRFD" "TestBufferPRFD")
jss_tests_compile_c("${PROJECT_SOURCE_DIR}/src/test/java/org/mozilla/jss/tests/TestBufferPRFDSSL.c" "${BIN_OUTPUT_DIR}/TestBufferPRFDSSL" "TestBufferPRFDSSL")
endmacro()
macro(jss_tests_compile_c C_FILE C_OUTPUT C_TARGET)
# Generate the target executable from C_FILE
add_custom_command(
OUTPUT "${C_OUTPUT}"
COMMAND ${CMAKE_C_COMPILER} ${JSS_C_FLAGS} -o ${C_OUTPUT} ${C_FILE} -L${LIB_OUTPUT_DIR} -ljss ${JSS_LD_FLAGS}
WORKING_DIRECTORY ${C_DIR}
DEPENDS "${C_FILE}"
DEPENDS "${JSS_TESTS_SO_PATH}"
DEPENDS generate_java
DEPENDS generate_includes
)
add_custom_target(
"generate_c_${C_TARGET}"
DEPENDS "${C_OUTPUT}"
)
add_dependencies("generate_so" "generate_c_${C_TARGET}")
endmacro()
function(jss_test_java)
set(TEST_FLAGS "NAME")
set(TEST_ARGS "COMMAND" "DEPENDS" "MODE")
cmake_parse_arguments(TEST_JAVA "" "${TEST_FLAGS}" "${TEST_ARGS}" ${ARGN})
list(APPEND EXEC_COMMAND "${Java_JAVA_EXECUTABLE}")
list(APPEND EXEC_COMMAND "-classpath")
list(APPEND EXEC_COMMAND "${TEST_CLASSPATH}")
list(APPEND EXEC_COMMAND "-ea")
list(APPEND EXEC_COMMAND "-Djava.library.path=${CMAKE_BINARY_DIR}")
if(TEST_JAVA_MODE STREQUAL "FIPS")
list(APPEND EXEC_COMMAND "-Djava.security.properties=${CONFIG_OUTPUT_DIR}/fips.security")
elseif(TEST_JAVA_MODE STREQUAL "INTERNET")
list(APPEND EXEC_COMMAND "-Djava.security.properties=${CONFIG_OUTPUT_DIR}/internet.security")
elseif(NOT TEST_JAVA_MODE STREQUAL "NONE")
list(APPEND EXEC_COMMAND "-Djava.security.properties=${CONFIG_OUTPUT_DIR}/java.security")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND EXEC_COMMAND "-Djava.util.logging.config.file=${PROJECT_SOURCE_DIR}/tools/logging.properties")
endif()
set(EXEC_COMMAND "${EXEC_COMMAND};${TEST_JAVA_COMMAND}")
if(TEST_JAVA_DEPENDS)
jss_test_exec(
NAME "${TEST_JAVA_NAME}"
COMMAND "${EXEC_COMMAND}"
DEPENDS ${TEST_JAVA_DEPENDS}
LIBRARY "java"
)
else()
jss_test_exec(
NAME "${TEST_JAVA_NAME}"
COMMAND "${EXEC_COMMAND}"
LIBRARY "java"
)
endif()
endfunction()
macro(jss_test_exec)
# Usage:
#
# jss_test_exec(
# NAME TEST_NAME
# COMMAND TEST_COMMAND
# [DEPENDS [TEST_DEPENDS TEST_DEPENDS...]]
#
# Note that TEST_COMMAND can be a list by quoting the list:
#
# jss_test_exec("NAME" "ARG1" "ARG2" "...")
set(TEST_FLAGS "NAME" "LIBRARY")
set(TEST_ARGS "COMMAND" "DEPENDS")
cmake_parse_arguments(TEST_EXEC "" "${TEST_FLAGS}" "${TEST_ARGS}" ${ARGN})
if(TEST_VALGRIND)
list(INSERT TEST_EXEC_COMMAND 0 "valgrind" "--track-origins=yes" "--leak-check=full")
endif()
add_test(
NAME "${TEST_EXEC_NAME}"
COMMAND ${TEST_EXEC_COMMAND}
)
list(APPEND LD_LIBRARY ${NSS_LIBRARIES})
list(APPEND LD_LIBRARY ${NSPR_LIBRARIES})
# If we are calling a java program, use the versioned library to ensure
# that any new JNI calls are made visible.
if(TEST_EXEC_LIBRARY AND (TEST_EXEC_LIBRARY STREQUAL "java"))
list(APPEND LD_LIBRARY "${CMAKE_BINARY_DIR}")
list(REMOVE_DUPLICATES LD_LIBRARY)
jss_list_join(LD_LIBRARY ":" LD_LIBRARY_PATH)
set_tests_properties(
"${TEST_EXEC_NAME}"
PROPERTIES ENVIRONMENT
"LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
)
else()
list(APPEND LD_LIBRARY "${LIB_OUTPUT_DIR}")
list(REMOVE_DUPLICATES LD_LIBRARY)
jss_list_join(LD_LIBRARY ":" LD_LIBRARY_PATH)
set_tests_properties(
"${TEST_EXEC_NAME}"
PROPERTIES ENVIRONMENT
"LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
)
endif()
if(TEST_EXEC_DEPENDS)
set_tests_properties(
"${TEST_EXEC_NAME}"
PROPERTIES DEPENDS
"${TEST_EXEC_DEPENDS}"
)
endif()
endmacro()
jss-5.0.0/cmake/Shims.cmake 0000664 0000000 0000000 00000001024 14125500636 0015457 0 ustar 00root root 0000000 0000000 # LIST(JOIN ...) was introduced in CMake verison 3.12
macro(jss_list_join LIST_ SEPARATOR_ VAR_)
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
set("${VAR_}" "")
foreach(ELEMENT ${${LIST_}})
set("${VAR_}" "${${VAR_}}${SEPARATOR_}${ELEMENT}")
endforeach()
string(LENGTH "${SEPARATOR_}" JSS_LIST_JOIN_SEPARATOR_LENGTH)
string(SUBSTRING "${${VAR_}}" ${JSS_LIST_JOIN_SEPARATOR_LENGTH} -1 "${VAR_}")
else()
list(JOIN ${LIST_} ${SEPARATOR_} ${VAR_})
endif()
endmacro()
jss-5.0.0/docs/ 0000775 0000000 0000000 00000000000 14125500636 0013245 5 ustar 00root root 0000000 0000000 jss-5.0.0/docs/build_system.md 0000664 0000000 0000000 00000013072 14125500636 0016275 0 ustar 00root root 0000000 0000000 # Build System
This document describes the CMake build system and various locations used
by CMake.
## Overview
The new build system relies on CMake to build JSS. Most of the functionality
is located under the `cmake/` directory in the root of the project. JSS is
built in five stages:
1. Classes are built from Java source and JNI headers are generated. This is
done in a single pass of the `javac` compiler. All Java source files under
`src/main/java/` are currently compiled to the `build/classes/` folder.
2. Any C header files are moved to the `build/includes/` folder.
3. C source files are compiled to objects and linked to form `libjss.so`,
excluding any C source files in `src/test/java/`. If any exist,
they'll be compiled at a later stage for `ctest`. This step is dependent
on steps 1 and 2.
4. Build the JAR archive from compiled Java classes. Note that at this time,
all classes in `build/classes/` are compiled into one JAR; in the future,
a white list might be applied and testing classes separated out into a
different JAR. This is dependent on step 1.
5. (Optionally) build Javadocs. This requires the user to build the `javadoc`
target.
The test suite is also generated using CMake in `cmake/JSSTests.cmake`. This
allows JSS to run its test in parallel.
## `CMakeLists.txt`
This is a file required by CMake for all CMake projects; it defines how the
project is built. We use it as a high-level overview of CMake: options are
defined, environment variables are read, modules are imported, and JSS is
built and tested through here.
JSS uses a direct approach to building: as a single call to `javac` suffices
to build all of our classes and JNI headers, we don't need a recursive
structure to build. This lets us have only one `CMakeLists.txt` in the root
of our project.
## `cmake/`
This directory contains two sets of files: dependencies and core modules.
The non-standard CMake dependencies currently include the `FindNSPR` and
`FindNSS` modules: these allow CMake to find NSPR and NSS system libraries
and were imported from PKI. The core modules include `JSSConfig`, which
sets useful variables for use within CMake, `JSSCommon`, which controls
building JSS, and `JSSTests`, which sets up the JSS test suite within
CTest.
### Available CMake Options
Our CMake generator currently understands the following options when
configuring the build system. Each option can either be specified on the CMake
command line with `-D=` syntax, or in the environment.
- `CHECK_DEPRECATION` -- enable `-Xlint:deprecation` when compiling JSS to
check for use of deprecated APIs.
- `FIPS_ENABLED` -- disable certain test cases which are known to fail in
FIPS mode for various reasons. These usually include tests which try to
disable FIPS mode, use unsupported ciphers, or too small of key sizes.
Note that NSS must still be built with FIPS mode support enabled.
- `SANDBOX` -- support building sandboxed builds to test changes to NSPR or
NSS alongside changes to JSS. This assumes you have the following
directory structure:
```
sandbox/
sandbox/nspr
sandbox/nss
sandbox/dist
sandbox/jss
```
Note that `sandbox` can be replaced by any directory name. The
`sandbox/dist` folder is automatically created by NSS upon build.
Please first build NSS (according to current instructions) and then
build JSS.
- `TEST_VALGRIND` -- run the entire test suite under Valgrind. This option
is quite slow. By default it passes two arguments: `--track-origins=yes`
and `--leak-check=full`. Modify `cmake/JSSTests.cmake` (macro:
`jss_test_exec`) to change these options.
- `WITH_INTERNET` -- run tests which require an internet connection. This
exposes your system to other hosts on the internet, including badssl.com
and www.mozilla.org. Correct execution requires a working `common_roots.sh`
script under `tools/`; update for your system as necessary.
### Adding a Test Case
To add a new test case, add an entry to `cmake/JSSTests.cmake`. There's two
useful helpers macros `jss_test_exec` and `jss_test_java`.
`jss_test_exec` takes a `NAME` parameter (to use to identify the test case
in output and when running particular tests), a `COMMAND` to execute, and an
optional set of dependencies (`DEPENDS ...`) on other tests. We use this
because `add_test` doesn't itself handle dependencies or set environment
variables (we need to inject `LD_LIBRARY_PATH` to handle testing our built
`libjss.so`).
`jss_test_java` is a wrapper over `jss_test_exec` which handles setting up
the JVM and passing required arguments to it (`-classpath`, `-enableasserts`,
etc.). Pass only the class you wish to execute and any arguments to it as
the COMMAND field. (e.g., `COMMAND "org.mozilla.jss.tests.TestBuffer"`).
There are a few useful variables defined:
- `JSS_TEST_DIR` -- directory to the souce code where the tests are
contained.
- `PASSWORD_FILE` -- password for the NSS DB tokens.
- `DB_PWD` -- password for the NSS DB internal (default) token.
- `RESULTS_DATA_OUTPUT_DIR` -- directory to write test results to.
- `RESULTS_NSSDB_OUTPUT_DIR` -- path of the non-FIPS NSS DB.
- `RESULTS_NSSDB_FIPS_OUTPUT_DIR` -- path of the FIPS NSS DB.
Note that, on a FIPS-enabled machine, `RESULTS_NSSDB_FIPS_OUTPUT_DIR` is
unused and `RESULTS_NSSDB_OUTPUT_DIR` is actually placed in FIPS mode.
For tests which would fail in FIPS mode, place them in the
`if(NOT FIPS_ENABLED)` block.
## `lib/`
This includes a few templated files including `jss.map`, the linker script
which contains a versioned API of JSS, and `MANIFEST.MF.in`, JSS's Jar
manifest file.
jss-5.0.0/docs/building.md 0000664 0000000 0000000 00000004751 14125500636 0015373 0 ustar 00root root 0000000 0000000 # Building JSS
As of version 4.5.1, JSS has moved to a CMake build system. This is a modern
alternative to our legacy build system and gives us a standard framework for
building and testing JSS. This also allows us to support parallel builds
and tests; to take advantage of this, specify the `-j` flag when using
`make` or `ctest`.
Please make sure the required dependencies are installed prior to building
(see: [`docs/dependencies`](dependencies.md)).
## In-Source Build
To build JSS from the source release, use `cmake`; JSS behaves much like
a regular CMake project.
### Building JSS
To build JSS using CMake:
cd jss/build
cmake ..
make all
To later rebuild from scratch, remove the build directory and recreate it.
This ensures that any new dependencies are reflected in the build system.
cd jss
rm -rf build && mkdir build && cd build
cmake ..
make all
### Building Documentation
Optionally, build the javadocs:
cd jss/build
make javadoc
### Testing
To run the test suite:
cd jss/build
make test
Note that the test suite currently doesn't handling re-running without
clearing the results directory. To re-run the test suite:
cd jss/build
rm -rf results
mkdir -p results/tests results/fips
make test
Alternatively, use CTest to run the test suite:
ctest --output-on-failure
Helpful flags for ctest are `--verbose` and `--output-log`; for more
information, read `man ctest`.
### Installation
To install JSS, place `jss.jar` and `libjss.so` in places where the system
can find them. We recommend the following locations on a 64-bit system:
cd jss/build
sudo cp jss.jar /usr/lib/java/jss.jar
sudo chown root:root /usr/lib/java/jss.jar
sudo chmod 644 /usr/lib/java/jss.jar
sudo cp libjss.so /usr/lib64/jss/libjss.so
sudo chown root:root /usr/lib64/jss/libjss.so
sudo chmod 755 /usr/lib64/jss/libjss.so
To uninstall, simply remove the created files (`/usr/lib/java/jss.jar` and
`/usr/lib64/jss/libjss.so`).
Note that the preferred way to install JSS is from your distribution or via
an RPM built with `build.sh`.
## RPM Builds
To build a RPM release, please ensure all dependencies are installed:
sudo dnf install rpm-build
cd jss && sudo dnf builddep --spec jss.spec
Then, issue a build using the `build.sh` interface:
./build.sh rpm
This will build RPMS and place them in `$HOME/build/jss` by default. For more
information about this build script, refer to its help text:
./build.sh --help
jss-5.0.0/docs/changes/ 0000775 0000000 0000000 00000000000 14125500636 0014655 5 ustar 00root root 0000000 0000000 jss-5.0.0/docs/changes/v5.0.0/ 0000775 0000000 0000000 00000000000 14125500636 0015503 5 ustar 00root root 0000000 0000000 jss-5.0.0/docs/changes/v5.0.0/API-Changes.adoc 0000664 0000000 0000000 00000001220 14125500636 0020305 0 ustar 00root root 0000000 0000000 = API Changes =
== Changes in org.mozilla.jss.netscape.security.x509.CertAndKeyGen ==
* The `getSelfCert()` has been deprecated in JSS 4 and dropped in JSS 5. Use `getSelfCertificate()` instead.
* The `setRandom()` has been deprecated in JSS 4 and dropped in JSS 5. It is no longer used.
== Changes in org.mozilla.jss.netscape.security.x509.X509Cert ==
The class has been deprecated in JSS 4 and dropped in JSS 5. Use `java.security.cert.Certificate` instead.
== Changes in org.mozilla.jss.netscape.security.x509.RevocationReasonAdapter ==
The class has been deprecated in JSS 4 and dropped in JSS 5. Use the revocation reason code or label instead.
jss-5.0.0/docs/ci.md 0000664 0000000 0000000 00000002220 14125500636 0014156 0 ustar 00root root 0000000 0000000 # Containers and Continuous Integration
JSS uses [Travis CI](https://travis-ci.org/dogtagpki/jss) for PR gating. We use
Linux containers to ensure a consistent build environment and to allow us
to test locally and in Travis on various platforms.
## Running CI Locally
The Docker images are built in Travis using the Dockerfiles in
`tools/Dockerfiles`; they are not pushed to DockerHub or similar platforms
at this time. To test locally, we recommend using the provided container
tool, `tools/run_container.sh`.
For a brief example:
```bash
cd /path/to/sandbox/jss
./tools/run_container.sh fedora_28
```
Note that this requires either Buildah and Podman or Docker to be installed.
For more extensive documentation, please refer to the
[Buildah](https://github.com/containers/buildah/blob/master/docs/) and
[Podman docs](https://github.com/containers/libpod/tree/master/docs) and
the code in the `tools/run_container.sh` script.
## Skipping CI
To skip running CI for a given commit (e.g., for updating documentation),
append `[skip ci]` to the commit summary. Note that the `ubuntu_jdk8` image
does not affect build status; it is included for reference only.
jss-5.0.0/docs/contributing.md 0000664 0000000 0000000 00000005123 14125500636 0016277 0 ustar 00root root 0000000 0000000 # Contributing to JSS
We welcome all contributions to JSS and thank you in advance for them! Below
are a few ways of contributing to JSS.
## Filing a Downstream Issue
If you're using JSS as shipped by a distribution, we recommend filing an issue
downstream first. In the case of a [RHCS](https://www.redhat.com/en/technologies/cloud-computing/certificate-system),
[RHEL](https://www.redhat.com/en/technologies/cloud-computing/certificate-system),
or [Fedora](https://getfedora.org/) release, the correct bugtracker is the
[Red Hat Bugzilla](https://bugzilla.redhat.com/) instance.
If you don't hear a response at the appropriate downstream tracker or if you
think the issue exists upstream as well, feel free to file an upstream issue.
## Filing an Upstream Issue
JSS's issue tracker can be found on
[GitHub](https://github.com/dogtagpki/jss/issues) under the
[Dogtag PKI organization](https://github.com/dogtagpki).
Note that this requires a GitHub account to create bugs.
### Legacy Issue Trackers
In the past, JSS has used the following issue trackers. Unfortunately, we
cannot monitor them and we were not able to migrate all issues to the new
sites.
- [Pagure](https://pagure.io/jss/issues)
- [Mozilla's Bugzilla instance](https://bugzilla.mozilla.org/buglist.cgi?classification=Components&list_id=15438920&query_format=advanced&product=JSS&component=Documentation&component=Library&component=Sample%20Code&component=Tests&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&resolution=---)
## Opening a Pull Request
If you'd like to contribute code to JSS, feel free to open a pull request
against JSS. We'd recommend filing an issue (see above) if you'd like to
introduce major change to JSS. This gives us a place to discuss the changes
before they are proposed.
Please fork the repository and make your changes in a new branch; before
proposing the pull request, rebase your branch against upstream master.
To test JSS locally, follow the [build instructions](building.md).
Additionally, it is possible to run the CI container instances locally;
follow directions in the [CI Overview](ci.md). We'd suggest making
sure a Fedora build passes (e.g., `fedora_28`) and the `stylecheck`
image passes as well. Then, feel free to open a PR.
If you're looking for more information, we suggest reading about the
[GitHub Flow](https://guides.github.com/introduction/flow/index.html)
and reaching out to the developers if you need any assistance.
## Contacting Us
See [Contact Us](https://github.com/dogtagpki/pki/wiki/Contact-Us).
Thanks!
jss-5.0.0/docs/dependencies.md 0000664 0000000 0000000 00000004344 14125500636 0016222 0 ustar 00root root 0000000 0000000 # Dependencies
## Build-time Dependencies
This project has the following dependencies:
- [NSPR](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR)
- [NSS](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS)
- A c and c++ compiler such as [gcc](ttps://gcc.gnu.org/)
- [zlib](https://zlib.net/)
- [OpenJDK 1.8.0 or newer](http://openjdk.java.net/)
- [CMake](https://cmake.org/)
- [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/)
- [SLF4J](https://www.slf4j.org/)
Additionally, a zipping and unzipping program is required to create
reproducible builds.
To install these dependencies on Fedora, execute the following:
sudo dnf install apache-commons-lang gcc-c++ java-devel jpackage-utils \
slf4j zlib-devel nss-tools nss-devel \
cmake junit
To install these dependencies on Debian, execute the following:
sudo apt-get install build-essential libcommons-lang-java libnss3-dev \
libslf4j-java default-jdk pkg-config zlib1g-dev \
libnss3-tools cmake zip unzip \
junit4
## Test Suite Dependencies:
In addition to the dependencies above, the test suite requires the following
additional packages:
- [SLF4J's JDK14 package](https://www.slf4j.org/api/org/slf4j/impl/JDK14LoggerAdapter.html)
- [NSS's pk12util](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Reference/NSS_tools_:_pk12util)
- [JUnit 4](https://junit.org/junit4/)
To install these dependencies on Fedora, execute the following:
sudo dnf install nss nss-tools slf4j-jdk14 junit
To install these dependencies on Debian, execute the following:
sudo apt-get install libnss3 libnss3-tools libslf4j-java \
junit4
## Run-time Dependencies
At run time, the following JARs are required to be specified on the
`CLASSPATH` of anyone wishing to use JSS:
- `jss.jar`
- `slf4j-api.jar`
- `apache-commons-lang.jar`
Note that these should already be installed when building JSS. For more
information, please refer to our documentation on using JSS:
[`docs/using_jss.md`](using_jss.md).
## Incompatibilities
Known NSS incompatibilities are documented in [`docs/nss.md`](nss.md).
jss-5.0.0/docs/development/ 0000775 0000000 0000000 00000000000 14125500636 0015567 5 ustar 00root root 0000000 0000000 jss-5.0.0/docs/development/Synchronizing-GitLab-Branch.adoc 0000664 0000000 0000000 00000003366 14125500636 0023626 0 ustar 00root root 0000000 0000000 = Synchronizing GitLab Branch =
== Overview ==
This page describes the procedure to synchronize a branch from an upstream repository
to a GitLab repository.
== Creating Access Token ==
In the GitLab repository create a project access token with a **write_repository** permission.
See link:https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#creating-a-project-access-token[Creating a project access token].
== Configuring Synchronization ==
In the GitLab repository create the following variables:
* `UPSTREAM_URL`: The URL of the upstream repository.
** Unselect **Protect variable** to synchronize unprotected branches.
* `ACCESS_TOKEN`: The value of the access token.
** Unselect **Protect variable** to synchronize unprotected branches.
** Select **Mask variable** to keep the access token hidden.
See link:https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project[Add a CI/CD variable to a project].
== Running Synchronization Manually ==
In the GitLab repository run a pipeline with the following parameters:
* **Run for branch name or tag**: The branch to be synchronized.
* **Variables**:
** `SYNC`: `true`
See link:https://docs.gitlab.com/ee/ci/pipelines/#run-a-pipeline-manually[Run a pipeline manually].
== Scheduling Automatic Synchronization ==
In the GitLab repository create a schedule with the following parameters:
* **Interval Pattern**: The frequency of synchronization.
** To synchronize every hour, enter: `0 * * * *`
* **Target Branch**: The branch to be synchronized.
* **Variables**:
** `SYNC`: `true`
Additional schedules can be created for synchronizing other branches.
See link:https://docs.gitlab.com/ee/ci/pipelines/schedules.html#configuring-pipeline-schedules[Configuring pipeline schedules].
jss-5.0.0/docs/gh_pages.md 0000664 0000000 0000000 00000002175 14125500636 0015351 0 ustar 00root root 0000000 0000000 # GitHub Pages
JSS uses the GitHub pages functionality to host our generated javadocs. This
allows developers to browse our documentation online without pulling down
the JSS sources.
Periodically, this documentation will need to be updated and will mirror the
latest contents of master. To do so:
1. Checkout the master branch and make sure it is up to date with `upstream`:
```
cd sandbox/jss
git remote add upstream https://github.com/dogtagpki/jss
git fetch --all
git checkout upstream/master
```
2. Build the javadocs; note that they are placed in `../dist/jssdocs`:
```
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0_openjdk
export USE_64=1
make javadoc
```
3. Copy the new-docs into the gh-pages branch:
```
git clean -xdf && git checkout gh-pages
rm -rf javadoc && cp ../dist/jssdoc javadoc -rv
git add javadoc && git commit -m "Update javadocs from master at $(date '+%Y-%m-%d %H:%M')" && git push origin gh-pages
```
4. Open a PR against `dogtagpki/jss` with the updates. This will
get reviewed, merged, and then automatically propagated to
GitHub Pages.
jss-5.0.0/docs/legacy_building.md 0000664 0000000 0000000 00000015076 14125500636 0016721 0 ustar 00root root 0000000 0000000 # Legacy Build Instructions
These instructions have been preserved from the README; if you are referring
to specific parts of the build instructions, they have been moved here.
Build/Test Instructions
-----------------------
### 1. Prepare a work area
(a) For upstream builds which checkout and utilize
the current NSPR and NSS source repositories:
```
# mkdir sandbox
# cd sandbox
# hg clone https://hg.mozilla.org/projects/nspr
# hg clone https://hg.mozilla.org/projects/nss
# git clone git@github.com:dogtagpki/jss.git
# cd ..
```
There is no need to clone every time. For additional builds,
simply use:
```
# cd nspr
# hg pull -u -v
# cd ..
# cd nss
# hg pull -u -v
# cd ..
# cd jss
# git pull -v
# cd ..
````
(b) Alternatively, for upstream builds which use
the NSPR and NSS installed on the system:
```
# mkdir sandbox
# cd sandbox
# export USE_INSTALLED_NSPR=1
# export USE_INSTALLED_NSS=1
# export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
# export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
# export NSPR_INCLUDE_DIR=`/usr/bin/pkg-config --cflags-only-I nspr | sed 's/-I//'`
# export NSPR_LIB_DIR=`/usr/bin/pkg-config --libs-only-L nspr | sed 's/-L//'`
# export NSS_INCLUDE_DIR=`/usr/bin/pkg-config --cflags-only-I nss | sed 's/-I//'`
# export NSS_LIB_DIR=`/usr/bin/pkg-config --libs-only-L nss | sed 's/-L//'`
# export XCFLAGS="-g"
# git clone https://hg.mozilla.org/projects/jss
# cd ..
```
There is no need to clone every time. For additional builds,
simply use:
```
# cd jss
# git pull -v
# cd ..
```
### 2. Prepare an interactive shell for building
```
# export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0_openjdk
# export USE_64=1
```
NOTE: JSS will now attempt to verify whether or not these two
environment variables have been set (JAVA_HOME is mandatory;
USE_64 is mandatory on 64-bit platforms when building 64-bit).
The following steps are optional, and left to the discretion of the user:
#### Normal vs. Optimized builds
By default, JSS will be built as a normal binaries.
To create an optimized build, set the following
environment variable:
```
# export BUILD_OPT=1
```
#### Beta vs. Non-Beta builds
Finally, by default, JSS is not built as a "beta" release (as
specified in 'org/mozilla/jss/util/jssver.h'):
```
#define JSS_BETA PR_FALSE
```
If a "beta" version of JSS is desired, reset this #define (as
specified in 'org/mozilla/jss/util/jssver.h') to:
```
#define JSS_BETA PR_TRUE
```
### 3. Build JSS
To build JSS, execute the following commands:
```
# cd sandbox/jss
# make clean all
# cd ../..
```
or you can run:
```
# script -c 'make clean all' typescript.build
```
NOTE: When build method (1)(a) is being utilized, if nss has not been
built, it will now automatically be built before jss; if nss has
already been built, only jss will be built/re-built.
### 4. Install JSS on the System (Optional)
If JSS already exists on the system, run something similar to the
following command(s):
```
# sudo mv /usr/lib/java/jss.jar /usr/lib/java/jss.jar.orig
```
If the platform is 32-bit Linux:
```
# sudo mv /usr/lib/jss/libjss.so /usr/lib/jss/libjss.so.orig
```
else if the platform is 64-bit Linux:
```
# sudo mv /usr/lib64/jss/libjss.so /usr/lib64/jss/libjss.so.orig
```
Then install the new JSS binaries:
```
# sudo cp sandbox/dist/xpclass.jar /usr/lib/java/jss.jar
# sudo chown root:root /usr/lib/java/jss.jar
# sudo chmod 644 /usr/lib/java/jss.jar
# sudo cp sandbox/jss/lib/Linux*.OBJ/libjss.so /usr/lib64/jss/libjss.so
# sudo chown root:root /usr/lib64/jss/libjss.so
# sudo chmod 755 /usr/lib64/jss/libjss.so
```
### 5. Run JSS Tests (Optional, but only if build method (1)(a) was utilized)
If build method (1)(a) is being utilized, it is possible to run the built-in JSS tests:
```
# cd sandbox/jss
# make test_jss
# cd ../..
```
or you can run:
```
# script -c 'make test_jss' typescript.tests
```
NOTE: This command is currently only available on Linux and Macintosh
platforms when method (1)(a) has been utilized to build JSS
since the tests are dependent upon the work area as setup in
this method; currently JSS must be built via 'make clean all' before
execution of this command (e.g. - build is separate from test).
### 6. Restoration of non-Test-Only Systems (Optional)
If step (4) above was run, and the system is being used for purposes
other than test, the user may wish to restore the original system JSS
by running the following commands:
```
# sudo mv /usr/lib/java/jss.jar.orig /usr/lib/java/jss.jar
```
If the platform is 32-bit Linux:
```
# sudo mv /usr/lib/jss/libjss.so.orig /usr/lib/jss/libjss.so
```
else if the platform is 64-bit Linux:
```
# sudo mv /usr/lib64/jss/libjss.so.orig /usr/lib64/jss/libjss.so
```
NOTE: For this procedure, no ownership or permission changes should
be necessary.
### 7. Tagging the Source Code for a Release
During development, several releases may be made. Consequently, it is
good practice to create a "regular tag" to the source code at these
various points in time using the following format:
```
# git tag -m "message" JSS___
```
where:
* major = JSS Major Version Number
* minor = JSS Minor Version Number
* YYYY = 4-digit year (e. g. - 2017)
* MM = 2-digit month (e. g. - 01, ..., 12)
* DD = 2-digit day of the month (e. g. - 01, ..., 31)
For example:
```
# git rev-parse HEAD
b3e864205ff0...
# git tag -m "Added tag JSS_4_4_20170328 for changeset b3e864205ff0" JSS_4_4_20170328
```
At the appropriate time, a new major.minor version may be created. At this
time, it is important to create a maintenance branch for any future changes
to the previous major.minor version:
For example:
```
# git rev-parse HEAD
f00f00f00f00...
# git checkout -b JSS_4_4_BRANCH
```
### 8. Known Issues
Some of the known issues are:
* Mozilla Bug #1346410 - Load JSS libraries appropriately
NOTE: This issue should not occur unless step (4) above was skipped.
Testing failures were found while working on Bug 1346410 when loading the
JSS libraries to meet requirements of certain operating systems. Our
investigation revealed that due to the nature of the changes made via this
patch and its interaction with the HMAC Tests (both non-FIPS and FIPS),
that a failure may be encountered on one or more of the HMAC algorithms
causing these two tests to fail. On 64-bit Linux, for example, the
workaround for this issue is to perform the following steps before
re-running the tests:
* Install the new JSS builds by executing step (4) above
* Execute the following commands:
```
# cd sandbox/jss
# make test_jss
```
NOTE: If the system is being used for purposes other than test, the user
may wish to restore the original JSS by executing step (6) above.
jss-5.0.0/docs/nss.md 0000664 0000000 0000000 00000002041 14125500636 0014367 0 ustar 00root root 0000000 0000000 # NSS
## Incompatible NSS/JSS Pairings
The minimum NSS version required by JSS is v3.44. Up to v3.44, NSS didn't
correctly support SECKEY_ConvertToPublicKey, returning NULL in some cases
with an EC private key. This was fixed in v3.44.
### JSS v4.6.3
JSS v4.6.3 doesn't support NSS versions between v3.47 and v3.50, inclusive.
This is because [moz-bz#1570501][moz-bz-1570501] introduced a bug that wasn't
caught and fixed until [moz-bz#1611209][moz-bz-1611209]. NSS versions v3.46
and earlier will work but lack CMAC and KBKDF support, and NSS versions v3.51
and later will work and have CMAC and KBKDF support.
JSS v4.6.4 introduces a check for working CMAC support (see the
[pull request][pr-425] or commit 16c8de46bb8f03a9e6e3489e751114655a31f9bf).
[moz-bz-1570501]: https://bugzilla.mozilla.org/show_bug.cgi?id=1570501 "Add CMAC to FreeBL and PKCS #11 libraries"
[moz-bz-1611209]: https://bugzilla.mozilla.org/show_bug.cgi?id=1611209 "Value of CKM_AES_CMAC and CKM_AES_CMAC_GENERAL are swapped"
[pr-425]: https://github.com/dogtagpki/jss/pull/425
jss-5.0.0/docs/pkcs11_constants.md 0000664 0000000 0000000 00000012404 14125500636 0016766 0 ustar 00root root 0000000 0000000 # PKCS11Constants
As of release 4.5.1, JSS now ships with a set of constants that enable JSS to
work on JDK versions greater than 8. In particular, JDK 9+ introduced the
concepts of Modules to Java, allowing previously exported classes to be
restricted. This resulted in the complete removal of all `sun.*` classes;
previously, these internal implementation details were exposed by the JDK.
These changes are documented more at the following locations:
- https://www.oracle.com/technetwork/java/faq-sun-packages-142232.html
- https://www.oracle.com/corporate/features/understanding-java-9-modules.html
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=875589
- https://wiki.debian.org/Java/Java9Pitfalls
As a replacement, we built a utility to convert NSS's header files (`pkcs11t.h`
and `pkcs11n.h`) to Java. The following sections describe this system.
## Regenerating PKCS11Constants.java
There are a few cases where updating PKCS11Constants.java is necessary:
- If NSS updates either of the two header files.
- If certain constants need to be excluded.
- If new constants need to be included.
In the former case, the CI job or container build of `pkcs11checks` will
fail, notifying us that this will need to be updated.
To do so, first make sure the system's NSS is up to date:
dnf update --refresh
dnf install nss-dev
Then, validate the location of the NSS header files; on Fedora, this location
is `/usr/include/nss3`:
ls /usr/include/nss3/pkcs11{t,n}.h
Lastly, run the utility:
python3 ./tools/build_pkcs11_constants.py --system \
--pkcs11t /usr/include/nss3/pkcs11t.h \
--pkcs11n /usr/include/nss3/pkcs11n.h \
--output src/main/java/org/mozilla/jss/pkcs11/PKCS11Constants.java
While not required, it is suggested to use the `--system` flag to ensure
the values of `PKCS11Constants.java` are the same as the installed NSS
values.
After this, rebuild JSS and run the test suite on a JDK8 machine:
source ./tools/autoenv.sh
cd build && cmake .. && make clean all check
This will trigger the interoperability tests against the Sun values.
## `tools/build_pkcs11_constants.py`
This utility generates the `PKCS11Constants.java` from the contents of the
NSS header files. It has the following flags:
-h / --help :: display the help text associated with the script
--pkcs11t :: path to the pkcs11t.h header file from a NSS
distribution; this header file contains the
general PKCS11 constants
--pkcs11n :: path to the pkcs11n.h header file from a NSS
distribution; this header file contains NSS
and Netscape-specific PKCS11 Constants
-o / --output :: path to output the generated Java file to
-s / --system :: assume the provided headers are from the system-installed
NSS; perform extended sanity checks by compiling the
parsed values and checking them against the NSS values
-v / --verbose :: generate extended debug information in the form of
comments in the generated file; this includes information
about parsing, resolution, and if applicable, the output
of the system checks
The code of this program is heavily documented and is roughly organized
from more specific methods to more general methods (e.g., `main`). A few
things are of particular note:
- This program attempts to verify correctness by ensuring that the internal
representation of a constant is as a Python `int`; this ensures that we
correctly parsed the value token and that, when we write the output,
the value doesn't depend on any other constants.
- This program treats all `#define`-d constants as if they were of a numeric
type, with all values being written as hex encoded longs.
- This program preserves the original ordering of constants, with constants in
`pkcs11t.h` appearing before constants in `pkcs11n.h`.
- This program currently parses only parenthesis in a token's value, but not
curly braces or square braces; the latter two shouldn't be present in most
numeric types. Any failure to parse as a numeric type is a parse error which
fails the script.
For more information about this script, please refer to the comments therein.
## Java Test
Included in the test suite when run on a JDK8 machine is a test called
[`TestPKCS11Constants`](../src/test/java/org/mozilla/jss/tests/TestPKCS11Constants.java).
This uses reflection to compare the values of the PKCS11Constants.java
provided by JSS and the version provided by Sun, reporting constants in
four categories:
1. Those which are "OK", i.e., present in both Sun and JSS with the same
value.
2. Those which are "JSS only", i.e., the constant name does not exist in
the Sun distribution. These are not treated as errors.
3. Those which are "Sun only", i.e., the constant name does not exist in
the JSS distribution. These are not treated as errors.
4. Those which are "not OK", i.e., present in both Sun and JSS but with
different values associated to them. This is not an error.
Information about all constants is written to stdout during testing; please
manually review the "JSS only" and "Sun only" cases to see if any results
are unexpected.
jss-5.0.0/docs/repo_archive.md 0000664 0000000 0000000 00000001607 14125500636 0016241 0 ustar 00root root 0000000 0000000 # JSS Archive
At the time of migration to GitHub, JSS had collected a significant number of
branches. Because these branches may be of historical importance, it has been
decided to archive them in a separate repository. This allows us to prune the
main repository while persisting this information. For more information on
this decision, please refer to the [RFC](https://pagure.io/jss/issue/25).
To view the JSS archive, navigate to the
[`jss-archive`](https://github.com/dogtagpki/jss-archive) repository. Because
this repository has the same commits as the `jss` repository, it is possible
to use both together:
```
cd /path/to/jss
git remote add jss-archive https://github.com/dogtagpki/jss-archive
git fetch jss-archive
```
At this point, all prior branches and tags will be synchronized with your
current repository. To checkout a retired branch:
```
git checkout jss-archive/BRANCH_NAME
```
jss-5.0.0/docs/usage/ 0000775 0000000 0000000 00000000000 14125500636 0014351 5 ustar 00root root 0000000 0000000 jss-5.0.0/docs/usage/benchmarksslsocket.md 0000664 0000000 0000000 00000015625 14125500636 0020571 0 ustar 00root root 0000000 0000000 # Usage
This benchmark is a server-side SSLSocket benchmark for use with clients
which measure performance. This benchmark does not, itself, make any
performance measurements. For instance:
```bash
$ ./run_test.sh org.mozilla.jss.tests.BenchmarkSSLSocket JSS.legacy Server_RSA 8443 1024 &
$ siege -c 100 -b -t 5m https://localhost:8443
$ kill %1
```
There are three supported SSLSocket implementations:
1. `org.mozilla.jss.ssl.SSLSocket`, JSS's legacy implementation
name: `JSS.legacy`
2. `org.mozilla.jss.ssl.javax.JSSSocket`, JSS's new javax implementation
name: `JSS.SSLSocket`
3. `sun.security`'s `SSLSocketImpl` from the current JDK.
name: `SunJSSE.SSLSocket`
It is suggested to disable all logging (for instance, via:
`truncate -s 0 tools/logging.properties`) in order have reproducible
results.
This class takes four arguments when invoked:
1. The name of the implementation to benchmark, see above.
2. An alias of the certificate or path to a PKCS#12 file. Only SunJSSE
accepts a PKCS#12 as path -- the two JSS based SSLSocket
implementations will utilize a nickname instead.
3. The port to listen on.
4. The size of the HTTP message to fake.
Note that, when utilizing a JSS provider, JSS must be loaded via a
java.security. When utilizing SunJSSE, for best results, do not load
JSS via java.security.
It is suggested to use `run_test.sh` from the `build/` directory for
executing this utility.
# Past Performance
## `JSSEngineReferenceImpl`
These are the results from siege [0] as run via:
```bash
$ siege -c 100 -b -t 5m https://localhost:8443
```
with the benchmarker set to send a faked 1024-byte message:
```bash
$ ./run_test.sh org.mozilla.jss.tests.BenchmarkSSLSocket JSS.legacy Server_RSA 8443 1024
```
The server certificate is 4096-bits. The selection of cipher suite and
protocol is left at their defaults. This is on a Lenovo Thinkpad P50
with an `Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz` processor and 32GB of RAM.
Each request gets spun off and handled by a new thread.
Using the legacy `org.mozilla.jss.ssl.SSLSocket` (old NSS-based socket)
memory stays stable and under ~1-2% of total memory:
```json
{
"transactions": 98588,
"availability": 100.00,
"elapsed_time": 299.43,
"data_transferred": 96.28,
"response_time": 0.30,
"transaction_rate": 329.25,
"throughput": 0.32,
"concurrency": 99.80,
"successful_transactions": 98588,
"failed_transactions": 0,
"longest_transaction": 29.94,
"shortest_transaction": 0.04
}
```
Using `javax.net.ssl.SSLSocket` provided by SunJSSE (but with JSS crypto
and potentially random) and stays under 1-2% of total memory:
```json
{
"transactions": 2417,
"availability": 100.00,
"elapsed_time": 299.36,
"data_transferred": 2.36,
"response_time": 12.12,
"transaction_rate": 8.07,
"throughput": 0.01,
"concurrency": 97.82,
"successful_transactions": 2417,
"failed_transactions": 0,
"longest_transaction": 21.27,
"shortest_transaction": 1.63
}
```
**Note** that the above option was removed from the benchmark utility as it
was significantly slower.
Using `javax.net.ssl.SSLSocket` provided by SunJSSE (without JSS crypto,
via exporting to PKCS12 file) and stays under 8% of total memory:
```json
{
"transactions": 93168,
"availability": 100.00,
"elapsed_time": 299.92,
"data_transferred": 90.98,
"response_time": 0.32,
"transaction_rate": 310.64,
"throughput": 0.30,
"concurrency": 99.51,
"successful_transactions": 93168,
"failed_transactions": 2,
"longest_transaction": 15.81,
"shortest_transaction": 0.02
}
```
And `javax.net.ssl.SSLSocket` provided by Mozilla-JSS, backed by our slow
JSSEngine (proposed for 8.3) -- memory grows to ~35% of total, which suggests
there's also at least one memory leak still...
```json
{
"transactions": 87768,
"availability": 100.00,
"elapsed_time": 299.08,
"data_transferred": 85.71,
"response_time": 0.34,
"transaction_rate": 293.46,
"throughput": 0.29,
"concurrency": 99.60,
"successful_transactions": 87768,
"failed_transactions": 1,
"longest_transaction": 16.05,
"shortest_transaction": 0.08
}
```
Prior to jss-pr#553 (commit 1bd646a45613d16f18f28c641381f680ba1df319), the
performance of Mozilla-JSS's `SSLSocket` was similar to
`javax.net.ssl.SSLSoket` using `Mozilla-JSS` for primitives:
```json
{
"transactions": 1551,
"availability": 85.98,
"elapsed_time": 299.53,
"data_transferred": 1.51,
"response_time": 13.02,
"transaction_rate": 5.18,
"throughput": 0.01,
"concurrency": 67.42,
"successful_transactions": 1551,
"failed_transactions": 253,
"longest_transaction": 78.01,
"shortest_transaction": 0.50
}
```
And for comparison, `nginx-1.18.0-1.fc32.x86_64`, using the same cert from
above (admittedly, it uses OpenSSL and an `epoll` framework) and same `siege`
output:
```json
{
"transactions": 214725,
"availability": 100.00,
"elapsed_time": 299.05,
"data_transferred": 209.90,
"response_time": 0.14,
"transaction_rate": 718.02,
"throughput": 0.70,
"concurrency": 99.40,
"successful_transactions": 214725,
"failed_transactions": 0,
"longest_transaction": 0.37,
"shortest_transaction": 0.07
}
```
jss-5.0.0/docs/usage/capabilities_list.md 0000664 0000000 0000000 00000005226 14125500636 0020364 0 ustar 00root root 0000000 0000000 CapabilitiesList
========================================
Overview
========================================
**CapabilitiesList** is a Java application to list the capabilities
of the "Mozilla-JSS" provider and other installed providers.
It does it in two fashions brief and verbose.
It lets JSS contributors see what features the JDK implements (at different versions)
and see what else we'd need to add in, to reach compatibility. Since we're
attempting to be a default crypto provider, it would be nice to ensure we're
mostly close to what the JDK provides. Hopefully other packages written to the
JDK provider can have similar algorithms available under JSS and behave well.
Large gaps in coverage are likely an issue such as [#341](https://github.com/dogtagpki/jss/issues/341)
and [#242](https://github.com/dogtagpki/jss/issues/242).
Usage
========================================
First build jss according to the instructions
here [README](../../README.md)
You should see in the build directory tests_jss.jar which is what
contains the application along with the regular tests.
From the `jss/build` directory execute
./run_test.sh org.mozilla.jss.tests.CapabilitiesList
and you should see a `listings` directory
Running `tree listings` should produce something like
listings/
├── brief
│ ├── Capabilities4JdkSASL.txt
│ ├── Capabilities4Mozilla-JSS.txt
│ ├── Capabilities4SunJCE.txt
│ ├── Capabilities4SunJSSE.txt
│ ├── Capabilities4SunPKCS11.txt
│ ├── Capabilities4SunRsaSign.txt
│ └── Capabilities4SUN.txt
└── verbose
├── Capabilities4JdkSASL.txt
├── Capabilities4Mozilla-JSS.txt
├── Capabilities4SunJCE.txt
├── Capabilities4SunJSSE.txt
├── Capabilities4SunPKCS11.txt
├── Capabilities4SunRsaSign.txt
└── Capabilities4SUN.txt
Here is a brief clip of Capabilities4Mozilla-JSS.txt
AlgorithmParameters : IvAlgorithmParameters
AlgorithmParameters : RC2AlgorithmParameters
AlgorithmParameters : RSAPSSAlgorithmParameters
Cipher : AES
Cipher : DES
Cipher : DESede
Alias: Cipher.DES3
Cipher : RC2
Cipher : RC4
Cipher : RSA
KeyFactory : DSA
KeyFactory : EC
KeyFactory : RSA
KeyGenerator : AES
KeyGenerator : DES
KeyGenerator : DESede
Alias: KeyGenerator.DES3
KeyGenerator : HmacSHA1
... ommitted ...
KeyGenerator : HmacSHA512
KeyGenerator : KbkdfCounter
Alias: KeyGenerator.SP800-108-Counter
... ommitted ...
Notice that the `Alias:` lines have extra indentation which makes it
easier to compare against the other providers.
jss-5.0.0/docs/usage/cryptomanager.md 0000664 0000000 0000000 00000016076 14125500636 0017560 0 ustar 00root root 0000000 0000000 # `CryptoManager`
## Design
### `CryptoManager`, `JSSProvider`, and `JSSLoader` interactions
`CryptoManager` is the central singleton of JSS. It controls access to the
NSS database and an instance (available to developers via the
`CryptoManager.getInstance()` call) signals that both JSS and NSS are properly
initialized. The existing relationship between `CryptoManager` and
`JSSProvider` is that a single `CryptoManager` instance has a single
`JSSProvider` instance, and moreso that the reverse is also true: the
`JSSProvider` instance has a single `CryptoManager` instance. Currently the
code assumes that there is only ever one `CryptoManager` instance, making
both singletons.
_Aside:_
> Future work could be done to enable either multiple `CryptoManager` instances
> with separate NSS DBs, or to enable multiple `JSSProvider` instances to
> reference one or more `CryptoManager` instances during normal operation.
> This currently will require significant restructuring as many internal
> provider methods (such as `Cipher`, `Signature` and others) get the global
> singleton instance directly (via `CryptoManager.getInstance()`).
>
> Additionally, NSS provides the option to load multiple NSS DBs into the
> current instance, which might satisfy the use case of multiple
> `CryptoManager` instances as well.
---
However, the existence of `JSSLoader` and subsequently allowing JSS to load
via the standard provider `java.security` file has complicated this slightly,
to enable new use cases for JSS.
Take the following code snippet for instance:
```java
import org.mozilla.jss.CryptoManager;
public class Example {
public static void main(String[] args) throws Exception {
CryptoManager cm = CryptoManager.getInstance();
// Additional code elided.
}
}
```
When used with JSS loaded via `java.security` override, the developer would
rightly expect that JSS will load first, allowing `CryptoManager` to return
a valid instance.
In order to facilitate this however, when the internal `instance` field is
`NULL`, JSS must first try to load itself via the Provider interface. That is,
it needs to do something akin to:
```java
java.security.Provider p = Security.getProvider("Mozilla-JSS");
```
in order to force Java to attempt to load JSS. Any equivalent call into the
Java security interface would also suffice (such as
`Signature.getInstance(algo, "Mozilla-JSS")`), but this call limits the size
of the resulting object and makes clear the intent.
_Aside:_
> This becomes a touch tricky though. In particular, `CryptoManager.instance`
> access is usually locked, to prevent modification by one thread while
> another is reading it. This is locked at the class level (via a
> `synchronized (CryptoManager.class)` statement explicitly or implicitly
> in the synchronized `initialize()` method). So, inside `getInstance()`, we
> explicitly acquire the lock to check the value of `instance`, release it for
> the provider call -- in case it loads JSS from the provider interface --
> and then explicitly re-acquire it to return the value. This should help to
> prevent race conditions and returning a partially-initialized
> `CryptoManager` instance before it is fully ready.
Otherwise, the call will fail and we'd require code changes, such as:
```java
import java.security.*;
import org.mozilla.jss.CryptoManager;
public class Example {
public static void main(String[] args) throws Exception {
Provider p = Security.getProvider("Mozilla-JSS");
CryptoManager cm = CryptoManager.getInstance();
// Additional code elided.
}
}
```
in order for this to work.
---
`CryptoManager` hasn't historically exposed a check to see if it is currently
initialized. Under earlier `JSSProvider` code, it would use
`CryptoManager.getInstance() != null` as the check for whether or not
`CryptoManager` was initialized. Consider the original code above: this leads
to the interesting recursion:
- `CryptoManager.getInstance()` sees that `instance` is `NULL`, triggering
`JSSProvider` to load.
- `JSSProvider` -- while checking whether it needs to load -- would in turn
call `CryptoManager.getInstance()` again.
- Because `CryptoManager.getInstance()` again sees that `instance is `NULL`
it will try to load `JSSProvider` again. Preventing us from infinite
recursion though, `Security.getProvider(...)` will return `NULL`, and we'll
successfully indicate that we need to load `JSSProvider`.
The net result is that we successfully load only a single `JSSProvider`
instance. However, when running with security debug flags (such as
`-Djava.security.debug=all`), the Provider loader would report the recursion
as a stack trace such as:
```java
ProviderConfig: Loading provider: org.mozilla.jss.JSSProvider('/home/ascheel/GitHub/sandbox/jss/build/config/jss.cfg')
ProviderConfig: Recursion loading provider: org.mozilla.jss.JSSProvider('/home/ascheel/GitHub/sandbox/jss/build/config/jss.cfg')
java.lang.Exception: Call trace
at sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:180)
at sun.security.jca.ProviderList.getProvider(ProviderList.java:233)
at sun.security.jca.ProviderList.getIndex(ProviderList.java:263)
at sun.security.jca.ProviderList.getProviderConfig(ProviderList.java:247)
at sun.security.jca.ProviderList.getProvider(ProviderList.java:253)
at java.security.Security.getProvider(Security.java:503)
at org.mozilla.jss.CryptoManager.getInstance(CryptoManager.java:368)
at org.mozilla.jss.JSSLoader.loaded(JSSLoader.java:86)
at org.mozilla.jss.JSSLoader.init(JSSLoader.java:111)
at org.mozilla.jss.JSSLoader.init(JSSLoader.java:103)
at org.mozilla.jss.JSSProvider.configure(JSSProvider.java:68)
at org.mozilla.jss.JSSProvider.(JSSProvider.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:224)
at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:206)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:206)
at sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:187)
at sun.security.jca.ProviderList.getProvider(ProviderList.java:233)
at sun.security.jca.ProviderList.getIndex(ProviderList.java:263)
at sun.security.jca.ProviderList.getProviderConfig(ProviderList.java:247)
at sun.security.jca.ProviderList.getProvider(ProviderList.java:253)
at java.security.Security.getProvider(Security.java:503)
at org.mozilla.jss.CryptoManager.getInstance(CryptoManager.java:368)
at org.mozilla.jss.tests.SymKeyGen.(SymKeyGen.java:210)
at org.mozilla.jss.tests.SymKeyGen.main(SymKeyGen.java:266)
```
By introducing a `isInitialized()` method, we can use a proper check that
doesn't invoke this recursion, namely `instance == null` directly in the
`CryptoManager` instance.
jss-5.0.0/docs/usage/jssengine.md 0000664 0000000 0000000 00000057362 14125500636 0016675 0 ustar 00root root 0000000 0000000 # `JSSEngine` - Documentation
## About `JSSEngine`
`JSSEngine` is JSS's implementation of the [`SSLEngine`][javax.ssl-engine]
contract for non-blocking TLS. Unlike the `SunJSSE` provider's `SSLEngine`
(when using the `SunPKCS11-NSS` provider for primitives), this is built
directly on NSS's high-level SSL module. This is better for FIPS compliance
and HSM support (as keys never leave the NSS cryptographic module) and also
means that we don't need to reimplement the underlying state machine. This
approach is consistent with our [JSS `SSLSocket`][jss.ssl-socket].
## Using `JSSEngine`
There are two ways to use the `JSSEngine`: via the JCA Provider interface,
or constructing a `JSSEngine` instance directly. The former method is
preferred out of the two.
Please refer to the [`JSSEngine` test cases][jss.jssengine.tests] or to
the [Oracle `SSLEngine` demo][oracle.sslengine.demo] for information on
using it. Usually a `SSLEngine` instance is asked by an external API
(e.g., Tomcat) or used inside a `SSLSocket` implementation, such as the
`SSLSocket` implementation provided by `Mozilla-JSS`'s SSLContext`.
### Via the JSSProvider
This is the preferred way of using the `JSSEngine`. To construct a new
[`SSLEngine`][javax.ssl-engine] instance, first get `Mozilla-JSS`'s
[`SSLContext`][javax.ssl-context]:
```java
// First get the necessary KeyManagers and TrustManagers. Note that
// selecting KeyManagers and TrustManagers is discussed more below.
KeyManagerFactory kmf = KeyManagerFactory.getInstance("NssX509", "Mozilla-JSS");
KeyManager[] kms = kmf.getKeyManagers();
TrustManagerFactory tmf = TrustManagerFactory.getInstance("NssX509", "Mozilla-JSS");
TrustManager[] tms = tmf.getTrustManagers();
// Then, initialize the SSLContext with the above information. Note that
// we don't utilize the SecureRandom parameter, as NSS internally handles
// generating random numbers for us.
SSLContext ctx = SSLContext.getInstance("TLS", "Mozilla-JSS");
ctx.init(kms, tms, null);
// If we don't have any peer host/port information, use this form:
SSLEngine engine = ctx.createSSLEngine();
// Otherwise, use this form:
SSLEngine engine = ctx.createSSLEngine(peerHost, peerPort);
```
The [`SSLContext`][javax.ssl-context] also provides methods helpful for
configuring the [`SSLEngine`][javax.ssl-engine]. These are
`SSLContext.getDefaultSSLParameters()` and
`SSLContext.getSupportedSSLParameters()`. These provide the default parameters
used by the SSLEngine and all supported SSLParameters, respectively.
For more information about configuring the `JSSEngine`, see the section below.
Note that the `Mozilla-JSS` provider's `SSLContext` instance also provides
methods for creating `SSLSocket` factories which conform to the same
`javax.net.ssl` interfaces. These sockets utilize the `JSSEngine` internally
and expose many of the same configuration methods under the `JSSSocket` class
namespace. The results of these factories can be directly cast to `JSSSocket`
or `JSSServerSocket` as appropriate.
### Direct Utilization
This is the less preferred way of using the `JSSEngine`. This requires
understanding the class layout of `JSSEngine`. See the section below for more
information.
First, get an instance of `JSSEngine`:
```java
/* If no session resumption hints are provided: */
// JSSEngine engine = new JSSEngine<$Impl>();
/* If we already know the peer's host and port: */
// String peerHost;
// int peerPort;
// JSSEngine engine = new JSSEngine<$Impl>(peerHost, peerPort);
/* Or laastly, if we know the peer's host and port, and want to set
* a certificate and key to use for our side of the connection: */
// X509Certificate localCert;
// PrivateKey localKey;
JSSEngine engine = new JSSEngine<$Impl>(peerHost, peerPort, localCert, localKey);
```
Replace `JSSEngine<$Impl>` with one of the implementing classes below.
Then, continue with configuring the `JSSEngine` below.
### Configuring the `JSSEngine`
Configuring the `JSSEngine` is a multi-step process. Below are common
configuration options grouped into categories.
#### Choosing Handshake Side
Configuring which side of the handshake this `JSSEngine` will use occurs via
a call to `setUseClientMode(boolean mode)`. When `mode` is `true`, this engine
will handshake as if it was the client. Otherwise, this engine will handshake
as a server. Note that calling `setUseClientMode(...)` after the handshake has
started (either via calling `beginHandshake(...)`, `wrap(...)`, or
`unwrap(...)`) isn't supported.
Checking the current mode can be done via `getUseClientMode(...)`.
#### Choosing Key Material
Key material can be chosen in several ways. In every scenario, a JSSKeyManager
instance needs to be passed to the JSSEngine:
```java
// JSSEngine inst;
inst.setKeyManager(new JSSKeyManager());
```
For direct selection of key from an existing instance, call `setKeyMaterials`:
```java
// JSSEngine inst;
inst.setKeyMaterials(myPK11Cert, myPK11PrivKey);
```
Note that these must be instances of [`PK11Cert`][jss.pk11-cert] and
[`PK11PrivKey`][jss.pk11-privkey] respectively. These can be obtained from
the [`CryptoManager`][jss.cryptomanager] and casting `X509Certificate` to
`PK11Cert` and `PrivateKey` to `PK11PrivKey`.
For selection of a key via an alias in the certificate database, call
`setCertFromAlias`:
```java
// JSSEngine inst;
inst.setCertFromAlias("server-cert-alias");
```
Lastly, key material could've been provided when the `JSSEngine` was
constructed; see the section on direct utilization above.
Note that SNI support isn't yet added so the key selection must occur prior
to the initial handshake.
#### Choosing TLS protocol version
There are two ways to choose TLS protocol version. The first is via the Java
Provider interface, selecting the TLS version directly. The `Mozilla-JSS`
provider understands the following aliases:
- `SSL` and `TLS`, enabling any allowed SSL and TLS protocol version,
- `TLSv1.1` to enable only TLS version 1.1 by default,
- `TLSv1.2` to enable only TLS version 1.2 by default, and
- `TLSv1.3` to enable only TLS version 1.3 by default.
Alternatively, the standard `SSLEngine` configuration method of passing
a list of protocols to `setEnabledProtocols` is also allowed. Note that this
will override any value passed via the Provider interface. Additionally, due
to restrictions in NSS, a contiguous range of protocols will be enabled. For
example, the following call:
```java
// SSLEngine inst;
inst.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.3" });
```
will enable TLSv1.1, TLSv1.2, and TLSv1.3.
Alternative methods are available that take JSS standard `SSLVersion` and
`SSLVersionRange` values as parameters; see the `JSSEngine` javadoc for
more information.
#### Choosing Cipher Suite
Configuring cipher suites is performed using the standard `SSLEngine`
configuration method of passing a list of cipher suites to
`setEnabledCipherSuites`. We filter the list of passed cipher suites to
only those allowed by local policy. For example:
```java
// SSLEngine inst;
inst.setEnabledCipherSuites(new String[] { "TLS_AES_128_GCM_SHA256" });
```
will enable only a single TLSv1.3 cipher suite.
Alternative methods are available that take JSS standard `SSLCipher`
values as parameters; see the `JSSEngine` javadoc for more information.
#### Using `JSSParameters`
`JSSParameters` largely aligns with `SSLParameters` except that it allows
two important introductions:
1. Selection of key material, like above. See the javadocs on `JSSParameters`
for more information.
2. Setting the peer's hostname, for use with validation of certificates. This
allows us to tie into NSS's hostname verification directly, instead of
responding after the fact by closing the connection.
Generally, using `SSLParameters` should be sufficient for most applications.
Two exceptions are when we wish to explicitly select key material (e.g., from
a certificate nickname) or when using NSS for SSL hostname validation.
#### Session Control
The `JSSEngine` lacks many of the session control functions other `SSLEngine`
implementations might have. In particular, we:
- Always enable session resumption; this cannot be disabled.
- Allow forced expiration of a session as long as the `SSLEngine`'s
connection isn't yet closed.
- Report accurate creation/expiration/last accessed times.
However, other features of sessions (such as configuring location and size of
the session cache) aren't yet configurable.
## Design of the `JSSEngine`
### Class Structuring
The below is a digram showing the structure of `JSSEngine` classes:
-----------
| JSSEngine |-------------------------
----------- \
/ \ \
------------------------ ------------------------ ------
| JSSEngineReferenceImpl | | JSSEngineOptimizedImpl | | .... |
------------------------ ------------------------ ------
`JSSEngine` is an abstract class extending [`SSLEngine`][javax.ssl-engine].
This class implements some of the boilerplate required for implementing a
`SSLEngine`, including handling cipher and protocol version configuration.
Individual implementations implement `wrap`, `unwrap`, and whatever specifics
are necessary to initialize and release the SSL-backed `PRFileDesc`.
We expect two primary implementations:
- `JSSEngineReferenceImpl`, a reference implementation with more logging
and debugging statements. This also includes port-based debugging, so
situations where a `SSLEngine` isn't writing to the network can still
be tracked and analyzed in Wireshark. Each call to `wrap` or `unwrap`
makes several JNI calls, incurring lots of overhead.
- `JSSEngineOptimizedImpl`, an optimized, production-ready implementation.
This one is harder to debug due to fewer logging statements, but does
improve performance significantly with fewer JNI calls.
### Non-Blocking IO
In order to implement `wrap` and `unwrap` on the SSLEngine, we use NSPR
sockets configured in non-blocking mode. Data is held in buffers rather
than being written to the network; in this way, data is passed from a
`unwrap` call to `NSPR` so that `NSS` can decrypt the wire data, with
the result being returned from `unwrap`.
This is implemented as follows:
NSPR introduces a platform-independent abstraction over C's file descriptors
(usually an `int`) in the form of the `PRFileDesc` structure. This is
layer-able, allowing us to write our own and then have it be accepted by
NSS's SSL `PRFileDesc` implementation as the underlying transport.
Our `PRFileDesc` is called `BufferPRFD` and lives next to the `JSSEngine`
implementation in `org/mozilla/jss/ssl/javax`. Each `BufferPRFD` is backed
by two `j_buffer` instances (located adjacent). A `j_buffer` is a circular
ring buffer optimized to allow efficient access to the underlying data. One
`j_buffer` is dedicated to the read end of this `BufferPRFD` (the data that
is returned when `recv(...)` is called); the other is dedicated to the write
end of this `BufferPRFD` (the data that is waiting to get sent on the wire).
Note that the `j_buffer` instances exist independently from the `BufferPRFD`:
the `JSSEngine` itself creates the `j_buffer`s and hands them to the
`BufferPRFD` to use, because it too needs to be able to read from them.
This forms the following data path once the initial handshake is complete:
-------------
| Application |
-------------
| ^
app | | wire SSLEngine.wrap(data, result)
data | | data
V |
----------- jb_read(write, result) ----------
| JSSEngine | <-------------------- | j_buffer |
----------- ----------
| ^
| PR.Write(ssl_fd, data) | jb_write(write, enc_data)
v |
----- -----------
| NSS | -----------------------> | PRFileDesc|
----- -----------
PR.Write(buffer_fd, enc_data)
The application creates application data it wants to send to its peer. It
invokes `SSLEngine.wrap(data, result)`, where `data` is the application data
and `result` is an empty buffer large enough to store the resulting wire data.
The `JSSEngine` passes this data (via a call to `PR.Write`) to NSS along the
SSL `PRFileDesc` (`ssl_fd`) associated with this `JSSEngine`. NSS encrypts
this data and writes it to the underlying `BufferPRFD`. If the `BufferPRFD`
has sufficient space in its write `j_buffer`, it can accept all the data.
This occurs in the `PR.Write` call on the `BufferPRFD`. At this point, the
call stack returns to `JSSEngine.wrap(...)`. When it sees that there is data
in the underlying write `j_buffer`, `JSSEngine` reads from the write
`j_buffer`, thereby freeing space in it for the next PR.Write(...) invocation,
and adds this to the application's `result` (wire data) buffer.
A similar process (with the bottom loop reversed) occurs for the application
decrypting data from its peer. In this case, encrypted wire data is written
to the read `j_buffer`, a call to `jb_read(read)` from `PR.Read(buffer_fd)`
occurs inside NSS when a call to `PR.Read(ssl_fd)` is made from the SSLEngine.
The unencrypted result is then passed to the caller of
`SSLEngine.unwrap(...)`.
### Handshaking
The data flow described above in the section on Non-Blocking IO applies to
the initial TLS Handshake as well, except there's no initial application data
and the `JSSEngine` doesn't call `PR.Write(...)`. [TLSv1.2][rfc.tls-1.2] and
[TLSv1.3][rfc.tls-1.3] both have state machines at the core of their handshake
mechanism. However, NSS doesn't expose the current state of the handshake or
whether or not we can continue without any additional information from the
remote peer.
When a `JSSEngine` is initialized, the first thing it expects to do is begin
a handshake with a peer. The TLS handshake begins with the client sending a
Client Hello message to the server. When the SSLEngine is initialized as a
client, it sets the handshake state to `NEED_WRAP` (so we can send the
outbound Client Hello); when initialized as a server, it gets set to
`NEED_UNWRAP` so we can receive the inbound Client Hello from the peer.
When `SSL.ForceHandshake` is called, NSS steps the internal state machine.
This results in a call to `PR.Read(...)` to read any inbound data, and if
this client needs to write a message, a call to `PR.Write(...)`. In this way,
all inbound data on the wire is consumed, and if a message needs to be
transmitted, we can check the amount of data in the write `j_buffer`. This
gives us the following heuristic for handshaking:
1. Get the Security Status prior to handshaking via `SSL.SecurityStatus(...)`
2. Perform `SSL.ForceHandshake(...)`
3. Get the Security Status again
4. Determine our next step:
- If we need to send data to the client (and this wasn't a `wrap` call),
change status to `NEED_WRAP`
- If the handshake status reports security is on (and there is no more
data to send in a `wrap` call!), we've just finished handshaking and
have sent the last commit message, so change status to `FINISHED`.
- If we have no more data to read from the client (and no outbound data
either), we assume we need more data from the client so we change the
status to `NEED_UNWRAP`.
- Otherwise, we keep the status the same. We increment a unknown state
counter -- this flips the value from its previous value to the opposite
of what it was (e.g., `NEED_WRAP` to `NEED_UNWRAP`). This helps to
ensure we don't ever get stuck.
This heuristic is wrapped in `updateHandshakeState`, which is called from
`wrap`, `unwrap`, and `getHandshakeStatus`; the unknown state counter gets
incremented in all three places.
### Post-Handshake Auth (PHA) and Re-Handshaking
Prior to TLS 1.3, clients and servers could initiate another handshake,
allowing clients the chance to specify authentication that wasn't provided at
the initial handshake. This also allowed the client and server to negotiate a
new key. Because this poses a [security risk][rfc.tls-renegotiation], a TLS
extension modifies the behavior to improve security. However, this behavior
was removed in TLS 1.3 and replaced with two separate steps: one mechanism
to provide authentication post-handshake and another to rekey the handshake.
By default, renegotiation and PHA support are both enabled for a `JSSEngine`.
In order to issue such a renegotiation, change the status of client
authentication after the initial handshake:
```java
// SSLEngine inst;
inst.setNeedClientAuth(true);
```
Then call `beginHandshake()` in order to re-handshake:
```java
inst.beginHandshake();
```
Complete a handshake as usual. Note that this will detect if TLS 1.3 or a
previous version was negotiated and choose between a rehandshaking and
PHA as appropriate for the selected TLS version.
#### Disabling Post-Handshake Auth (PHA)
In order to disable PHA support, cast `SSLEngine` to a `JSSEngine` instance
prior to the initial handshake and remove the PHA configuration option,
`SSL.ENABLE_POST_HANDSHAKE_AUTH` or set it to `0` to disable it:
```java
import org.mozilla.jss.ssl.javax.JSSEngine;
import org.mozilla.jss.nss.SSL;
// JSSEngine inst;
inst.addConfiguration(SSL.ENABLE_POST_HANDSHAKE_AUTH, 0);
```
Note that this must be done before `beginHandshake()`, `wrap()`, or `unwrap()`
is called.
#### Disabling Re-Handshaking
In order to disable or configure secure renegotiation, the following
configuration options can be modified:
- `SSL.ENABLE_RENEGOTATION` - set to `SSL.RENEGOTIATE_NEVER` to disable all
attempts at renegotation; set to `SSL.RENEGOTIATE_UNRESTRICTED` to always
renegotiation even in unsafe scenarios; set to
`SSL.RENEGOTIATE_REQUIRES_XTN` to only allow secure renegotiation; set to
`SSL.RENEGOTIATE_TRANSITIONAL` to require the renegotiation extension
when this is a server connection, but allowing clients to handshake with
vulnerable servers.
- `SSL.REQUIRE_SAFE_NEGOTIATION` - set to `1` by default, can be set to `0`
to enable unsafe renegotiation.
- `SSL.ENABLE_FALLBACK_SCSV` - set to `1` by default to send the fallback
`SCSV` pseudo-ciphersuite; can be set to `0` to disable sending the
option.
For example, to disable renegotiation completely:
```java
import org.mozilla.jss.ssl.javax.JSSEngine;
import org.mozilla.jss.nss.SSL;
// JSSEngine inst;
inst.addConfiguration(SSL.ENABLE_RENEGOTATION, SSL.RENEGOTIATE_NEVER);
```
Note that this must be done before `beginHandshake()`, `wrap()`, or `unwrap()`
or called.
### SSL Alert Handling
NSS exposes access to protocol-level alerts via the two callback functions,
`SSL_AlertReceivedCallback` (for when an alert was received from the remote
peer) and `SSL_AlertSentCallback` (for when NSS sends an alert to the
remote peer). When attempting non-blocking IO, there's a weird quirk about
how these callbacks function: the only execute when a NSPR `PR_Read(...)` or
`PR_Write(...)` call executes on the SSL `PRFileDesc`. In particular, it
isn't sufficient to simply call `SSL_ForceHandshake(...)`! The callbacks
strictly occur when the alerts are on the wire, and don't execute for future
alerts we're expecting to send. This convolutes our exception handling
slightly.
JSS takes the following approach to handling SSL Alerts and exposing them to
callers via exceptions:
1. `SSLFDProxy` contains separate queues of inbound and outbound `SSLAlert`s.
2. `checkSSLAlert` verifies whether or not a fatal alert was received and/or
sent.
3. The first such fatal alert that was received or sent is converted into an
`SSLException` instance; this is saved to the `JSSEngine`'s state and
returned.
4. `updateHandshakeState()` checks to see if a SSL alert occurred prior to
calling SSL_ForceHandshake(...)` -- if so, it does no work.
5. `wrap` and `unwrap` also check SSL alerts after all work is done. This
ensures we always trigger a call into NSPR's `PR_Write(...)` or
`PR_Read(...)`.
6. When an alert occurs in `unwrap` (especially during a handshake), we
make sure to set the state to `wrap` so our response (either the alert
itself or our confirmation of it) is recorded.
7. Lastly, we make sure to throw an exception only once and not multiple
times.
### `wrap`/`unwrap` with large Buffers
While `SSLSession` indiciates the size of its internal buffers (via
`SSLSession.getApplicationBufferSize()`), we might get `src` and `dst`
buffers large enough to overflow our internal buffer multiple times. While
we could indicate this via returning a short read (`bytesConsumed()` or
`bytesProduced()` on `SSLEngineResult` from a `wrap` or `unwrap`
respectively), this could make the application allocate multiple buffers or
invoke `wrap()`/`unwrap()` multiple times. This overhead isn't necessary, as
we can detect this ourselves within `JSSEngine`.
For a `wrap()` call, there's two places data could be produced: in
`updateHandshakeState()` when we're handshaing or in `writeData()`. There's
only one place wire data is placed: `write_buf`. Because `write_buf` is
limited to `BUFFER_SIZE` bytes, we could produce bytes (up to the capacity
of `write_buf`), write them to `dst`, and then be able to produce more bytes.
We stop when we are no longer producing or consuming any bytes. This leaves
us with one extra invocation of `updateHandshakeState()`, `writeData()`, and
reading from `write_buf`, but this is necessary to flush the internal NSS
buffer.
A similar description applies to `unwrap`. To accomplish handling large
buffers, we simply wrap the core body of `wrap()` and `unwrap()` in a loop,
stopping when no more data is being produced and consumed. This will stop
because: the input and output buffers we're given are bounded in size and
if an exception occurs, after writting the appropriate alert to the wire,
NSS will quit reading/writing data. This means these loops are bound to
terminate eventually.
### Future Improvements
Currently we've only implemented the `JSSEngineReferenceImpl`; the optimized
implementation still needs to be written. In particular, the performance of
multiple JNI calls per step (`wrap` or `unwrap`) needs to be evaluated. We
could replace this with a copy of the contents of the underlying ByteBuffer,
perform a PR_Read or PR_Write operation, and then (in the event of a write),
copy the modified data back. This would give us better performance for large
buffers.
We only have a single `JSSKeyManager` that doesn't understand SNI; we should
make sure we support SNI from a client and server perspective.
We need to make sure we can interact with external (non-JSS)
[`X509TrustManager`s](javax.x09trustmanager) and use them to validate the
peer's certificates.
[javax.ssl-context]: https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html "javax.net.ssl.SSLContext"
[javax.ssl-engine]: https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLEngine.html "javax.net.ssl.SSLEngine"
[javax.x509trustmanager]: https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/X509TrustManager.html "javax.net.ssl.X509TrustManager"
[jss.jssengine-tests]: https://github.com/dogtagpki/jss/blob/master/org/mozilla/jss/tests/TestSSLEngine.java "JSS SSLEngine tests"
[jss.pk11-cert]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/pkcs11/PK11Cert.html "org.mozilla.jss.pkcs11.PK11Cert"
[jss.pk11-privkey]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/pkcs11/PK11PrivKey.html "org.mozilla.jss.pkcs11.PK11PrivKey"
[jss.ssl-socket]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/ssl/SSLSocket.html "org.mozilla.jss.ssl.SSLSocket"
[oracle.sslengine.demo]: https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/samples/sslengine/SSLEngineSimpleDemo.java "Oracle SSLEngineSimpleDemo"
[rfc.tls-1.2]: https://tools.ietf.org/html/rfc5246 "TLSv1.2 RFC 5246"
[rfc.tls-renegotiation]: https://tools.ietf.org/html/rfc5746#section-5
[rfc.tls-1.3]: https://tools.ietf.org/html/rfc8446 "TLSv1.3 RFC 8446"
jss-5.0.0/docs/usage/jssprovider.md 0000664 0000000 0000000 00000016317 14125500636 0017255 0 ustar 00root root 0000000 0000000 # `Mozilla-JSS` Provider
The `Mozilla-JSS` JCA-compatible Provider exposes most of the functionality
of JSS to external packages. This interface is the recommend interface most
developers should build against. However, once the dependencies are satisfied
and JSS's native component is available to the JVM, we still have to load
and initialize JSS.
There are two routes to do this:
1. Via the `CryptoManager` interface, _and_
2. Via `java.security`, directly loading the `JSSProvider`.
## Loading JSS via `CryptoManager`
To load JSS from a `CryptoManager`, it is necessary to decide what level of
configuration is necessary. If you're happy with the defaults, it is
sufficient to only specify a NSS DB:
```java
import org.mozilla.jss.CryptoManager;
CryptoManager.initialize("/path/to/nss-db");
```
At this point, JSS will be initialized and can be used. A password might be
required, so see the section below for providing password callback handlers.
Certain default values might not work in all situations. For instance,
Candlepin expects other providers to be default, with the Mozilla-JSS
provider being the least-preferred provider. To do this, they'd construct an
`InitializationValues` instance and pass that to
`CryptoManager.initialize(...)`:
```java
import org.mozilla.jss.InitializationValues;
InitializationValues ivs = new InitializationValues("/path/to/nss-db");
ivs.installJSSProviderFirst = false;
CryptoManager.initialize(ivs);
```
See the section below on other options available to configure.
### `InitializationValues` options
There are two constructors for `InitializationValues`:
- Taking only a NSS DB directory. This was utilized above.
- Taking a NSS DB directory, a prefix for the certificate database, a
prefix for the key database, and the name of the secmod configuration.
The latter is a more advanced use case and few individuals likely need to use
it. For more information, see the corresponding NSS documentation on these
values.
Refer to the javadoc for `InitializationValues` for the supported parameters
and their default values.
### `PasswordCallback` handlers
In order to authenticate against a PKCS#11 token or to the internal
certificate store, it is necessary to select a `PasswordCallback` handler.
By default this is a console-based `PasswordCallback` handler. This prompts
the user for the password via the Console. However, this is not appropriate
in all scenarios.
Developers are expected to extend and implement this as desired by their
application.
For example, to set a static `PasswordCallback` handler:
```java
CryptoManager cm = CryptoManager.getInstance();
cm.setPasswordCallback(new Password("password".toCharArray()));
```
## Loading JSS via `java.security`
You can directly add the `JSSProvider` by adding it to the `java.security`
file:
```properties
security.provider. = org.mozilla.jss.JSSProvider /path/to/jss.cfg
```
There are two ways use this `java.security` file: by directly installing
it to the system or by using `-Djava.security.properties=/path/to/file`.
Note that two equals signs may be used, in which case the system configuration
is ignored and fully overridden by this file.
`JSSProvider` behaves like the `SunPKCS11-NSS` provider, requiring a
configuration file to initialize JSS (and the `CryptoManager` object).
`jss.cfg` takes the same `InitializationValues` parameters, except in a
properties file format.
### JSS Config
| property | Mapped To |
|------------------------------------|--------------------------------------------------|
| `jss.fips` | `InitializationValues.fipsMode` |
| `jss.ocsp.enabled` | `InitializationValues.ocspCheckingEnabled` |
| `jss.ocsp.policy` | `CryptoManager.setOCSPPolicy` |
| `jss.ocsp.responder.cert_nickname` | `InitializationValues.ocspResponderCertNickname` |
| `jss.ocsp.responder.url` | `InitializationValues.ocspResponderURL` |
| `jss.password` | `CryptoManager.setPasswordCallback` |
| `nss.config_dir` | `InitializationValues.configDir` |
| `nss.cert_prefix` | `InitializationValues.certPrefix` |
| `nss.cooperate` | `InitializationValues.cooperate` |
| `nss.force_open` | `InitializationValues.forceOpen` |
| `nss.java_only` | `InitializationValues.javaOnly` |
| `nss.key_prefix` | `InitializationValues.keyPrefix` |
| `nss.no_cert_db` | `InitializationValues.noCertDB` |
| `nss.no_mod_db` | `InitializationValues.noModDB` |
| `nss.no_pk11_finalize` | `InitializationValues.noPK11Finalize` |
| `nss.no_root_init` | `InitializationValues.noRootInit` |
| `nss.optimizeSpace` | `InitializationValues.optimizeSpace` |
| `nss.pkix_verify` | `InitializationValues.pkixVerify` |
| `nss.pk11_reload` | `InitializationValues.PK11Reload` |
| `nss.pk11_thread_safe` | `InitializationValues.PK11ThreadSafe` |
| `nss.read_only` | `InitializationValues.readOnly` |
| `nss.secmod_name` | `InitializationValues.secmodName` |
Note that the parameters `installJSSProvider`, `removeSunProvider`, and
`installJSSProviderFirst` are ignored, as they can be controlled by directly
manipulating the `java.security` file.
## Upgrading Old Code
There are two paths to upgrade an older code base to a newer JSS version,
using the JSSProvider interface:
1. Continue using `CryptoManager.initialize(...)` as before. This gives the
local application the most control over the NSS DB path. No changes are
required.
2. Switch to using `java.security`-based configuration (either via local
policy with `-Djava.security.properties=/path` specified on the JVM
command line or via system-wide policy by modifying the
`$JAVA_HOME/conf/security/java.security` file). You can then remove the
call to `CryptoManager.initialize(...)`. If this call is necessary for
backwards-compatibility reasons (to support multiple JSS versions), it
would be sufficient to check the value of `CryptoManager.getInstance(...)`
before configuration:
```java
try {
cm = CryptoManager.getInstance();
} catch (NotInitializedException nie) {
// Or throw this exception and provide instructions on how to
// configure Mozilla-JSS in the java.security provider list.
CryptoManager.initialize(...);
cm = CryptoManager.getInstance();
}
```
This gives the user control over NSS DB path via modifying either of
those two configuration files (or by providing a local override).
Note that, between `java.security` and `CryptoManager.initialize()`, the
latter takes precedence unless `CryptoManager` has already been initialized.
This would happen if any java Security Provider calls are made or if
`CryptoManager.getInstance()` is called.
jss-5.0.0/docs/usage/kbkdf.md 0000664 0000000 0000000 00000035447 14125500636 0015771 0 ustar 00root root 0000000 0000000 # KBKDF - Documentation
## About KBKDF
KBKDF is defined in [NIST's SP800-108][sp800-108]: Key Based Key Derivation
Functions. These are a collection of three KDFs based on MACing primitives:
1. Counter Mode in 5.1,
2. Feedback Mode in 5.2, and
3. Double Pipeline Mode in 5.3.
These KDFs see usage in GlobalPlatform's Secure Channel Protocol 03, Kerberos,
and other places. This KDF is implemented using [PKCS#11 v3.0][pkcs11-kbkdf];
refer to that document for additional information about using this KDF.
## Using KBKDF
KBKDF usage is available from the `Mozilla-JSS` provider through the javax
[`KeyGenerator`][key-generator] interface. There are two categories of KDF
implementations:
1. `CKO_SECRET_KEY` keys, which cannot be extracted when the system is
running in FIPS mode or when the key lives on an HSM, and
2. `CKO_DATA_OBJECT` keys, which can always be extract.
The latter category is suitable for generating SCP03 challenges, but shouldn't
be used with cryptographic operations. They have the "Data" suffix in the
provider list.
### Constructing a KBKDF `KeyGenerator`
To construct a KBKDF generator, get the instance via the provider interface:
```java
import javax.crypto.KeyGenerator;
KeyGenerator kg = KeyGenerator.getInstance("", "Mozilla-JSS");
```
Where name depends on the choice of KBKDF:
| KeyGenerator Name | Mode | Data | Parameter Class |
|-------------------|----------|------|----------------------------------------------|
| KbkdfCounter | Counter | no | [KBKDFCounterParams][kbkdf-counter-params] |
| KbkdfCounterData | Counter | yes | [KBKDFCounterParams][kbkdf-counter-params] |
| KbkdfFeedback | Feedback | no | [KBKDFFeedbackParams][kbkdf-feedback-params] |
| KbkdfFeedbackData | Feedback | yes | [KBKDFFeedbackParams][kbkdf-feedback-params] |
| KbkdfPipeline | Pipeline | no | [KBKDFPipelineParams][kbkdf-pipeline-params] |
| KbkdfPipelineData | Pipeline | yes | [KBKDFPipelineParams][kbkdf-pipeline-params] |
Various aliases for these KeyGenerators also exist; this allows for greater
compatibility with existing systems which implement this KDF. These exist
because the [Java Cryptography Architecture][jca] doesn't specify canonical
names for these KDFs.
### Construct a KBKDF Parameter Specification
Each KBKDF mode has its own parameter specification class, which must be used
with a `KeyGenerator` of only that type. These classes are given in the above
table and exist in the [`org.mozilla.jss.crypto`][jss-crypto] package. Each
parameter spec derives from [`KBKDFParameterSpec`][kbkdf-spec].
These arguments are:
| Name | Description | Modes | Setter |
|-------------------------|--------------------------------------|----------|-----------------------------------------------------------------------------------------------------|
| PRF | PRF used during KBKDF (HMAC or CMAC) | All | [`setPRF`][kbkdf-spec-set-prf] |
| PRF Key | Key used for the PRF | All | [`setPRFKey`][kbkdf-spec-set-prf-key] |
| Derived Algorithm | Algorithm of the primary derived key | All | [`setDerivedKeyAlgorithm`][kbkdf-spec-set-derived-algo] |
| Key Size | Size of the primary derived key | All | [`setKeySize`][kbkdf-spec-set-key-size] |
| Initial Value | Initial chaining value | Feedback | [`setInitialValue`][kbkdf-spec-set-iv] |
| PRF Data Parameters | Parameters to control PRF input | All | [`setParameters`][kbkdf-spec-set-params] / [`addParameter`][kbkdf-spec-add-param] |
| Additional Derived Keys | Additional keys to derive | All | [`setAdditionalDerivedKeys`][kbkdf-spec-set-keys] / [`addAdditionalDerivedKey`][kbkdf-spec-add-key] |
Note: the methods and fields inherited from `NativeEnclosure` shouldn't be
called by the KBKDF user during normal usage.
#### Using Algorithms
When using this KBKDF, both the PRF and the derived key's algorithm must be
specified. In both cases, the user has a choice: either use the
[PKCS#11 Constant][jss-pkcs11-constants] for the algorithm, or use the
algorithm as specified in the [PKCS#11 Algorithm][jss-pkcs11-algorithm]
enumeration.
For example, the following are equivalent:
```java
import org.mozilla.jss.pkcs11.PKCS11Constants;
KBKDFCounterParams params = new KBDKFCounterParams();
params.setPRF(PKCS11Constants.CKM_AES_CMAC);
```
and
```java
import org.mozilla.jss.crypto.PKCS11Algorithm;
KBKDFCounterParams params = new KBKDFCounterParams();
params.setPRF(PKCS11Algorithm.CKM_AES_CMAC);
```
The latter gives a little more type safety and ensures that the specified
algorithm is understood and implemented by JSS; otherwise, they're equivalent.
#### Constructing KDF PRF Input Stream (Data) Parameters
The core of PKCS#11's KBKDF implementation allows great flexibility in
crafting the input stream to the underlying PRF invocation. This allows for
a wide range of usages (including in SCP03), assuming some care is taken in
ensuring the resulting KBKDF is secure from length extension attacks. See
NIST S800-108 for more details regarding concerns.
PKCS#11 v3.0 defines four types of input parameters:
| Name | Description |
|-----------------------------|------------------------------------------------------------|
| KBKDFByteArrayParam | A static array of bytes to add to the PRF input stream |
| KBKDFDKMLengthParam | A structure for encoding and calculating KDF output length |
| KBKDFIterationVariableParam | Either an incrementing counter or a chaining value |
| KBKDFOptionalCounterParam | (In Feedback and Pipeline Modes); an optional counter |
Please refer to [section 2.42.2 Mechanism Parameters][pkcs11-kbkdf-params]
for more information about correct usage of each parameter, how they correlate
to names in NIST SP800-108, and with which KDF modes each parameter can be
used.
#### Deriving Additional Keys
PKCS#11 v3.0 defines a way of extracting additional keys from the derived key
material. See [section 2.42.6 Deriving Additional Keys][pkcs11-kbkdf-adk] for
a comprehensive reference.
The `CK_DERIVED_KEY` PKCS#11 structure is mirrored in the `KBKDFDerivedKey`
class. Add PKCS#11 Attributes to the derived key, specify it in the KDF
parameter. After `kg.generateKey(...)` has been called, `getKey(...)` will
return the additional key.
### Example KBKDF Usage
Putting this all together, the following is a short example of how to use the
KBKDF to derive a single key for the SCP03 protocol.
```java
public SymmetricKey kbkdfDeriveSCP03Key(SymmetricKey master,
byte[] context,
byte kdfConstant,
int kdfOutputSizeBytes) {
KeyGenerator kg = KeyGenerator.getInstance("KbkdfCounter", "Mozilla-JSS");
KBKDFCounterParams kcp = new KBKDFCounterParams();
kcp.setPRF(PKCS11Algorithm.CKM_AES_CMAC);
kcp.setPRFKey(master);
kcp.setKeySize(kdfOutputSizeBytes);
byte[] label = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, kdfConstant };
kcp.addParameter(new KBKDFByteArrayParam(label));
byte[] separator = new byte[] { 0x00 };
kcp.addParameter(new KBKDFByteArrayParam(separator));
KBKDFDataParameter length = new KBKDFDKMLengthParam(
// How to calculate the length, were there multiple derived keys.
PKCS11Constants.CK_SP800_108_DKM_LENGTH_SUM_OF_SEGMENTS,
// This length is big endian, so littleEndian == false.
false,
// How many bits to encode the length. SCP03 requires two bytes.
2*8
);
kcp.addParameter(length);
KBKDFDataParameter counter = new KBKDFIterationVariableParam(false, 1*8);
kcp.addParameter(counter);
kcp.addParameter(new KBKDFByteArrayParam(context));
kcp.setDerivedKeyAlgorithm(PKCS11Algorithm.CKM_AES_CBC);
kg.init(kcp);
return kg.generateKey();
}
```
## Design of KBKDF
Unlike past key generation mechanisms, the `CKM_SP800_108_*` PKCS#11 mechs
require extensive mechanism parameters. Under Java, these take the form of
[`java.security.spec.AlgorithmParameterSpec`][alg-param-spec] implementations,
but this leaves much to be desired when bridging the JNI gap. Our approach
involved creating new extensions to the [`NativeProxy`][native-proxy] class:
the [`NativeEnclosure`][native-enclosure].
Unlike a `NativeProxy` -- whose scope is implicit, a `NativeEnclosure`
formalizes and specifies the exact scope of a C pointer. In particular, a
`NativeProxy` instance could be created at any time by the JNI code; it is
then given to Java to handle usage and cleanup. Additionally, a `NativeProxy`
instance doesn't exist until it is created by C code.
Contrasting with that, we need our parameter specifications to exist prior
to the creation of the `NativeProxy` instance -- so we can populate them -- but
we still need to capture the creation, use, and destruction of the underlying
`NativeProxy`. This leads to two NativeEnclosure methods:
- `acquireNativeResources(...)` to trigger an allocation of the
`NativeProxy`, storing it on the `mPointer` member, and
- `releaseNativeResources(...)` to trigger freeing it.
These get wrapped in `open(...)` and `close(...)` respective, allowing us to
implement the [`java.lang.AutoCloseable`][auto-close] class.
This lets us use the parameters in the `KeyGenerator` as following: prior
to the call (via JNI) to `PK11_DeriveKey(...)`. We call `open(...)` and
handle any issues creating the `CK_SP800_108_KDF_PARAMS` or
`CK_SP800_108_FEEDBACK_KDF_PARAMS` pointer. We pass this pointer directly to
`PK11_DeriveKey(...)`, and when we're done, call `close(...)` to handle
freeing it.
Thus, we incur only a single allocation and free when we're ready to use
the parameter, and the complexities of handling the JNI translation are
hidden from the programmer wishing to use it.
[alg-param-spec]: https://docs.oracle.com/javase/8/docs/api/java/security/spec/AlgorithmParameterSpec.html "java.security.spec.AlgorithmParameterSpec"
[auto-close]: https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html "java.lang.AutoCloseable"
[jca]: https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html "Java Cryptography Architecture Reference Guide"
[jss-crypto]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/package-summary.html "org.mozilla.jss.crypto.*"
[jss-pkcs11-algorithm]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/PKCS11Algorithm.html "org.mozilla.jss.crypto.PKCS11Algorithm"
[jss-pkcs11-constants]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/pkcs11/PKCS11Constants.html "org.mozilla.jss.pkcs11.PKCS11Constants"
[kbkdf-counter-params]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFCounterParams.html "org.mozilla.jss.crypto.KBKDFCounterParams"
[kbkdf-feedback-params]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFFeedbackParams.html "org.mozilla.jss.crypto.KBKDFFeedbackParams"
[kbkdf-pipeline-params]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFPipelineParams.html "org.mozilla.jss.crypto.KBKDFPipelineParams"
[kbkdf-spec]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html "org.mozilla.jss.crypto.KBKDFParameterSpec"
[kbkdf-spec-set-prf]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#setPRF-org.mozilla.jss.crypto.PKCS11Algorithm- "org.mozilla.jss.crypto.KBKDFParameterSpec setPRF(...)"
[kbkdf-spec-set-prf-key]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#setPRFKey-javax.crypto.SecretKey- "org.mozilla.jss.crypto.KBKDFParameterSpec setPRFKey(...)"
[kbkdf-spec-set-derived-algo]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#setDerivedKeyAlgorithm-org.mozilla.jss.crypto.PKCS11Algorithm- "org.mozilla.jss.crypto.KBKDFParameterSpec setDerivedKeyAlgorithm(...)"
[kbkdf-spec-set-key-size]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#setKeySize-int- "org.mozilla.jss.crypto.KBKDFParameterSpec setKeySize(...)"
[kbkdf-spec-set-iv]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFFeedbackParams.html
[kbkdf-spec-set-params]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#setParameters-org.mozilla.jss.crypto.KBKDFDataParameter:A- "org.mozilla.jss.crypto.KBKDFParameterSpec setParameters(...)"
[kbkdf-spec-add-param]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#addParameter-org.mozilla.jss.crypto.KBKDFDataParameter- "org.mozilla.jss.crypto.KBKDFParameterSpec addParameter(...)"
[kbkdf-spec-set-keys]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#setAdditionalDerivedKeys-org.mozilla.jss.crypto.KBKDFDerivedKey:A- "org.mozilla.jss.crypto.KBKDFParameterSpec setAdditionalDerivedKeys(...)"
[kbkdf-spec-add-key]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/crypto/KBKDFParameterSpec.html#addAdditionalDerivedKey-org.mozilla.jss.crypto.KBKDFDerivedKey- "org.mozilla.jss.crypto.KBKDFParameterSpec addAdditionalDerivedKey(...)"
[key-generator]: https://docs.oracle.com/javase/8/docs/api/javax/crypto/KeyGenerator.html "javax.crypto.KeyGenerator"
[native-enclosure]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/util/NativeEnclosure.html "org.mozilla.jss.util.NativeEnclosure"
[native-proxy]: https://dogtagpki.github.io/jss/master/javadocs/org/mozilla/jss/util/NativeProxy.html "org.mozilla.jss.util.NativeProxy"
[pkcs11-kbkdf]: https://docs.oasis-open.org/pkcs11/pkcs11-curr/v3.0/csprd01/pkcs11-curr-v3.0-csprd01.html#_Toc437440585 "PKCS#11 v3.0: SP 800-108 Key Derivation"
[pkcs11-kbkdf-params]: https://docs.oasis-open.org/pkcs11/pkcs11-curr/v3.0/csprd01/pkcs11-curr-v3.0-csprd01.html#_Toc8118473 "PKCS#11 v3.0: SP 800-108 Key Derivation: 2.42.2 Mechanism Parameters"
[pkcs11-kbkdf-adk]: https://docs.oasis-open.org/pkcs11/pkcs11-curr/v3.0/csprd01/pkcs11-curr-v3.0-csprd01.html#_Toc8118477 "PKCS#11 v3.0: SP 800-108 Key Derivation: 2.42.6 Deriving Additional Keys"
[sp800-108]: https://csrc.nist.gov/publications/detail/sp/800-108/final "Recommendation for Key Derivation using Pseudorandom Functions (Revised)"
jss-5.0.0/docs/using_jss.md 0000664 0000000 0000000 00000003061 14125500636 0015573 0 ustar 00root root 0000000 0000000 # Using JSS
Please make sure `libjss.so` is included in your library path or set it via
the `LD_LIBRARY_PATH` environment variable. See `man 8 ld.so` for more
information. Alternatively, this can be done by setting `-Djava.library.path`
to the directory with `libjss.so` on the command line of all Java programs
using JSS. Note that without `libjss.so`, using JSS in nearly any capacity
will fail.
## Classpath Dependencies
To use JSS in your project after installation, you'll need to ensure the
following dependencies are available in your `CLASSPATH`:
- `jss.jar` -- provided by the `jss` package and installed to
`/usr/lib/java/jss.jar`.
- `slf4j-api.jar` -- provided by the `slf4j` package and installed to
`/usr/share/java/slf4j/slf4j-api.jar`.
- `apache-commons-lang.jar` -- provided by the `apache-commons-lang` package
and installed to `/usr/share/java/apache-commons-lang.jar`.
Note that the above paths and packages are for Fedora; for a list of packages
in Debian, please see the [dependencies document](dependencies.md). Note that
paths might differ between various platforms and versions of Fedora.
## Developing against JSS
We recommend referring to the javadoc distribution generated when JSS was
installed. On Fedora-like systems, this is provided by the `jss-javadoc`
package; for an online version tracking master, please refer to our
[live instance](https://dogtagpki.github.io/jss/javadoc/index.html).
## More Information
For more information about using JSS, please see our documentation on loading
the [`JSSProvider`](usage/jssprovider.md).
jss-5.0.0/examples/ 0000775 0000000 0000000 00000000000 14125500636 0014133 5 ustar 00root root 0000000 0000000 jss-5.0.0/examples/README.adoc 0000664 0000000 0000000 00000000411 14125500636 0015714 0 ustar 00root root 0000000 0000000 = JSS Examples =
Below are examples of how to use JSS:
* link:src/main/java/examples/pkcs12.java[pkcs12.java]
* link:src/main/java/examples/PQGGen.java[PQGGen.java]
More examples are available in the link:../src/test/java/org/mozilla/jss/tests[tests] directory.
jss-5.0.0/examples/pom.xml 0000664 0000000 0000000 00000001776 14125500636 0015463 0 ustar 00root root 0000000 0000000
4.0.0
org.dogtagpki
jss-example
5.0.0-SNAPSHOT
org.dogtagpki
jss
5.0.0-SNAPSHOT
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
11
jss-5.0.0/examples/src/ 0000775 0000000 0000000 00000000000 14125500636 0014722 5 ustar 00root root 0000000 0000000 jss-5.0.0/examples/src/main/ 0000775 0000000 0000000 00000000000 14125500636 0015646 5 ustar 00root root 0000000 0000000 jss-5.0.0/examples/src/main/java/ 0000775 0000000 0000000 00000000000 14125500636 0016567 5 ustar 00root root 0000000 0000000 jss-5.0.0/examples/src/main/java/examples/ 0000775 0000000 0000000 00000000000 14125500636 0020405 5 ustar 00root root 0000000 0000000 jss-5.0.0/examples/src/main/java/examples/PQGGen.java 0000664 0000000 0000000 00000003635 14125500636 0022340 0 ustar 00root root 0000000 0000000 package examples;
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import org.mozilla.jss.*;
import org.mozilla.jss.crypto.*;
/**
* A command-line utility for generating PQG parameters for DSA
* Key operations. Can be used for testing.
* Takes the keysize as the sole argument.
*/
public class PQGGen {
public static void main(String args[]) {
int size;
PQGParams pqg;
try {
if(args.length != 1) {
throw new Exception("Usage: java PQGGen ");
}
size = Integer.parseInt(args[0]);
System.out.println("Generating PQG parameters for "+size+
"-bit keypairs. This could take hours...");
CryptoManager.initialize(".");
pqg = PQGParams.generate(size);
System.out.println("Generated PQG Parameters.");
System.out.println("Verifying PQG Parameters. "+
"This could take a few minutes...");
if( ! pqg.paramsAreValid() ) {
throw new Exception("ERROR: Generated parameters are invalid.");
}
System.out.println("Parameters are valid!");
System.out.println("P: "+pqg.getP());
System.out.println("Q: "+pqg.getQ());
System.out.println("G: "+pqg.getG());
System.out.println("H: "+pqg.getH());
System.out.println("seed: "+pqg.getSeed());
System.out.println("counter: "+pqg.getCounter());
} catch(NumberFormatException e) {
System.err.println("Invalid key size: "+e);
} catch(PQGParamGenException e) {
System.err.println(e);
} catch(java.security.InvalidParameterException e) {
System.err.println("Invalid key size: "+e);
} catch(Exception e) {
System.err.println(e);
}
}
}
jss-5.0.0/examples/src/main/java/examples/pkcs12.java 0000664 0000000 0000000 00000026325 14125500636 0022363 0 ustar 00root root 0000000 0000000 package examples;
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* This program reads in a PKCS #12 file and dumps its contents to the screen.
* At the same time, it creates a new PKCS #12 file. As it reads through the
* old file, it writes its contents into the new file. Then the new file
* is encrypted and MACed with a new, different password.
*/
/* note that this code still has some problems reading PKCS12 file
* generated with Communicator.
*/
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import org.mozilla.jss.CryptoManager;
import org.mozilla.jss.asn1.ANY;
import org.mozilla.jss.asn1.ASN1Util;
import org.mozilla.jss.asn1.ASN1Value;
import org.mozilla.jss.asn1.BMPString;
import org.mozilla.jss.asn1.OCTET_STRING;
import org.mozilla.jss.asn1.SEQUENCE;
import org.mozilla.jss.asn1.SET;
import org.mozilla.jss.crypto.CryptoStore;
import org.mozilla.jss.crypto.CryptoToken;
import org.mozilla.jss.crypto.JSSSecureRandom;
import org.mozilla.jss.crypto.PBEAlgorithm;
import org.mozilla.jss.crypto.PrivateKey;
import org.mozilla.jss.pkcs12.AuthenticatedSafes;
import org.mozilla.jss.pkcs12.CertBag;
import org.mozilla.jss.pkcs12.PFX;
import org.mozilla.jss.pkcs12.PasswordConverter;
import org.mozilla.jss.pkcs12.SafeBag;
import org.mozilla.jss.pkix.cert.Certificate;
import org.mozilla.jss.pkix.primitive.Attribute;
import org.mozilla.jss.pkix.primitive.EncryptedPrivateKeyInfo;
import org.mozilla.jss.pkix.primitive.PrivateKeyInfo;
import org.mozilla.jss.util.ConsolePasswordCallback;
import org.mozilla.jss.util.Password;
public class pkcs12 {
public static void main(String []args) {
try {
// Read arguments
if( args.length != 3 ) {
System.out.println("Usage: PFX ");
System.exit(-1);
}
// open input file for reading
FileInputStream infile=null;
try {
infile = new FileInputStream(args[1]);
}
catch (FileNotFoundException f) {
System.out.println("Cannot open file "+args[1]+
" for reading: "+f.getMessage());
return;
}
int certfile = 0;
// initialize CryptoManager. This is necessary because there is
// crypto involved with decoding a PKCS #12 file
CryptoManager.initialize( args[0] );
CryptoManager manager = CryptoManager.getInstance();
// Decode the P12 file
PFX.Template pfxt = new PFX.Template();
PFX pfx;
try (BufferedInputStream is = new BufferedInputStream(infile, 2048)) {
pfx = (PFX) pfxt.decode(is);
}
System.out.println("Decoded PFX");
// print out information about the top-level PFX structure
System.out.println("Version: "+pfx.getVersion());
AuthenticatedSafes authSafes = pfx.getAuthSafes();
SEQUENCE safeContentsSequence = authSafes.getSequence();
System.out.println("AuthSafes has "+
safeContentsSequence.size()+" SafeContents");
// Get the password for the old file
System.out.println("Enter password: ");
Password pass = Password.readPasswordFromConsole();
// get new password, which will be used for the new file we create
// later
System.out.println("Enter new password:");
Password newPass = Password.readPasswordFromConsole();
// Verify the MAC on the PFX. This is important to be sure
// it hasn't been tampered with.
StringBuffer sb = new StringBuffer();
if( pfx.verifyAuthSafes(pass, sb) ) {
System.out.println("AuthSafes verifies correctly.");
} else {
System.out.println("AuthSafes failed to verify because: "+
sb);
}
// Create a new AuthenticatedSafes. As we read the contents of the
// old authSafes, we will store them into the new one. After we have
// cycled through all the contents, they will all have been copied into
// the new authSafes.
AuthenticatedSafes newAuthSafes = new AuthenticatedSafes();
// Loop over contents of the old authenticated safes
//for(int i=0; i < asSeq.size(); i++) {
for(int i=0; i < safeContentsSequence.size(); i++) {
// The safeContents may or may not be encrypted. We always send
// the password in. It will get used if it is needed. If the
// decryption of the safeContents fails for some reason (like
// a bad password), then this method will throw an exception
SEQUENCE safeContents = authSafes.getSafeContentsAt(pass, i);
System.out.println("\n\nSafeContents #"+i+" has "+
safeContents.size()+" bags");
// Go through all the bags in this SafeContents
for(int j=0; j < safeContents.size(); j++) {
SafeBag safeBag = (SafeBag) safeContents.elementAt(j);
// The type of the bag is an OID
System.out.println("\nBag "+j+" has type "+
safeBag.getBagType() );
// look for bag attributes
SET attribs = safeBag.getBagAttributes();
if( attribs == null ) {
System.out.println("Bag has no attributes");
} else {
for(int b=0; b < attribs.size(); b++) {
Attribute a = (Attribute) attribs.elementAt(b);
if( a.getType().equals(SafeBag.FRIENDLY_NAME)) {
// the friendly name attribute is a nickname
BMPString bs = (BMPString) ((ANY)a.getValues().
elementAt(0)).decodeWith(
BMPString.getTemplate());
System.out.println("Friendly Name: "+bs);
} else if(a.getType().equals(SafeBag.LOCAL_KEY_ID)){
// the local key id is used to match a key
// to its cert. The key id is the SHA-1 hash of
// the DER-encoded cert.
OCTET_STRING os =(OCTET_STRING)
((ANY)a.getValues().
elementAt(0)).decodeWith(
OCTET_STRING.getTemplate());
System.out.println("LocalKeyID:");
/*
AuthenticatedSafes.
print_byte_array(os.toByteArray());
*/
} else {
System.out.println("Unknown attribute type: "+
a.getType().toString());
}
}
}
// now look at the contents of the bag
ASN1Value val = safeBag.getInterpretedBagContent();
if( val instanceof PrivateKeyInfo ) {
// A PrivateKeyInfo contains an unencrypted private key
System.out.println("content is PrivateKeyInfo");
} else if( val instanceof EncryptedPrivateKeyInfo ) {
// An EncryptedPrivateKeyInfo is, well, an encrypted
// PrivateKeyInfo. Usually, strong crypto is used in
// an EncryptedPrivateKeyInfo.
EncryptedPrivateKeyInfo epki =
((EncryptedPrivateKeyInfo)val);
System.out.println(
"content is EncryptedPrivateKeyInfo, algoid:"
+ epki.getEncryptionAlgorithm().getOID());
// Because we are in a PKCS #12 file, the passwords are
// char-to-byte converted in a special way. We have to
// use the special converter class instead of the default.
PrivateKeyInfo pki = epki.decrypt(pass,
new org.mozilla.jss.pkcs12.PasswordConverter() );
// import the key into the key3.db
CryptoToken tok = manager.getTokenByName("Internal Key Storage Token");
CryptoStore store = tok.getCryptoStore();
tok.login( new ConsolePasswordCallback());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
pki.encode(baos);
store.importPrivateKey(baos.toByteArray(),
PrivateKey.RSA);
// re-encrypt the PrivateKeyInfo with the new password
// and random salt
byte[] salt = new byte[
PBEAlgorithm.PBE_SHA1_DES3_CBC.getSaltLength()];
JSSSecureRandom rand = CryptoManager.getInstance().
getSecureRNG();
rand.nextBytes(salt);
epki = EncryptedPrivateKeyInfo.createPBE(
PBEAlgorithm.PBE_SHA1_DES3_CBC, newPass,
salt, 1, new PasswordConverter(), pki);
// Overwrite the previous EncryptedPrivateKeyInfo with
// this new one we just created using the new password.
// This is what will get put in the new PKCS #12 file
// we are creating.
safeContents.insertElementAt(
new SafeBag( safeBag.getBagType(),
epki, safeBag.getBagAttributes()), i);
safeContents.removeElementAt(i+1);
} else if( val instanceof CertBag ) {
System.out.println("content is CertBag");
CertBag cb = (CertBag) val;
if( cb.getCertType().equals(CertBag.X509_CERT_TYPE)) {
// this is an X.509 certificate
OCTET_STRING os = (OCTET_STRING)cb.getInterpretedCert();
Certificate cert = (Certificate)
ASN1Util.decode(Certificate.getTemplate(),
os.toByteArray());
cert.getInfo().print(System.out);
} else {
System.out.println("Unrecognized cert type");
}
} else {
System.out.println("content is ANY");
}
}
// Add the new safe contents to the new authsafes
if( authSafes.safeContentsIsEncrypted(i) ) {
newAuthSafes.addEncryptedSafeContents(
AuthenticatedSafes.DEFAULT_KEY_GEN_ALG, newPass,
null, AuthenticatedSafes.DEFAULT_ITERATIONS, safeContents);
} else {
newAuthSafes.addSafeContents( safeContents );
}
}
// Create new PFX from the new authsafes
PFX newPfx = new PFX(newAuthSafes);
// Add a MAC to the new PFX
newPfx.computeMacData(newPass, null, PFX.DEFAULT_ITERATIONS);
// write the new PFX out to a file
FileOutputStream fos = new FileOutputStream(args[2]);
newPfx.encode(fos);
fos.close();
} catch( Exception e ) {
e.printStackTrace();
}
}
}
jss-5.0.0/examples/src/main/resources/ 0000775 0000000 0000000 00000000000 14125500636 0017660 5 ustar 00root root 0000000 0000000 jss-5.0.0/examples/src/main/resources/inputfile.pfx 0000664 0000000 0000000 00000010322 14125500636 0022374 0 ustar 00root root 0000000 0000000 0€0€ *†H†÷
€$€0€0€ *†H†÷
€$€0‚0‚*†H†÷
‚¥0‚¡0
*†H†÷
0
Ð*vÃ~Å/[‚€‚€‚€–Å=õC,ʆ´éƒLÖK Q÷ˆt¹ôrÒ„ó#QA¼R×–Ø×É3)c‡gˆqÃȵÝG?o;féÙ€H ø[yûspXêmà%R–@4~Š€üQØ%:SÔÎ ‹}V¹úΛ
Eš=Êól¥o+á÷K>;¯6¬m´#„aE±h5e?/£:'ñ(¶y[8ô€ëfI(4Fq HãòG>5çÄÀí¿Ù‹t©c£%5TLR[¹áÿÊÄÓl}lõ¨Öz–t›Ã¥¡Aü@ü¿ÀûÊ:›{“cè},Á»VBã®NØ25ëXàÚt16dÁÃÉ¥´CXcͽÓ[ƶ«4oûD?תz¸OÉäUºüî´3ãqü½JʘZ—ƒ›fËF2ÜÙÊ>|ûR„½’µßŠÀ¦Î¯†ïÖV˜ž-Â!Mna–vàK·%s.\# ¨t‘Q@/™¤•zˆ´ê›BñâMá àÅÖ1®¢WÜqI:£Ä;÷©!¸ö–Ö~0;ôTZ7._ö%p¾¢Öß&Oî—½!ËÔfçѦ5v“¸¿Uµïu[Ÿ(ªWµÝiseçS"ýÞóN÷Œû…!#Nðˆ×)Œ.s•éQ`ïË®‡íkG¯Þ,âð6ƒœ£ƒ[‹k7Wæƒ(Î
£á;Qû/¾uÄz%,ÈÀ鸚༠?¿äU5TÄÆÙü0bÃ;JÔ™B1xN»+'±oÈ3Ç” !Ù«ûêñ`ö)MËGÑï÷MË<ý8qçaáÙ0Å.*%úªä¯ÐN¸
&Ì[K¹O1b0; *†H†÷
1.,,, C M S A d m i n i s t r a t o r ' s I D0# *†H†÷
1ôé"H Ín!Ù+„¸_Ϋ 0€ *†H†÷
€0€ 0€ *†H†÷
0
*†H†÷
0
ˆ—Õù¶$ª €¾)ØÕ¸’Ì>ŒØoäqƇ8.¢Ð4Ebp
a±ÀèípÁe€yz¥Á;ùmh‚‚¸‚¸òý*³Å/6GÚ[ÎÖ½@Ô» €ÛCBéߨè©òpvr3¡¡êr’«SÖ¾{KDÇK0ƒrþ2òYÑ®¥=“Wbשd¼gÚ®ÚŸêšRJŸ¢ñçbõYžïÎòò€c['y^t“ù쟴Wê„ó?ÔçmTt>
‰[ùSoÇʹ[©„;ø%à"„Ç
ÞU=æ…6ÞëÍS-x¶` ~ÐP£TÁpW<£âtœ„DÒõÿwj˜r&¤lV(c¾i7ŠÅ‹ál¬N@$}:¢›<ù·C¬aª¶ùÒfî;[Ó‘ÙÔ Áñ±ßnVýì-•-‚„0x>kÚ…X7ž³’#{ªÜŒ¨%f,èâÁ
¤áwÛæqü-F“ ¶¤]Ù`Ìv-Ô23,,ÅÍB¶ší¹Cą㯿+I=2m`9 ð2]4ÿP*²½MPN=$ÃÄ1N0UÐÑjá¤WòðU^Õþ0‹ð–¡þ«B§ð ¶^WYìûVÉÕ…`+sEê4pï*`Å‹ HGEãƒ)Ô©Üåç½:¤]?Ä™`S;ÚV‘ceαVi—S[²ºµéMßÇ4׈UÀ‚"Ô+‚æ]Þ/á ¢kvdµ[$µX½Lò8òö„‰œˆdÿeÁÜ‚Ä%Vo4óq'C0ß.ú'º¶íM6•¬¿ÌŒJml;$Üh‰KBÐíLM)¦Õ[wãÈl~ê`
ý¶ŸmAý.RiŽkÓž‰…8‰VS#îðjæUaÂÝÁŠcˆbH—›ãÝî\г‰?L éï.’'g™ýÓ š²ß5àv_Øi—|úWØcWc‡ëá^CŸ= àõ’ ûe–êwŒ™K›IÌ+ÙN~šL\EÌS˜îṴ̀ÐT,ª"d4¼òȦζ Q XÎÈÚ{’nrÔìÀÚw$ª`½“¬Òjhl¼”à¨á3OþeŠ·Â3¥‹Ùÿ1ŽÉÖyNÝ nY@$¶ÐJ}Å`‰C Ö³+_S£î+ì
p[o: «ô—͆n7Gq6Ñ@<îC!‰l¦‡R“Ò3 }ƒ£rK[[9½;c‘¶^µi&ó>zœ~m1!!¢Ì…ÜóŒ]è²ß3»¯'®fnAQ:6å>