Skip to content
Snippets Groups Projects
Unverified Commit e91513ec authored by Wendland, Florian's avatar Wendland, Florian
Browse files

Prepare release 1.6.0

parent 16047291
No related branches found
No related tags found
No related merge requests found
Showing
with 980 additions and 117 deletions
# exclude everything
*
# include binary distribution archives
!build/distributions/
# exclude nothing
......@@ -4,8 +4,7 @@
.secret
#logging
crymlin.log
medina-codyze.log
*.log
# Mobile Tools for Java (J2ME)
.mtj.tmp/
......
FROM openjdk:11-jre-slim
# Builder
FROM eclipse-temurin:11.0.20.1_1-jdk AS builder
# required for Codyze MEDINA functionalities -> git, gpg
RUN apt-get update && apt-get -y --no-install-recommends install \
unzip \
wget
git \
gpg \
&& rm -rf /var/lib/apt/lists/*
# add distribution
ADD build/distributions/codyze-*.tar /usr/local/lib/
# add links for ease of use
RUN ln -s /usr/local/lib/codyze-*/bin/codyze /usr/local/bin/ \
&& ln -s /usr/local/lib/codyze-* /codyze
WORKDIR /codyze-medina
RUN wget "https://github.com/Fraunhofer-AISEC/codyze/archive/refs/heads/main.zip" \
&& unzip main.zip \
&& mv codyze-main/src/dist/mark/ /codyze/mark/ \
&& rm -rf main.zip codyze-main
# files for build filtered by .dockerignore
ADD . .
RUN ./gradlew --parallel \
generateAll \
&& ./gradlew --parallel \
build \
installDist
# working location with sources to be analyzed
WORKDIR /source
# Executable image
FROM eclipse-temurin:11.0.20.1_1-jre
LABEL org.opencontainers.image.authors="Fraunhofer AISEC <codyze@aisec.fraunhofer.de>"
LABEL org.opencontainers.image.vendor="Fraunhofer AISEC"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.title="Codyze for MEDINA"
LABEL org.opencontainers.image.description="Compliance checks for source code using Codyze. Adjusted for MEDINA framework."
COPY --from=builder /codyze-medina/build/install/ /
RUN ln -st /usr/local/bin/ /codyze-medina/bin/codyze-medina
# required for Codyze MEDINA functionalities -> git, gpg
RUN apt-get update && apt-get -y --no-install-recommends install \
git \
gpg \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /project
# Add workdir to safe directories
RUN git config --global --add safe.directory /project
# default entrypoint and parameters
ENTRYPOINT ["codyze"]
CMD ["-c"]
ENTRYPOINT ["codyze-medina"]
\ No newline at end of file
......@@ -48,14 +48,22 @@ This makes Codyze for MEDINA available for immediate use in `./build/install/cod
Codyze for MEDINA provides a CLI. The main options are:
| Option | Description |
|-----------------------|-------------------------------------------------------------|
| `--endpoint <URL>` | URL of Orchestrator endpoint |
| `--oauth-endpoint <URL>` | URL of OAuth endpoint |
| `--username <STRING> \| -u <STRING>` | username for OAuth |
| `--password <STRING> \| -p <STRING>` | password for OAuth |
| `--ci <STRING>` | CI environment being used (i.e., [GITLAB, GITHUB, JENKINS]) |
| `--config <FILE>` | configuration file for Codyze |
| Option | Default | Description |
|-------------------------------------|:--------------------------:|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `--id <STRING>` | - | UUID of the analyzed cloud service |
| `--rules <FILE>` | codyze-medina-metrics.yaml | File specifying environmental MEDINA rules |
| `--medina-output <PATH>` | codyze-medina.sarif | File where MEDINA rule evaluations will be stored. In case `combined-output` is set to true, this is the location of the combined result file |
| `--combined-output <BOOLEAN>` | true | Whether the respective SARIF files created by Codyze and the MEDINA evaluation should be merged |
| `--key-location <PATH>` | public-keys/ | Location of public key files necessary to evaluate signatures |
| `--endpoint <URL>` | - | URL of Orchestrator endpoint |
| `--oauth-endpoint <URL>` | - | URL of OAuth endpoint |
| `--username <STRING> / -u <STRING>` | - | username for OAuth |
| `--password <STRING> / -p <STRING>` | - | password for OAuth |
| `--required <BOOLEAN>` | true | Whether analysis fails on Orchestrator connection issues. |
| `--mark-builtin <LIST<FILE>>` | [] | Builtin MARK files used in the analysis |
| `--mark-project <LIST<FILE>>` | [] | External MARK files used in the analysis |
| `--ci <STRING>` | NONE | CI environment being used (i.e., [GITLAB, GITHUB, JENKINS]). If set to `NONE`, The program will try to determine this at runtime. |
| `--config <FILE>` | codyze-medina.yaml | Configuration file for Codyze |
In addition, Codyze for MEDINA passes CLI options along to Codyze v2. Options for Codyze v2 can be found in the
documentation at [codyze.io](shttps://www.codyze.io/Getting%20Started/configuration/).
......@@ -71,24 +79,87 @@ The structure of a configuration file is:
```yaml
orchestrator:
required: <BOOLEAN>
endpoint: <URL>
auth:
oauth-endpoint: <URL>
username: <STRING>
password: <STRING>
mark:
builtin:
- <PATH>
- ...
project:
- <PATH>
- ...
id: <STRING>
rules: <FILE>
# ... additional optional parameters ...
# ... additional parameters from original Codyze ...
```
The MARK file paths are interpreted based on the location of the codyze distribution:
- The `builtin` segment represents included MARK rule groups found in `codyze-medina/mark`. Expected inputs are the names of the respective subdirectories.
- The `project` segment represents additional MARK rules provided by any other source. Note that they also need to include a valid mapping file to be considered during the analysis.
See the test resources for an example configuration file. It uses a locally running Orchestrator.
The configuration file should be located within the target project to comply with the following assumptions:
- All **relative paths** used in the configuration of Codyze for MEDINA are evaluated relative to the location of the configuration file.
- The specified MEDINA Metrics from the `rules` parameter are evaluated at the location of the configuration file.
## Mapping
Mapping from `Finding`s to `AssessmentResult`s is currently handled by the mapping file
`src/main/java/resoures/mappings.txt`. Its entries follow the
scheme `[findingId0:findingId1:...]->(metricId;isDefault;operator;targetValue;valueType)`
where `;` separates different parameters and `:` separates elements of a list. See the mapping file in this project for
an example.
`mappings.txt`.
Its entries follow this scheme:
```
metrics:
- name: <Metric Name>
rules:
- <Required MARK Rule>
- <Required MARK Rule>
- ...
configuration:
default: <Whether Config is Default>
operator: <Comparator as String>
type: [STRING, NUMBER, BOOLEAN]
target:
- <Target Value>
- ...
- ...
```
All findings NOT mapped in such a file are ignored during the analysis.
> More information about the mapping file can be found in `docs/mapping.md`
## Exit Codes
Codyze for MEDINA currently returns one of the following exit codes depending on the situation:
| Exit Code | Meaning |
|-----------|---------------------------------------------------------|
| **126** | Orchestrator Connection Failed |
| **3** | Unrecognized Cloud Service Id |
| **127** | General Execution Error (consult logs for more details) |
| **1** | Violations found during analysis |
| **0** | No violations or errors |
Exit codes higher up in this list take priority over lower ones, e.g. a return code of 126 does not exclude violations within the analysis results.
## Environment Variables
The following environment variables can be used to additionally configure the execution:
| Name | Effect |
|------------------|---------------------------------------------------------------------------------------------------------------------|
| CODYZE_PWD | Sets the orchestrator password. Overwrites configuration file entries but is overwritten by command line arguments. |
| CODYZE_LOG_LEVEL | Manually overrides the log level |
Additionally, Codyze for MEDINA parses variables automatically set by the CI system to gain necessary information about the environment.
All findings NOT mapped in this file are ignored when sending results to the orchestrator (they will still be present in
the result file).
\ No newline at end of file
> Codyze for MEDINA requires the target project to be within a Git repository.
> Additionally, GnuPG must be available in order to evaluate any signatures.
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
plugins {
java
kotlin("jvm") version "1.7.20"
kotlin("jvm") version "1.9.20"
application
id("org.openapi.generator") version "6.2.0"
// generator for OpenAPI specs
id("org.openapi.generator") version "7.1.0"
// code quality
jacoco
id("com.diffplug.spotless") version "6.11.0"
id("com.diffplug.spotless") version "6.22.0"
// documentation
id("org.jetbrains.dokka") version "1.7.20"
id("org.jetbrains.dokka") version "1.9.10"
}
group = "de.fraunhofer.aisec.codyze.medina"
version = "1.0.0"
version = "1.6.0"
repositories {
// JitPack for packages build directly from GitHub repos
......@@ -50,53 +50,55 @@ repositories {
}
dependencies {
// Java only
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.1")
// testing
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
testImplementation("org.mockito:mockito-junit-jupiter:5.7.0")
// depend on executing the build.gradle of the generated openapi-projects
api(project("generator_orchestrator"))
api(project("generator_evidence"))
// codyze
api("com.github.Fraunhofer-AISEC:codyze:2.2.0")
// Codyze
implementation("com.github.Fraunhofer-AISEC:codyze:2.3.0")
implementation(
"com.github.Fraunhofer-AISEC.codyze-mark-eclipse-plugin:de.fraunhofer.aisec.mark:2.0.0:repackaged"
)
// CLI using picocli
implementation("info.picocli:picocli:4.6.3")
annotationProcessor("info.picocli:picocli-codegen:4.6.3")
implementation("info.picocli:picocli:4.7.5")
annotationProcessor("info.picocli:picocli-codegen:4.7.5")
// OAuth2
api("org.dmfs:oauth2-essentials:0.18")
implementation("org.dmfs:httpurlconnection-executor:0.20")
implementation("org.dmfs:oauth2-essentials:0.22.1")
implementation("org.dmfs:httpurlconnection-executor:1.22.1")
// Logging
implementation("io.github.microutils:kotlin-logging-jvm:3.0.2")
implementation("org.slf4j:slf4j-simple:2.0.3")
// logging
implementation("io.github.oshai:kotlin-logging-jvm:5.1.0")
implementation("org.slf4j:slf4j-api:2.0.9") // required by `io.github.oshai:kotlin-logging-jvm`
implementation("org.apache.logging.log4j:log4j-core:2.21.1")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl:2.21.1")
// additional dependencies
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.4.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.4")
// YAML configuration files
implementation("com.fasterxml.jackson.core:jackson-databind:2.16.0")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.0")
// kotlin
implementation(kotlin("stdlib-jdk8"))
// SARIF Kotlin bindings
implementation("io.github.detekt.sarif4k:sarif4k:0.5.0")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
kotlin {
jvmToolchain(11)
}
application {
mainClass.set("de.fraunhofer.aisec.codyze.medina.CodyzeMedinaKt")
mainClass.set("de.fraunhofer.aisec.codyze.medina.main.CodyzeMedinaKt")
}
distributions {
main {
contents {
// copy over important files
from("mark/") {
into("mark/")
}
......@@ -109,6 +111,8 @@ distributions {
// license header used with spotless
val license =
"""
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) ${"$"}YEAR, Fraunhofer AISEC. All rights reserved.
*
......@@ -123,6 +127,7 @@ val license =
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
......@@ -131,28 +136,37 @@ val license =
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*
* This file is part of the MEDINA Framework.
*/
""".trimIndent()
spotless {
ratchetFrom("origin/main")
java {
importOrder()
removeUnusedImports()
googleJavaFormat()
licenseHeader(license).yearSeparator("-")
}
kotlin {
ktfmt().kotlinlangStyle()
licenseHeader(license).yearSeparator("-")
}
}
// Manually exclude all spotless-Tasks of the "generator_"-subprojects from the gradle task graph.
// This is a workaround to prevent the exceptions thrown from the outdated google-java-format specified there
gradle.taskGraph.whenReady {
if(hasTask(":spotlessJava") || hasTask(":spotlessJavaDiagnose")) {
allTasks.forEach {
for (project in subprojects) {
if(it.path.matches(":generator_.+:spotless.*".toRegex())) {
it.enabled = false
}
}
}
}
}
// generates an openapi-project from the `orchestrator.yaml` specification in the resources
// directory
tasks.register<GenerateTask>("generateOrchestrator") {
inputSpec.set("$rootDir/src/main/resources/orchestrator.yaml")
outputDir.set("$buildDir/generator_orchestrator")
outputDir.set("${layout.buildDirectory.get().asFile}/generator_orchestrator")
generatorName.set("java")
apiPackage.set("org.openapitools.client.orchestrator.api")
modelPackage.set("org.openapitools.client.orchestrator.model")
......@@ -162,7 +176,7 @@ tasks.register<GenerateTask>("generateOrchestrator") {
// generates an openapi-project from the `evidence.yaml` specification in the resources directory
tasks.register<GenerateTask>("generateEvidence") {
inputSpec.set("$rootDir/src/main/resources/evidence.yaml")
outputDir.set("$buildDir/generator_evidence")
outputDir.set("${layout.buildDirectory.get().asFile}/generator_evidence")
generatorName.set("java")
apiPackage.set("org.openapitools.client.evidence.api")
modelPackage.set("org.openapitools.client.evidence.model")
......@@ -175,7 +189,9 @@ tasks.register("generateAll") {
dependsOn(tasks.named("generateEvidence"))
}
tasks.named<Test>("test") { useJUnitPlatform() }
tasks.named<Test>("test") {
useJUnitPlatform()
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
......@@ -191,3 +207,19 @@ tasks.jacocoTestReport {
tasks.dokkaHtml.configure {
outputDirectory.set(rootDir.resolve("docs"))
}
tasks {
jar {
from("LICENSE") {
into("META-INF/")
}
// add name and version from gradle configuration to jar manifest
manifest {
attributes(
"Implementation-Title" to rootProject.name,
"Implementation-Version" to rootProject.version,
"Bundle-License" to "https://opensource.org/licenses/Apache-2.0"
)
}
}
}
# Mapping Documentation
## Content of a single mapping
To adapt the provided mapping, the following syntax must be considered:
The mapping consists of a set of **metrics**, which define the results as they will be sent to the Orchestrator.
Each metric is specified by its **name**, **rules** and **configuration**.
### Rules
It is possible to define one or multiple rules for each metric. These rules represent the MARK rules evaluated by Codyze.
A metric will only be evaluated if _all_ of its rules have been evaluated prior. Only if _all_ of its rules passed the metric will be evaluated as compliant.
### Configuration
The configuration of a metric defines its evaluation in the Orchestrator.
The **default** value indicates whether this configuration represents a default configuration or has been modified.
The **operator** specifies the operator which is used to compare different results of this metric with the target value.
The **type** specifies the data type the results of this metric have. Possible values are *BOOLEAN*, *NUMBER* and *STRING*.
The **target** value specifies one or multiple values that define - together with the operator - which results are considered good.
## Having multiple mappings
There are many reasons why one would want to have multiple mapping files.
One of them being that there may be rules with the same name in different modules which should not be verified together.
Therefore, the specified Mark directory is being scanned top-to-bottom until a mapping is found.
This mapping is subsequently applied to all hierarchical equivalent or lower rules within the same directory.
Other mapping files found below an existing mapping will be ignored.
When creating multiple mappings consider that every evaluated mapping will cause a separate analysis run.
### Example
Consider the following structure of the Mark rule source directory:
```
mark/
├─ botan/
│ ├─ botan-rules-1/
│ │ ├─ mapping.yaml [0]
│ │ ├─ botan-rule-1.mark
│ ├─ botan-rules-2/
│ │ ├─ botan-rule-2.mark
│ ├─ botan-rule-0.mark
├─ bouncycastle/
│ ├─ mapping.yaml [1]
│ ├─ bc-rules-1/
│ │ ├─ bc-rule-1.mark
│ ├─ bc-rules-2/
│ │ ├─ bc-rule-2.mark
│ │ ├─ mapping.yaml [2]
│ ├─ bc-rule-0.mark
```
In this scenario, `botan-rule-1.mark` will be included in the run evaluating `[0]`.
All other rules in the `botan/` directory will be ignored as there is no mapping at or above their level.
Within the `bouncycastle/` directory all rules will be analyzed in the context of `[1]`.
The mapping found at `[2]` will not be applied as it is within a directory that already belongs to `[1]`.
\ No newline at end of file
# MEDINA Rule Documentation
## Content of a rule specification
The file containing the MEDINA rules is specified by the program argument `--rules` and defaults to `medina.yaml`.
The YAML content is expected to be structured in the following way:
```
metrics:
- name: <METRIC1>
target:
- <TARGET1>
- ...
- name: <METRIC2>
target:
- <TARGET1>
- ...
- ...
```
### Available rules
The following table lists all currently available rules and the expected format for their respective target values:
| Name | Target Value | Explanation |
|:--------------|:--------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------|
| CodeSignoff | "<SIGNER_NAME>" | Checks for a Signoff by the specified signer |
| SignedCommits | "<SIGNING_KEY_ID>" | Checks for a valid GPG signature from the specified key |
| SignedSignoff | <div>Map: {</br>name: "<SIGNER_NAME>", </br>email: "<SIGNER_EMAIL>", </br>pub-key-id: "<SIGNING_KEY_ID>"</br>}</div> | Checks whether the commit contains a valid signature and signoff from the specified subject |
| ApprovedCommitAuthor | "<AUTHOR_NAME>" | Checks whether the commit was authored from a specified subject |
The `SIGNING_KEY_ID` is expected to be the 16-character-long ID of the key used for signing.
No preview for this file type
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
......@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
......@@ -80,13 +80,11 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
......@@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
......@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
......
......@@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
......
FROM eclipse-temurin:11.0.20.1_1-jre
LABEL org.opencontainers.image.authors="Fraunhofer AISEC <codyze@aisec.fraunhofer.de>"
LABEL org.opencontainers.image.vendor="Fraunhofer AISEC"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.title="Codyze for MEDINA"
LABEL org.opencontainers.image.description="Compliance checks for source code using Codyze. Adjusted for MEDINA framework."
# required for Codyze MEDINA functionalities -> git, gpg
RUN apt-get update && apt-get -y --no-install-recommends install \
git \
gpg \
&& rm -rf /var/lib/apt/lists/*
# add distribution
ADD build/distributions/codyze-*.tar /usr/local/lib/
# add links for ease of use
RUN ln -s /usr/local/lib/codyze-*/bin/codyze-medina /usr/local/bin/ \
&& ln -s /usr/local/lib/codyze-* /codyze-medina
WORKDIR /project
# Add workdir to safe directories
RUN git config --global --add safe.directory /project
# default entrypoint
ENTRYPOINT ["codyze-medina"]
\ No newline at end of file
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2020-2023, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
* | | / _ \ / _` | | | |_ / _ \
* | |___| (_) | (_| | |_| |/ / __/
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*/
package java.jca
entity Cipher {
var transform;
var provider;
var opmode;
var certificate;
var random;
var key;
var params;
var paramspec;
var input;
var output;
var wrappedkey;
var wrappedkeyalgorithm;
var wrappedkeytype;
op instantiate {
javax.crypto.Cipher.getInstance(
transform : java.lang.String
);
javax.crypto.Cipher.getInstance(
transform : java.lang.String,
provider : java.lang.String | java.security.Provider
);
}
op init {
javax.crypto.Cipher.init(
opmode : int,
certificate : java.security.cert.Certificate
);
javax.crypto.Cipher.init(
opmode : int,
certificate : java.security.cert.Certificate,
random : java.security.SecureRandom
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
params : java.security.AlgorithmParameters
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
params : java.security.AlgorithmParameters,
random : java.security.SecureRandom
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
random : java.security.SecureRandom
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
paramspec : java.security.spec.AlgorithmParameterSpec
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
paramspec : javax.crypto.spec.IvParameterSpec
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
paramspec : java.security.spec.AlgorithmParameterSpec,
random : java.security.SecureRandom
);
javax.crypto.Cipher.init(
opmode : int,
key : java.security.Key,
paramspec : javax.crypto.spec.IvParameterSpec,
random : java.security.SecureRandom
);
}
op aad {
javax.crypto.Cipher.updateAAD(src : byte[] | java.nio.ByteBuffer);
javax.crypto.Cipher.updateAAD(src: byte[], ...);
}
op update {
output = javax.crypto.Cipher.update(input : byte[]);
output = javax.crypto.Cipher.update(input : byte[], _, _);
javax.crypto.Cipher.update(input : byte[], _, _, output : byte[]);
javax.crypto.Cipher.update(input : byte[], _, _, output : byte[], _);
javax.crypto.Cipher.update(input : java.nio.ByteBuffer, output : java.nio.ByteBuffer);
}
op finalize {
output = javax.crypto.Cipher.doFinal();
output = javax.crypto.Cipher.doFinal(input : byte[]);
javax.crypto.Cipher.doFinal(output : byte[], _);
output = javax.crypto.Cipher.doFinal(input : byte[], _, _);
javax.crypto.Cipher.doFinal(input : byte[], _, _, output : byte[]);
javax.crypto.Cipher.doFinal(input : byte[], _, _, output : byte[], _);
javax.crypto.Cipher.doFinal(input : java.nio.ByteBuffer, output: java.nio.ByteBuffer);
}
op keywrap {
wrappedkey = javax.crypto.Cipher.wrap(key : java.security.Key);
key = javax.crypto.Cipher.unwrap(
wrappedkey : byte[],
wrappedkeyalgorithm : java.lang.String,
wrappedkeytype : int
);
}
}
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2020-2023, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
* | | / _ \ / _` | | | |_ / _ \
* | |___| (_) | (_| | |_| |/ / __/
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*/
package java.jca
entity KeyAgreement {
......
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2020-2023, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
* | | / _ \ / _` | | | |_ / _ \
* | |___| (_) | (_| | |_| |/ / __/
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*/
package java.jca
/*
......@@ -14,7 +40,6 @@ entity Mac {
var input;
var output;
op instantiate {
javax.crypto.Mac.getInstance(
algorithm : java.lang.String
......@@ -47,5 +72,4 @@ entity Mac {
op reset {
javax.crypto.Mac.reset();
}
}
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2020-2023, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
* | | / _ \ / _` | | | |_ / _ \
* | |___| (_) | (_| | |_| |/ / __/
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*/
package java.jca
/*
......@@ -35,5 +61,4 @@ entity MessageDigest {
op reset {
java.security.MessageDigest.reset();
}
}
# MARK for Bouncy Castle's JCA/JCE Provider
## License
These files are part of [Codyze](https://www.codyze.io/).
They are distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt).
They have been included from [Codyze on GitHub](https://github.com/Fraunhofer-AISEC/codyze/) into Codyze for MEDINA.
Adjustments within the [MEDINA project](https://medina-project.eu/) are marked appropriately.
\ No newline at end of file
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2020-2023, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
* | | / _ \ / _` | | | |_ / _ \
* | |___| (_) | (_| | |_| |/ / __/
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*/
package java.jca
entity SecureRandom {
......@@ -54,5 +80,4 @@ entity SecureRandom {
params : java.security.SecureRandomParameters
);
}
}
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (c) 2020-2023, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* _____ _
* / ____| | |
* | | ___ __| |_ _ _______
* | | / _ \ / _` | | | |_ / _ \
* | |___| (_) | (_| | |_| |/ / __/
* \_____\___/ \__,_|\__, /___\___|
* __/ |
* |___/
*/
package java.jca
entity Signature {
var algorithm;
var provider;
var privateKey;
var random;
var certificate;
var publicKey;
var b;
var data;
var off;
var len;
var outbuf;
var offset;
var len;
var signature;
var offset;
var length;
op instantiate {
java.security.Signature.getInstance(
algorithm : java.lang.String
);
java.security.Signature.getInstance(
algorithm : java.lang.String,
provider : java.lang.String | java.security.Provider
);
}
op initsign {
java.security.Signature.initSign(
privateKey : java.security.PrivateKey
);
java.security.Signature.initSign(
privateKey : java.security.PrivateKey,
random : java.security.SecureRandom
);
}
op initverify {
java.security.Signature.initVerify(
certificate : java.security.cert.Certificate
);
java.security.Signature.initVerify(
publicKey : java.security.PublicKey
);
}
op update {
java.security.Signature.update(
b : byte
);
java.security.Signature.update(
data : byte[] | java.nio.ByteBuffer
);
java.security.Signature.update(
data : byte[],
off : int,
len : int
);
}
op sign {
signature = java.security.Signature.sign();
java.security.Signature.sign(
outbuf : byte[],
offseet : int,
len : int
);
}
op verify {
java.security.Signature.verify(
signature : byte[]
);
java.security.Signature.verify(
signature : byte[],
offset : int,
length : int
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment