-
Notifications
You must be signed in to change notification settings - Fork 4
refactor: Implement major interfaces of Java Cryptography Architecture and reorganize existed services into OpenSslProvider
#25
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
base: main
Are you sure you want to change the base?
Changes from all commits
8649b03
301b479
64b4406
b7443a7
01554ca
4c9333d
bf6d424
8293ad5
d03685c
2285a9a
bd3b9a1
e43ca07
61221b0
e4990d5
0034f7a
655d992
983f83e
0e2d118
51c385c
682ca87
c89bb7d
9e6a653
63e9bd4
6351785
a1b8bb5
2ef935e
0392a08
d9ebcab
317bc15
4ed725a
d8deccd
f859f97
e656f45
dec711d
20cbbbb
caafafe
beca7fc
b8ba198
9e24fbd
226324c
b840f11
08bd032
4648003
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.mill linguist-language=Scala |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| version = "3.8.3" | ||
| runner.dialect = scala213 | ||
| runner.dialect = scala213 | ||
|
|
||
| # automatically appended by scalafmt itself | ||
| project.excludePaths = ["glob:**/out/**", "glob:**/jwt-scala-tests/src/**"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ import com.goyeau.mill.scalafix.ScalafixModule | |
| import mill.util.VcsVersion | ||
| import mill.contrib.buildinfo.BuildInfo | ||
|
|
||
| import scala.util.Properties | ||
|
|
||
| val scala212 = "2.12.20" | ||
| val scala213 = "2.13.17" | ||
| val scala3 = "3.3.6" | ||
|
|
@@ -60,6 +62,27 @@ trait ScalaNativeCryptoModule extends Shared with Publish { | |
| def scalacOptions = super.scalacOptions() ++ Seq( | ||
| "-P:scalanative:genStaticForwardersForNonTopLevelObjects" | ||
| ) | ||
|
|
||
| val osName = { | ||
| val _osName = Properties.osName.toLowerCase() | ||
| if (_osName.contains("mac")) "darwin" | ||
| else if (_osName.contains("windows")) "windows" | ||
| else "linux" | ||
| } | ||
| val archName = Properties.propOrEmpty("os.arch").toLowerCase() match { | ||
| case "amd64" => "x86_64" // try to follow llvm triple | ||
| case "arm64" => "aarch64" | ||
| case s => s | ||
| } | ||
|
Comment on lines
+66
to
+76
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would avoid this indirection to make java os.arch and osName to look like clang target triple values.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or follow the GCC triple? I copy similar conditional detections from mill project to detect platform (win/linux/mac). But the The main purpose is to provide basic snippets for finding proper include libs. Do you have better ideas? |
||
| val openSslIncludePath: String = (osName, archName) match { | ||
| case ("linux", "x86_64") => "-I/usr/include/openssl" | ||
| case ("darwin", "x86_64") => "-I/usr/local/homebrew/opt/openssl/include" | ||
| case ("darwin", "aarch64") => "-I/opt/homebrew/opt/openssl/include" | ||
| case (_, _) => "" | ||
| } | ||
|
|
||
| def nativeCompileOptions = super.nativeCompileOptions() ++ Seq(openSslIncludePath) | ||
|
|
||
| // Remove class and tasty files | ||
| override def jar = Task { | ||
| val jar = Task.dest / "out.jar" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package com.github.lolgab.scalanativecrypto | ||
|
|
||
| // Java Cryptography Architecture (JCA) Service identifier | ||
| // for better type safety | ||
| class JcaService( | ||
| val name: String | ||
| ) extends AnyVal | ||
|
|
||
| object JcaService { | ||
| val AlgorithmParameterGenerator = new JcaService( | ||
| "AlgorithmParameterGenerator" | ||
| ) | ||
| val AlgorithmParameters = new JcaService("AlgorithmParameters") | ||
| val CertificateFactory = new JcaService("CertificateFactory") | ||
| val CertPath = new JcaService("CertPath") | ||
| val CertPathBuilder = new JcaService("CertPathBuilder") | ||
| val CertPathValidator = new JcaService("CertPathValidator") | ||
| val CertStore = new JcaService("CertStore") | ||
| val Cipher = new JcaService("Cipher") | ||
| val KeyAgreement = new JcaService("KeyAgreement") | ||
| val KeyFactory = new JcaService("KeyFactory") | ||
| val KeyGenerator = new JcaService("KeyGenerator") | ||
| val KeyPairGenerator = new JcaService("KeyPairGenerator") | ||
| val KeyStore = new JcaService("KeyStore") | ||
| val Mac = new JcaService("Mac") | ||
| val MessageDigest = new JcaService("MessageDigest") | ||
| val SecretKeyFactory = new JcaService("SecretKeyFactory") | ||
| val SecureRandom = new JcaService("SecureRandom") | ||
| val Signature = new JcaService("Signature") | ||
|
|
||
| val names: Set[String] = Set( | ||
| AlgorithmParameterGenerator.name, | ||
| AlgorithmParameters.name, | ||
| CertificateFactory.name, | ||
| CertPath.name, | ||
| CertPathBuilder.name, | ||
| CertPathValidator.name, | ||
| CertStore.name, | ||
| Cipher.name, | ||
| KeyAgreement.name, | ||
| KeyFactory.name, | ||
| KeyGenerator.name, | ||
| KeyPairGenerator.name, | ||
| KeyStore.name, | ||
| Mac.name, | ||
| MessageDigest.name, | ||
| SecretKeyFactory.name, | ||
| SecureRandom.name, | ||
| Signature.name | ||
| ).map(_.toUpperCase()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why excluding
jwt-scala-tests? Doesn't sound correct.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, I can remove it. Since these also aren't added by myself either.
scalafmt(via metals) will hint these while opening current project with IDE combo: VS Code + metals +mill