@@ -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,25 @@ 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
+
217
+ func (cr ComplianceRegion ) String () string {
218
+ switch cr {
219
+ case ComplianceRegionFedRAMPHigh :
220
+ return "fedramp_high"
221
+ default :
222
+ return "retail"
223
+ }
224
+ }
225
+
205
226
const (
206
227
paddedLength = 1024
207
228
headerSize = 8
@@ -405,30 +426,32 @@ func (p *Packet) ReadFrom(r io.Reader) (n int64, err error) {
405
426
406
427
// Operation defines a single (repeatable) keyless operation.
407
428
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
429
+ Opcode Op
430
+ Payload []byte
431
+ Extra []byte
432
+ SKI SKI
433
+ Digest Digest
434
+ ClientIP net.IP
435
+ ServerIP net.IP
436
+ SNI string
437
+ CertID string
438
+ ForwardingSvc int64
439
+ CustomFuncName string
440
+ JaegerSpan []byte
441
+ ReqContext []byte
442
+ ComplianceRegion ComplianceRegion
421
443
}
422
444
423
445
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]" ,
446
+ return fmt .Sprintf ("[Opcode: %v, SKI: %v, Digest: %02x, Client IP: %s, Server IP: %s, SNI: %s, Forwarding Service: %v, ComplianceRegion %v ]" ,
425
447
o .Opcode ,
426
448
o .SKI ,
427
449
o .Digest ,
428
450
o .ClientIP ,
429
451
o .ServerIP ,
430
452
o .SNI ,
431
453
o .ForwardingSvc ,
454
+ o .ComplianceRegion ,
432
455
)
433
456
}
434
457
@@ -512,6 +535,8 @@ func (o *Operation) Bytes() uint16 {
512
535
if o .ReqContext != nil {
513
536
add (tlvLen (len (o .ReqContext )))
514
537
}
538
+ // compliance region
539
+ add (tlvLen (1 ))
515
540
if int (length )+ headerSize < paddedLength {
516
541
// TODO: Are we sure that's the right behavior?
517
542
@@ -586,6 +611,8 @@ func (o *Operation) MarshalBinary() ([]byte, error) {
586
611
b = append (b , tlvBytes (TagReqContext , o .ReqContext )... )
587
612
}
588
613
614
+ b = append (b , tlvBytes (TagComplianceRegion , []byte {byte (o .ComplianceRegion )})... )
615
+
589
616
if len (b )+ headerSize < paddedLength {
590
617
// TODO: Are we sure that's the right behavior?
591
618
@@ -673,6 +700,11 @@ func (o *Operation) UnmarshalBinary(body []byte) error {
673
700
o .JaegerSpan = data
674
701
case TagReqContext :
675
702
o .ReqContext = data
703
+ case TagComplianceRegion :
704
+ if len (data ) != 1 {
705
+ return fmt .Errorf ("invalid ComplianceRegion: %s" , data )
706
+ }
707
+ o .ComplianceRegion = ComplianceRegion (data [0 ])
676
708
default :
677
709
// Silently ignore any unknown tags (to allow for new tags to be gradually added to the protocol).
678
710
continue
0 commit comments