Skip to content

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Oct 11, 2024

This PR contains three main things:

  1. New sample Android Studio project file (IDE/Android), which can be used as a simple example for adding wolfCrypt JNI/JCE to an Android Studio project. It is also used as the basis for the GitHub Action test.
  2. New Android gradle Github Actions PRB test that does an Android gradle build. Configured to treat all build warnings as errors.
  3. Fixes for warnings that showed up with Android gradle build.

The fixes/refactors made to resolve build warnings include:

  • Calling WolfCryptDebug.log() directly since it is a static method
  • Delaying of native struct initialization until object first use. Native structs were previously initialized in the constructor when objects were created. This was throwing warnings of potential threading issues if we would try to use structs before sublcasses/superclasses were fully initialized.
  • Because of delayed struct initialization, several constructs were marked @Deprecated, which now throw exceptions telling users what to replace that usage with. (See section below for specifically deprecated APIs). Deprecating these APIs also has the benefit of us not storing key material in memory at the Java level. When the appropriate setKey()/etc method is called we can pass the keying material directly down to native wolfSSL in the JNI call.
  • Fix potential serialization issues on objects that extend Serializable, or parent classes that do.
  • Throw more exceptions when some features are not compiled in

Deprecated Class Constructors (in package com.wolfssl.wolfcrypt):

  • Aes(byte[] key, byte[] iv, int opmode) -> use Aes() + Aes.setKey(byte[] key, byte[] iv, int opmode)
  • AesGcm(byte[] key) -> use AesGcm() + AesGcm.setKey(byte[] key)
  • Des3(byte[] key, byte[] iv, int opmode) -> use Des3() + Des3.setKey(byte[] key, byte[] iv, int opmode)
  • Hmac(int type, byte[] key) -> use Hmac() + Hmac.setKey(int type, byte[] key)
  • Rsa(byte[] key) -> use Rsa() + Rsa.decodePrivateKey(byte[] key)
  • Rsa(byte[] n, byte[] e) -> use Rsa() + Rsa.decodeRawPublicKey(byte[] n, byte[] e)
  • Md5(Md5 md5) -> use Md5.clone()
  • Sha(Sha sha) -> use Sha.clone()
  • Sha256(Sha256 sha256) -> use Sha256.clone()
  • Sha384(Sha384 sha384) -> use Sha384.clone()
  • Sha512(Sha512 sha512) -> use Sha512.clone()

@cconlon cconlon assigned cconlon and JacobBarthelmeh and unassigned cconlon Oct 11, 2024
Copy link
Contributor

@JacobBarthelmeh JacobBarthelmeh left a comment

Choose a reason for hiding this comment

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

The code changes look good to me. Pinged you about one question with the example.

@JacobBarthelmeh JacobBarthelmeh merged commit ddddfc6 into wolfSSL:master Oct 11, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants