Merge pull request #142 from ProtonMail/new-key-entity
Add NewKeyFromEntity
This commit is contained in:
commit
2329c36a25
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
### Security
|
### Added
|
||||||
- All keys are now checked on parsing from the underlying library
|
- `NewKeyFromEntity` to create a key from an openpgp entity
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Dummy keys now show the correct locked/unlocked status
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Improved documentation for differences between text and binary messages
|
- 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
|
### Deprecated
|
||||||
- `(key *Key) Check() (bool, error)` is now deprecated, all keys are now checked upon import from x/crypto
|
- `(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
|
## [2.2.1] 2021-07-27
|
||||||
### Changed
|
### 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`.
|
- 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))
|
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.
|
// GenerateRSAKeyWithPrimes generates a RSA key using the given primes.
|
||||||
func GenerateRSAKeyWithPrimes(
|
func GenerateRSAKeyWithPrimes(
|
||||||
name, email string,
|
name, email string,
|
||||||
|
|
@ -466,7 +473,7 @@ func generateKey(
|
||||||
return nil, errors.New("gopenpgp: error in generating private key")
|
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.
|
// keyIDToHex casts a keyID to hex with the correct padding.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue