Source file src/crypto/internal/fips140/mlkem/cast_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mlkem
     6  
     7  import "testing"
     8  
     9  func TestCASTRejectionPaths(t *testing.T) {
    10  	var rejected, notRejected bool
    11  	testingOnlyRejectionOutcome = func(compare int) {
    12  		if compare == 1 {
    13  			t.Log("non-rejection path hit")
    14  			notRejected = true
    15  		} else {
    16  			t.Log("rejection path hit")
    17  			rejected = true
    18  		}
    19  	}
    20  	t.Cleanup(func() {
    21  		testingOnlyRejectionOutcome = nil
    22  	})
    23  
    24  	if err := fips140CAST(); err != nil {
    25  		t.Fatal(err)
    26  	}
    27  
    28  	if !rejected {
    29  		t.Error("rejection path not hit")
    30  	}
    31  	if !notRejected {
    32  		t.Error("non-rejection path not hit")
    33  	}
    34  }
    35  

View as plain text