Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / library / e2ee-openpgp / src / main / java / com / vayunmathur / e2ee / PgpNative.kt

PgpNative.kt45 lines · 1.6 KiBRaw
1package com.vayunmathur.e2ee
2
3// PACKAGE STRUCTURE EXCEPTION (JNI)
4
5/**
6 * JNI surface for the native Rust OpenPGP module (libe2ee_pgp.so, `pgp.rs` via
7 * rPGP): Ed25519 primary + X25519 subkey generation, armor, encrypt, decrypt.
8 *
9 * Keys cross as ASCII armor (UTF-8 bytes); ciphertext crosses as raw PGP bytes
10 * (armored only for SMTP federation via [nativePgpArmorMessage]). Null on any
11 * failure — callers in [Pgp] map null to errors.
12 */
13internal object PgpNative {
14 external fun nativePgpGenerate(userId: ByteArray, passphrase: ByteArray): Array<ByteArray>?
15 external fun nativePgpFingerprint(armoredPublic: ByteArray): ByteArray?
16 external fun nativePgpNormalizeKey(input: ByteArray): ByteArray?
17 external fun nativePgpEncrypt(armoredPublic: ByteArray, plaintext: ByteArray): ByteArray?
18 external fun nativePgpEncryptSigned(
19 armoredPublic: ByteArray,
20 armoredSecret: ByteArray,
21 passphrase: ByteArray,
22 plaintext: ByteArray,
23 ): ByteArray?
24 external fun nativePgpDecrypt(
25 armoredSecret: ByteArray,
26 passphrase: ByteArray,
27 ciphertext: ByteArray,
28 ): ByteArray?
29 external fun nativePgpDecryptVerify(
30 armoredSecret: ByteArray,
31 passphrase: ByteArray,
32 ciphertext: ByteArray,
33 verifierPublic: ByteArray,
34 ): Array<ByteArray>?
35 external fun nativePgpArmorMessage(raw: ByteArray): ByteArray?
36 external fun nativePgpSignDetached(
37 armoredSecret: ByteArray,
38 passphrase: ByteArray,
39 data: ByteArray,
40 ): ByteArray?
41
42 init {
43 System.loadLibrary("e2ee_pgp")
44 }
45}