Encrypt session key to multiple keys in keyring. (#59)

`EncryptSessionKey` now creates encrypted key packet for each valid key
in keyring.

Co-authored-by: Aron Wussler <aron@wussler.it>
This commit is contained in:
Ilya Chesnokov 2020-07-10 00:31:57 +07:00 committed by GitHub
parent a232124b70
commit b38f993c25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 11 deletions

View file

@ -331,13 +331,13 @@ A session key can be generated, encrypted to a Asymmetric/Symmetric key packet a
sessionKey, err := crypto.GenerateSessionKey()
keyPacket, err := publicKeyRing.EncryptSessionKey(sessionKey)
keyPacket, err := publicKeyRing.EncryptSessionKey(sessionKey) // Will encrypt to all the keys in the keyring
keyPacketSymm, err := crypto.EncryptSessionKeyWithPassword(sessionKey, password)
```
`KeyPacket` is a `[]byte` containing the session key encrypted with the private key or password.
```go
decodedKeyPacket, err := privateKeyRing.DecryptSessionKey(keyPacket)
decodedKeyPacket, err := privateKeyRing.DecryptSessionKey(keyPacket) // Will decode with the first valid key found
decodedSymmKeyPacket, err := crypto.DecryptSessionKeyWithPassword(keyPacketSymm, password)
```
`decodedKeyPacket` and `decodedSymmKeyPacket` are objects of type `*SymmetricKey` that can