Documentation
¶
Index ¶
- Constants
- Variables
- func CryptoSchemaList(splite string) string
- func CryptoShortList(splite string) string
- func CryptoTypeList(splite string) string
- func GenKeyPair(ty CryptoType, privatePath, publicPath string) error
- func LoadKeyInfo(info *KeyInfo) (PrivateKey, PublicKey, error)
- func LoadKeyInfoFile(filePath string) (PrivateKey, PublicKey, error)
- func ShowKeyInfo(ki *KeyInfo) error
- func ShowKeyInfoFile(dst string) error
- type CryptoInfo
- type CryptoType
- func (l CryptoType) Boolean() bool
- func (l CryptoType) Schema() string
- func (l *CryptoType) Set(value string) error
- func (l *CryptoType) SetInt(value int) error
- func (l *CryptoType) SetScheme(value string) error
- func (l *CryptoType) SetShort(value string) error
- func (l CryptoType) Short() string
- func (l *CryptoType) String() string
- func (l CryptoType) Type() string
- type Ed25519PrivKey
- func (p *Ed25519PrivKey) Empty() bool
- func (p *Ed25519PrivKey) Generate() error
- func (p *Ed25519PrivKey) Key() crypto.PrivateKey
- func (p *Ed25519PrivKey) KeyInfo() (*KeyInfo, error)
- func (p *Ed25519PrivKey) ParsePem(key []byte) error
- func (p *Ed25519PrivKey) Pem() ([]byte, error)
- func (p *Ed25519PrivKey) Public() PublicKey
- func (p *Ed25519PrivKey) SetKey(k crypto.PrivateKey) error
- func (p *Ed25519PrivKey) Signer() crypto.Signer
- func (p *Ed25519PrivKey) Type() CryptoType
- type Ed25519PubKey
- func (p *Ed25519PubKey) Empty() bool
- func (p *Ed25519PubKey) Key() crypto.PublicKey
- func (p *Ed25519PubKey) KeyInfo() (*KeyInfo, error)
- func (p *Ed25519PubKey) ParsePem(key []byte) error
- func (p *Ed25519PubKey) Pem() ([]byte, error)
- func (p *Ed25519PubKey) SetKey(k crypto.PublicKey) error
- func (p *Ed25519PubKey) Type() CryptoType
- type KeyInfo
- func (ki *KeyInfo) CheckType() (CryptoType, error)
- func (ki *KeyInfo) Empty() bool
- func (ki *KeyInfo) ID() (string, error)
- func (ki *KeyInfo) IsPrivate() bool
- func (ki *KeyInfo) IsPublic() bool
- func (ki *KeyInfo) Load(src string) error
- func (ki *KeyInfo) PrivData() (string, error)
- func (ki *KeyInfo) PubData() (string, error)
- func (ki *KeyInfo) Save(dst string, privMode os.FileMode) error
- type PrivateKey
- type PublicKey
- type RSAPrivKey
- func (p *RSAPrivKey) Empty() bool
- func (p *RSAPrivKey) Generate() error
- func (p *RSAPrivKey) Key() crypto.PrivateKey
- func (p *RSAPrivKey) KeyInfo() (*KeyInfo, error)
- func (p *RSAPrivKey) ParsePem(key []byte) error
- func (p *RSAPrivKey) Pem() ([]byte, error)
- func (p *RSAPrivKey) Public() PublicKey
- func (p *RSAPrivKey) SetKey(k crypto.PrivateKey) error
- func (p *RSAPrivKey) Signer() crypto.Signer
- func (p *RSAPrivKey) Type() CryptoType
- type RSAPubKey
- func (p *RSAPubKey) Empty() bool
- func (p *RSAPubKey) Key() crypto.PublicKey
- func (p *RSAPubKey) KeyInfo() (*KeyInfo, error)
- func (p *RSAPubKey) ParsePem(key []byte) error
- func (p *RSAPubKey) Pem() ([]byte, error)
- func (p *RSAPubKey) SetKey(k crypto.PublicKey) error
- func (p *RSAPubKey) Type() CryptoType
Constants ¶
View Source
const ( KeyTypeEd25519 = "ed25519" KeyTypeECDSA_SHA2_P256_COMPAT = "ecdsa-sha2-nistp256" KeyTypeECDSA_SHA2_P256 = "ecdsa" KeyTypeRSASSA_PSS_SHA256 = "rsa" KeySchemeEd25519 = "ed25519" KeySchemeECDSA_SHA2_P256 = "ecdsa-sha2-nistp256" KeySchemeECDSA_SHA2_P384 = "ecdsa-sha2-nistp384" KeySchemeRSASSA_PSS_SHA256 = "rsassa-pss-sha256" )
View Source
const ( ED25519_TYPE = 0 RSA_TYPE = 3 ECDSA_P256_TYPE = 1 ECDSA_TYPE = 2 INVALID_TYPE = 4 )
View Source
const (
RSAKeyLength = 2048
)
Variables ¶
View Source
var ( ErrorEmptyKey = errors.New("error on key empty, check if the key has been initialized") // ErrorUnsupportedKeyType means we don't supported this type of key ErrorUnsupportedKeyType = errors.New("provided key type not supported") )
View Source
var ( InvalidCryptoInvalid = "INVALID" CryptoInfoList = []CryptoInfo{ { Short: "ed25519", Type: KeyTypeEd25519, Schema: KeySchemeEd25519, }, { Short: "ecdsa-p256", Type: KeyTypeECDSA_SHA2_P256_COMPAT, Schema: KeySchemeECDSA_SHA2_P256, }, { Short: "ecdsa", Type: KeyTypeECDSA_SHA2_P256, Schema: KeySchemeECDSA_SHA2_P384, }, { Short: "rsa", Type: KeyTypeRSASSA_PSS_SHA256, Schema: KeySchemeRSASSA_PSS_SHA256, }, } )
Functions ¶
func CryptoSchemaList ¶
func CryptoShortList ¶
func CryptoTypeList ¶
func GenKeyPair ¶
func GenKeyPair(ty CryptoType, privatePath, publicPath string) error
func LoadKeyInfo ¶
func LoadKeyInfo(info *KeyInfo) (PrivateKey, PublicKey, error)
func LoadKeyInfoFile ¶
func LoadKeyInfoFile(filePath string) (PrivateKey, PublicKey, error)
func ShowKeyInfo ¶
func ShowKeyInfoFile ¶
Types ¶
type CryptoInfo ¶
type CryptoType ¶
type CryptoType int
func (CryptoType) Boolean ¶
func (l CryptoType) Boolean() bool
func (CryptoType) Schema ¶
func (l CryptoType) Schema() string
func (*CryptoType) Set ¶
func (l *CryptoType) Set(value string) error
func (*CryptoType) SetInt ¶
func (l *CryptoType) SetInt(value int) error
func (*CryptoType) SetScheme ¶
func (l *CryptoType) SetScheme(value string) error
func (*CryptoType) SetShort ¶
func (l *CryptoType) SetShort(value string) error
func (CryptoType) Short ¶
func (l CryptoType) Short() string
func (*CryptoType) String ¶
func (l *CryptoType) String() string
func (CryptoType) Type ¶
func (l CryptoType) Type() string
type Ed25519PrivKey ¶
type Ed25519PrivKey struct {
// contains filtered or unexported fields
}
func (*Ed25519PrivKey) Empty ¶
func (p *Ed25519PrivKey) Empty() bool
func (*Ed25519PrivKey) Generate ¶
func (p *Ed25519PrivKey) Generate() error
func (*Ed25519PrivKey) Key ¶
func (p *Ed25519PrivKey) Key() crypto.PrivateKey
func (*Ed25519PrivKey) KeyInfo ¶
func (p *Ed25519PrivKey) KeyInfo() (*KeyInfo, error)
func (*Ed25519PrivKey) ParsePem ¶
func (p *Ed25519PrivKey) ParsePem(key []byte) error
func (*Ed25519PrivKey) Pem ¶
func (p *Ed25519PrivKey) Pem() ([]byte, error)
func (*Ed25519PrivKey) Public ¶
func (p *Ed25519PrivKey) Public() PublicKey
func (*Ed25519PrivKey) SetKey ¶
func (p *Ed25519PrivKey) SetKey(k crypto.PrivateKey) error
func (*Ed25519PrivKey) Signer ¶
func (p *Ed25519PrivKey) Signer() crypto.Signer
func (*Ed25519PrivKey) Type ¶
func (p *Ed25519PrivKey) Type() CryptoType
type Ed25519PubKey ¶
type Ed25519PubKey struct {
// contains filtered or unexported fields
}
func (*Ed25519PubKey) Empty ¶
func (p *Ed25519PubKey) Empty() bool
func (*Ed25519PubKey) Key ¶
func (p *Ed25519PubKey) Key() crypto.PublicKey
func (*Ed25519PubKey) KeyInfo ¶
func (p *Ed25519PubKey) KeyInfo() (*KeyInfo, error)
func (*Ed25519PubKey) ParsePem ¶
func (p *Ed25519PubKey) ParsePem(key []byte) error
func (*Ed25519PubKey) Pem ¶
func (p *Ed25519PubKey) Pem() ([]byte, error)
func (*Ed25519PubKey) SetKey ¶
func (p *Ed25519PubKey) SetKey(k crypto.PublicKey) error
SetKey set raw public key
func (*Ed25519PubKey) Type ¶
func (p *Ed25519PubKey) Type() CryptoType
type KeyInfo ¶
type KeyInfo struct {
Type string `json:"keytype"`
Value map[string]string `json:"keyval"`
Scheme string `json:"scheme"`
}
KeyInfo is the manifest structure of a single key
func NewKeyInfo ¶
func NewKeyInfo() *KeyInfo
func (*KeyInfo) CheckType ¶
func (ki *KeyInfo) CheckType() (CryptoType, error)
Load loads a KeyInfo object from a JSON file
type PrivateKey ¶
type PrivateKey interface {
Empty() bool
// Type returns the type of the key, e.g. RSA
Type() CryptoType
// Signer returns the signer of the private key
Signer() crypto.Signer
// Public returns public key of the PrivKey
Public() PublicKey
// Key returns the raw public key
Key() crypto.PrivateKey
SetKey(crypto.PrivateKey) error
// Pem returns the raw private key in PEM format
Pem() ([]byte, error)
// Pem returns the raw private key in PEM format
ParsePem([]byte) error
// KeyInfo pack KeyInfo for public key
KeyInfo() (*KeyInfo, error)
/// Generate private key for this key
Generate() error
}
PrivKey is the private key that provide signature method
func NewEd25519PrivKey ¶
func NewEd25519PrivKey() PrivateKey
func NewRSAPrivKey ¶
func NewRSAPrivKey() PrivateKey
type PublicKey ¶
type PublicKey interface {
// Type returns the type of the key, e.g. RSA
Type() CryptoType
// Key returns the raw public key
Key() crypto.PublicKey
// SetKey set raw public key
SetKey(crypto.PublicKey) error
// Pem returns the raw private key in PEM format
Pem() ([]byte, error)
// Pem returns the raw private key in PEM format
ParsePem([]byte) error
// KeyInfo pack KeyInfo for public key
KeyInfo() (*KeyInfo, error)
}
PublicKey is a public key available to KMOPT
func NewEd25519PubKey ¶
func NewEd25519PubKey() PublicKey
func NewPublicKey ¶
func NewPublicKey(ty CryptoType) (PublicKey, error)
func NewRSAPublicKey ¶
func NewRSAPublicKey() PublicKey
type RSAPrivKey ¶
type RSAPrivKey struct {
// contains filtered or unexported fields
}
func (*RSAPrivKey) Empty ¶
func (p *RSAPrivKey) Empty() bool
func (*RSAPrivKey) Generate ¶
func (p *RSAPrivKey) Generate() error
func (*RSAPrivKey) Key ¶
func (p *RSAPrivKey) Key() crypto.PrivateKey
func (*RSAPrivKey) KeyInfo ¶
func (p *RSAPrivKey) KeyInfo() (*KeyInfo, error)
func (*RSAPrivKey) ParsePem ¶
func (p *RSAPrivKey) ParsePem(key []byte) error
func (*RSAPrivKey) Pem ¶
func (p *RSAPrivKey) Pem() ([]byte, error)
func (*RSAPrivKey) Public ¶
func (p *RSAPrivKey) Public() PublicKey
func (*RSAPrivKey) SetKey ¶
func (p *RSAPrivKey) SetKey(k crypto.PrivateKey) error
func (*RSAPrivKey) Signer ¶
func (p *RSAPrivKey) Signer() crypto.Signer
func (*RSAPrivKey) Type ¶
func (p *RSAPrivKey) Type() CryptoType
Click to show internal directories.
Click to hide internal directories.