@@ -21,7 +21,7 @@ import (
21
21
"github.com/cloudflare/cfssl/helpers/derhelpers"
22
22
)
23
23
24
- //go:generate stringer -type=Tag,Op -output=protocol_string.go
24
+ //go:generate stringer -type=Tag,Op,ComplianceRegion -output=protocol_string.go
25
25
26
26
// Tag marks the type of an Item.
27
27
type Tag byte
@@ -51,6 +51,8 @@ const (
51
51
TagJaegerSpan Tag = 0x15
52
52
// TagReqContext contains request metadata
53
53
TagReqContext Tag = 0x16
54
+ // TagComplianceRegion implies the compliance region of the operation which can impact behavior
55
+ TagComplianceRegion Tag = 0x17
54
56
// TagPadding implies an item with a meaningless payload added for padding.
55
57
TagPadding Tag = 0x20
56
58
)
@@ -202,6 +204,16 @@ func (e Error) String() string {
202
204
}
203
205
}
204
206
207
+ // ComplianceRegion describes any guardrails that gokeyless should follow when accessing data from
208
+ // external applications
209
+ type ComplianceRegion byte
210
+
211
+ const (
212
+ // ComplianceRegionFedRAMPHigh signals that this operation should only interact
213
+ // with the FedRAMP High QS instance
214
+ ComplianceRegionFedRAMPHigh ComplianceRegion = 0x01
215
+ )
216
+
205
217
const (
206
218
paddedLength = 1024
207
219
headerSize = 8
@@ -405,30 +417,32 @@ func (p *Packet) ReadFrom(r io.Reader) (n int64, err error) {
405
417
406
418
// Operation defines a single (repeatable) keyless operation.
407
419
type Operation struct {
408
- Opcode Op
409
- Payload []byte
410
- Extra []byte
411
- SKI SKI
412
- Digest Digest
413
- ClientIP net.IP
414
- ServerIP net.IP
415
- SNI string
416
- CertID string
417
- ForwardingSvc int64
418
- CustomFuncName string
419
- JaegerSpan []byte
420
- ReqContext []byte
420
+ Opcode Op
421
+ Payload []byte
422
+ Extra []byte
423
+ SKI SKI
424
+ Digest Digest
425
+ ClientIP net.IP
426
+ ServerIP net.IP
427
+ SNI string
428
+ CertID string
429
+ ForwardingSvc int64
430
+ CustomFuncName string
431
+ JaegerSpan []byte
432
+ ReqContext []byte
433
+ ComplianceRegion ComplianceRegion
421
434
}
422
435
423
436
func (o * Operation ) String () string {
424
- return fmt .Sprintf ("[Opcode: %v, SKI: %v, Digest: %02x, Client IP: %s, Server IP: %s, SNI: %s, Forwarding Service: %v]" ,
437
+ return fmt .Sprintf ("[Opcode: %v, SKI: %v, Digest: %02x, Client IP: %s, Server IP: %s, SNI: %s, Forwarding Service: %v, ComplianceRegion %v ]" ,
425
438
o .Opcode ,
426
439
o .SKI ,
427
440
o .Digest ,
428
441
o .ClientIP ,
429
442
o .ServerIP ,
430
443
o .SNI ,
431
444
o .ForwardingSvc ,
445
+ o .ComplianceRegion ,
432
446
)
433
447
}
434
448
@@ -512,6 +526,8 @@ func (o *Operation) Bytes() uint16 {
512
526
if o .ReqContext != nil {
513
527
add (tlvLen (len (o .ReqContext )))
514
528
}
529
+ // compliance region
530
+ add (tlvLen (1 ))
515
531
if int (length )+ headerSize < paddedLength {
516
532
// TODO: Are we sure that's the right behavior?
517
533
@@ -586,6 +602,8 @@ func (o *Operation) MarshalBinary() ([]byte, error) {
586
602
b = append (b , tlvBytes (TagReqContext , o .ReqContext )... )
587
603
}
588
604
605
+ b = append (b , tlvBytes (TagComplianceRegion , []byte {byte (o .ComplianceRegion )})... )
606
+
589
607
if len (b )+ headerSize < paddedLength {
590
608
// TODO: Are we sure that's the right behavior?
591
609
@@ -673,6 +691,11 @@ func (o *Operation) UnmarshalBinary(body []byte) error {
673
691
o .JaegerSpan = data
674
692
case TagReqContext :
675
693
o .ReqContext = data
694
+ case TagComplianceRegion :
695
+ if len (data ) != 1 {
696
+ return fmt .Errorf ("invalid ComplianceRegion: %s" , data )
697
+ }
698
+ o .ComplianceRegion = ComplianceRegion (data [0 ])
676
699
default :
677
700
// Silently ignore any unknown tags (to allow for new tags to be gradually added to the protocol).
678
701
continue
0 commit comments