diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt index 03e30b47fc..73197abb87 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt @@ -62,16 +62,17 @@ fun PGPKeyRing.toPgpKeyDetails(): PgpKeyDetails { } return PgpKeyDetails( - isFullyDecrypted = keyRingInfo.isFullyDecrypted, - isFullyEncrypted = keyRingInfo.isFullyEncrypted, - privateKey = privateKey, - publicKey = publicKey, - users = keyRingInfo.userIds, - ids = keyIdList, - created = keyRingInfo.creationDate.time, - lastModified = keyRingInfo.lastModified.time, - expiration = keyRingInfo.primaryKeyExpirationDate?.time, - algo = algo) + isFullyDecrypted = keyRingInfo.isFullyDecrypted, + isFullyEncrypted = keyRingInfo.isFullyEncrypted, + privateKey = privateKey, + publicKey = publicKey, + users = keyRingInfo.userIds, + ids = keyIdList, + created = keyRingInfo.creationDate.time, + lastModified = keyRingInfo.lastModified?.time, + expiration = keyRingInfo.primaryKeyExpirationDate?.time, + algo = algo + ) } @Throws(IOException::class) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/model/PgpKeyDetails.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/model/PgpKeyDetails.kt index f2a69f3a5d..cab597ce3b 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/model/PgpKeyDetails.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/model/PgpKeyDetails.kt @@ -27,18 +27,20 @@ import javax.mail.internet.InternetAddress * Time: 1:23 PM * E-mail: DenBond7@gmail.com */ -data class PgpKeyDetails constructor(@Expose val isFullyDecrypted: Boolean, - @Expose val isFullyEncrypted: Boolean, - @Expose @SerializedName("private") val privateKey: String?, - @Expose @SerializedName("public") val publicKey: String, - @Expose val users: List, - @Expose val ids: List, - @Expose val created: Long, - @Expose val lastModified: Long, - @Expose val expiration: Long? = null, - @Expose val algo: Algo, - var tempPassphrase: CharArray? = null, - var passphraseType: KeyEntity.PassphraseType? = null) : Parcelable { +data class PgpKeyDetails constructor( + @Expose val isFullyDecrypted: Boolean, + @Expose val isFullyEncrypted: Boolean, + @Expose @SerializedName("private") val privateKey: String?, + @Expose @SerializedName("public") val publicKey: String, + @Expose val users: List, + @Expose val ids: List, + @Expose val created: Long, + @Expose val lastModified: Long? = null, + @Expose val expiration: Long? = null, + @Expose val algo: Algo, + var tempPassphrase: CharArray? = null, + var passphraseType: KeyEntity.PassphraseType? = null +) : Parcelable { val primaryPgpContact: PgpContact get() = determinePrimaryPgpContact() @@ -61,19 +63,20 @@ data class PgpKeyDetails constructor(@Expose val isFullyDecrypted: Boolean, } constructor(source: Parcel) : this( - source.readValue(Boolean::class.java.classLoader) as Boolean, - source.readValue(Boolean::class.java.classLoader) as Boolean, - source.readString(), - source.readString() ?: throw IllegalArgumentException("pubkey can't be null"), - source.createStringArrayList() ?: throw NullPointerException(), - source.createTypedArrayList(KeyId.CREATOR) ?: throw NullPointerException(), - source.readLong(), - source.readLong(), - source.readValue(Long::class.java.classLoader) as Long?, - source.readParcelable(Algo::class.java.classLoader) ?: throw NullPointerException(), - source.createCharArray(), - source.readParcelable( - KeyEntity.PassphraseType::class.java.classLoader) + source.readValue(Boolean::class.java.classLoader) as Boolean, + source.readValue(Boolean::class.java.classLoader) as Boolean, + source.readString(), + source.readString() ?: throw IllegalArgumentException("pubkey can't be null"), + source.createStringArrayList() ?: throw NullPointerException(), + source.createTypedArrayList(KeyId.CREATOR) ?: throw NullPointerException(), + source.readLong(), + source.readValue(Long::class.java.classLoader) as Long?, + source.readValue(Long::class.java.classLoader) as Long?, + source.readParcelable(Algo::class.java.classLoader) ?: throw NullPointerException(), + source.createCharArray(), + source.readParcelable( + KeyEntity.PassphraseType::class.java.classLoader + ) ) override fun describeContents() = 0 @@ -86,7 +89,7 @@ data class PgpKeyDetails constructor(@Expose val isFullyDecrypted: Boolean, writeStringList(users) writeTypedList(ids) writeLong(created) - writeLong(lastModified) + writeValue(lastModified) writeValue(expiration) writeParcelable(algo, flags) writeCharArray(tempPassphrase) @@ -208,7 +211,7 @@ data class PgpKeyDetails constructor(@Expose val isFullyDecrypted: Boolean, result = 31 * result + users.hashCode() result = 31 * result + ids.hashCode() result = 31 * result + created.hashCode() - result = 31 * result + lastModified.hashCode() + result = 31 * result + (lastModified?.hashCode() ?: 0) result = 31 * result + (expiration?.hashCode() ?: 0) result = 31 * result + algo.hashCode() result = 31 * result + (tempPassphrase?.contentHashCode() ?: 0)