Documentation ¶
Index ¶
- Constants
- Variables
- func LoadPEMBlock(file, kind string, v interface{}) (err error)
- func ParsePEMBlock(data []byte, kind string, v interface{}) (err error)
- type Key
- func (key *Key) AsPublicKey() *Key
- func (key *Key) BoxPrivateKey() *[keySize]byte
- func (key *Key) BoxPublicKey() *[keySize]byte
- func (key *Key) Decrypt(in []byte, nonce *[24]byte, peer *Key) ([]byte, bool)
- func (key *Key) Encrypt(message []byte, nonce *[24]byte, peer *Key) []byte
- func (key *Key) IsPrivate() bool
- func (key *Key) IsPublic() bool
- func (key *Key) Marshal() (out []byte, err error)
- func (key *Key) Save(file string) (err error)
Constants ¶
View Source
const ( // PEMPublicKey is the PEM encoding type for secrets public keys PEMPublicKey = "SECRETS PUBLIC KEY" // PEMPrivateKey is the PEM encoding type for secrets private keys PEMPrivateKey = "SECRETS PRIVATE KEY" )
Variables ¶
View Source
var ( // OIDPublicKey is the ASN.1 object identifier for secrets public keys OIDPublicKey = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 27266, 11, 17, 1} // OIDPrivateKey is the ASN.1 object identifier for secrets private keys OIDPrivateKey = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 27266, 11, 17, 2} )
Functions ¶
func LoadPEMBlock ¶
LoadPEMBlock loads a PEM block from a file.
func ParsePEMBlock ¶
ParsePEMBlock parsea a PEM block from a byte slice.
Types ¶
type Key ¶
type Key struct { ID asn1.ObjectIdentifier PublicKey []byte PrivateKey []byte `asn1:"omitempty"` }
Key is a NaCL box key
func LoadPrivateKey ¶
LoadPrivateKey loads a NaCL box key pair PEM file.
func LoadPublicKey ¶
LoadPublicKey loads a NaCL box public key PEM file.
func NewPrivateKey ¶
NewPrivateKey generates a new NaCL box key pair.
func ParsePublicKey ¶
ParsePublicKey parses a NaCL box public key byte slice. TODO: error checking
func (*Key) AsPublicKey ¶
AsPublicKey returns only the private part of the key.
func (*Key) BoxPrivateKey ¶
BoxPrivateKey returns the public key in NaCL box usable format
func (*Key) BoxPublicKey ¶
BoxPublicKey returns the public key in NaCL box usable format
Click to show internal directories.
Click to hide internal directories.