mirror of
https://github.com/siderolabs/omni.git
synced 2026-05-10 09:06:11 +02:00
Bump copyright for conformance to 2026 Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
38 lines
776 B
Go
38 lines
776 B
Go
// Copyright (c) 2026 Sidero Labs, Inc.
|
|
//
|
|
// Use of this software is governed by the Business Source License
|
|
// included in the LICENSE file.
|
|
|
|
package handler_test
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"errors"
|
|
)
|
|
|
|
type mockSignerVerifier struct {
|
|
appendSignature []byte
|
|
}
|
|
|
|
func (mock mockSignerVerifier) Fingerprint() string {
|
|
return "mock-fingerprint"
|
|
}
|
|
|
|
func (mock mockSignerVerifier) Sign(data []byte) ([]byte, error) {
|
|
hash := sha256.Sum256(data)
|
|
|
|
return []byte(hex.EncodeToString(append(hash[:], mock.appendSignature...))), nil
|
|
}
|
|
|
|
func (mock mockSignerVerifier) Verify(data, signature []byte) error {
|
|
expected, _ := mock.Sign(data) //nolint:errcheck
|
|
|
|
if !bytes.Equal(signature, expected) {
|
|
return errors.New("invalid signature")
|
|
}
|
|
|
|
return nil
|
|
}
|