Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions cryptography/lib/src/cryptography/secret_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class SecretKeyData extends SecretKey {
return false;
}
return other is SecretKeyData &&
!other.hasBeenDestroyed &&
constantTimeBytesEquality.equals(bytes, other.bytes);
}

Expand Down
26 changes: 18 additions & 8 deletions cryptography_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ allprojects {
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
def agpMajor = agpVersion.tokenize('.')[0].toInteger()
if (agpMajor < 9) {
apply plugin: "kotlin-android"
}

android {
namespace = "dev.dint.cryptography_flutter"
Expand All @@ -34,13 +39,9 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
main.java.srcDirs += "src/main/kotlin"
test.java.srcDirs += "src/test/kotlin"
main.kotlin.srcDirs += "src/main/kotlin"
test.kotlin.srcDirs += "src/test/kotlin"
}

defaultConfig {
Expand All @@ -65,6 +66,15 @@ android {
}
}

// Access the extension by name to be safe in Groovy
if (project.extensions.findByName("kotlin")) {
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
}

dependencies {
implementation "androidx.security:security-crypto:1.1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ class CryptographyFlutterPlugin : FlutterPlugin, MethodCallHandler {
parameters.init(ECGenParameterSpec(curve))
val ecParameters = parameters.getParameterSpec(ECParameterSpec::class.java)
val privateKeySpec = ECPrivateKeySpec(
BigInteger(d),
BigInteger(1, d),
ecParameters
)

val remoteX = call.argument<ByteArray>("remoteX")!!
val remoteY = call.argument<ByteArray>("remoteY")!!
val remotePublicPoint = ECPoint(BigInteger(remoteX), BigInteger(remoteY))
val remotePublicPoint = ECPoint(BigInteger(1, remoteX), BigInteger(1, remoteY))
val remotePublicKeySpec = ECPublicKeySpec(remotePublicPoint, ecParameters)

val keyFactory = when (provider) {
Expand Down Expand Up @@ -386,7 +386,7 @@ class CryptographyFlutterPlugin : FlutterPlugin, MethodCallHandler {
parameters.init(ECGenParameterSpec(curve))
val ecParameters = parameters.getParameterSpec(ECParameterSpec::class.java)
val privateKeySpec = ECPrivateKeySpec(
BigInteger(d),
BigInteger(1, d),
ecParameters
)

Expand Down Expand Up @@ -430,8 +430,8 @@ class CryptographyFlutterPlugin : FlutterPlugin, MethodCallHandler {
}!!

val message = call.argument<ByteArray>("data")!!
val x = BigInteger(call.argument<ByteArray>("x")!!)
val y = BigInteger(call.argument<ByteArray>("y")!!)
val x = BigInteger(1, call.argument<ByteArray>("x")!!)
val y = BigInteger(1, call.argument<ByteArray>("y")!!)
val verifiedSignatureBytes = call.argument<ByteArray>("signature")!!
val provider = call.argument<String>("androidProvider")

Expand Down
16 changes: 11 additions & 5 deletions cryptography_flutter/example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

val agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.substringBefore('.').toInt()
if (agpMajor < 9) {
apply(plugin = "org.jetbrains.kotlin.android")
}

android {
namespace = "dev.dint.cryptography_flutter_example"
compileSdk = flutter.compileSdkVersion
Expand All @@ -15,10 +19,6 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "dev.dint.cryptography_flutter_example"
Expand All @@ -39,6 +39,12 @@ android {
}
}

project.extensions.configure(org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension::class.java) {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}

flutter {
source = "../.."
}
16 changes: 11 additions & 5 deletions cryptography_flutter_integration_test/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}

val agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.substringBefore('.').toInt()
if (agpMajor < 9) {
apply(plugin = "org.jetbrains.kotlin.android")
}

android {
namespace = "com.example.cryptography_flutter_integration_test"
compileSdk = flutter.compileSdkVersion
Expand All @@ -15,10 +19,6 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.cryptography_flutter_integration_test"
Expand All @@ -39,6 +39,12 @@ android {
}
}

project.extensions.configure(org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension::class.java) {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}

flutter {
source = "../.."
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false