Skip to content

Commit

Permalink
Release 1.1.82.5 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
antkorczak authored and JakubLedworowski committed Dec 23, 2021
1 parent bb17b52 commit c578ec7
Show file tree
Hide file tree
Showing 76 changed files with 591 additions and 249 deletions.
2 changes: 1 addition & 1 deletion Verifier/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 125,7 @@ dependencies {
}

testImplementation "org.junit.jupiter:junit-jupiter-engine:${junit5_version}"
testImplementation "org.mockito:mockito-core:${mockito_version}"
testImplementation "org.mockito:mockito-inline:${mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}"
testImplementation "org.junit.platform:junit-platform-launcher:${junit5_platform_version}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 86,8 @@ void prepareSut() {
static void init() throws Exception {
aliasCert = X509_PARSER.toX509(getBytesFromFile("UDS_EFUSE_ALIAS_3AB5A0DC4DE7CB08.cer"));
firmwareCert = X509_PARSER.toX509(getBytesFromFile("FIRMWARE_3AB5A0DC4DE7CB08.cer"));
deviceIdCert = X509_PARSER.toX509(getBytesFromFile("deviceid_08cbe74ddca0b53a_7eukZEEF-nzSZWoH.cer"));
deviceIdCert = X509_PARSER.toX509(getBytesFromFile("deviceid_08cbe74ddca0b53a_7eukZEEF-nzSZWoHQrqQf53ru9A"
".cer"));
productFamilyCert = X509_PARSER.toX509(getBytesFromFile("IPCS_agilex.cer"));
rootCert = X509_PARSER.toX509(getBytesFromFile("DICE_RootCA.cer"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 65,8 @@ public class X509CertificateChainVerifierTestDiceIT {
static void init() throws Exception {
aliasCert = X509_PARSER.toX509(getBytesFromFile("UDS_EFUSE_ALIAS_3AB5A0DC4DE7CB08.cer"));
firmwareCert = X509_PARSER.toX509(getBytesFromFile("FIRMWARE_3AB5A0DC4DE7CB08.cer"));
deviceIdCert = X509_PARSER.toX509(getBytesFromFile("deviceid_08cbe74ddca0b53a_7eukZEEF-nzSZWoH.cer"));
deviceIdCert = X509_PARSER.toX509(getBytesFromFile("deviceid_08cbe74ddca0b53a_7eukZEEF-nzSZWoHQrqQf53ru9A"
".cer"));
productFamilyCert = X509_PARSER.toX509(getBytesFromFile("IPCS_agilex.cer"));
rootCert = X509_PARSER.toX509(getBytesFromFile("DICE_RootCA.cer"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 48,9 @@
import java.security.SignatureException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

public class X509CertificateUtils {

Expand Down Expand Up @@ -112,7 114,9 @@ public static boolean isSelfSigned(final X509Certificate certificate) {
*/
public static boolean containsExtension(final X509Certificate certificate, ASN1ObjectIdentifier extensionOid) {
final String oid = extensionOid.getId();
return certificate.getCriticalExtensionOIDs().contains(oid)
|| certificate.getNonCriticalExtensionOIDs().contains(oid);
final Set<String> allExtOids = new HashSet<>();
Optional.ofNullable(certificate.getCriticalExtensionOIDs()).ifPresent(allExtOids::addAll);
Optional.ofNullable(certificate.getNonCriticalExtensionOIDs()).ifPresent(allExtOids::addAll);
return allExtOids.contains(oid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 33,21 @@

package com.intel.bkp.ext.core.crl;

import com.intel.bkp.ext.utils.HexConverter;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.math.BigInteger;
import java.nio.ByteBuffer;

import static com.intel.bkp.ext.utils.HexConverter.fromHex;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CrlSerialNumberBuilder {

public static final byte CRL_VERSION_BYTE = (byte)0x01;

public static BigInteger convertToBigInteger(String deviceId) {
return convertToBigInteger(HexConverter.fromHex(deviceId));
return convertToBigInteger(fromHex(deviceId));
}

public static BigInteger convertToBigInteger(byte[] deviceId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 33,13 @@

package com.intel.bkp.ext.core.manufacturing.model;

import com.intel.bkp.ext.utils.HexConverter;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.EnumSet;
import java.util.Locale;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

/**
* The PufType enumeration.
*/
Expand All @@ -54,7 54,7 @@ public static PufType fromOrdinal(int ordinal) {
}

public static String getPufTypeHex(PufType pufType) {
return HexConverter.toHex(ByteBuffer.allocate(Integer.BYTES)
return toHex(ByteBuffer.allocate(Integer.BYTES)
.order(ByteOrder.BIG_ENDIAN)
.putInt(pufType.ordinal())
.array()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,6 @@
package com.intel.bkp.ext.core.psgcertificate.model;

import com.intel.bkp.ext.core.interfaces.IPsgFormat;
import com.intel.bkp.ext.utils.HexConverter;
import lombok.Getter;
import lombok.Setter;

Expand Down Expand Up @@ -68,8 67,4 @@ public byte[] array() {
.put(pointY)
.array();
}

public String toHex() {
return HexConverter.toHex(array());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,6 @@
package com.intel.bkp.verifier.command;

import com.intel.bkp.ext.utils.ByteBufferSafe;
import com.intel.bkp.ext.utils.HexConverter;
import com.intel.bkp.verifier.command.header.CommandHeader;
import com.intel.bkp.verifier.command.header.CommandHeaderManager;
import com.intel.bkp.verifier.interfaces.CommandLayer;
Expand All @@ -44,6 43,8 @@

import java.nio.ByteBuffer;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

@Slf4j
public class MailboxCommandLayer implements CommandLayer {

Expand All @@ -56,13 57,13 @@ public byte[] create(Message data, CommandIdentifier command) {
final byte[] dataBytes = data.array();
final byte[] header = buildCommandHeader(commandCode, getArgumentsLen(dataBytes), 0, CLIENT_IDENTIFIER);
final byte[] rawData = withAppendedHeader(dataBytes, header);
log.trace("Sending raw data for command {}: {}", command.name(), HexConverter.toHex(rawData));
log.trace("Sending raw data for command {}: {}", command.name(), toHex(rawData));
return rawData;
}

@Override
public byte[] retrieve(byte[] data, CommandIdentifier command) {
log.trace("Received raw data for response {}: {}", command.name(), HexConverter.toHex(data));
log.trace("Received raw data for response {}: {}", command.name(), toHex(data));
CommandHeaderManager.validateCommandHeaderCode(data, command.name());
return ByteBufferSafe.wrap(data).skip(COMMAND_HEADER_LEN).getRemaining();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 33,7 @@

package com.intel.bkp.verifier.command.logger;

import com.intel.bkp.ext.utils.HexConverter;
import static com.intel.bkp.ext.utils.HexConverter.toHex;

public interface ILogger {

Expand All @@ -42,6 42,6 @@ default byte[] array() {
}

default String hex() {
return HexConverter.toHex(array());
return toHex(array());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 36,6 @@
import com.intel.bkp.ext.core.manufacturing.model.PufType;
import com.intel.bkp.ext.utils.ByteBufferSafe;
import com.intel.bkp.ext.utils.ByteSwap;
import com.intel.bkp.ext.utils.HexConverter;
import com.intel.bkp.verifier.command.messages.VerifierDHCertBuilder;
import com.intel.bkp.verifier.command.messages.VerifierDhEntryManager;
import com.intel.bkp.verifier.model.RootChainType;
Expand All @@ -45,6 44,7 @@
import java.nio.ByteBuffer;

import static com.intel.bkp.ext.utils.ByteSwapOrder.B2L;
import static com.intel.bkp.ext.utils.HexConverter.fromHex;
import static com.intel.bkp.verifier.command.Magic.GET_MEASUREMENT;

@NoArgsConstructor
Expand Down Expand Up @@ -82,7 82,7 @@ public GetMeasurementMessageBuilder pufType(PufType pufType) {

public GetMeasurementMessageBuilder context(String context) {
ByteBuffer.allocate(CONTEXT_LEN)
.put(HexConverter.fromHex(context))
.put(fromHex(context))
.rewind()
.get(this.verifierInputContext);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 36,14 @@
import com.intel.bkp.ext.core.manufacturing.model.PufType;
import com.intel.bkp.ext.utils.ByteBufferSafe;
import com.intel.bkp.ext.utils.ByteSwap;
import com.intel.bkp.ext.utils.HexConverter;
import com.intel.bkp.verifier.command.messages.VerifierDHCertBuilder;
import com.intel.bkp.verifier.command.messages.VerifierDhEntryManager;
import com.intel.bkp.verifier.model.RootChainType;

import java.nio.ByteBuffer;

import static com.intel.bkp.ext.utils.ByteSwapOrder.B2L;
import static com.intel.bkp.ext.utils.HexConverter.fromHex;
import static com.intel.bkp.verifier.command.Magic.CREATE_SUBKEY;

public class CreateAttestationSubKeyMessageBuilder {
Expand Down Expand Up @@ -81,7 81,7 @@ public CreateAttestationSubKeyMessageBuilder pufType(PufType pufType) {

public CreateAttestationSubKeyMessageBuilder context(String context) {
ByteBuffer.allocate(CONTEXT_LEN)
.put(HexConverter.fromHex(context))
.put(fromHex(context))
.rewind()
.get(this.verifierInputContext);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 33,15 @@

package com.intel.bkp.verifier.command.messages.subkey;

import com.intel.bkp.ext.utils.HexConverter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.nio.file.Path;
import java.security.SecureRandom;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

@Slf4j
@NoArgsConstructor
public class VerifierChainBackupUtil {
Expand Down Expand Up @@ -76,6 77,6 @@ long getTimestamp() {
String getRandomizedHex() {
final byte[] randomized = new byte[Integer.BYTES];
new SecureRandom().nextBytes(randomized);
return HexConverter.toHex(randomized);
return toHex(randomized);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 36,11 @@
import com.intel.bkp.ext.utils.ByteBufferSafe;
import com.intel.bkp.ext.utils.ByteSwap;
import com.intel.bkp.ext.utils.ByteSwapOrder;
import com.intel.bkp.ext.utils.HexConverter;

import java.nio.ByteBuffer;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

public class DeviceStateMeasurementRecord {

private static final int FLAGS_LEN = Integer.BYTES;
Expand All @@ -57,7 58,7 @@ public DeviceStateMeasurementRecord(ByteBufferSafe buffer) {
}

public String getData() {
return HexConverter.toHex(ByteBuffer.allocate(flags.length counters.length)
return toHex(ByteBuffer.allocate(flags.length counters.length)
.put(flags)
.put(counters)
.array());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,8 @@
package com.intel.bkp.verifier.command.responses.attestation;

import com.intel.bkp.ext.utils.ByteBufferSafe;
import com.intel.bkp.ext.utils.HexConverter;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

public class UserDesignMeasurementRecord {

Expand All @@ -45,6 46,6 @@ public UserDesignMeasurementRecord(ByteBufferSafe buffer) {
}

public String getData() {
return HexConverter.toHex(measurementValue);
return toHex(measurementValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 36,11 @@
import com.intel.bkp.ext.utils.ByteBufferSafe;
import com.intel.bkp.verifier.exceptions.SigmaException;
import com.intel.bkp.verifier.model.CertificateRequestType;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

@Getter
@Setter
@Slf4j
public class GetCertificateResponseBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 34,8 @@
package com.intel.bkp.verifier.command.responses.chip;

import com.intel.bkp.ext.utils.ByteBufferSafe;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class GetChipIdResponseBuilder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 33,19 @@

package com.intel.bkp.verifier.command.responses.chip;

import lombok.Getter;
import lombok.Setter;
import com.intel.bkp.verifier.exceptions.SigmaException;

@Getter
@Setter
public class SigmaTeardownResponseBuilder {

public SigmaTeardownResponse build() {
return new SigmaTeardownResponse();
}

public SigmaTeardownResponseBuilder parse(byte[] message) {
if (message.length > 0) {
throw new SigmaException(
String.format("Message size invalid. Expected: %d, Actual: %d", 0, message.length));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 33,6 @@

package com.intel.bkp.verifier.database.repository;

import com.intel.bkp.ext.utils.HexConverter;
import com.intel.bkp.verifier.database.model.DiceRevocationCacheEntity;
import com.intel.bkp.verifier.database.table.DiceTableDefinition;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -42,6 41,8 @@
import java.sql.Connection;
import java.util.Optional;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

@Slf4j
public class DiceRevocationCacheEntityService extends CacheEntityServiceBase {

Expand All @@ -56,7 57,7 @@ public DiceRevocationCacheEntityService store(DiceRevocationCacheEntity entity)
}

public Optional<DiceRevocationCacheEntity> read(byte[] deviceId) {
final String deviceIdHex = HexConverter.toHex(deviceId);
final String deviceIdHex = toHex(deviceId);
log.debug("Reading cached entity for deviceId: {}", deviceIdHex);

return select(getResultsHandler())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 33,6 @@

package com.intel.bkp.verifier.database.repository;

import com.intel.bkp.ext.utils.HexConverter;
import com.intel.bkp.verifier.database.model.S10CacheEntity;
import com.intel.bkp.verifier.database.table.S10TableDefinition;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -42,6 41,8 @@
import java.sql.Connection;
import java.util.Optional;

import static com.intel.bkp.ext.utils.HexConverter.toHex;

@Slf4j
public class S10CacheEntityService extends CacheEntityServiceBase {

Expand All @@ -56,7 57,7 @@ public S10CacheEntityService store(S10CacheEntity entity) {
}

public Optional<S10CacheEntity> read(byte[] deviceId) {
final String deviceIdHex = HexConverter.toHex(deviceId);
final String deviceIdHex = toHex(deviceId);
log.debug("Reading cached entity for deviceId: {}", deviceIdHex);

return select(getResultsHandler())
Expand Down
Loading

0 comments on commit c578ec7

Please sign in to comment.