mirror of
https://github.com/crazy-max/diun.git
synced 2025-01-03 16:09:41 +00:00
24 lines
471 B
Go
24 lines
471 B
Go
// +build libtrust_openssl
|
|
|
|
package libtrust
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto"
|
|
"crypto/ecdsa"
|
|
"crypto/rand"
|
|
"fmt"
|
|
"io"
|
|
"math/big"
|
|
)
|
|
|
|
func (k *ecPrivateKey) sign(data io.Reader, hashID crypto.Hash) (r, s *big.Int, err error) {
|
|
hId := k.signatureAlgorithm.HashID()
|
|
buf := new(bytes.Buffer)
|
|
_, err = buf.ReadFrom(data)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("error reading data: %s", err)
|
|
}
|
|
|
|
return ecdsa.HashSign(rand.Reader, k.PrivateKey, buf.Bytes(), hId)
|
|
}
|