Skip to content

Commit ded9f57

Browse files
authored
Restore CON-1135
# changes - Restore changes to gradle plugin that were inadvertently reverted by release merge #109.
1 parent b7e1422 commit ded9f57

File tree

4 files changed

+61
-21
lines changed

4 files changed

+61
-21
lines changed

docs/docs/enclave-configuration.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,28 @@ The path should be absolute or relative to the root of the enclave module.
316316
when building on Windows and macOS platforms. Additionally, on Windows, paths must use forwardslashes rather than
317317
the usual backslashes.
318318

319+
## Enclave build process
320+
321+
The Conclave gradle plugin automates the process of building a Conclave enclave and packaging it so that it can be
322+
instantiated elsewhere in a project.
323+
324+
### Code hash and signer output
325+
326+
When a Conclave enclave is built, information about the enclave is printed during the build process:
327+
328+
```
329+
Enclave code hash: 4BEF016A8D35E04FCCFDDB725CE678C29A3FC284F47723869961334CED4C2A55
330+
Enclave code signer: 4924CA3A9C8241A3C0AA1A24A407AA86401D2B79FA9FF84932DA798A942166D4
331+
Enclave mode: SIMULATION (INSECURE)
332+
```
333+
334+
These values can then be used by attesting parties as part of an [enclave constraints](constraints.md) string.
335+
336+
The code hash and signer are also written to files in the enclave module build directory at the following paths:
337+
338+
- Code hash: `<enclave-module-dir>/build/conclave/<enclave-mode>/mrenclave`
339+
- Code signer: `<enclave-module-dir>/build/conclave/<enclave-mode>/mrsigner`
340+
319341
## Assisted configuration of Native Image builds
320342

321343
You can generate the reflection and serialization configuration files by using the

docs/docs/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release notes
22

3+
## 1.3.1
4+
1. To make deploying enclaves built with conclave easier, files containing the enclave code hash and signer are now
5+
generated when an enclave is built. See [here](enclave-configuration.md#enclave-build-process) for more information.
6+
37
## 1.3
48

59
1. :tada: **The Conclave Core SDK is now open source!** :tada: Read our

plugin-enclave-gradle/src/main/kotlin/com/r3/conclave/plugin/enclave/gradle/GenerateEnclaveMetadata.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.r3.conclave.plugin.enclave.gradle
22

3+
import com.r3.conclave.utilities.internal.toHexString
34
import org.gradle.api.file.RegularFileProperty
45
import org.gradle.api.model.ObjectFactory
56
import org.gradle.api.tasks.InputFile
7+
import org.gradle.api.tasks.OutputFile
68
import org.gradle.internal.os.OperatingSystem
79
import javax.inject.Inject
810
import kotlin.io.path.absolutePathString
@@ -16,6 +18,12 @@ open class GenerateEnclaveMetadata @Inject constructor(
1618
@get:InputFile
1719
val inputSignedEnclave: RegularFileProperty = objects.fileProperty()
1820

21+
@get:OutputFile
22+
val mrsignerOutputFile: RegularFileProperty = objects.fileProperty()
23+
24+
@get:OutputFile
25+
val mrenclaveOutputFile: RegularFileProperty = objects.fileProperty()
26+
1927
override fun action() {
2028
val metadataFile = temporaryDir.toPath().resolve("enclave_metadata.txt")
2129

@@ -40,6 +48,10 @@ open class GenerateEnclaveMetadata @Inject constructor(
4048
}
4149

4250
val enclaveMetadata = EnclaveMetadata.parseMetadataFile(metadataFile)
51+
52+
mrsignerOutputFile.asFile.get().writeText(enclaveMetadata.mrsigner.bytes.toHexString().uppercase())
53+
mrenclaveOutputFile.asFile.get().writeText(enclaveMetadata.mrenclave.bytes.toHexString().uppercase())
54+
4355
logger.lifecycle("Enclave code hash: ${enclaveMetadata.mrenclave}")
4456
logger.lifecycle("Enclave code signer: ${enclaveMetadata.mrsigner}")
4557

plugin-enclave-gradle/src/main/kotlin/com/r3/conclave/plugin/enclave/gradle/GradleEnclavePlugin.kt

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -371,32 +371,34 @@ class GradleEnclavePlugin @Inject constructor(private val layout: ProjectLayout)
371371
type,
372372
linuxExec
373373
) { task ->
374-
val signingTask = enclaveExtension.signingType.map {
375-
when (it) {
376-
SigningType.DummyKey -> signEnclaveWithKeyTask
377-
SigningType.PrivateKey -> signEnclaveWithKeyTask
378-
else -> addEnclaveSignatureTask
379-
}
374+
val signingTask = enclaveExtension.signingType.map {
375+
when (it) {
376+
SigningType.DummyKey -> signEnclaveWithKeyTask
377+
SigningType.PrivateKey -> signEnclaveWithKeyTask
378+
else -> addEnclaveSignatureTask
380379
}
381-
task.dependsOn(signingTask)
382-
val signedEnclaveFile = enclaveExtension.signingType.flatMap {
383-
when (it) {
384-
SigningType.DummyKey -> signEnclaveWithKeyTask.outputSignedEnclave
385-
SigningType.PrivateKey -> signEnclaveWithKeyTask.outputSignedEnclave
386-
else -> {
387-
if (!enclaveExtension.mrsignerPublicKey.isPresent) {
388-
throwMissingConfigForExternalSigning("mrsignerPublicKey")
389-
}
390-
if (!enclaveExtension.mrsignerSignature.isPresent) {
391-
throwMissingConfigForExternalSigning("mrsignerSignature")
392-
}
393-
addEnclaveSignatureTask.outputSignedEnclave
380+
}
381+
task.dependsOn(signingTask)
382+
val signedEnclaveFile = enclaveExtension.signingType.flatMap {
383+
when (it) {
384+
SigningType.DummyKey -> signEnclaveWithKeyTask.outputSignedEnclave
385+
SigningType.PrivateKey -> signEnclaveWithKeyTask.outputSignedEnclave
386+
else -> {
387+
if (!enclaveExtension.mrsignerPublicKey.isPresent) {
388+
throwMissingConfigForExternalSigning("mrsignerPublicKey")
389+
}
390+
if (!enclaveExtension.mrsignerSignature.isPresent) {
391+
throwMissingConfigForExternalSigning("mrsignerSignature")
394392
}
393+
addEnclaveSignatureTask.outputSignedEnclave
395394
}
396395
}
397-
task.inputSignedEnclave.set(signedEnclaveFile)
398-
task.inputs.files(signedEnclaveFile)
399396
}
397+
task.inputSignedEnclave.set(signedEnclaveFile)
398+
task.inputs.files(signedEnclaveFile)
399+
task.mrsignerOutputFile.set(enclaveDirectory.resolve("mrsigner").toFile())
400+
task.mrenclaveOutputFile.set(enclaveDirectory.resolve("mrenclave").toFile())
401+
}
400402

401403
val buildSignedEnclaveTask = target.createTask<BuildSignedEnclave>("buildSignedEnclave$type") { task ->
402404
task.dependsOn(generateEnclaveMetadataTask)

0 commit comments

Comments
 (0)