mirror of
https://github.com/cheat/cheat.git
synced 2024-11-24 06:51:36 +01:00
80c91cbdee
Integrate `go-git` into the application, and use it to `git clone` cheatsheets when the installer runs. Previously, the installer required that `git` be installed on the system `PATH`, so this change has to big advantages: 1. It removes that system dependency on `git` 2. It paves the way for implementing the `--update` command Additionally, `cheat` now performs a `--depth=1` clone when installing cheatsheets, which should at least somewhat improve installation times (especially on slow network connections).
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
// Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.
|
|
package ecc
|
|
|
|
import (
|
|
"io"
|
|
"math/big"
|
|
)
|
|
|
|
type Curve interface {
|
|
GetCurveName() string
|
|
}
|
|
|
|
type ECDSACurve interface {
|
|
Curve
|
|
MarshalIntegerPoint(x, y *big.Int) []byte
|
|
UnmarshalIntegerPoint([]byte) (x, y *big.Int)
|
|
MarshalIntegerSecret(d *big.Int) []byte
|
|
UnmarshalIntegerSecret(d []byte) *big.Int
|
|
GenerateECDSA(rand io.Reader) (x, y, secret *big.Int, err error)
|
|
Sign(rand io.Reader, x, y, d *big.Int, hash []byte) (r, s *big.Int, err error)
|
|
Verify(x, y *big.Int, hash []byte, r, s *big.Int) bool
|
|
ValidateECDSA(x, y *big.Int, secret []byte) error
|
|
}
|
|
|
|
type EdDSACurve interface {
|
|
Curve
|
|
MarshalBytePoint(x []byte) []byte
|
|
UnmarshalBytePoint([]byte) (x []byte)
|
|
MarshalByteSecret(d []byte) []byte
|
|
UnmarshalByteSecret(d []byte) []byte
|
|
MarshalSignature(sig []byte) (r, s []byte)
|
|
UnmarshalSignature(r, s []byte) (sig []byte)
|
|
GenerateEdDSA(rand io.Reader) (pub, priv []byte, err error)
|
|
Sign(publicKey, privateKey, message []byte) (sig []byte, err error)
|
|
Verify(publicKey, message, sig []byte) bool
|
|
ValidateEdDSA(publicKey, privateKey []byte) (err error)
|
|
}
|
|
type ECDHCurve interface {
|
|
Curve
|
|
MarshalBytePoint([]byte) (encoded []byte)
|
|
UnmarshalBytePoint(encoded []byte) ([]byte)
|
|
MarshalByteSecret(d []byte) []byte
|
|
UnmarshalByteSecret(d []byte) []byte
|
|
GenerateECDH(rand io.Reader) (point []byte, secret []byte, err error)
|
|
Encaps(rand io.Reader, point []byte) (ephemeral, sharedSecret []byte, err error)
|
|
Decaps(ephemeral, secret []byte) (sharedSecret []byte, err error)
|
|
ValidateECDH(public []byte, secret []byte) error
|
|
}
|