Add NewKeyFromEntity
This commit is contained in:
parent
f9295608fa
commit
e0531b779c
2 changed files with 16 additions and 6 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -5,11 +5,8 @@ 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
|
||||
- All keys are now checked on parsing from the underlying library
|
||||
|
||||
### Fixed
|
||||
- Dummy keys now show the correct locked/unlocked status
|
||||
### Added
|
||||
- `NewKeyFromEntity` to create a key from an openpgp entity
|
||||
|
||||
### Changed
|
||||
- Improved documentation for differences between text and binary messages
|
||||
|
|
@ -17,6 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Deprecated
|
||||
- `(key *Key) Check() (bool, error)` is now deprecated, all keys are now checked upon import from x/crypto
|
||||
|
||||
### Fixed
|
||||
- Dummy keys now show the correct locked/unlocked status
|
||||
|
||||
### Security
|
||||
- All keys are now checked on parsing from the underlying library
|
||||
|
||||
## [2.2.1] 2021-07-27
|
||||
### Changed
|
||||
- Changed the returned `SignatureVerificationError.Status` when trying to verify a message with no embedded signature. It used to return `constants.SIGNATURE_NO_VERIFIER` and now returns `constants.SIGNATURE_NOT_SIGNED`.
|
||||
|
|
|
|||
|
|
@ -59,6 +59,13 @@ func NewKeyFromArmored(armored string) (key *Key, err error) {
|
|||
return NewKeyFromArmoredReader(strings.NewReader(armored))
|
||||
}
|
||||
|
||||
func NewKeyFromEntity(entity *openpgp.Entity) (*Key, error) {
|
||||
if entity == nil {
|
||||
return nil, errors.New("gopenpgp: nil entity provided")
|
||||
}
|
||||
return &Key{entity: entity}, nil
|
||||
}
|
||||
|
||||
// GenerateRSAKeyWithPrimes generates a RSA key using the given primes.
|
||||
func GenerateRSAKeyWithPrimes(
|
||||
name, email string,
|
||||
|
|
@ -466,7 +473,7 @@ func generateKey(
|
|||
return nil, errors.New("gopenpgp: error in generating private key")
|
||||
}
|
||||
|
||||
return &Key{newEntity}, nil
|
||||
return NewKeyFromEntity(newEntity)
|
||||
}
|
||||
|
||||
// keyIDToHex casts a keyID to hex with the correct padding.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue