From 0f35072bc4ad42153e90cf9c3e4d91dff743e25f Mon Sep 17 00:00:00 2001 From: zugzwang Date: Sat, 25 Apr 2020 16:28:07 +0200 Subject: [PATCH] Documentation fixes (#43) * Fix Comment - NewKeyFromReader * Trailing whitespace, correct function name * Update CHANGELOG * update README Co-authored-by: zugzwang Co-authored-by: Aron Wussler --- CHANGELOG.md | 4 ++++ README.md | 17 +++++++++-------- crypto/key.go | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54713dd..2c5d708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Security +- Updated underlying crypto library + ### Fixed - Fixed test `TestMultipleKeyMessageEncryption` +- Fixed garbage collection issues when compiled on gomobile, by copying byte slices ### Added - SHA256 fingerprint support diff --git a/README.md b/README.md index 8fc59c7..33e8103 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # GopenPGP V2 +[![Build Status](https://travis-ci.org/ProtonMail/gopenpgp.svg?branch=master)](https://travis-ci.org/ProtonMail/gopenpgp) GopenPGP is a high-level OpenPGP library built on top of [a fork of the golang crypto library](https://github.com/ProtonMail/crypto). @@ -92,7 +93,7 @@ Finally, build the application ```bash sh build.sh ``` -This script will build for both android and iOS at the same time, +This script will build for both android and iOS at the same time, to filter one out you can comment out the line in the corresponding section. ## Examples @@ -225,7 +226,7 @@ The output is an armored signature. const privkey = `-----BEGIN PGP PRIVATE KEY BLOCK----- ... -----END PGP PRIVATE KEY BLOCK-----` // Encrypted private key -const passphrase = []byte("LongSecret") // Private key passphrase +const passphrase = []byte("LongSecret") // Private key passphrase var message = crypto.NewPlaintextMessage("Verified message") @@ -360,26 +361,26 @@ pgpMessage := pgpSplitMessage.GetPGPMessage() // And vice-versa newPGPSplitMessage, err := pgpMessage.SeparateKeyAndData() -// Key Packet is in newPGPSplitMessage.GetKeyPacket() -// Data Packet is in newPGPSplitMessage.GetDataPacket() +// Key Packet is in newPGPSplitMessage.GetBinaryKeyPacket() +// Data Packet is in newPGPSplitMessage.GetBinaryDataPacket() ``` ### Checking keys In order to check that the primary key is valid the `Key#Check` function can be used. -This operation is as of 2.0.0 fairly expensive, as it requires a signature operation. +This operation is as of 2.0.0 fairly expensive, as it requires a signature operation. It will be improved in the future versions, and possibly expanded to the subkeys, that are for now assumed to be correct thanks to the binding signature. ```go const privkey = `-----BEGIN PGP PRIVATE KEY BLOCK----- ... -----END PGP PRIVATE KEY BLOCK-----` // Encrypted private key -const passphrase = []byte("LongSecret") // Private key passphrase +const passphrase = []byte("LongSecret") // Private key passphrase privateKeyObj, err := crypto.NewKeyFromArmored(privkey) unlockedKeyObj = privateKeyObj.Unlock(passphrase) -isVerified, _ := unlockedKeyObj.Check(); -if !isVerified { +isVerified, _ := unlockedKeyObj.Check(); +if !isVerified { // Handle broken keys } ``` diff --git a/crypto/key.go b/crypto/key.go index 2328fdb..106c33f 100644 --- a/crypto/key.go +++ b/crypto/key.go @@ -39,7 +39,7 @@ func NewKeyFromArmoredReader(r io.Reader) (key *Key, err error) { return key, nil } -// NewKeyFromReader reads an binary data into Key +// NewKeyFromReader reads binary data into a Key object. func NewKeyFromReader(r io.Reader) (key *Key, err error) { key = &Key{} err = key.readFrom(r, false)