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 index 47971e6b93..6d3b08bf6d 100644 --- a/src/main/java/org/cyclonedx/model/component/crypto/enums/Primitive.java +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/Primitive.java @@ -30,6 +30,8 @@ public enum Primitive AE("ae"), @JsonProperty("combiner") COMBINER("combiner"), + @JsonProperty("key-wrap") + KEY_WRAP("key-wrap"), @JsonProperty("other") OTHER("other"), @JsonProperty("unknown") 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 index d94c8f694f..20da55dfd2 100644 --- a/src/main/java/org/cyclonedx/model/component/crypto/enums/ProtocolType.java +++ b/src/main/java/org/cyclonedx/model/component/crypto/enums/ProtocolType.java @@ -16,6 +16,18 @@ public enum ProtocolType SSTP("sstp", "Secure Socket Tunneling Protocol"), @JsonProperty("wpa") WPA("wpa", "Wi-Fi Protected Access"), + @JsonProperty("dtls") + DTLS("dtls", "Datagram Transport Layer Security"), + @JsonProperty("quic") + QUIC("quic", "Quick UDP Internet Connections"), + @JsonProperty("eap-aka") + EAP_AKA("eap-aka", "Extensible Authentication Protocol variant"), + @JsonProperty("eap-aka-prime") + EAP_AKA_PRIME("eap-aka-prime", "Enhanced version of EAP-AKA"), + @JsonProperty("prins") + PRINS("prins", "Protection of Inter-Network Signaling"), + @JsonProperty("5g-aka") + FIVE_G_AKA("5g-aka", "Authentication and Key Agreement for 5G"), @JsonProperty("other") OTHER("other", "Another protocol type"), @JsonProperty("unknown") diff --git a/src/test/java/org/cyclonedx/parsers/JsonParserTest.java b/src/test/java/org/cyclonedx/parsers/JsonParserTest.java index d0dc354659..1d7cdaf193 100644 --- a/src/test/java/org/cyclonedx/parsers/JsonParserTest.java +++ b/src/test/java/org/cyclonedx/parsers/JsonParserTest.java @@ -55,6 +55,7 @@ import org.cyclonedx.model.component.crypto.enums.ImplementationPlatform; import org.cyclonedx.model.component.crypto.enums.Mode; import org.cyclonedx.model.component.crypto.enums.Primitive; +import org.cyclonedx.model.component.crypto.enums.ProtocolType; import org.cyclonedx.model.component.data.Content; import org.cyclonedx.model.component.evidence.Identity; import org.cyclonedx.model.component.modelCard.Considerations; @@ -866,6 +867,22 @@ public void schema16_cbom() throws Exception { CryptoFunction.TAG))); } + @Test + public void schema17_cbom_enums() throws Exception { + final Bom bom = getJsonBom("1.7/valid-cryptography-enums-1.7.json"); + + assertEquals(7, bom.getComponents().size()); + + assertEquals(Primitive.KEY_WRAP, + bom.getComponents().get(0).getCryptoProperties().getAlgorithmProperties().getPrimitive()); + + List protocolTypes = bom.getComponents().subList(1, 7).stream() + .map(c -> c.getCryptoProperties().getProtocolProperties().getType()) + .collect(Collectors.toList()); + assertEquals(Arrays.asList(ProtocolType.DTLS, ProtocolType.QUIC, ProtocolType.EAP_AKA, + ProtocolType.EAP_AKA_PRIME, ProtocolType.PRINS, ProtocolType.FIVE_G_AKA), protocolTypes); + } + @Test public void testIssue562Regression() throws Exception { final Bom bom = getJsonBom("regression/issue562.json"); diff --git a/src/test/java/org/cyclonedx/parsers/XmlParserTest.java b/src/test/java/org/cyclonedx/parsers/XmlParserTest.java index 2bd179688e..7e4791e167 100644 --- a/src/test/java/org/cyclonedx/parsers/XmlParserTest.java +++ b/src/test/java/org/cyclonedx/parsers/XmlParserTest.java @@ -55,6 +55,7 @@ import org.cyclonedx.model.component.crypto.enums.ImplementationPlatform; import org.cyclonedx.model.component.crypto.enums.Mode; import org.cyclonedx.model.component.crypto.enums.Primitive; +import org.cyclonedx.model.component.crypto.enums.ProtocolType; import org.cyclonedx.model.component.data.Content; import org.cyclonedx.model.component.evidence.Identity; import org.cyclonedx.model.component.modelCard.Considerations; @@ -998,6 +999,22 @@ public void schema16_cbom() throws Exception { CryptoFunction.TAG))); } + @Test + public void schema17_cbom_enums() throws Exception { + final Bom bom = getXmlBom("1.7/valid-cryptography-enums-1.7.xml"); + + assertEquals(7, bom.getComponents().size()); + + assertEquals(Primitive.KEY_WRAP, + bom.getComponents().get(0).getCryptoProperties().getAlgorithmProperties().getPrimitive()); + + List protocolTypes = bom.getComponents().subList(1, 7).stream() + .map(c -> c.getCryptoProperties().getProtocolProperties().getType()) + .collect(Collectors.toList()); + assertEquals(Arrays.asList(ProtocolType.DTLS, ProtocolType.QUIC, ProtocolType.EAP_AKA, + ProtocolType.EAP_AKA_PRIME, ProtocolType.PRINS, ProtocolType.FIVE_G_AKA), protocolTypes); + } + @Test public void testIssue562Regression() throws Exception { final Bom bom = getXmlBom("regression/issue562.xml"); diff --git a/src/test/resources/1.7/valid-cryptography-enums-1.7.json b/src/test/resources/1.7/valid-cryptography-enums-1.7.json new file mode 100644 index 0000000000..c7de75b4bb --- /dev/null +++ b/src/test/resources/1.7/valid-cryptography-enums-1.7.json @@ -0,0 +1,95 @@ +{ + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7", + "serialNumber": "urn:uuid:7b4c3f0e-5a1d-4c8e-9f2a-1d6e8b3c4a70", + "version": 1, + "components": [ + { + "type": "cryptographic-asset", + "bom-ref": "aes-128-kw", + "name": "AES-128-KW", + "cryptoProperties": { + "assetType": "algorithm", + "algorithmProperties": { + "primitive": "key-wrap", + "algorithmFamily": "AES", + "parameterSetIdentifier": "128", + "cryptoFunctions": [ + "encrypt", + "decrypt" + ] + }, + "oid": "2.16.840.1.101.3.4.1.5" + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "protocol-dtls", + "name": "DTLS", + "cryptoProperties": { + "assetType": "protocol", + "protocolProperties": { + "type": "dtls", + "version": "1.3" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "protocol-quic", + "name": "QUIC", + "cryptoProperties": { + "assetType": "protocol", + "protocolProperties": { + "type": "quic", + "version": "1" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "protocol-eap-aka", + "name": "EAP-AKA", + "cryptoProperties": { + "assetType": "protocol", + "protocolProperties": { + "type": "eap-aka" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "protocol-eap-aka-prime", + "name": "EAP-AKA-PRIME", + "cryptoProperties": { + "assetType": "protocol", + "protocolProperties": { + "type": "eap-aka-prime" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "protocol-prins", + "name": "PRINS", + "cryptoProperties": { + "assetType": "protocol", + "protocolProperties": { + "type": "prins" + } + } + }, + { + "type": "cryptographic-asset", + "bom-ref": "protocol-5g-aka", + "name": "5G-AKA", + "cryptoProperties": { + "assetType": "protocol", + "protocolProperties": { + "type": "5g-aka" + } + } + } + ] +} diff --git a/src/test/resources/1.7/valid-cryptography-enums-1.7.xml b/src/test/resources/1.7/valid-cryptography-enums-1.7.xml new file mode 100644 index 0000000000..e9807ba1d2 --- /dev/null +++ b/src/test/resources/1.7/valid-cryptography-enums-1.7.xml @@ -0,0 +1,80 @@ + + + + + AES-128-KW + + algorithm + + key-wrap + AES + 128 + + encrypt + decrypt + + + 2.16.840.1.101.3.4.1.5 + + + + DTLS + + protocol + + dtls + 1.3 + + + + + QUIC + + protocol + + quic + 1 + + + + + EAP-AKA + + protocol + + eap-aka + + + + + EAP-AKA-PRIME + + protocol + + eap-aka-prime + + + + + PRINS + + protocol + + prins + + + + + 5G-AKA + + protocol + + 5g-aka + + + + +