Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
18b9e9a
peer to peer navigation (#372)
wafalakhal Mar 25, 2025
0e0b53a
peerToPeer register and prepare upload implementation (#375)
wafalakhal May 21, 2025
9cbf510
Merge branch 'develop' into feat/stable_peer_to_peer
ahlem-jarrar May 21, 2025
3302904
show connect manual informations
ahlem-jarrar May 22, 2025
bd15467
Finish sender manual connection design
ahlem-jarrar May 23, 2025
2abd9ff
implement prepare upload view
wafalakhal May 23, 2025
5cf1bcf
implement add files in the send view
wafalakhal May 28, 2025
a6713af
continue on implementing the design of the send view
wafalakhal May 29, 2025
b8252f2
WIP manual connection
ahlem-jarrar May 29, 2025
49423e0
WIP show hash flow
ahlem-jarrar May 30, 2025
ec84943
wip prepareUpload api implementation
wafalakhal Jun 2, 2025
95c3a5c
reformat code
wafalakhal Jun 2, 2025
86d4671
save connection Infos
wafalakhal Jun 2, 2025
b276dbf
wip prepareUpload flow and api change
wafalakhal Jun 3, 2025
e9507ae
wip manual connection
ahlem-jarrar Jun 3, 2025
9bc9b80
WIP manual connection
ahlem-jarrar Jun 3, 2025
49cd5b1
Finish manual connection
ahlem-jarrar Jun 4, 2025
7e38153
wip navigation based on event emitted in the server api
wafalakhal Jun 4, 2025
79cd1e2
comment the prepareUploadEvent
wafalakhal Jun 4, 2025
a7f6f4b
add the accept or reject files view and its navigation
wafalakhal Jun 4, 2025
5391b8a
clean flow
ahlem-jarrar Jun 4, 2025
c19c68a
handle the accept reject flow
wafalakhal Jun 4, 2025
0bc3a8a
handle discard and go back to first destination
ahlem-jarrar Jun 4, 2025
f6740c3
wip flow prepare load
wafalakhal Jun 4, 2025
f226f89
Wip finish manual connection
ahlem-jarrar Jun 4, 2025
4d3a778
wip add success message
wafalakhal Jun 4, 2025
8abd68a
WIP on feat/stable_peer_to_peer
ahlem-jarrar Jun 4, 2025
a692d50
add message of success
wafalakhal Jun 4, 2025
28c3d86
add success string
ahlem-jarrar Jun 10, 2025
d311889
change the connectCode to ipAdress
wafalakhal Jun 10, 2025
55911ea
wip reject flow
wafalakhal Jun 19, 2025
4e43a3a
wip reject flow in the sender and recipient
wafalakhal Jun 20, 2025
a097910
Fix hash problem, wip send/receive manual
ahlem-jarrar Jun 20, 2025
c08816c
wip reject flow and refactor code
wafalakhal Jun 24, 2025
1302359
change naming
wafalakhal Jun 24, 2025
a34f59b
WIP manual register flow
ahlem-jarrar Jun 24, 2025
a430931
Revert "change the connectCode to ipAdress"
ahlem-jarrar Jun 26, 2025
f717ab3
Finish connect flow
ahlem-jarrar Jun 26, 2025
2b180cb
finish reject flow
wafalakhal Jun 27, 2025
6b126e0
fix merge conflicts
wafalakhal Jun 27, 2025
c4d338c
delete old code
wafalakhal Jun 30, 2025
a195b50
wip import files
wafalakhal Jun 30, 2025
874597d
fix hash generation to match the ios
wafalakhal Jul 1, 2025
30862cb
Fix qr code flow
ahlem-jarrar Jul 1, 2025
0fcf9d0
Correct ios/android connect flow
ahlem-jarrar Jul 1, 2025
fa439ca
refactor code
wafalakhal Jul 2, 2025
9108c34
Fix prepare upload (ios/Android)
ahlem-jarrar Jul 2, 2025
0f07fe7
add error in case adressIp is null
wafalakhal Jul 2, 2025
9e9eab4
get the mimeType dynamically and save the transmissionId
wafalakhal Jul 2, 2025
44e478c
Improve code, unify routes api
ahlem-jarrar Jul 3, 2025
abb43c7
unify code in TellaPeerToPeerClient
wafalakhal Jul 3, 2025
fdfae55
Fix wifi integration
ahlem-jarrar Jul 3, 2025
4351bcf
refactor code
wafalakhal Jul 4, 2025
25152dd
fix audio recorder
ahlem-jarrar Jul 4, 2025
9dc0e97
WIP unify code
ahlem-jarrar Jul 4, 2025
d2557e2
refactor code
wafalakhal Jul 7, 2025
9240ee9
wip save the fileId and tokens
wafalakhal Jul 8, 2025
fa3a9be
WIP fix prepare upload files
ahlem-jarrar Jul 8, 2025
80e8976
WIP submission
wafalakhal Jul 8, 2025
3ada26c
WIP fix state
ahlem-jarrar Jul 9, 2025
af896c6
clean code
ahlem-jarrar Jul 9, 2025
7968532
wip submission files workflow
wafalakhal Jul 9, 2025
5997358
WIP unify client/server state
ahlem-jarrar Jul 10, 2025
0ab3c7c
wip fix state
wafalakhal Jul 11, 2025
74e1a66
Fix logic with the new state
ahlem-jarrar Jul 11, 2025
3d96b7b
WIP send files flow
ahlem-jarrar Jul 11, 2025
0c76a8c
Fix prepare upload flow and response
ahlem-jarrar Jul 13, 2025
1bc76e2
prepare files for sender/receiver ui from the state
ahlem-jarrar Jul 13, 2025
2d84572
Prepare data to send files
ahlem-jarrar Jul 13, 2025
f00b044
WIP client upload
ahlem-jarrar Jul 13, 2025
041f4f3
Fix reciepient fragment
ahlem-jarrar Jul 13, 2025
7952e5c
change viewmodel package
ahlem-jarrar Jul 14, 2025
5a74657
fix location display for wifi display
wafalakhal Jul 14, 2025
c060dc4
add error handling in registration flow
wafalakhal Jul 15, 2025
5495835
wip recipient flow in upload
wafalakhal Jul 15, 2025
49891c9
WIP sending problem
ahlem-jarrar Jul 15, 2025
3c35253
change post to put
ahlem-jarrar Jul 15, 2025
ae84efc
Fix client upload code
ahlem-jarrar Jul 15, 2025
1a94fab
wip errors in registration
wafalakhal Jul 16, 2025
abee08e
Fix regression
ahlem-jarrar Jul 16, 2025
812ec13
sender progress flow
ahlem-jarrar Jul 16, 2025
1dff4f3
wip cancel button
wafalakhal Jul 16, 2025
ae1235f
wip resultView
wafalakhal Jul 16, 2025
8a13fd4
wip recipient progress and result view
wafalakhal Jul 16, 2025
8818868
WIP save files in the recepient
ahlem-jarrar Jul 16, 2025
14fb06b
Finish saving files in DB
ahlem-jarrar Jul 16, 2025
07524d7
wip finish peer to peer result
ahlem-jarrar Jul 16, 2025
633df7e
WIP fix design and result progress state
wafalakhal Jul 17, 2025
f66069a
fix qrcode design
wafalakhal Jul 17, 2025
1f0bf26
fix design of all buttons
wafalakhal Jul 17, 2025
9ae5269
fix design
wafalakhal Jul 17, 2025
f4c7a7f
WIP code
ahlem-jarrar Jul 17, 2025
9e5e81c
fix design
wafalakhal Jul 17, 2025
4dd1f1a
add action
wafalakhal Jul 17, 2025
f5a1688
send octet stream
ahlem-jarrar Jul 17, 2025
c5138b8
add collapsable view
ahlem-jarrar Jul 21, 2025
d08df40
Fix sender/receiver manual verification design
ahlem-jarrar Jul 22, 2025
b861372
navigate from view files to attachments
ahlem-jarrar Jul 22, 2025
2fbb2a4
fix nearbysharing display
wafalakhal Jul 22, 2025
26aac6b
fix navigation issue
wafalakhal Jul 22, 2025
37e2c6c
wip fix
wafalakhal Jul 23, 2025
5dc5a2f
wip fixes
ahlem-jarrar Jul 23, 2025
7146c18
handle back
wafalakhal Jul 23, 2025
dd36505
WIP sheet progress state
wafalakhal Jul 23, 2025
01fb213
WIP server celan up
ahlem-jarrar Jul 24, 2025
a4e732c
add close connexion endpoint
wafalakhal Jul 24, 2025
53b75df
show all files result
ahlem-jarrar Jul 24, 2025
57bf126
add stopserver
wafalakhal Jul 24, 2025
9cdbc11
fix injection
wafalakhal Jul 24, 2025
0703422
Fix close connection api
ahlem-jarrar Jul 24, 2025
6556dd7
fix error
ahlem-jarrar Jul 24, 2025
76956ac
Fix and improve flow
ahlem-jarrar Jul 24, 2025
8333804
clean code
ahlem-jarrar Jul 24, 2025
21559bf
Fix sheet progress
ahlem-jarrar Jul 25, 2025
2451c65
WIP fix manual connection
ahlem-jarrar Jul 25, 2025
e5cc6a5
Fix wifi problem
ahlem-jarrar Jul 29, 2025
8208b23
Fix wifi
ahlem-jarrar Jul 31, 2025
e3c9d2c
add the wifi screen in the sender
wafalakhal Aug 1, 2025
2c62374
fix thumbnail issue between ios and android
wafalakhal Aug 8, 2025
12d0f56
fix T-And-1697 - Get connected screen is showing an incorrect text
wafalakhal Aug 8, 2025
c90333d
add byteArrayFlexibleSerializer
wafalakhal Aug 18, 2025
e835c98
wip handle success uploading file in the sender side
wafalakhal Aug 18, 2025
8c7a856
Revert "wip handle success uploading file in the sender side"
ahlem-jarrar Aug 21, 2025
267967e
Fix hotspot shared for registartion issue
ahlem-jarrar Aug 21, 2025
537f291
Fix success screen
ahlem-jarrar Aug 22, 2025
91b50c3
Revert "Fix success screen"
wafalakhal Aug 26, 2025
6ff4c24
update the p2pFile Status while upload/ cancel
wafalakhal Aug 26, 2025
72f6696
Fix files status preview
ahlem-jarrar Aug 27, 2025
1d5bbf2
Fix design
ahlem-jarrar Sep 3, 2025
bb4c70c
add nearby settings/home screen
ahlem-jarrar Sep 5, 2025
6ecc850
Baypass ping call certificate
ahlem-jarrar Sep 8, 2025
91bc181
add new custom tips card view
wafalakhal Sep 9, 2025
e6659c1
add new fragment tips logic + layout
wafalakhal Sep 9, 2025
6018782
Adjust new logic removal for wifi + tips
wafalakhal Sep 9, 2025
2e5f3e0
Fix network update
wafalakhal Sep 9, 2025
2ae40ba
Merge the feature with develop
ahlem-jarrar Sep 10, 2025
821e45a
new T-And-1676 - Update Onboarding with p2p info
ahlem-jarrar Sep 10, 2025
0daf238
make nearby sharing home button visible by default
ahlem-jarrar Sep 10, 2025
6d2f30e
Remove text all caps redundant
ahlem-jarrar Sep 10, 2025
9c2904e
apply protocol fixes
ahlem-jarrar Sep 15, 2025
3d88c75
Fix finger print fetcher
wafalakhal Sep 15, 2025
e551780
Fix ping isse problem
ahlem-jarrar Sep 15, 2025
0a950fc
Apply design changes
ahlem-jarrar Sep 16, 2025
1467771
WIP WAITING/ACCEPT validation
ahlem-jarrar Sep 16, 2025
ab09925
Fix
ahlem-jarrar Sep 17, 2025
b28efc1
Fix server/receipient flow
wafalakhal Sep 17, 2025
3ab1050
Release 3.0.0 "211"
wafalakhal Sep 17, 2025
2870d08
Revert "Release 3.0.0 "211""
ahlem-jarrar Sep 18, 2025
0263f01
fix upload problem related to duplicated files/folders
wafalakhal Sep 18, 2025
c807bc5
update version code
wafalakhal Sep 18, 2025
9199dc6
Fix gradle problem
wafalakhal Sep 18, 2025
c542f59
fix prepareUpload request
wafalakhal Sep 19, 2025
145ca5c
fix strings display
wafalakhal Sep 19, 2025
08b24a1
fix design
wafalakhal Sep 19, 2025
ce376b9
fix strings
wafalakhal Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buildscript {
versions.coroutinesAndroid = '1.5.2'
versions.gson = '2.9.0'
versions.legacyV4 = '1.0.0'
versions.tooltip = '1.0.0-alpha06-SNAPSHOT'
versions.tooltip = '0.2.0'
versions.retrofit2KotliCoroutinesAdapter = '0.9.2'
versions.desugar = '1.1.5'
versions.multidex = '2.0.1'
Expand Down Expand Up @@ -102,6 +102,7 @@ buildscript {
classpath "com.google.firebase:firebase-crashlytics-gradle:$versions.crashlyticsGradle"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.50'
classpath "org.jetbrains.kotlin:kotlin-serialization:$versions.kotlin"
}
}

Expand Down
22 changes: 19 additions & 3 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'dagger.hilt.android.plugin'
id 'com.google.firebase.crashlytics'
id 'com.google.gms.google-services'
id 'org.jetbrains.kotlin.plugin.serialization'
}

android {
Expand All @@ -14,8 +15,8 @@ android {
minSdkVersion versions.minSdk
compileSdkVersion versions.compileSdk
targetSdkVersion versions.targetSdk
versionCode 211
versionName "2.17.0"
versionCode 212
versionName "3.0.0"
multiDexEnabled true

ndk {
Expand Down Expand Up @@ -88,7 +89,7 @@ android {
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'

exclude 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
}
namespace 'org.horizontal.tella.mobile'
}
Expand Down Expand Up @@ -233,6 +234,21 @@ dependencies {
implementation "com.github.nextcloud-deps.hwsecurity:hwsecurity-fido:$versions.fidoVersion"
implementation "com.github.nextcloud-deps.hwsecurity:hwsecurity-fido2:$versions.fidoVersion"

//QR CODE SCAN/GENERATE LIBRARY
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'

//ktor imp
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.9")
implementation("io.ktor:ktor-server-core:2.3.9")
implementation("io.ktor:ktor-server-netty:2.3.9")
implementation("io.ktor:ktor-server-content-negotiation:2.3.9")
implementation("io.ktor:ktor-server-cio:2.3.9")
implementation "io.ktor:ktor-server-call-logging:2.3.9" // or your current version


implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3' // Use the latest version


}

def getLocalProperties() {
Expand Down
5 changes: 4 additions & 1 deletion mobile/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,7 @@
-if class androidx.credentials.CredentialManager
-keep class androidx.credentials.playservices.** {
*;
}
}

-keep class org.bouncycastle.** { *; }
-dontwarn org.bouncycastle.**
10 changes: 9 additions & 1 deletion mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" />

<queries>
<intent>
Expand All @@ -49,9 +50,9 @@
android:icon="@mipmap/tella_icon"
android:label="@string/app_name"
android:largeHeap="true"
android:localeConfig="@xml/locales_config"
android:networkSecurityConfig="@xml/configure_localhost_media_file_http_server"
android:roundIcon="@mipmap/tella_icon_round"
android:localeConfig="@xml/locales_config"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
Expand Down Expand Up @@ -502,6 +503,7 @@

<activity
android:name=".views.activity.MainActivity"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar" />
<activity
Expand Down Expand Up @@ -698,6 +700,12 @@

</activity>

<activity
android:name=".views.fragment.peertopeer.activity.PeerToPeerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize" />

</application>

</manifest>
1 change: 1 addition & 0 deletions mobile/src/main/assets/testDemo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a test yo
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.http.HttpResponseCache;
import android.os.Build;
import android.os.StrictMode;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand All @@ -19,6 +21,7 @@
import androidx.appcompat.app.AppCompatDelegate;
import androidx.hilt.work.HiltWorkerFactory;
import androidx.lifecycle.ProcessLifecycleOwner;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import androidx.work.Configuration;

Expand All @@ -36,6 +39,7 @@
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.horizontal.tella.mobile.data.KeyRxVault;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.hzontal.shared_ui.data.CommonPrefs;

import org.conscrypt.Conscrypt;
Expand All @@ -53,6 +57,7 @@
import java.io.File;
import java.lang.ref.WeakReference;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;

Expand Down Expand Up @@ -101,8 +106,6 @@ public class MyApplication extends MultiDexApplication implements IUnlockRegistr
Vault.Config vaultConfig;
private static final String TAG = MyApplication.class.getSimpleName();
public static final String DOT = ".";
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_17;
private static WeakReference<Context> appContext;
private long startTime;
private long totalTimeSpent = 0; // Store total time spent in the app
private int activityReferences = 0;
Expand Down Expand Up @@ -168,6 +171,7 @@ public static void resetKeys() {

@Override
protected void attachBaseContext(Context newBase) {
MultiDex.install(this);
CommonPrefs.getInstance().init(newBase);
SharedPrefs.getInstance().init(newBase);
super.attachBaseContext(LocaleManager.getInstance().getLocalizedContext(newBase));
Expand Down Expand Up @@ -240,6 +244,7 @@ public void accept(Throwable throwable) {
TellaKeysUI.initialize(mainKeyStore, mainKeyHolder, unlockRegistry, this, Preferences.getFailedUnlockOption(), Preferences.getUnlockRemainingAttempts(), Preferences.isShowUnlockRemainingAttempts());
insertConscrypt();
enableStrictMode();
setupBouncyCastleProvider();
}

private void configureCrashlytics() {
Expand Down Expand Up @@ -443,4 +448,15 @@ private void enableStrictMode() {
}


private void setupBouncyCastleProvider() {
try {
if (Security.getProvider("BC") == null) {
Security.addProvider(new BouncyCastleProvider());
Timber.i("BouncyCastle provider registered");
}
} catch (Exception e) {
Timber.e(e, "Failed to register BouncyCastle provider");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.horizontal.tella.mobile.certificate

import org.bouncycastle.asn1.x500.X500Name
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder
import org.bouncycastle.jce.provider.BouncyCastleProvider
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder
import java.security.KeyPair
import java.security.KeyPairGenerator
import java.security.Security
import java.security.cert.X509Certificate
import java.util.Date

object CertificateGenerator {

init {
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
Security.addProvider(BouncyCastleProvider())
}
}

fun generateCertificate(
commonName: String = "Tella Android",
organization: String = "Tella",
validityDays: Int = 7,
ipAddress: String
): Pair<KeyPair, X509Certificate> {
require(ipAddress.isNotBlank()) { "IP address must not be empty when generating a certificate." }

val keyGen = KeyPairGenerator.getInstance("RSA")
keyGen.initialize(2048)
val keyPair = keyGen.generateKeyPair()

val now = Date()
val validTo = Date(now.time + validityDays * 86400000L)

val issuer = X500Name("CN=$commonName,O=$organization")
val subject = issuer

val serialNumber = CertificateUtils.generateSerialNumber()

val certBuilder = JcaX509v3CertificateBuilder(
issuer, serialNumber, now, validTo, subject, keyPair.public
)

val san = org.bouncycastle.asn1.x509.GeneralNames(
org.bouncycastle.asn1.x509.GeneralName(
org.bouncycastle.asn1.x509.GeneralName.iPAddress, ipAddress
)
)
certBuilder.addExtension(
org.bouncycastle.asn1.x509.Extension.subjectAlternativeName,
false,
san
)

val signer = JcaContentSignerBuilder("SHA256withRSA")
.build(keyPair.private)

val holder = certBuilder.build(signer)

val certificate = JcaX509CertificateConverter()
.getCertificate(holder)

return Pair(keyPair, certificate)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.horizontal.tella.mobile.certificate

import android.util.Base64
import org.bouncycastle.asn1.x500.X500Name
import org.bouncycastle.asn1.x509.Extension
import org.bouncycastle.asn1.x509.GeneralName
import org.bouncycastle.asn1.x509.GeneralNames
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder
import java.math.BigInteger
import java.security.KeyPair
import java.security.SecureRandom
import java.security.cert.CertificateFactory
import java.security.cert.X509Certificate
import java.security.KeyStore
import java.util.Date
import java.util.UUID
import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManagerFactory
import javax.net.ssl.X509TrustManager

object CertificateUtils {


fun generateKeyPair(): KeyPair {
val keyPairGenerator = java.security.KeyPairGenerator.getInstance("RSA")
keyPairGenerator.initialize(2048)
return keyPairGenerator.generateKeyPair()
}

fun generateSelfSignedCertificate(keyPair: KeyPair, ipAddress: String): X509Certificate {
val now = Date()
val until = Date(now.time + 365L * 24 * 60 * 60 * 1000) // Valid for 1 year

val serial = BigInteger(128, SecureRandom())
val dn = X500Name("CN=Tella P2P, O=Tella, C=US")

val certBuilder = JcaX509v3CertificateBuilder(
dn, serial, now, until, dn, keyPair.public
)

val san = GeneralNames(
GeneralName(GeneralName.iPAddress, ipAddress)
)

certBuilder.addExtension(
Extension.subjectAlternativeName, false, san
)

val signer = JcaContentSignerBuilder("SHA256WithRSAEncryption").build(keyPair.private)

val certHolder = certBuilder.build(signer)
return JcaX509CertificateConverter().setProvider(org.bouncycastle.jce.provider.BouncyCastleProvider())
.getCertificate(certHolder)
}


fun generateSerialNumber(): BigInteger {
return BigInteger(128, SecureRandom())
}

fun certificateToPem(certificate: X509Certificate): String {
val encoded = Base64.encodeToString(certificate.encoded, Base64.NO_WRAP)
return "-----BEGIN CERTIFICATE-----\n$encoded\n-----END CERTIFICATE-----"
}

fun getPublicKeyHash(certificate: X509Certificate): String {
val digest = java.security.MessageDigest.getInstance("SHA-256")
val hash = digest.digest(certificate.encoded)
return hash.joinToString("") { "%02x".format(it) } // <-- fix here
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Context;
import android.database.Cursor;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand Down
Loading