github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/boot/stboot/signature_test.go (about)

     1  // Copyright 2018 the u-root 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 stboot
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  var testHash = []byte{184, 125, 17, 19, 148, 144, 119, 239, 215, 18, 102, 79, 239, 214, 17, 133, 71, 108, 137, 131, 240, 22, 15, 165, 145, 215, 69, 91, 64, 30, 69, 244, 75, 50, 66, 44, 239, 120, 166, 25, 48, 230, 19, 190, 162, 4, 72, 244, 43, 62, 207, 124, 163, 49, 79, 215, 70, 55, 210, 29, 167, 131, 37, 43}
    14  
    15  // not ready yet
    16  func TestHash(t *testing.T) {
    17  	signer := Sha512PssSigner{}
    18  	hash, err := signer.Hash("testdata/testConfigDir/kernels/kernel1.vmlinuz")
    19  	lenght := len(hash)
    20  	t.Logf("hash: %v", hash)
    21  	require.NoError(t, err)
    22  	require.Equal(t, 64, lenght)
    23  }
    24  
    25  //not ready yet
    26  func TestSign(t *testing.T) {
    27  	signer := Sha512PssSigner{}
    28  	sig, err := signer.Sign("testdata/keys/signing-key-1.key", testHash)
    29  	t.Logf("signature: %v", sig)
    30  	require.NoError(t, err)
    31  	require.NotNil(t, sig)
    32  }