Source file src/crypto/internal/fips140/tls13/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 tls13
     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.3-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  		want := []byte{
    22  			0x78, 0x20, 0x71, 0x75, 0x52, 0xfd, 0x47, 0x67,
    23  			0xe1, 0x07, 0x5c, 0x83, 0x74, 0x2e, 0x49, 0x43,
    24  			0xf7, 0xe3, 0x08, 0x6a, 0x2a, 0xcb, 0x96, 0xc7,
    25  			0xa3, 0x1f, 0xe3, 0x23, 0x56, 0x6e, 0x14, 0x5b,
    26  		}
    27  		es := NewEarlySecret(sha256.New, nil)
    28  		hs := es.HandshakeSecret(nil)
    29  		ms := hs.MasterSecret()
    30  		transcript := sha256.New()
    31  		transcript.Write(input)
    32  		if got := ms.ResumptionMasterSecret(transcript); !bytes.Equal(got, want) {
    33  			return errors.New("unexpected result")
    34  		}
    35  		return nil
    36  	})
    37  }
    38  

View as plain text