pgp

package module
v0.0.0-...-90207ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2020 License: GPL-3.0 Imports: 21 Imported by: 0

README

Easy GO PGP

API

import (
    "time"
    "github.com/ProxeusApp/pgp"
)

func main(){
    keyPairMap, err :=  pgp.Create("my name","my@email.com",4096/*rsa bits*/,24*time.Hour)

    ok         :=       pgp.ValidatePrivateKey(privKey)
    ok         :=       pgp.ValidatePublicKey(publicKey)

    valid, err :=       pgp.Verify(data, signature, publicKeys)
    valid, err :=       pgp.VerifyBundle(armoredDataAndSignature, publicKeys)
    valid, err =        pgp.VerifyStream(dataReader, signatureReader, publicKeys)

    signedBytes, err := pgp.Sign(data, passphrase/*nil if private key is not encrypted*/, privateKey)
    err =               pgp.SignStream(dataReader, outWriter, passphrase, privateKey)

    encBytes, err :=    pgp.Encrypt(dataBytes, publicKeys)
    err =               pgp.EncryptStream(reader, outWriter, publicKeys)

    decBytes, err :=    pgp.Decrypt(data, passphrase/*nil if private key is not encrypted*/, privateKey)
    err =               pgp.DecryptStream(dataReader, outWriter, passphrase, privateKey)

    list, err :=        pgp.ReadIdentity(keys)

    keyPairMap, err :=  pgp.WriteIdentity([]byte("abc"), []byte(privateKey1), "thenewname", "", "newemail")

    pubKeyBytes, err := pgp.ReadPublicKey([]byte("abc"), []byte(sigPriv))

    encPrivKey, err  := pgp.EncryptPrivateKeys(passphrase, privatekeyBytes)

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(name, email string, rsaBits int, expiry time.Duration) (map[string][]byte, error)

func Decrypt

func Decrypt(msg, passphrase, privKey []byte) ([]byte, error)

func DecryptStream

func DecryptStream(in io.Reader, out io.Writer, passphrase, privKey []byte) (int64, error)

func Encrypt

func Encrypt(msg []byte, pubKey [][]byte) ([]byte, error)

func EncryptPrivateKeys

func EncryptPrivateKeys(passphrase string, privateKey []byte) ([]byte, error)

func EncryptStream

func EncryptStream(in io.Reader, out io.Writer, pubKey [][]byte) (int64, error)

func ReadIdentity

func ReadIdentity(pubKey [][]byte) ([]map[string]string, error)

func ReadPublicKey

func ReadPublicKey(passphrase, privKey []byte) ([]byte, error)

func Sign

func Sign(msg []byte, passphrase []byte, privKey [][]byte) ([]byte, error)

func SignStream

func SignStream(in io.Reader, out io.Writer, passphrase []byte, privKey [][]byte) error

func ValidatePrivateKey

func ValidatePrivateKey(privateKey []byte) bool

func ValidatePublicKey

func ValidatePublicKey(publicKey []byte) bool

func Verify

func Verify(data, signature []byte, pubKey [][]byte) (bool, error)

func VerifyBundle

func VerifyBundle(signatureIncludingData []byte, pubkey [][]byte) (bool, error)

func VerifyStream

func VerifyStream(dataReader, signatureReader io.Reader, pubKey [][]byte) (bool, error)

func WriteIdentity

func WriteIdentity(pw, privKey []byte, name, comment, email string) (map[string][]byte, error)

Types

type EncryptablePrivateKey

type EncryptablePrivateKey struct {
	packet.PrivateKey
	// contains filtered or unexported fields
}

func (*EncryptablePrivateKey) Encrypt

func (pk *EncryptablePrivateKey) Encrypt(passphrase []byte) error

Encrypts private key with aes-128 CFB, based on an iterated/salted s2k key derivation of the supplied passphrase and uses SHA1 as checksum

func (*EncryptablePrivateKey) NewEncryptablePrivateKey

func (pk *EncryptablePrivateKey) NewEncryptablePrivateKey(priv *packet.PrivateKey)

func (*EncryptablePrivateKey) SerializePrivate

func (pk *EncryptablePrivateKey) SerializePrivate(w io.Writer) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL