Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 7b25bf8

Browse files
committed
openpgp-ktx: import at 95eed95fb5654e9dcfe32c3712ae97385e186396
Signed-off-by: Harsh Shandilya <[email protected]>
1 parent fa2a937 commit 7b25bf8

17 files changed

+1762
-0
lines changed

openpgp-ktx/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# openpgp-ktx [![Download](https://api.bintray.com/packages/android-password-store/openpgp-ktx/openpgp-ktx/images/download.svg)](https://bintray.com/android-password-store/openpgp-ktx/openpgp-ktx/_latestVersion)
2+
3+
Reimplementation of [OpenKeychain]'s integration library [openpgp-api]. Written entirely in Kotlin, it leverages Jetpack to be compatible with modern apps, unlike the original library.
4+
5+
## Using this with your projects
6+
7+
```gradle
8+
dependencies {
9+
implementation("com.github.androidpasswordstore:openpgp-ktx:<latest-version>")
10+
}
11+
```
12+
13+
[OpenKeychain]: https://github.com/open-keychain/open-keychain
14+
[openpgp-api]: https://github.com/open-keychain/openpgp-api

openpgp-ktx/api/openpgp-ktx.api

Lines changed: 272 additions & 0 deletions
Large diffs are not rendered by default.

openpgp-ktx/build.gradle.kts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id("com.android.library")
3+
id("maven-publish")
4+
kotlin("android")
5+
`aps-plugin`
6+
}
7+
8+
android {
9+
defaultConfig {
10+
consumerProguardFiles("consumer-rules.pro")
11+
}
12+
13+
buildFeatures.aidl = true
14+
15+
kotlin {
16+
explicitApi()
17+
}
18+
19+
kotlinOptions {
20+
freeCompilerArgs = freeCompilerArgs + listOf(
21+
"-Xexplicit-api=strict"
22+
)
23+
}
24+
}
25+
26+
dependencies {
27+
implementation(Dependencies.Kotlin.Coroutines.core)
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-keep class org.openintents.openpgp.**

openpgp-ktx/gradle.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
GROUP=com.github.androidpasswordstore
2+
VERSION_NAME=2.2.0
3+
POM_ARTIFACT_ID=openpgp-ktx
4+
POM_ARTIFACT_DESCRIPTION=Reimplementation of OpenKeychain's integration library in Kotlin
5+
6+
POM_URL=https://github.com/Android-Password-Store/android-password-store
7+
POM_SCM_URL=https://github.com/Android-Password-Store/android-password-store
8+
POM_SCM_CONNECTION=scm:git:https://github.com/Android-Password-Store/android-password-store.git
9+
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]:Android-Password-Store/android-password-store
10+
11+
POM_LICENSE_NAME=LGPL-3.0-only WITH LGPL-3.0-linking-exception
12+
POM_LICENSE_URL=https://www.gnu.org/licenses/lgpl-3.0.txt
13+
POM_LICENSE_DIST=repo
14+
15+
POM_DEVELOPER_ID=android-password-store
16+
POM_DEVELOPER_NAME=The Android Password Store Authors
17+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest package="me.msfjarvis.openpgpktx" />
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright © 2019 The Android Password Authors. All Rights Reserved.
3+
* SPDX-License-Identifier: GPL-3.0-Only
4+
*/
5+
package org.openintents.openpgp;
6+
7+
interface IOpenPgpService2 {
8+
9+
/**
10+
* see org.openintents.openpgp.util.OpenPgpApi for documentation
11+
*/
12+
ParcelFileDescriptor createOutputPipe(in int pipeId);
13+
14+
/**
15+
* see org.openintents.openpgp.util.OpenPgpApi for documentation
16+
*/
17+
Intent execute(in Intent data, in ParcelFileDescriptor input, int pipeId);
18+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright © 2019 The Android Password Authors. All Rights Reserved.
3+
* SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
4+
*/
5+
package me.msfjarvis.openpgpktx
6+
7+
import android.os.Parcel
8+
import android.os.Parcelable
9+
import android.os.Parcelable.Creator
10+
import java.util.Date
11+
12+
public class AutocryptPeerUpdate() : Parcelable {
13+
14+
private var keyData: ByteArray? = null
15+
private var effectiveDate: Date? = null
16+
private lateinit var preferEncrypt: PreferEncrypt
17+
18+
internal constructor(
19+
keyData: ByteArray?,
20+
effectiveDate: Date?,
21+
preferEncrypt: PreferEncrypt
22+
) : this() {
23+
this.keyData = keyData
24+
this.effectiveDate = effectiveDate
25+
this.preferEncrypt = preferEncrypt
26+
}
27+
28+
private constructor(source: Parcel, version: Int) : this() {
29+
keyData = source.createByteArray()
30+
effectiveDate = if (source.readInt() != 0) Date(source.readLong()) else null
31+
preferEncrypt = PreferEncrypt.values()[source.readInt()]
32+
}
33+
34+
public fun createAutocryptPeerUpdate(
35+
keyData: ByteArray?,
36+
timestamp: Date?
37+
): AutocryptPeerUpdate {
38+
return AutocryptPeerUpdate(keyData, timestamp, PreferEncrypt.NOPREFERENCE)
39+
}
40+
41+
public fun getKeyData(): ByteArray? {
42+
return keyData
43+
}
44+
45+
public fun hasKeyData(): Boolean {
46+
return keyData != null
47+
}
48+
49+
public fun getEffectiveDate(): Date? {
50+
return effectiveDate
51+
}
52+
53+
public fun getPreferEncrypt(): PreferEncrypt? {
54+
return preferEncrypt
55+
}
56+
57+
override fun describeContents(): Int {
58+
return 0
59+
}
60+
61+
override fun writeToParcel(dest: Parcel, flags: Int) {
62+
/**
63+
* NOTE: When adding fields in the process of updating this API, make sure to bump
64+
* [.PARCELABLE_VERSION].
65+
*/
66+
dest.writeInt(PARCELABLE_VERSION)
67+
// Inject a placeholder that will store the parcel size from this point on
68+
// (not including the size itself).
69+
val sizePosition = dest.dataPosition()
70+
dest.writeInt(0)
71+
val startPosition = dest.dataPosition()
72+
// version 1
73+
dest.writeByteArray(keyData)
74+
if (effectiveDate != null) {
75+
dest.writeInt(1)
76+
dest.writeLong(effectiveDate!!.time)
77+
} else {
78+
dest.writeInt(0)
79+
}
80+
dest.writeInt(preferEncrypt.ordinal)
81+
// Go back and write the size
82+
val parcelableSize = dest.dataPosition() - startPosition
83+
dest.setDataPosition(sizePosition)
84+
dest.writeInt(parcelableSize)
85+
dest.setDataPosition(startPosition + parcelableSize)
86+
}
87+
88+
public companion object CREATOR : Creator<AutocryptPeerUpdate> {
89+
90+
private const val PARCELABLE_VERSION = 1
91+
override fun createFromParcel(source: Parcel): AutocryptPeerUpdate? {
92+
val version = source.readInt() // parcelableVersion
93+
val parcelableSize = source.readInt()
94+
val startPosition = source.dataPosition()
95+
val vr = AutocryptPeerUpdate(source, version)
96+
// skip over all fields added in future versions of this parcel
97+
source.setDataPosition(startPosition + parcelableSize)
98+
return vr
99+
}
100+
101+
override fun newArray(size: Int): Array<AutocryptPeerUpdate?>? {
102+
return arrayOfNulls(size)
103+
}
104+
}
105+
106+
public enum class PreferEncrypt {
107+
NOPREFERENCE, MUTUAL
108+
}
109+
}

0 commit comments

Comments
 (0)