Skip to content

Commit 07c7eff

Browse files
aykevldeadprogram
authored andcommitted
runtime: add FIPS helper functions
Not entirely sure what they're for, but the Go runtime also stores this information per goroutine so let's go with that.
1 parent a1be8cd commit 07c7eff

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/internal/task/task.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ type Task struct {
2121
// state is the underlying running state of the task.
2222
state state
2323

24+
// This is needed for some crypto packages.
25+
FipsIndicator uint8
26+
2427
// DeferFrame stores a pointer to the (stack allocated) defer frame of the
2528
// goroutine that is used for the recover builtin.
2629
DeferFrame unsafe.Pointer

src/runtime/panic.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,8 @@ func divideByZeroPanic() {
226226
func blockingPanic() {
227227
runtimePanicAt(returnAddress(0), "trying to do blocking operation in exported function")
228228
}
229+
230+
//go:linkname fips_fatal crypto/internal/fips140.fatal
231+
func fips_fatal(msg string) {
232+
runtimePanic(msg)
233+
}

src/runtime/scheduler.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ func scheduleLogChan(msg string, ch *channel, t *task.Task) {
3131
func Goexit() {
3232
panicOrGoexit(nil, panicGoexit)
3333
}
34+
35+
//go:linkname fips_getIndicator crypto/internal/fips140.getIndicator
36+
func fips_getIndicator() uint8 {
37+
return task.Current().FipsIndicator
38+
}
39+
40+
//go:linkname fips_setIndicator crypto/internal/fips140.setIndicator
41+
func fips_setIndicator(indicator uint8) {
42+
// This indicator is stored per goroutine.
43+
task.Current().FipsIndicator = indicator
44+
}

0 commit comments

Comments
 (0)