Skip to content

Commit

Permalink
Use integer consistently for productID
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ghtym0 authored and thomasten committed Nov 19, 2020
1 parent df284df commit f1bbfcc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
12 changes: 10 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Here is an example that has only the `SecurityVersion` and `ProductID` set:
"Packages": {
"backend": {
"SecurityVersion": 1,
"ProductID": [3]
"ProductID": 3
}
},
"Infrastructures": {
Expand Down Expand Up @@ -150,4 +150,12 @@ go test ./test/ -v -tags integration --args -b ../build/ -s

```bash
go test ./test/ -v -tags integration --args -b ../build/ -s -noenclave
```
```

### Dockerimage

You can build the docker image by providing a signing key:

```bash
docker buildx build --secret id=repoaccess,src=<path to .netrc> --secret id=signingkey,src=<path to private.pem> --target release --tag ghcr.io/edgelesssys/coordinator:latest .
```
5 changes: 2 additions & 3 deletions coordinator/quote/ert.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package quote

import (
"bytes"
"strings"

"github.com/google/go-cmp/cmp"
Expand All @@ -17,7 +16,7 @@ type PackageProperties struct {
// Hash of the enclave signer's public key
SignerID string
// Product ID of the package
ProductID []byte
ProductID *uint64
// Security version number of the package
SecurityVersion *uint
}
Expand Down Expand Up @@ -46,7 +45,7 @@ func (required PackageProperties) IsCompliant(given PackageProperties) bool {
if len(required.SignerID) > 0 && !strings.EqualFold(required.SignerID, given.SignerID) {
return false
}
if len(required.ProductID) > 0 && !bytes.Equal(required.ProductID, given.ProductID[:len(required.ProductID)]) {
if required.ProductID != nil && *required.ProductID != *given.ProductID {
return false
}
if required.SecurityVersion != nil && *required.SecurityVersion > *given.SecurityVersion {
Expand Down
4 changes: 3 additions & 1 deletion coordinator/quote/ertvalidator/ertvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ertvalidator
import (
"bytes"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"fmt"

Expand Down Expand Up @@ -34,11 +35,12 @@ func (m *ERTValidator) Validate(givenQuote []byte, cert []byte, pp quote.Package
}

// Verify PackageProperties
productID := binary.LittleEndian.Uint64(report.ProductID)
reportedProps := quote.PackageProperties{
UniqueID: hex.EncodeToString(report.UniqueID),
SignerID: hex.EncodeToString(report.SignerID),
Debug: report.Debug,
ProductID: report.ProductID,
ProductID: &productID,
SecurityVersion: &report.SecurityVersion,
}
if !pp.IsCompliant(reportedProps) {
Expand Down
8 changes: 3 additions & 5 deletions docs/add-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The manifest contains a section with the information used to authenticate each s
"backend": {
"UniqueID": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"SignerID": "c0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffee",
"ProductID": [1337],
"ProductID": 1337,
"SecurityVersion": 1,
"Debug": false
},
Expand All @@ -46,9 +46,7 @@ You'll see something like this:
```json
{
"SecurityVersion": 1,
"ProductID": [
3
],
"ProductID": 3
"UniqueID": "6b2822ac2585040d4b9397675d54977a71ef292ab5b3c0a6acceca26074ae585",
"SignerID": "5826218dbe96de0d7b3b1ccf70ece51457e71e886a3d4c1f18b27576d22cdc74"
}
Expand All @@ -61,7 +59,7 @@ You can add this directly to your `manifest.json` file like so:
"backend": {
"UniqueID": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"SignerID": "c0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffee",
"ProductID": [1337],
"ProductID": 1337,
"SecurityVersion": 1,
"Debug": false
},
Expand Down
4 changes: 2 additions & 2 deletions docs/set-manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ See the following manifest for example (manifest.jso
"backend": {
"UniqueID": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"SignerID": "c0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffeec0ffee",
"ProductID": [1337],
"ProductID": 1337,
"SecurityVersion": 1,
"Debug": false
},
"frontend": {
"UniqueID": "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100",
"ProductID": [42],
"ProductID": 42,
"SecurityVersion": 3,
"Debug": true
}
Expand Down
6 changes: 2 additions & 4 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/binary"
"encoding/json"
"flag"
"fmt"
Expand Down Expand Up @@ -80,7 +79,7 @@ func updateManifest() {
SecurityVersion uint
UniqueID string
SignerID string
ProductID []uint64
ProductID uint64
}
if err := json.Unmarshal(config, &cfg); err != nil {
panic(err)
Expand All @@ -90,8 +89,7 @@ func updateManifest() {
pkg.UniqueID = cfg.UniqueID
pkg.SignerID = cfg.SignerID
pkg.SecurityVersion = &cfg.SecurityVersion
pkg.ProductID = make([]byte, 8)
binary.LittleEndian.PutUint64(pkg.ProductID, cfg.ProductID[0])
pkg.ProductID = &cfg.ProductID
manifest.Packages["backend"] = pkg
}

Expand Down
6 changes: 3 additions & 3 deletions test/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ManifestJSON string = `{
},
"frontend": {
"SignerID": "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100",
"ProductID": [44],
"ProductID": 44,
"SecurityVersion": 3,
"Debug": true
}
Expand Down Expand Up @@ -87,12 +87,12 @@ const IntegrationManifestJSON string = `{
"backend": {
"Debug": true,
"SecurityVersion": 1,
"ProductID": [3]
"ProductID": 3
},
"frontend": {
"Debug": true,
"SecurityVersion": 2,
"ProductID": [3]
"ProductID": 3
}
},
"Infrastructures": {
Expand Down
2 changes: 1 addition & 1 deletion tools/create_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def parseSignInfo(info):
m = re.findall(r"product_id=(\d+)", info)
if len(m) <= 0:
raise Exception("Couldn't find product_id in signature info")
config["ProductID"] = [int(m[0])]
config["ProductID"] = int(m[0])

m = re.findall(r"mrenclave=([abcdef\d]+)", info)
if len(m) <= 0:
Expand Down

0 comments on commit f1bbfcc

Please sign in to comment.