Black Lives Matter. Support the Equal Justice Initiative.

Source file src/crypto/sha512/fallback_test.go

Documentation: crypto/sha512

     1  // Copyright 2016 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  //go:build s390x
     6  // +build s390x
     7  
     8  package sha512
     9  
    10  import (
    11  	"fmt"
    12  	"io"
    13  	"testing"
    14  )
    15  
    16  // Tests the fallback code path in case the optimized asm
    17  // implementation cannot be used.
    18  // See also TestBlockGeneric.
    19  func TestGenericPath(t *testing.T) {
    20  	if useAsm == false {
    21  		t.Skipf("assembly implementation unavailable")
    22  	}
    23  	useAsm = false
    24  	defer func() { useAsm = true }()
    25  	c := New()
    26  	in := "ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϺϘΡΣΤΥΦΧΨΩ"
    27  	gold := "6922e319366d677f34c504af31bfcb29" +
    28  		"e531c125ecd08679362bffbd6b6ebfb9" +
    29  		"0dcc27dfc1f3d3b16a16c0763cf43b91" +
    30  		"40bbf9bbb7233724e9a0c6655b185d76"
    31  	if _, err := io.WriteString(c, in); err != nil {
    32  		t.Fatalf("could not write to c: %v", err)
    33  	}
    34  	out := fmt.Sprintf("%x", c.Sum(nil))
    35  	if out != gold {
    36  		t.Fatalf("mismatch: got %s, wanted %s", out, gold)
    37  	}
    38  }
    39  

View as plain text