diff --git a/src/main/java/org/cyclonedx/model/Component.java b/src/main/java/org/cyclonedx/model/Component.java index 4f7ac795c..f914d3fdd 100644 --- a/src/main/java/org/cyclonedx/model/Component.java +++ b/src/main/java/org/cyclonedx/model/Component.java @@ -24,6 +24,7 @@ import org.cyclonedx.Version; import org.cyclonedx.model.component.ModelCard; +import org.cyclonedx.model.component.crypto.CryptoProperties; import org.cyclonedx.model.component.modelCard.ComponentData; import org.cyclonedx.util.deserializer.ExternalReferencesDeserializer; import org.cyclonedx.util.deserializer.HashesDeserializer; @@ -68,7 +69,9 @@ "releaseNotes", "modelCard", "data", - "signature" + "cryptoProperties", + "signature", + "provides" }) public class Component extends ExtensibleElement { @@ -96,7 +99,10 @@ public enum Type { @JsonProperty("machine-learning-model") MACHINE_LEARNING_MODEL("machine-learning-model"), @JsonProperty("data") - DATA("data"); + DATA("data"), + @VersionFilter(value = Version.VERSION_16) + @JsonProperty("cryptographic-asset") + CRYPTOGRAPHIC_ASSET("cryptographic-asset"); private final String name; @@ -179,6 +185,14 @@ public String getScopeName() { @JsonProperty("data") private ComponentData data; + @VersionFilter(value = Version.VERSION_16) + @JsonProperty("cryptoProperties") + private CryptoProperties cryptoProperties; + + @VersionFilter(value = Version.VERSION_16) + @JsonProperty("provides") + private List provides; + @JsonOnly @VersionFilter(Version.VERSION_14) private Signature signature; @@ -463,6 +477,22 @@ public void setSwhid(final List swhid) { this.swhid = swhid; } + public CryptoProperties getCryptoProperties() { + return cryptoProperties; + } + + public void setCryptoProperties(final CryptoProperties cryptoProperties) { + this.cryptoProperties = cryptoProperties; + } + + public List getProvides() { + return provides; + } + + public void setProvides(final List provides) { + this.provides = provides; + } + @Override public int hashCode() { return Objects.hash(author, publisher, group, name, version, description, scope, hashes, license, copyright, diff --git a/src/main/java/org/cyclonedx/model/component/crypto/AlgorithmProperties.java b/src/main/java/org/cyclonedx/model/component/crypto/AlgorithmProperties.java new file mode 100644 index 000000000..7423f5f36 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/AlgorithmProperties.java @@ -0,0 +1,145 @@ +package org.cyclonedx.model.component.crypto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.cyclonedx.model.component.crypto.enums.CertificationLevel; +import org.cyclonedx.model.component.crypto.enums.CryptoFunction; +import org.cyclonedx.model.component.crypto.enums.ExecutionEnvironment; +import org.cyclonedx.model.component.crypto.enums.ImplementationPlatform; +import org.cyclonedx.model.component.crypto.enums.Mode; +import org.cyclonedx.model.component.crypto.enums.Padding; +import org.cyclonedx.model.component.crypto.enums.Primitive; +import org.cyclonedx.util.deserializer.CertificationLevelDeserializer; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({ + "primitive", + "parameterSetIdentifier", + "curve", + "executionEnvironment", + "implementationPlatform", + "certificationLevel", "mode", "padding", "cryptoFunctions", + "classicalSecurityLevel", "nistQuantumSecurityLevel" +}) +public class AlgorithmProperties +{ + private Primitive primitive; + + private String parameterSetIdentifier; + + private String curve; + + private ExecutionEnvironment executionEnvironment; + + private ImplementationPlatform implementationPlatform; + + @JsonDeserialize(using = CertificationLevelDeserializer.class) + private CertificationLevel certificationLevel; + + private Mode mode; + + private Padding padding; + + private List cryptoFunctions; + + private Integer classicalSecurityLevel; + + private Integer nistQuantumSecurityLevel; + + public Primitive getPrimitive() { + return primitive; + } + + public void setPrimitive(final Primitive primitive) { + this.primitive = primitive; + } + + public String getParameterSetIdentifier() { + return parameterSetIdentifier; + } + + public void setParameterSetIdentifier(final String parameterSetIdentifier) { + this.parameterSetIdentifier = parameterSetIdentifier; + } + + public String getCurve() { + return curve; + } + + public void setCurve(final String curve) { + this.curve = curve; + } + + public ExecutionEnvironment getExecutionEnvironment() { + return executionEnvironment; + } + + public void setExecutionEnvironment(final ExecutionEnvironment executionEnvironment) { + this.executionEnvironment = executionEnvironment; + } + + public ImplementationPlatform getImplementationPlatform() { + return implementationPlatform; + } + + public void setImplementationPlatform(final ImplementationPlatform implementationPlatform) { + this.implementationPlatform = implementationPlatform; + } + + public CertificationLevel getCertificationLevel() { + return certificationLevel; + } + + public void setCertificationLevel(final CertificationLevel certificationLevel) { + this.certificationLevel = certificationLevel; + } + + public Mode getMode() { + return mode; + } + + public void setMode(final Mode mode) { + this.mode = mode; + } + + public Padding getPadding() { + return padding; + } + + public void setPadding(final Padding padding) { + this.padding = padding; + } + + @JacksonXmlElementWrapper(localName = "cryptoFunctions") + @JacksonXmlProperty(localName = "cryptoFunction") + public List getCryptoFunctions() { + return cryptoFunctions; + } + + public void setCryptoFunctions(final List cryptoFunctions) { + this.cryptoFunctions = cryptoFunctions; + } + + public Integer getClassicalSecurityLevel() { + return classicalSecurityLevel; + } + + public void setClassicalSecurityLevel(final Integer classicalSecurityLevel) { + this.classicalSecurityLevel = classicalSecurityLevel; + } + + public Integer getNistQuantumSecurityLevel() { + return nistQuantumSecurityLevel; + } + + public void setNistQuantumSecurityLevel(final Integer nistQuantumSecurityLevel) { + this.nistQuantumSecurityLevel = nistQuantumSecurityLevel; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/CertificateProperties.java b/src/main/java/org/cyclonedx/model/component/crypto/CertificateProperties.java new file mode 100644 index 000000000..4277ea344 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/CertificateProperties.java @@ -0,0 +1,100 @@ +package org.cyclonedx.model.component.crypto; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({ + "subjectName", + "issuerName", + "notValidBefore", + "notValidAfter", + "signatureAlgorithmRef", + "subjectPublicKeyRef", + "certificateFormat", + "certificateExtension" + }) +public class CertificateProperties +{ + private String subjectName; + + private String issuerName; + + private String notValidBefore; + + private String notValidAfter; + + private String signatureAlgorithmRef; + + private String subjectPublicKeyRef; + + private String certificateFormat; + + private String certificateExtension; + + public String getSubjectName() { + return subjectName; + } + + public void setSubjectName(final String subjectName) { + this.subjectName = subjectName; + } + + public String getIssuerName() { + return issuerName; + } + + public void setIssuerName(final String issuerName) { + this.issuerName = issuerName; + } + + public String getNotValidBefore() { + return notValidBefore; + } + + public void setNotValidBefore(final String notValidBefore) { + this.notValidBefore = notValidBefore; + } + + public String getNotValidAfter() { + return notValidAfter; + } + + public void setNotValidAfter(final String notValidAfter) { + this.notValidAfter = notValidAfter; + } + + public String getSignatureAlgorithmRef() { + return signatureAlgorithmRef; + } + + public void setSignatureAlgorithmRef(final String signatureAlgorithmRef) { + this.signatureAlgorithmRef = signatureAlgorithmRef; + } + + public String getSubjectPublicKeyRef() { + return subjectPublicKeyRef; + } + + public void setSubjectPublicKeyRef(final String subjectPublicKeyRef) { + this.subjectPublicKeyRef = subjectPublicKeyRef; + } + + public String getCertificateFormat() { + return certificateFormat; + } + + public void setCertificateFormat(final String certificateFormat) { + this.certificateFormat = certificateFormat; + } + + public String getCertificateExtension() { + return certificateExtension; + } + + public void setCertificateExtension(final String certificateExtension) { + this.certificateExtension = certificateExtension; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/CipherSuite.java b/src/main/java/org/cyclonedx/model/component/crypto/CipherSuite.java new file mode 100644 index 000000000..d099ce084 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/CipherSuite.java @@ -0,0 +1,44 @@ +package org.cyclonedx.model.component.crypto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({"name", "algorithms", "identifiers"}) +public class CipherSuite +{ + + private String name; + + private List algorithms; + + private List identifiers; + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public List getAlgorithms() { + return algorithms; + } + + public void setAlgorithms(final List algorithms) { + this.algorithms = algorithms; + } + + public List getIdentifiers() { + return identifiers; + } + + public void setIdentifiers(final List identifiers) { + this.identifiers = identifiers; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/CryptoProperties.java b/src/main/java/org/cyclonedx/model/component/crypto/CryptoProperties.java new file mode 100644 index 000000000..ea081d488 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/CryptoProperties.java @@ -0,0 +1,80 @@ +package org.cyclonedx.model.component.crypto; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.cyclonedx.model.component.crypto.enums.AssetType; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({ + "assetType", + "algorithmProperties", + "certificateProperties", + "relatedCryptoMaterialProperties", + "protocolProperties", + "oid" +}) +public class CryptoProperties +{ + + private AssetType assetType; + + private AlgorithmProperties algorithmProperties; + + private CertificateProperties certificateProperties; + + private RelatedCryptoMaterialProperties relatedCryptoMaterialProperties; + + private ProtocolProperties protocolProperties; + + private String oid; + + public AssetType getAssetType() { + return assetType; + } + + public void setAssetType(final AssetType assetType) { + this.assetType = assetType; + } + + public AlgorithmProperties getAlgorithmProperties() { + return algorithmProperties; + } + + public void setAlgorithmProperties(final AlgorithmProperties algorithmProperties) { + this.algorithmProperties = algorithmProperties; + } + + public CertificateProperties getCertificateProperties() { + return certificateProperties; + } + + public void setCertificateProperties(final CertificateProperties certificateProperties) { + this.certificateProperties = certificateProperties; + } + + public RelatedCryptoMaterialProperties getRelatedCryptoMaterialProperties() { + return relatedCryptoMaterialProperties; + } + + public void setRelatedCryptoMaterialProperties(final RelatedCryptoMaterialProperties relatedCryptoMaterialProperties) { + this.relatedCryptoMaterialProperties = relatedCryptoMaterialProperties; + } + + public ProtocolProperties getProtocolProperties() { + return protocolProperties; + } + + public void setProtocolProperties(final ProtocolProperties protocolProperties) { + this.protocolProperties = protocolProperties; + } + + public String getOid() { + return oid; + } + + public void setOid(final String oid) { + this.oid = oid; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/CryptoRef.java b/src/main/java/org/cyclonedx/model/component/crypto/CryptoRef.java new file mode 100644 index 000000000..4fb6f6630 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/CryptoRef.java @@ -0,0 +1,16 @@ +package org.cyclonedx.model.component.crypto; + +import java.util.List; + +public class CryptoRef +{ + private List ref; + + public List getRef() { + return ref; + } + + public void setRef(final List ref) { + this.ref = ref; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/ProtocolProperties.java b/src/main/java/org/cyclonedx/model/component/crypto/ProtocolProperties.java new file mode 100644 index 000000000..db4d3bd9b --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/ProtocolProperties.java @@ -0,0 +1,65 @@ +package org.cyclonedx.model.component.crypto; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.cyclonedx.model.component.crypto.enums.ProtocolType; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({"type", "version", "cipherSuites", "ikev2TransformTypes", "cryptoRefArray"}) +public class ProtocolProperties +{ + private ProtocolType type; + + private String version; + + private List cipherSuites; + + private Map ikev2TransformTypes; + + private CryptoRef cryptoRefArray; + + public ProtocolType getType() { + return type; + } + + public void setType(final ProtocolType type) { + this.type = type; + } + + public String getVersion() { + return version; + } + + public void setVersion(final String version) { + this.version = version; + } + + public List getCipherSuites() { + return cipherSuites; + } + + public void setCipherSuites(final List cipherSuites) { + this.cipherSuites = cipherSuites; + } + + public Map getIkev2TransformTypes() { + return ikev2TransformTypes; + } + + public void setIkev2TransformTypes(final Map ikev2TransformTypes) { + this.ikev2TransformTypes = ikev2TransformTypes; + } + + public CryptoRef getCryptoRefArray() { + return cryptoRefArray; + } + + public void setCryptoRefArray(final CryptoRef cryptoRefArray) { + this.cryptoRefArray = cryptoRefArray; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/RelatedCryptoMaterialProperties.java b/src/main/java/org/cyclonedx/model/component/crypto/RelatedCryptoMaterialProperties.java new file mode 100644 index 000000000..484240bee --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/RelatedCryptoMaterialProperties.java @@ -0,0 +1,126 @@ +package org.cyclonedx.model.component.crypto; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.cyclonedx.model.component.crypto.enums.RelatedCryptoMaterialType; +import org.cyclonedx.model.component.crypto.enums.State; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({ + "type", "id", "state", "algorithmRef", "creationDate", + "activationDate", "updateDate", "expirationDate", "value", + "size", "format", "securedBy" +}) +public class RelatedCryptoMaterialProperties +{ + private RelatedCryptoMaterialType type; + private String id; + private State state; + private String algorithmRef; + private String creationDate; + private String activationDate; + private String updateDate; + private String expirationDate; + private String value; + private Integer size; + private String format; + private SecuredBy securedBy; + + public RelatedCryptoMaterialType getType() { + return type; + } + + public void setType(final RelatedCryptoMaterialType type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public State getState() { + return state; + } + + public void setState(final State state) { + this.state = state; + } + + public String getAlgorithmRef() { + return algorithmRef; + } + + public void setAlgorithmRef(final String algorithmRef) { + this.algorithmRef = algorithmRef; + } + + public String getCreationDate() { + return creationDate; + } + + public void setCreationDate(final String creationDate) { + this.creationDate = creationDate; + } + + public String getActivationDate() { + return activationDate; + } + + public void setActivationDate(final String activationDate) { + this.activationDate = activationDate; + } + + public String getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(final String updateDate) { + this.updateDate = updateDate; + } + + public String getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(final String expirationDate) { + this.expirationDate = expirationDate; + } + + public String getValue() { + return value; + } + + public void setValue(final String value) { + this.value = value; + } + + public Integer getSize() { + return size; + } + + public void setSize(final Integer size) { + this.size = size; + } + + public String getFormat() { + return format; + } + + public void setFormat(final String format) { + this.format = format; + } + + public SecuredBy getSecuredBy() { + return securedBy; + } + + public void setSecuredBy(final SecuredBy securedBy) { + this.securedBy = securedBy; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/SecuredBy.java b/src/main/java/org/cyclonedx/model/component/crypto/SecuredBy.java new file mode 100644 index 000000000..bfecf51a9 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/SecuredBy.java @@ -0,0 +1,31 @@ +package org.cyclonedx.model.component.crypto; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonPropertyOrder({"", "mechanism", "algorithmRef"}) +public class SecuredBy +{ + private String mechanism; + + private String algorithmRef; + + public String getMechanism() { + return mechanism; + } + + public void setMechanism(final String mechanism) { + this.mechanism = mechanism; + } + + public String getAlgorithmRef() { + return algorithmRef; + } + + public void setAlgorithmRef(final String algorithmRef) { + this.algorithmRef = algorithmRef; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/AssetType.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/AssetType.java new file mode 100644 index 000000000..196f7a8bf --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/AssetType.java @@ -0,0 +1,24 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum AssetType { + @JsonProperty("algorithm") + ALGORITHM("algorithm"), + @JsonProperty("certificate") + CERTIFICATE("certificate"), + @JsonProperty("protocol") + PROTOCOL("protocol"), + @JsonProperty("related-crypto-material") + RELATED_CRYPTO_MATERIAL("related-crypto-material"); + + private final String name; + + AssetType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/CertificationLevel.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/CertificationLevel.java new file mode 100644 index 000000000..374cfe6c6 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/CertificationLevel.java @@ -0,0 +1,87 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.cyclonedx.model.LifecycleChoice.Phase; + +public enum CertificationLevel +{ + @JsonProperty("none") + NONE("none"), + @JsonProperty("fips140-1-l1") + FIPS140_1_L1("fips140-1-l1"), + @JsonProperty("fips140-1-l2") + FIPS140_1_L2("fips140-1-l2"), + @JsonProperty("fips140-1-l3") + FIPS140_1_L3("fips140-1-l3"), + @JsonProperty("fips140-1-l4") + FIPS140_1_L4("fips140-1-l4"), + @JsonProperty("fips140-2-l1") + FIPS140_2_L1("fips140-2-l1"), + @JsonProperty("fips140-2-l2") + FIPS140_2_L2("fips140-2-l2"), + @JsonProperty("fips140-2-l3") + FIPS140_2_L3("fips140-2-l3"), + @JsonProperty("fips140-2-l4") + FIPS140_2_L4("fips140-2-l4"), + @JsonProperty("fips140-3-l1") + FIPS140_3_L1("fips140-3-l1"), + @JsonProperty("fips140-3-l2") + FIPS140_3_L2("fips140-3-l2"), + @JsonProperty("fips140-3-l3") + FIPS140_3_L3("fips140-3-l3"), + @JsonProperty("fips140-3-l4") + FIPS140_3_L4("fips140-3-l4"), + @JsonProperty("cc-eal1") + CC_EAL1("cc-eal1"), + @JsonProperty("cc-eal1+") + CC_EAL1_PLUS("cc-eal1+"), + @JsonProperty("cc-eal2") + CC_EAL2("cc-eal2"), + @JsonProperty("cc-eal2+") + CC_EAL2_PLUS("cc-eal2+"), + @JsonProperty("cc-eal3") + CC_EAL3("cc-eal3"), + @JsonProperty("cc-eal3+") + CC_EAL3_PLUS("cc-eal3+"), + @JsonProperty("cc-eal4") + CC_EAL4("cc-eal4"), + @JsonProperty("cc-eal4+") + CC_EAL4_PLUS("cc-eal4+"), + @JsonProperty("cc-eal5") + CC_EAL5("cc-eal5"), + @JsonProperty("cc-eal5+") + CC_EAL5_PLUS("cc-eal5+"), + @JsonProperty("cc-eal6") + CC_EAL6("cc-eal6"), + @JsonProperty("cc-eal6+") + CC_EAL6_PLUS("cc-eal6+"), + @JsonProperty("cc-eal7") + CC_EAL7("cc-eal7"), + @JsonProperty("cc-eal7+") + CC_EAL7_PLUS("cc-eal7+"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + CertificationLevel(String name) { + this.name = name; + } + + @JsonCreator + public static CertificationLevel fromString(String value) { + for (CertificationLevel level : CertificationLevel.values()) { + if (level.name.equalsIgnoreCase(value)) { + return level; + } + } + throw new IllegalArgumentException("Invalid level: " + value); + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/CryptoFunction.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/CryptoFunction.java new file mode 100644 index 000000000..60ed1deb1 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/CryptoFunction.java @@ -0,0 +1,43 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum CryptoFunction +{ + @JsonProperty("generate") + GENERATE("generate"), + @JsonProperty("keygen") + KEYGEN("keygen"), + @JsonProperty("encrypt") + ENCRYPT("encrypt"), + @JsonProperty("decrypt") + DECRYPT("decrypt"), + @JsonProperty("digest") + DIGEST("digest"), + @JsonProperty("tag") + TAG("tag"), + @JsonProperty("keyderive") + KEYDERIVE("keyderive"), + @JsonProperty("sign") + SIGN("sign"), + @JsonProperty("verify") + VERIFY("verify"), + @JsonProperty("encapsulate") + ENCAPSULATE("encapsulate"), + @JsonProperty("decapsulate") + DECAPSULATE("decapsulate"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + CryptoFunction(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/ExecutionEnvironment.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/ExecutionEnvironment.java new file mode 100644 index 000000000..4f3b4c0af --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/ExecutionEnvironment.java @@ -0,0 +1,30 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum ExecutionEnvironment +{ + @JsonProperty("software-plain-ram") + SOFTWARE_PLAIN_RAM("software-plain-ram"), + @JsonProperty("software-encrypted-ram") + SOFTWARE_ENCRYPTED_RAM("software-encrypted-ram"), + @JsonProperty("software-tee") + SOFTWARE_TEE("software-tee"), + @JsonProperty("hardware") + HARDWARE("hardware"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + + private final String name; + + ExecutionEnvironment(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/FipsLevel.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/FipsLevel.java new file mode 100644 index 000000000..df0ec509d --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/FipsLevel.java @@ -0,0 +1,43 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum FipsLevel +{ + @JsonProperty("none") + NONE("none"), + @JsonProperty("fips140-1-l1") + FIPS140_1_L1("fips140-1-l1"), + @JsonProperty("fips140-1-l2") + FIPS140_1_L2("fips140-1-l2"), + @JsonProperty("fips140-1-l3") + FIPS140_1_L3("fips140-1-l3"), + @JsonProperty("fips140-1-l4") + FIPS140_1_L4("fips140-1-l4"), + @JsonProperty("fips140-2-l1") + FIPS140_2_L1("fips140-2-l1"), + @JsonProperty("fips140-2-l2") + FIPS140_2_L2("fips140-2-l2"), + @JsonProperty("fips140-2-l3") + FIPS140_2_L3("fips140-2-l3"), + @JsonProperty("fips140-2-l4") + FIPS140_2_L4("fips140-2-l4"), + @JsonProperty("fips140-3-l1") + FIPS140_3_L1("fips140-3-l1"), + @JsonProperty("fips140-3-l2") + FIPS140_3_L2("fips140-3-l2"), + @JsonProperty("fips140-3-l3") + FIPS140_3_L3("fips140-3-l3"), + @JsonProperty("fips140-3-l4") + FIPS140_3_L4("fips140-3-l4"); + + private final String name; + + FipsLevel(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/ImplementationPlatform.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/ImplementationPlatform.java new file mode 100644 index 000000000..b1f1a0607 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/ImplementationPlatform.java @@ -0,0 +1,45 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum ImplementationPlatform +{ + @JsonProperty("generic") + GENERIC("generic"), + @JsonProperty("x86_32") + X86_32("x86_32"), + @JsonProperty("x86_64") + X86_64("x86_64"), + @JsonProperty("armv7-a") + ARMV7_A("armv7-a"), + @JsonProperty("armv7-m") + ARMV7_M("armv7-m"), + @JsonProperty("armv8-a") + ARMV8_A("armv8-a"), + @JsonProperty("armv8-m") + ARMV8_M("armv8-m"), + @JsonProperty("armv9-a") + ARMV9_A("armv9-a"), + @JsonProperty("armv9-m") + ARMV9_M("armv9-m"), + @JsonProperty("s390x") + S390X("s390x"), + @JsonProperty("ppc64") + PPC64("ppc64"), + @JsonProperty("ppc64le") + PPC64LE("ppc64le"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + ImplementationPlatform(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/Mechanism.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/Mechanism.java new file mode 100644 index 000000000..4e0adcc65 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/Mechanism.java @@ -0,0 +1,27 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Mechanism +{ + @JsonProperty("HSM") + HSM("HSM"), + @JsonProperty("TPM") + TPM("TPM"), + @JsonProperty("SGX") + SGX("SGX"), + @JsonProperty("Software") + SOFTWARE("Software"), + @JsonProperty("None") + NONE("None"); + + private final String name; + + Mechanism(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/MemoryType.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/MemoryType.java new file mode 100644 index 000000000..99889c3e4 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/MemoryType.java @@ -0,0 +1,29 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum MemoryType +{ + @JsonProperty("rom") + ROM("rom"), + @JsonProperty("flash") + FLASH("flash"), + @JsonProperty("eeprom") + EEPROM("eeprom"), + @JsonProperty("ram") + RAM("ram"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + MemoryType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/Mode.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/Mode.java new file mode 100644 index 000000000..ffc870859 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/Mode.java @@ -0,0 +1,35 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Mode +{ + @JsonProperty("cbc") + CBC("cbc"), + @JsonProperty("ecb") + ECB("ecb"), + @JsonProperty("ccm") + CCM("ccm"), + @JsonProperty("gcm") + GCM("gcm"), + @JsonProperty("cfb") + CFB("cfb"), + @JsonProperty("ofb") + OFB("ofb"), + @JsonProperty("ctr") + CTR("ctr"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + Mode(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/Padding.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/Padding.java new file mode 100644 index 000000000..a79286b2b --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/Padding.java @@ -0,0 +1,31 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Padding +{ + @JsonProperty("pkcs5") + PKCS5("pkcs5"), + @JsonProperty("pkcs7") + PKCS7("pkcs7"), + @JsonProperty("pkcs1v15") + PKCS1V15("pkcs1v15"), + @JsonProperty("oaep") + OAEP("oaep"), + @JsonProperty("raw") + RAW("raw"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + Padding(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/Primitive.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/Primitive.java new file mode 100644 index 000000000..47971e6b9 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/Primitive.java @@ -0,0 +1,47 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Primitive +{ + @JsonProperty("drbg") + DRBG("drbg"), + @JsonProperty("mac") + MAC("mac"), + @JsonProperty("block-cipher") + BLOCK_CIPHER("block-cipher"), + @JsonProperty("stream-cipher") + STREAM_CIPHER("stream-cipher"), + @JsonProperty("signature") + SIGNATURE("signature"), + @JsonProperty("hash") + HASH("hash"), + @JsonProperty("pke") + PKE("pke"), + @JsonProperty("xof") + XOF("xof"), + @JsonProperty("kdf") + KDF("kdf"), + @JsonProperty("key-agree") + KEY_AGREE("key-agree"), + @JsonProperty("kem") + KEM("kem"), + @JsonProperty("ae") + AE("ae"), + @JsonProperty("combiner") + COMBINER("combiner"), + @JsonProperty("other") + OTHER("other"), + @JsonProperty("unknown") + UNKNOWN("unknown"); + + private final String name; + + Primitive(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/ProtocolType.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/ProtocolType.java new file mode 100644 index 000000000..d94c8f694 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/ProtocolType.java @@ -0,0 +1,39 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum ProtocolType +{ + @JsonProperty("tls") + TLS("tls", "Transport Layer Security"), + @JsonProperty("ssh") + SSH("ssh", "Secure Shell"), + @JsonProperty("ipsec") + IPSEC("ipsec", "Internet Protocol Security"), + @JsonProperty("ike") + IKE("ike", "Internet Key Exchange"), + @JsonProperty("sstp") + SSTP("sstp", "Secure Socket Tunneling Protocol"), + @JsonProperty("wpa") + WPA("wpa", "Wi-Fi Protected Access"), + @JsonProperty("other") + OTHER("other", "Another protocol type"), + @JsonProperty("unknown") + UNKNOWN("unknown", "The protocol type is not known"); + + private final String name; + private final String description; + + ProtocolType(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/RelatedCryptoMaterialType.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/RelatedCryptoMaterialType.java new file mode 100644 index 000000000..cacce9243 --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/RelatedCryptoMaterialType.java @@ -0,0 +1,61 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum RelatedCryptoMaterialType +{ + @JsonProperty("private-key") + PRIVATE_KEY("private-key", "The type for the related cryptographic material: Private Key"), + @JsonProperty("public-key") + PUBLIC_KEY("public-key", "The type for the related cryptographic material: Public Key"), + @JsonProperty("secret-key") + SECRET_KEY("secret-key", "The type for the related cryptographic material: Secret Key"), + @JsonProperty("key") + KEY("key", "The type for the related cryptographic material: Key"), + @JsonProperty("ciphertext") + CIPHERTEXT("ciphertext", "The type for the related cryptographic material: Ciphertext"), + @JsonProperty("signature") + SIGNATURE("signature", "The type for the related cryptographic material: Signature"), + @JsonProperty("digest") + DIGEST("digest", "The type for the related cryptographic material: Digest"), + @JsonProperty("initialization-vector") + INITIALIZATION_VECTOR("initialization-vector", "The type for the related cryptographic material: Initialization Vector"), + @JsonProperty("nonce") + NONCE("nonce", "The type for the related cryptographic material: Nonce"), + @JsonProperty("seed") + SEED("seed", "The type for the related cryptographic material: Seed"), + @JsonProperty("salt") + SALT("salt", "The type for the related cryptographic material: Salt"), + @JsonProperty("shared-secret") + SHARED_SECRET("shared-secret", "The type for the related cryptographic material: Shared Secret"), + @JsonProperty("tag") + TAG("tag", "The type for the related cryptographic material: Tag"), + @JsonProperty("additional-data") + ADDITIONAL_DATA("additional-data", "The type for the related cryptographic material: Additional Data"), + @JsonProperty("password") + PASSWORD("password", "The type for the related cryptographic material: Password"), + @JsonProperty("credential") + CREDENTIAL("credential", "The type for the related cryptographic material: Credential"), + @JsonProperty("token") + TOKEN("token", "The type for the related cryptographic material: Token"), + @JsonProperty("other") + OTHER("other", "The type for the related cryptographic material: Other"), + @JsonProperty("unknown") + UNKNOWN("unknown", "The type for the related cryptographic material: Unknown"); + + private final String name; + private final String description; + + RelatedCryptoMaterialType(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/crypto/enums/State.java b/src/main/java/org/cyclonedx/model/component/crypto/enums/State.java new file mode 100644 index 000000000..8d38f656f --- /dev/null +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/State.java @@ -0,0 +1,35 @@ +package org.cyclonedx.model.component.crypto.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum State +{ + @JsonProperty("pre-activation") +PRE_ACTIVATION("pre-activation", "Key state: Pre-activation"), + @JsonProperty("active") + ACTIVE("active", "Key state: Active"), + @JsonProperty("suspended") + SUSPENDED("suspended", "Key state: Suspended"), + @JsonProperty("deactivated") + DEACTIVATED("deactivated", "Key state: Deactivated"), + @JsonProperty("compromised") + COMPROMISED("compromised", "Key state: Compromised"), + @JsonProperty("destroyed") + DESTROYED("destroyed", "Key state: Destroyed"); + + private final String name; + private final String description; + + State(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} diff --git a/src/main/java/org/cyclonedx/model/component/evidence/Occurrence.java b/src/main/java/org/cyclonedx/model/component/evidence/Occurrence.java index 895f0ca35..c7ab8f4b8 100644 --- a/src/main/java/org/cyclonedx/model/component/evidence/Occurrence.java +++ b/src/main/java/org/cyclonedx/model/component/evidence/Occurrence.java @@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import org.cyclonedx.Version; import org.cyclonedx.model.ExtensibleElement; +import org.cyclonedx.model.VersionFilter; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_EMPTY) @@ -16,6 +18,18 @@ public class Occurrence extends ExtensibleElement private String location; + @VersionFilter(value = Version.VERSION_16) + private Integer line; + + @VersionFilter(value = Version.VERSION_16) + private Integer offset; + + @VersionFilter(value = Version.VERSION_16) + private Integer symbol; + + @VersionFilter(value = Version.VERSION_16) + private String additionalContext; + public String getBomRef() { return bomRef; } @@ -31,4 +45,36 @@ public String getLocation() { public void setLocation(final String location) { this.location = location; } + + public Integer getLine() { + return line; + } + + public void setLine(final Integer line) { + this.line = line; + } + + public Integer getOffset() { + return offset; + } + + public void setOffset(final Integer offset) { + this.offset = offset; + } + + public Integer getSymbol() { + return symbol; + } + + public void setSymbol(final Integer symbol) { + this.symbol = symbol; + } + + public String getAdditionalContext() { + return additionalContext; + } + + public void setAdditionalContext(final String additionalContext) { + this.additionalContext = additionalContext; + } } diff --git a/src/main/java/org/cyclonedx/util/deserializer/CertificationLevelDeserializer.java b/src/main/java/org/cyclonedx/util/deserializer/CertificationLevelDeserializer.java new file mode 100644 index 000000000..344220158 --- /dev/null +++ b/src/main/java/org/cyclonedx/util/deserializer/CertificationLevelDeserializer.java @@ -0,0 +1,27 @@ +package org.cyclonedx.util.deserializer; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import org.cyclonedx.model.component.crypto.enums.CertificationLevel; + +public class CertificationLevelDeserializer + extends JsonDeserializer +{ + @Override + public CertificationLevel deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonNode node = parser.getCodec().readTree(parser); + + JsonNode certificationLevelNode = node.has("certificationLevel") ? node.get("certificationLevel") : node; + + if (certificationLevelNode.isArray()) { + return CertificationLevel.fromString(certificationLevelNode.get(0).asText()); + } + else { + return CertificationLevel.fromString(certificationLevelNode.asText()); + } + } +} \ No newline at end of file