Edits for bridge (#22)

* Edits for bridge

* Add keyring method to extract first key, improve docs
This commit is contained in:
wussler 2019-08-29 17:45:13 +02:00 committed by GitHub
parent 4ef79f1d12
commit 72e33612c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 217 additions and 40 deletions

View file

@ -309,3 +309,22 @@ var verifyTime = pgp.GetUnixTime()
verifiedPlainText, err := VerifyCleartextMessageArmored(publicKey, armored, verifyTime)
```
### Encrypting and decrypting session Keys
```go
// Keys initialization as before (omitted)
symmetricKey := &SymmetricKey{
Key: "RandomTokenabcdef",
Algo: constants.AES256,
}
keyPacket, err := publicKey.EncryptSessionKey(symmetricKey)
```
`KeyPacket` is a `[]byte` containing the session key encrypted with the private key.
```go
outputSymmetricKey, err := privateKey.DecryptSessionKey(keyPacket)
```
`outputSymmetricKey` is an object of type `*SymmetricKey` that can be used to decrypt the correspondig message.