Source file src/crypto/internal/fips140/tls12/cast.go

     1  // Copyright 2024 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 tls12
     6  
     7  import (
     8  	"bytes"
     9  	"crypto/internal/fips140"
    10  	_ "crypto/internal/fips140/check"
    11  	"crypto/internal/fips140/sha256"
    12  	"errors"
    13  )
    14  
    15  func init() {
    16  	fips140.CAST("TLSv1.2-SHA2-256", func() error {
    17  		input := []byte{
    18  			0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
    19  			0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
    20  		}
    21  		transcript := []byte{
    22  			0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
    23  			0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
    24  		}
    25  		want := []byte{
    26  			0x8c, 0x3e, 0xed, 0xa7, 0x1c, 0x1b, 0x4c, 0xc0,
    27  			0xa0, 0x44, 0x90, 0x75, 0xa8, 0x8e, 0xbc, 0x7c,
    28  			0x5e, 0x1c, 0x4b, 0x1e, 0x4f, 0xe3, 0xc1, 0x06,
    29  			0xeb, 0xdc, 0xc0, 0x5d, 0xc0, 0xc8, 0xec, 0xf3,
    30  			0xe2, 0xb9, 0xd1, 0x03, 0x5e, 0xb2, 0x60, 0x5d,
    31  			0x12, 0x68, 0x4f, 0x49, 0xdf, 0xa9, 0x9d, 0xcc,
    32  		}
    33  		if got := MasterSecret(sha256.New, input, transcript); !bytes.Equal(got, want) {
    34  			return errors.New("unexpected result")
    35  		}
    36  		return nil
    37  	})
    38  }
    39  

View as plain text