Compare commits

..

1 commit

Author SHA1 Message Date
Lysann Tranvouez
b9bcee0815 add helper to export key metadata for pass for iOS 2026-03-16 23:09:41 +01:00

View file

@ -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