Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/cyclonedx/parsers/JsonParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ProtocolType> 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");
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/cyclonedx/parsers/XmlParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ProtocolType> 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");
Expand Down
95 changes: 95 additions & 0 deletions src/test/resources/1.7/valid-cryptography-enums-1.7.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
}
80 changes: 80 additions & 0 deletions src/test/resources/1.7/valid-cryptography-enums-1.7.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.7"
serialNumber="urn:uuid:7b4c3f0e-5a1d-4c8e-9f2a-1d6e8b3c4a70"
version="1"
>
<components>
<component type="cryptographic-asset" bom-ref="aes-128-kw">
<name>AES-128-KW</name>
<cryptoProperties>
<assetType>algorithm</assetType>
<algorithmProperties>
<primitive>key-wrap</primitive>
<algorithmFamily>AES</algorithmFamily>
<parameterSetIdentifier>128</parameterSetIdentifier>
<cryptoFunctions>
<cryptoFunction>encrypt</cryptoFunction>
<cryptoFunction>decrypt</cryptoFunction>
</cryptoFunctions>
</algorithmProperties>
<oid>2.16.840.1.101.3.4.1.5</oid>
</cryptoProperties>
</component>
<component type="cryptographic-asset" bom-ref="protocol-dtls">
<name>DTLS</name>
<cryptoProperties>
<assetType>protocol</assetType>
<protocolProperties>
<type>dtls</type>
<version>1.3</version>
</protocolProperties>
</cryptoProperties>
</component>
<component type="cryptographic-asset" bom-ref="protocol-quic">
<name>QUIC</name>
<cryptoProperties>
<assetType>protocol</assetType>
<protocolProperties>
<type>quic</type>
<version>1</version>
</protocolProperties>
</cryptoProperties>
</component>
<component type="cryptographic-asset" bom-ref="protocol-eap-aka">
<name>EAP-AKA</name>
<cryptoProperties>
<assetType>protocol</assetType>
<protocolProperties>
<type>eap-aka</type>
</protocolProperties>
</cryptoProperties>
</component>
<component type="cryptographic-asset" bom-ref="protocol-eap-aka-prime">
<name>EAP-AKA-PRIME</name>
<cryptoProperties>
<assetType>protocol</assetType>
<protocolProperties>
<type>eap-aka-prime</type>
</protocolProperties>
</cryptoProperties>
</component>
<component type="cryptographic-asset" bom-ref="protocol-prins">
<name>PRINS</name>
<cryptoProperties>
<assetType>protocol</assetType>
<protocolProperties>
<type>prins</type>
</protocolProperties>
</cryptoProperties>
</component>
<component type="cryptographic-asset" bom-ref="protocol-5g-aka">
<name>5G-AKA</name>
<cryptoProperties>
<assetType>protocol</assetType>
<protocolProperties>
<type>5g-aka</type>
</protocolProperties>
</cryptoProperties>
</component>
</components>
</bom>