Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JavaThemis Secure Cell API #634

Merged
merged 12 commits into from
May 11, 2020
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ _Code:_
Run `./gradlew :desktop:tasks` to learn more
([#633](https://github.com/cossacklabs/themis/pull/633)).

- Secure Cell API updates:

- New encryption/decryption API with consistent naming: `encrypt` and `decrypt`
([#634](https://github.com/cossacklabs/themis/pull/634)).
- Improved Token Protect API
([#634](https://github.com/cossacklabs/themis/pull/634)).
- Decryption no longer requires an intermediate `SecureCellData` object.
- Secure Cell mode can now be selected by instantiating an appropriate interface:

| New API | Old API |
| ------- | ------- |
| `SecureCell.SealWithKey(key)` | `new SecureCell(key, SecureCell.MODE_SEAL)` |
| `SecureCell.TokenProtectWithKey(key)` | `new SecureCell(key, SecureCell.MODE_TOKEN_PROTECT)` |
| `SecureCell.ContextImprintWithKey(key)` | `new SecureCell(key, SecureCell.MODE_CONTEXT_IMPRINT)` |

- **Node.js**

- New class `SymmetricKey` can be used to generate symmetric keys for Secure Cell ([#562](https://github.com/cossacklabs/themis/pull/562)).
Expand Down
10 changes: 10 additions & 0 deletions src/wrappers/themis/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ buildscript {

dependencies {
implementation project(":boringssl")
// Use a compatibility version to support Java 6.
implementation 'org.jetbrains:annotations-java5:16.0.2'
// Instrumentation tests
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
// Keep it at 1.2, see tests/themis/wrappers/android/com/cossacklabs/themis/test/Base64.java
androidTestImplementation 'commons-codec:commons-codec:1.2'
}

android {
Expand All @@ -35,6 +39,12 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

// Compile for Java 7.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

sourceSets {
main {
java.srcDirs = ['../java']
Expand Down
12 changes: 9 additions & 3 deletions src/wrappers/themis/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ sourceSets {
}

dependencies {
// Nullable annotations, etc.
// Use a compatibility version to support Java 6.
implementation 'org.jetbrains:annotations-java5:16.0.2'
// Unit tests
testImplementation 'junit:junit:4.13'
// Keep it at 1.2, see tests/themis/wrappers/android/com/cossacklabs/themis/test/Base64.java
testImplementation 'commons-codec:commons-codec:1.2'
}

test {
Expand All @@ -25,10 +31,10 @@ archivesBaseName = 'java-themis'
version = javaThemisVersion
group = 'com.cossacklabs'

// Compile for Java 8.
// Compile for Java 7.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java 7? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 7?

Modern Android systems support most of Java 8 features, but not quite everything, and there may be some older systems that do not support Java 8. Obviously, Java 9 and later are off limits as well (and will probably remain that way in the nearest future). So we’re effectively limited to Java 7 feature set on Android.

Since desktop Java builds from the same source code, it’s a good idea to limit it to Java 7 as well. it’s likely that given Gradle support for desktop Java, most of the development will happen there, so I don’t want to accidentally use Java 8 features and find out later that Android cannot compile that.

Though, it kinda sucks since Java 8 has so many goodies, like lambdas, default implementations in interfaces, etc. Well, we can live with that since Themis is just a simple wrapper.

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

// Tweak compiler options.
Expand Down
Loading