Documentation
¶
Index ¶
- Constants
- func GenerateKeyPair() (*PublicKey, *PrivateKey, error)
- type PrivateKey
- func (p *PrivateKey) Equal(other crypto.PrivateKey) bool
- func (p *PrivateKey) KeyExchange(remote crypto.PublicKey) ([]byte, error)
- func (p *PrivateKey) Public() crypto.PublicKey
- func (p *PrivateKey) PublicKeyIsCompatible(remote crypto.PublicKey) bool
- func (p *PrivateKey) ToBytes() []byte
- func (p *PrivateKey) ToPKCS8DER() []byte
- func (p *PrivateKey) ToPKCS8PEM() string
- type PublicKey
- func PublicKeyFromBytes(b []byte) (*PublicKey, error)
- func PublicKeyFromEd25519(pub ed25519.PublicKey) (*PublicKey, error)
- func PublicKeyFromPublicKeyMultibase(multibase string) (*PublicKey, error)
- func PublicKeyFromX509DER(bytes []byte) (*PublicKey, error)
- func PublicKeyFromX509PEM(str string) (*PublicKey, error)
Constants ¶
const ( // PublicKeyBytesSize is the size, in bytes, of public keys in raw bytes. PublicKeyBytesSize = 32 // PrivateKeyBytesSize is the size, in bytes, of private keys in raw bytes. PrivateKeyBytesSize = 32 MultibaseCode = uint64(0xec) )
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (*PublicKey, *PrivateKey, error)
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(b []byte) (*PrivateKey, error)
PrivateKeyFromBytes converts a serialized private key to a PrivateKey. This compact serialization format is the raw key material, without metadata or structure. It errors if len(privateKey) is not PrivateKeyBytesSize.
func PrivateKeyFromEd25519 ¶
func PrivateKeyFromEd25519(priv ed25519.PrivateKey) (*PrivateKey, error)
PrivateKeyFromEd25519 converts an ed25519 private key to a x25519 private key. It errors if the slice is not the right size.
This function is based on the algorithm described in https://datatracker.ietf.org/doc/html/draft-ietf-core-oscore-groupcomm#name-curve25519
func PrivateKeyFromPKCS8DER ¶
func PrivateKeyFromPKCS8DER(bytes []byte) (*PrivateKey, error)
PrivateKeyFromPKCS8DER decodes a PKCS#8 DER (binary) encoded private key.
func PrivateKeyFromPKCS8PEM ¶
func PrivateKeyFromPKCS8PEM(str string) (*PrivateKey, error)
PrivateKeyFromPKCS8PEM decodes an PKCS#8 PEM (string) encoded private key.
func (*PrivateKey) Equal ¶
func (p *PrivateKey) Equal(other crypto.PrivateKey) bool
func (*PrivateKey) KeyExchange ¶
func (p *PrivateKey) KeyExchange(remote crypto.PublicKey) ([]byte, error)
func (*PrivateKey) Public ¶
func (p *PrivateKey) Public() crypto.PublicKey
func (*PrivateKey) PublicKeyIsCompatible ¶
func (p *PrivateKey) PublicKeyIsCompatible(remote crypto.PublicKey) bool
func (*PrivateKey) ToBytes ¶
func (p *PrivateKey) ToBytes() []byte
func (*PrivateKey) ToPKCS8DER ¶
func (p *PrivateKey) ToPKCS8DER() []byte
func (*PrivateKey) ToPKCS8PEM ¶
func (p *PrivateKey) ToPKCS8PEM() string
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func PublicKeyFromBytes ¶
PublicKeyFromBytes converts a serialized public key to a PublicKey. This compact serialization format is the raw key material, without metadata or structure. It errors if the slice is not the right size.
func PublicKeyFromEd25519 ¶
PublicKeyFromEd25519 converts an ed25519 public key to a x25519 public key. It errors if the slice is not the right size.
This function is based on the algorithm described in https://datatracker.ietf.org/doc/html/draft-ietf-core-oscore-groupcomm#name-curve25519
func PublicKeyFromPublicKeyMultibase ¶
PublicKeyFromPublicKeyMultibase decodes the public key from its Multibase form
func PublicKeyFromX509DER ¶
PublicKeyFromX509DER decodes an X.509 DER (binary) encoded public key.
func PublicKeyFromX509PEM ¶
PublicKeyFromX509PEM decodes an X.509 PEM (string) encoded public key.