Skip to content

Commit 0e8ed10

Browse files
committed
Release 25.1-2 (#17)
1 parent 83ee2a9 commit 0e8ed10

File tree

139 files changed

+16211
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+16211
-3
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* This project is licensed as below.
3+
*
4+
* **************************************************************************
5+
*
6+
* Copyright 2020-2025 Altera Corporation. All Rights Reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
* **************************************************************************
31+
*/
32+
33+
package com.intel.bkp.command.messages.sigma;
34+
35+
import com.intel.bkp.command.logger.ILogger;
36+
import com.intel.bkp.utils.interfaces.BytesConvertible;
37+
import lombok.Getter;
38+
import lombok.Setter;
39+
40+
import java.nio.ByteBuffer;
41+
42+
@Getter
43+
@Setter
44+
public class CreateAttestationSubKeyMessage implements BytesConvertible, ILogger {
45+
46+
private byte[] reservedHeader = new byte[0];
47+
private byte[] magic = new byte[0];
48+
private byte[] reserved1 = new byte[0];
49+
private byte[] verifierDhPubKey = new byte[0];
50+
private byte[] attestationCertificateType = new byte[0];
51+
private byte[] reserved2 = new byte[0];
52+
private byte[] verifierInputContext = new byte[0];
53+
private byte[] verifierCounter = new byte[0];
54+
private byte[] userKeyChain = new byte[0];
55+
56+
@Override
57+
public byte[] array() {
58+
return ByteBuffer.allocate(
59+
reservedHeader.length
60+
+ magic.length
61+
+ reserved1.length
62+
+ verifierDhPubKey.length
63+
+ attestationCertificateType.length
64+
+ reserved2.length
65+
+ verifierInputContext.length
66+
+ verifierCounter.length
67+
+ userKeyChain.length)
68+
.put(reservedHeader)
69+
.put(magic)
70+
.put(reserved1)
71+
.put(verifierDhPubKey)
72+
.put(attestationCertificateType)
73+
.put(reserved2)
74+
.put(verifierInputContext)
75+
.put(verifierCounter)
76+
.put(userKeyChain)
77+
.array();
78+
}
79+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
* This project is licensed as below.
3+
*
4+
* **************************************************************************
5+
*
6+
* Copyright 2020-2025 Altera Corporation. All Rights Reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
* **************************************************************************
31+
*/
32+
33+
package com.intel.bkp.command.messages.sigma;
34+
35+
import com.intel.bkp.core.manufacturing.model.PufType;
36+
import com.intel.bkp.utils.ByteBufferSafe;
37+
import com.intel.bkp.utils.ByteSwap;
38+
39+
import java.nio.ByteBuffer;
40+
import java.util.function.Function;
41+
42+
import static com.intel.bkp.command.model.Magic.CREATE_SUBKEY;
43+
import static com.intel.bkp.utils.ByteSwapOrder.B2L;
44+
import static com.intel.bkp.utils.HexConverter.fromHex;
45+
46+
public class CreateAttestationSubKeyMessageBuilder {
47+
48+
private static final int DH_PUBLIC_KEY_LEN = 96;
49+
private static final int RESERVED1_LEN = 4;
50+
private static final int RESERVED2_LEN = 12;
51+
private static final int CONTEXT_LEN = 28;
52+
private static final int COUNTER_LEN = Integer.BYTES;
53+
54+
private final byte[] reservedHeader = new byte[Integer.BYTES];
55+
private final byte[] magic = ByteSwap.getSwappedArray(CREATE_SUBKEY.getCode(), B2L);
56+
private final byte[] reserved1 = new byte[RESERVED1_LEN];
57+
private final byte[] verifierDhPubKey = new byte[DH_PUBLIC_KEY_LEN];
58+
private final byte[] attestationCertificateType = new byte[Integer.BYTES];
59+
private final byte[] reserved2 = new byte[RESERVED2_LEN];
60+
private final byte[] verifierInputContext = new byte[CONTEXT_LEN];
61+
private final byte[] verifierCounter = new byte[COUNTER_LEN];
62+
private byte[] userKeyChain = new byte[0];
63+
64+
public CreateAttestationSubKeyMessageBuilder verifierDhPubKey(byte[] verifierDhPubKey) {
65+
ByteBufferSafe.wrap(verifierDhPubKey).getAll(this.verifierDhPubKey);
66+
return this;
67+
}
68+
69+
public CreateAttestationSubKeyMessageBuilder pufType(PufType pufType) {
70+
byte[] pufTypeArray =
71+
ByteSwap.getSwappedArray(pufType.ordinal(), B2L);
72+
ByteBufferSafe.wrap(pufTypeArray).getAll(this.attestationCertificateType);
73+
return this;
74+
}
75+
76+
public CreateAttestationSubKeyMessageBuilder context(String context) {
77+
ByteBuffer.allocate(CONTEXT_LEN)
78+
.put(fromHex(context))
79+
.rewind()
80+
.get(this.verifierInputContext);
81+
return this;
82+
}
83+
84+
public CreateAttestationSubKeyMessageBuilder counter(int counter) {
85+
byte[] swapped = ByteSwap.getSwappedArray(counter, B2L);
86+
ByteBufferSafe.wrap(swapped).getAll(this.verifierCounter);
87+
return this;
88+
}
89+
90+
public CreateAttestationSubKeyMessageBuilder userKeyChain(
91+
byte[] parentKeyChain, Function<byte[], byte[]> getDhEntry) {
92+
final byte[] dhEntry = getDhEntry.apply(getDataToSign());
93+
this.userKeyChain = ByteBuffer.allocate(parentKeyChain.length + dhEntry.length)
94+
.put(parentKeyChain)
95+
.put(dhEntry)
96+
.array();
97+
return this;
98+
}
99+
100+
public CreateAttestationSubKeyMessage build() {
101+
CreateAttestationSubKeyMessage message = new CreateAttestationSubKeyMessage();
102+
message.setReservedHeader(reservedHeader);
103+
message.setMagic(magic);
104+
message.setReserved1(reserved1);
105+
message.setVerifierDhPubKey(verifierDhPubKey);
106+
message.setAttestationCertificateType(attestationCertificateType);
107+
message.setReserved2(reserved2);
108+
message.setVerifierInputContext(verifierInputContext);
109+
message.setVerifierCounter(verifierCounter);
110+
message.setUserKeyChain(userKeyChain);
111+
return message;
112+
}
113+
114+
public CreateAttestationSubKeyMessageBuilder parse(byte[] message) {
115+
ByteBufferSafe buffer = ByteBufferSafe.wrap(message)
116+
.get(reservedHeader)
117+
.get(magic)
118+
.get(reserved1)
119+
.get(verifierDhPubKey)
120+
.get(attestationCertificateType)
121+
.get(reserved2)
122+
.get(verifierInputContext)
123+
.get(verifierCounter);
124+
userKeyChain = buffer.getRemaining();
125+
return this;
126+
}
127+
128+
private byte[] getDataToSign() {
129+
return ByteBuffer.allocate(
130+
magic.length
131+
+ reserved1.length
132+
+ verifierDhPubKey.length
133+
+ attestationCertificateType.length
134+
+ reserved2.length
135+
+ verifierInputContext.length
136+
+ verifierCounter.length)
137+
.put(magic)
138+
.put(reserved1)
139+
.put(verifierDhPubKey)
140+
.put(attestationCertificateType)
141+
.put(reserved2)
142+
.put(verifierInputContext)
143+
.put(verifierCounter)
144+
.array();
145+
}
146+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* This project is licensed as below.
3+
*
4+
* **************************************************************************
5+
*
6+
* Copyright 2020-2025 Altera Corporation. All Rights Reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
* **************************************************************************
31+
*/
32+
33+
package com.intel.bkp.command.messages.sigma;
34+
35+
import com.intel.bkp.command.logger.ILogger;
36+
import com.intel.bkp.utils.interfaces.BytesConvertible;
37+
import lombok.Getter;
38+
import lombok.Setter;
39+
40+
import java.nio.ByteBuffer;
41+
42+
@Getter
43+
@Setter
44+
public class GetMeasurementMessage implements BytesConvertible, ILogger {
45+
46+
private byte[] reservedHeader = new byte[0];
47+
private byte[] magic = new byte[0];
48+
private byte[] flags = new byte[0];
49+
private byte[] verifierDhPubKey = new byte[0];
50+
private byte[] attestationCertificateType = new byte[0];
51+
private byte[] reserved2 = new byte[0];
52+
private byte[] verifierInputContext = new byte[0];
53+
private byte[] verifierCounter = new byte[0];
54+
private byte[] userKeyChain = new byte[0];
55+
56+
@Override
57+
public byte[] array() {
58+
return ByteBuffer.allocate(
59+
reservedHeader.length
60+
+ magic.length
61+
+ flags.length
62+
+ verifierDhPubKey.length
63+
+ attestationCertificateType.length
64+
+ reserved2.length
65+
+ verifierInputContext.length
66+
+ verifierCounter.length
67+
+ userKeyChain.length)
68+
.put(reservedHeader)
69+
.put(magic)
70+
.put(flags)
71+
.put(verifierDhPubKey)
72+
.put(attestationCertificateType)
73+
.put(reserved2)
74+
.put(verifierInputContext)
75+
.put(verifierCounter)
76+
.put(userKeyChain)
77+
.array();
78+
}
79+
}
80+

0 commit comments

Comments
 (0)