Skip to content

lolgab/scala-native-crypto

Repository files navigation

scala-native-crypto

java.security Scala Native implementation based on OpenSSL

Getting started

You need to add the dependency to your Scala Native project.

On SBT:

libraryDependencies += "com.github.lolgab" %%% "scala-native-crypto" % "x.y.z"

On Mill:

def ivyDeps = super.ivyDeps() ++ Agg(ivy"com.github.lolgab::scala-native-crypto::x.y.z")

You need also to install OpenSSL:

On Debian/Ubuntu:

sudo apt install libssl-dev

On macOS (with Homebrew):

brew install openssl

On Windows (with vcpkg):

# Global `vcpkg`
vcpkg install openssl
# In workspace (we've added `openssl` to `vcpkg.json`)
vcpkg install

And you need to have libcrypto in your linking path (e.g., libcrypto.so on Linux, libcrypto.dylib on macOS, and libcrypto*.dll + libcrypto.lib on Windows).

In Ubuntu it works out of the box since openssl is installed in the main lib directory.

In Mac OS X you will need to add the path via nativeLinkingOptions.

On SBT:

nativeConfig ~= { c => c.withLinkingOptions(c.nativeLinkingOptions :+ "-L/usr/local/opt/openssl@3/lib") }

On Mill:

def nativeLinkingOptions = super.nativeLinkingOptions() ++ Seq("-L/usr/local/opt/openssl@3/lib")

Implemented classes

According JDK Security Algorithm Implementation Requirements, the following classes and algorithm checked are implemented and those unchecked are minimal requirements for interoperable JDK shims.

Welcome contributions to implement the missing algorithms/classes!

(The sequence is in the same order of the reference table)

  • java.security..AlgorithmParameterGenerator
    • DiffieHellman (1024, 2048)
    • DSA (1024, 2048)
  • java.security.AlgorithmParameters
    • AES
    • ChaCha20-Poly1305
    • DESede
    • DiffieHellman
    • DSA
    • EC (secp256r1, secp384r1)
    • RSASSA-PSS (MGF1 mask generation function and SHA-256 or SHA-384 hash algorithms)
  • java.security.cert.CertificateFactory
    • X.509
  • java.security.cert.CertPath Encoding
    • PKCS7
    • PkiPath
  • java.security.cert.CertPathBuilder
    • PKIX
  • java.security.cert.CertPathValidator
    • PKIX
  • java.security.cert.CertStore
    • Collection
  • javax.crypto.Cipher
    • AES/CBC/NoPadding (128)
    • AES/CBC/PKCS5Padding (128)
    • AES/ECB/NoPadding (128)
    • AES/ECB/PKCS5Padding (128)
    • AES/GCM/NoPadding (128, 256)
    • ChaCha20-Poly1305
    • DESede/CBC/NoPadding (168)
    • DESede/CBC/PKCS5Padding (168)
    • DESede/ECB/NoPadding (168)
    • DESede/ECB/PKCS5Padding (168)
    • RSA/ECB/PKCS1Padding (1024, 2048)
    • RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048)
    • RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048)
  • javax.crypto.KeyAgreement
    • DiffieHellman
    • ECDH (secp256r1, secp384r1)
    • X25519
  • java.security.KeyFactory
    • DiffieHellman
    • DSA
    • EC
    • RSA
    • RSASSA-PSS
    • X25519
  • javax.crypto.KeyGenerator
    • AES (128, 256)
    • ChaCha20
    • DESede (168)
    • HmacSHA1
    • HmacSHA256
  • java.security.KeyPairGenerator
    • DiffieHellman (1024, 2048, 3072, 4096)
    • DSA (1024, 2048)
    • EC (secp256r1, secp384r1)
    • RSA (1024, 2048, 3072, 4096)
    • RSASSA-PSS (2048, 3072, 4096)
    • X25519
  • java.security.KeyStore
    • PKCS12
  • javax.crypto.Mac
    • HmacSHA1
    • HmacSHA256
    • extra
      • HmacSHA224
      • HmacSHA384
      • HmacSHA512
      • HmacSHA3-224
      • HmacSHA3-256
      • HmacSHA3-384
      • HmacSHA3-512
  • java.security.MessageDigest
    • SHA-1
    • SHA-256
    • SHA-384
    • extra
      • SHA3-224
      • SHA3-256
      • SHA3-384
      • SHA3-512
  • javax.crypto.SecretKeyFactory
    • DESede
  • java.security.SecureRandom
  • java.security.Signature
  • javax.net.ssl.SSLContext: See downstream project lqhuang/scala-native-http
    • TLSv1.2
    • TLSv1.3
  • javax.net.ssl.TrustManagerFactory: See downstream project lqhuang/scala-native-http
    • PKIX

About

java.security implementation for Scala Native

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages