Compare commits
1 commit
v2.8.1-pas
...
v2.8.1-pas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9bcee0815 |
1 changed files with 35 additions and 0 deletions
|
|
@ -72,6 +72,41 @@ func PassGetHexSubkeyIDsJSON(key *crypto.Key) []byte {
|
|||
return result
|
||||
}
|
||||
|
||||
type passKeyInfo struct {
|
||||
UserIDs []string `json:"userIDs"`
|
||||
CreationTime int64 `json:"creationTime"`
|
||||
ExpirationTime int64 `json:"expirationTime"` // 0 means no expiration
|
||||
}
|
||||
|
||||
func PassGetKeyInfoJSON(key *crypto.Key) []byte {
|
||||
entity := key.GetEntity()
|
||||
|
||||
userIDs := make([]string, 0, len(entity.Identities))
|
||||
for name := range entity.Identities {
|
||||
userIDs = append(userIDs, name)
|
||||
}
|
||||
|
||||
creationTime := entity.PrimaryKey.CreationTime.Unix()
|
||||
|
||||
var expirationTime int64
|
||||
identity := entity.PrimaryIdentity()
|
||||
if identity != nil && identity.SelfSignature != nil && identity.SelfSignature.KeyLifetimeSecs != nil && *identity.SelfSignature.KeyLifetimeSecs != 0 {
|
||||
expirationTime = creationTime + int64(*identity.SelfSignature.KeyLifetimeSecs)
|
||||
}
|
||||
|
||||
info := passKeyInfo{
|
||||
UserIDs: userIDs,
|
||||
CreationTime: creationTime,
|
||||
ExpirationTime: expirationTime,
|
||||
}
|
||||
|
||||
result, err := json.Marshal(info)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
func PassDecryptWithSessionKey(pgpMessage *crypto.PGPMessage, sk *crypto.SessionKey) (plain_message *crypto.PlainMessage, err error) {
|
||||
var p packet.Packet
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue