-
Notifications
You must be signed in to change notification settings - Fork 959
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
Add JRE support for javax.crypto package #432
Comments
While the JRE emulation support Please rebuild without this flag to get the full list of classes your Java On Tue Nov 11 2014 at 11:52:57 PM Aries notifications@github.com wrote:
|
Thanks your reply. There are some 'javax.crypto' dependencies in the java project. |
Hi, Any idea when this might be done? Thanks. |
You asked when it was done, and since there are 36 classes in javax.crypto, I strongly recommend that instead of waiting, you refactor your app's If your goal is to port an Android app while writing the minimum If you have some Java security skill, a third option is to implement the On Fri, Sep 25, 2015 at 12:46 AM lrbtony notifications@github.com wrote:
|
HI, |
Here's how to do crypto on iOS today: https://developer.apple.com/library/mac/documentation/Security/Conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html |
Why don't you use Bouncycastle library to improve javax.crypto support? Or at least provide the basic scaffolding to incoroporate Bouncycastle to a project? Thanks |
Using crypto APIs other than the iOS Security Framework requires that every j2objc app would need to follow the U.S. Export Compliance steps, which may require submitting compliance declaration forms with every AppStore submission. You are of course welcome to directly include BouncyCastle in your own app if you are okay with this export requirement, but it can’t be included in the platform without impacting all other app teams using j2objc. Before you translate BouncyCastle (not difficult, but it's big), consider what exactly your app's crypto requirements are. Java's security API is huge to handle all possible scenarios for all platforms, but most mobile apps have very narrow needs. These apps can therefore define a simple "security" or "crypto" interface for their cross-platform code, then implement it separately for Android and iOS, often with a single simple class since it just calls either the JRE on Android or the Security Framework on iOS. That's why we get requests for full JRE support when an app team first hits this issue, but then they don't need it later. Unfortunately, every app's needs tend to be different, which is why we can't provide a security subset that will meet the needs of all j2objc users. We plan on implementing crypto next year, in large part because the macOS and iOS security APIs have been unifying in recent releases (especially iOS 10). |
The |
Sorry for reopening this but I'd need help with exactly this: transpiling the bouncycastle source into a project. I'd like to work with a java library that uses AES encryption (and some other) in its code and before I'd gone to the length of rewriting the code into objc native code, I thought about adding the appropriate security provider through bouncycastle to at least test if the code works after translating it to objc. Unfortunately here I am a little lost: the first thing is that I don't really know which source from bouncycastle am I supposed to use. There are so many choices of different jdks and modules. Do I use only the In fact I have already tried various approaches. Using only the I couldn't find anything that helps by searching other than the statement that it should be fairly simple (twice). So any help would be appreciated (or a nudge in the right direction for that matter). Thx! |
The general trick to translating a new library is to first come up with a
command-line for *javac* that builds, not j2objc. Be sure to add source
directories and/or source jars to the -sourcepath, and *don't use the
-classpath argument* (the latter is for class files, which j2objc doesn't
use). For BouncyCastle, this is likely to mean several source directories,
but start with the one directory that has the AES support you need, then
add other directories only if the javac command fails due to missing
references.
Once you have a javac command that builds all the Java sources
successfully, then change the "javac" in the command to "j2objc" and use
the same arguments and file list. Unless this code uses API that the j2objc
JRE doesn't support, this should just work. Since BouncyCastle uses very
little of the JRE API (it's mostly math), though, it should be fine. One
reason I'm confident about this is because I used BouncyCastle a lot when
profiling j2objc performance.
Why does starting with javac first work so well? It's because j2objc uses
javac for its front-end, so all of those javac flags are passed unchanged
to the front-end by j2objc. All of the missing class errors you see are
from the javac front-end, as nothing j2objc-specific has executed yet.
Why does thiswork better than starting with j2objc? For whatever reason,
when an experienced Java developer hits a javac error, they usually
understand what's wrong and are comfortable fixing it themselves. Type
"j2objc", though, and suddenly they doubt themselves and ask for support.
Under the hood the j2objc translator is just a Java compiler.
…On Wed, Nov 2, 2022 at 12:36 AM thieren ***@***.***> wrote:
Before you translate BouncyCastle (not difficult, but it's big)
Sorry for reopening this but I'd need help with exactly this: transpiling
the bouncycastle source into a project.
I'd like to work with a java library that uses AES encryption (and some
other) in its code and before I'd gone to the length of rewriting the code
into objc native code, I thought about adding the appropriate security
provider through bouncycastle to at least test if the code works after
translating it to objc.
Unfortunately here I am a little lost: the first thing is that I don't
really know which source from bouncycastle am I supposed to use. There are
so many choices of different jdks and modules. Do I use only the prov
module, or do I need to add the core also?
I know that this is not the bouncycastle repo here, so this question is
most likely out of scope, but at least I DO find it difficult to transpire
the bouncycastle source into objc.
In fact I have already tried various approaches. Using only the prov
module and also with core, with different sources (jce, jcajce, ...) but
every time there are compiling errors when trying to compile it with j2objc.
Mostly it is either missing classes (hence adding the core module) or
there are class names doubled in different packages of the bouncycastle
source.
I couldn't find anything that helps by searching other than the statement
that it should be fairly simple (twice).
So any help would be appreciated (or a nudge in the right direction for
that matter).
Thx!
—
Reply to this email directly, view it on GitHub
<#432 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAW2JLZ3P246GIMDF4YMD63WGIKWXANCNFSM4AXH7LTA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Thx for the nudge and the overall determination to help. :-) The tip with finding a One major difference I've noticed between But that's actually no real problem in my case, since I've actually just looked at the generated *.class files and used the according *.java files in my Xcode project. Again, many thanks for your help! |
To compile all dependent Java sources like javac does, use
j2objc's --build-closure flag. It's not the default behavior because
several build systems work best with explicit outputs generated for
specified inputs.
Don't use the --no-package-directories flag, as that's likely the cause of
the Xcode errors. Since Xcode doesn't support relative paths for source
files (that flag is just a hack to get beginners started), the work around
is to define an External Build rule for the Java sources that uses an
external build tool, then have the Xcode app depend upon that rule.
The JreEmulation.xcodeproj
Xcode project
<https://github.com/google/j2objc/tree/master/jre_emul/JreEmulation.xcodeproj>
does this to invoke Make for the Java build. Initially, though, you can
just use the same command-line as you successfully did by hand.
…On Thu, Nov 3, 2022 at 3:10 AM thieren ***@***.***> wrote:
Thx for the nudge and the overall determination to help. :-)
The tip with finding a javac command first was very good. At least I got
this to compile, so I think I've got the right source files now.
One major difference I've noticed between javac and j2objc command is,
that when I compile a *.java (e.g. javac -d dist -sourcepath src
./src/org/path/to/my/file.java) it will compile all needed class files
that my file.java depends on from other packages into the dist folder. But
j2objc won't do the same for the objective-c code. Is there a way to get
this working?
But that's actually no real problem in my case, since I've actually just
looked at the generated *.class files and used the according *.java files
in my Xcode project.
Unfortunately now I'm back at the error that says that multiple commands
generate the same output file, since bouncycastle uses the same class names
in different packages. If you've got any on that let me know.
Again, many thanks for your help!
—
Reply to this email directly, view it on GitHub
<#432 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAW2JL4RZRYKNESX4VYQHSDWGOFRTANCNFSM4AXH7LTA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Hi,
I used j2objc to convert java code to oc. I have convert the code by eclipse plugin. When I take the oc code to ios project, I have an error ActiveCodeHandler.java:10:10: 'javax/crypto/BadPaddingException.h' file not found. So I can not find the header in the dist/include. Now I have no idea for this. ps: The code isn't android project. Who can help me. thanks.
The text was updated successfully, but these errors were encountered: