...

Source file src/github.com/sigstore/timestamp-authority/pkg/verification/verify_request_test.go

Documentation: github.com/sigstore/timestamp-authority/pkg/verification

     1  // Copyright 2022 The Sigstore Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package verification
    16  
    17  import (
    18  	"crypto"
    19  	"testing"
    20  
    21  	"github.com/digitorus/timestamp"
    22  )
    23  
    24  func TestVerifyRequest(t *testing.T) {
    25  	tsReq := &timestamp.Request{}
    26  
    27  	for _, alg := range []crypto.Hash{crypto.SHA256, crypto.SHA384, crypto.SHA512} {
    28  		tsReq.HashAlgorithm = alg
    29  		if err := VerifyRequest(tsReq); err != nil {
    30  			t.Fatalf("unexpected error verifying request, got %v", err)
    31  		}
    32  	}
    33  
    34  	tsReq.HashAlgorithm = crypto.SHA1
    35  	if err := VerifyRequest(tsReq); err != ErrWeakHashAlg {
    36  		t.Fatalf("expected error with weak hash algorithm, got %v", err)
    37  	}
    38  }
    39  

View as plain text