Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'CT' Assertion for SCION End Entity PKI #226

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion internal/pkg/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ func (obj *Object) UnmarshalArray(in []interface{}) error {
Data: data,
}
obj.Value = co
case OTCTInfo:
data, ok := in[1].([]byte)
if !ok {
return errors.New("cbor object encoding of cert data not a byte array")
}
co := CTProof{
Data: data,
}
obj.Value = co
case OTServiceInfo:
name, ok := in[1].(string)
if !ok {
Expand Down Expand Up @@ -340,6 +349,12 @@ func (obj Object) MarshalCBOR(w *cbor.CBORWriter) error {
return fmt.Errorf("expected OTCertInfo object to be Certificate, but got: %T", obj.Value)
}
res = []interface{}{OTCertInfo, int(co.Type), int(co.Usage), int(co.HashAlgo), co.Data}
case OTCTInfo:
co, ok := obj.Value.(CTProof)
if !ok {
return fmt.Errorf("expected OTCTInfo object to be CTProof, but got: %T", obj.Value)
}
res = []interface{}{OTCTInfo, co.Data}
case OTServiceInfo:
si, ok := obj.Value.(ServiceInfo)
if !ok {
Expand Down Expand Up @@ -511,6 +526,7 @@ const (
OTNextKey Type = 13
OTScionAddr6 Type = 14
OTScionAddr4 Type = 15
OTCTInfo Type = 16
)

//ParseTypes returns the object type(s) specified in qType
Expand All @@ -534,6 +550,8 @@ func ParseTypes(qType string) ([]Type, error) {
return []Type{OTNameset}, nil
case "cert":
return []Type{OTCertInfo}, nil
case "ct":
return []Type{OTCTInfo}, nil
case "srv":
return []Type{OTServiceInfo}, nil
case "regr":
Expand Down Expand Up @@ -573,6 +591,8 @@ func (t Type) CLIString() string {
return "nameset"
case OTCertInfo:
return "cert"
case OTCTInfo:
return "ct"
case OTServiceInfo:
return "srv"
case OTRegistrar:
Expand All @@ -592,7 +612,7 @@ func (t Type) CLIString() string {
//AllTypes returns all object types.
func AllTypes() []Type {
return []Type{OTName, OTIP6Addr, OTIP4Addr, OTRedirection,
OTDelegation, OTNameset, OTCertInfo, OTServiceInfo,
OTDelegation, OTNameset, OTCertInfo, OTCTInfo, OTServiceInfo,
OTRegistrar, OTRegistrant, OTInfraKey, OTExtraKey,
OTNextKey, OTScionAddr6, OTScionAddr4}
}
Expand Down Expand Up @@ -636,6 +656,11 @@ type Certificate struct {
Data []byte
}

//CTProof contains a certificate presence/absence proof for a certain ISD
type CTProof struct {
Data []byte
}

//CompareTo compares two certificateObject objects and returns 0 if they are equal, 1 if c is greater than cert and -1 if c is smaller than cert
func (c Certificate) CompareTo(cert Certificate) int {
if c.Type < cert.Type {
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/siglib/rainsSiglib.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func checkObjectFields(objs []object.Object) bool {
return false
}
case object.OTCertInfo:
case object.OTCTInfo:
case object.OTServiceInfo:
if srvInfo, ok := obj.Value.(object.ServiceInfo); ok {
if containsZoneFileType(srvInfo.Name) {
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/util/rainslibUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func init() {
gob.Register(&section.Zone{})
gob.Register(object.ServiceInfo{})
gob.Register(object.Certificate{})
gob.Register(object.CTProof{})
gob.Register(object.Name{})
gob.Register(net.IP{})
gob.Register(&object.SCIONAddress{})
Expand Down
Loading