-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/runtime/host/sgx: Add support for SIGSTRUCTs
For now this will just generate one, signed with the same key that `runtime-loader` used to use (the Fortanix dummy key), but this will also support using file backed signatures, once we have an idea on how we are going to handle the process for such things.
- Loading branch information
Showing
4 changed files
with
129 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go/runtime/host/sgx: Add support for SIGSTRUCTs | ||
|
||
For now this will just generate one, signed with the same key that | ||
`runtime-loader` used to use (the Fortanix dummy key), but this will | ||
also support using file backed signatures, once we have an idea on how | ||
we are going to handle the process for such things. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package sigstruct | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/oasislabs/oasis-core/go/common/sgx" | ||
) | ||
|
||
// UnsafeDebugForEnclave returns the SIGSTRUCT corresponding to the provided | ||
// SGX enclave binary, signed using the Fortanix Rust SDK's dummy signing key. | ||
// | ||
// This routine is deterministic, and MUST only ever be used for testing. | ||
func UnsafeDebugForEnclave(sgxs []byte) ([]byte, error) { | ||
// Note: The key is unavailable unless DontBlameOasis is enabled. | ||
signingKey := sgx.UnsafeFortanixDummyKey() | ||
if signingKey == nil { | ||
return nil, fmt.Errorf("sgx/sigstruct: debug signing key unavailable") | ||
} | ||
|
||
var enclaveHash sgx.MrEnclave | ||
if err := enclaveHash.FromSgxsBytes(sgxs); err != nil { | ||
return nil, fmt.Errorf("sgx/sigstruct: failed to derive EnclaveHash: %w", err) | ||
} | ||
|
||
builder := New( | ||
WithAttributes(sgx.Attributes{ | ||
Flags: sgx.AttributeDebug | sgx.AttributeMode64Bit, | ||
Xfrm: 3, // X87, SSE ("XFRM[1:0] must be set to 0x3") | ||
}), | ||
WithAttributesMask([2]uint64{^uint64(0), ^uint64(0)}), | ||
WithEnclaveHash(enclaveHash), | ||
) | ||
|
||
ret, err := builder.Sign(signingKey) | ||
if err != nil { | ||
return nil, fmt.Errorf("sgx/sigstruct: failed to sign with test key: %w", err) | ||
} | ||
|
||
return ret, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters