Documentation ¶
Index ¶
Constants ¶
View Source
const ( // KeyTypeRSA represents the RSA type of keys KeyTypeRSA = "rsa" // KeySchemeRSASSAPSSSHA256 represents rsassa-pss-sha256 scheme KeySchemeRSASSAPSSSHA256 = "rsassa-pss-sha256" )
View Source
const RSAKeyLength = 2048
RSAKeyLength define the length of RSA keys
Variables ¶
View Source
var ( // ErrorKeyUninitialized will be present when key is used before Deserialize called ErrorKeyUninitialized = errors.New("key not initialized, call Deserialize first") // ErrorDeserializeKey means the key format is not valid ErrorDeserializeKey = errors.New("error on deserialize key, check if the key is valid") // ErrorUnsupportedKeyType means we don't supported this type of key ErrorUnsupportedKeyType = errors.New("provided key type not supported") // ErrorUnsupportedKeySchema means we don't support this schema ErrorUnsupportedKeySchema = errors.New("provided schema not supported") )
Functions ¶
func NewKeyPair ¶
NewKeyPair return a pair of key
Types ¶
type PrivKey ¶
type PrivKey interface { Serializable // Type returns the type of the key, e.g. RSA Type() string // Scheme returns the scheme of signature algorithm, e.g. rsassa-pss-sha256 Scheme() string // Signature sign a signature with the key for payload Signature(payload []byte) (string, error) // Public returns public key of the PrivKey Public() PubKey }
PrivKey is the private key that provide signature method
type PubKey ¶
type PubKey interface { Serializable // Type returns the type of the key, e.g. RSA Type() string // Scheme returns the scheme of signature algorithm, e.g. rsassa-pss-sha256 Scheme() string // VerifySignature check the signature is right VerifySignature(payload []byte, sig string) error }
PubKey is a public key available to TiUp
type RSAPrivKey ¶
type RSAPrivKey struct {
// contains filtered or unexported fields
}
RSAPrivKey represents the private key of RSA
func (*RSAPrivKey) Deserialize ¶
func (k *RSAPrivKey) Deserialize(key []byte) error
Deserialize generate a private key from pem format
func (*RSAPrivKey) Public ¶
func (k *RSAPrivKey) Public() PubKey
Public returns public key of the PrivKey
func (*RSAPrivKey) Scheme ¶
func (k *RSAPrivKey) Scheme() string
Scheme returns the scheme of signature algorithm, e.g. rsassa-pss-sha256
func (*RSAPrivKey) Serialize ¶
func (k *RSAPrivKey) Serialize() ([]byte, error)
Serialize generate the pem format for a key
func (*RSAPrivKey) Signature ¶
func (k *RSAPrivKey) Signature(payload []byte) (string, error)
Signature sign a signature with the key for payload
func (*RSAPrivKey) Type ¶
func (k *RSAPrivKey) Type() string
Type returns the type of the key, e.g. RSA
type RSAPubKey ¶
type RSAPubKey struct {
// contains filtered or unexported fields
}
RSAPubKey represents the public key of RSA
func (*RSAPubKey) Deserialize ¶
Deserialize generate a public key from pem format
Click to show internal directories.
Click to hide internal directories.