Tarun Khandelwal

Greenhorn
+ Follow
since Feb 23, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tarun Khandelwal

Hello,

I have to test my application.
It uses data from another application through Socket Connection.
I don't want to install this application, So how can i mock the Socket Service easily.
One way that i know is to create a local service that will work same as actual service by creating local ServerSocket.

Is there any way i can do that, just like mocking db connections, so that i don't have to take care of synchronizing Sockets and there Streams.

Thanks,
Tarun Khandelwal
10 years ago
I want to create a Web Service using Jersey so that it will handle multiple context path.
Eg http://<IPADDRESS>:<PORTNO.>/path1
http://<IPADDRESS>:<PORTNO.>/path2
http://<IPADDRESS>:<PORTNO.>/path3
http://<IPADDRESS>:<PORTNO.>/path4

Can you please tell me how i can do that.

Thanks,
Tarun Khandelwal
10 years ago
Hello Everyone,

The process that c code is using to generate both keys is,

First it is using R_GeneratePEMKeys for getting Public and Private key Object.
Than it is using R_EcodePEMBlock function to encode both private and public key individually.
I am receiving this PEM Encoded private key.
Now i have to load RSAPrivatekey object using this key object.
How can i do that?

Thanks,
Tarun Khandelwal
11 years ago
Hello Everyone,

In my application i am receiving RSA private key that is being generated using C code. in c RSA library is used.
Now i am not getting how to load that private key into RSAPrivateKey Object.
Please let me know how could i do that.
RSA Lib I am using consists of:-
DES.H
DIGIT.H
GLOBAL.H
MD2.H
MD5.h
NN.H
PRIME.H
R_RANDOM.H
RSA.H
RSAREF.H
DESC.C
DIGIT.C
MD2C.C
MD5C.C
NN.C
PRIME.C
R_DH.C
R_ENCODE.C
R_ENHANCE.C
R_KEYGEN.C
R_RANDOM.C
R_STDLIB.C
RSA.C

It would be great if i can get how to load private key from the one generated by c code.


Thanks,
Tarun Khandelwal
11 years ago
Thanks Henry,

You are absolutely correct.
The KeyPair is being generated before by the C code.
Now i have to load the Private key from the object that i am getting from C.

I will look into your suggestion.
But it would be great if i get how to load the file.

Thanks
Tarun Khandelwal
11 years ago
Hello Everyone,

I have to Implement RSA Decryption. For that i think i will be requiring Private Key.
I am receiving a file which is being created by c code. Where the key is generated using R_ENCODE.c class , function :- R_GeneratePEMKeys.
Than the buffer is being passed to R_EncodePEMBlock.

I am not getting how to get Private Key Object from that file?
Waiting for Response.

Thanks,
Tarun Khandelwal
11 years ago
Hello Tim,

Till now i haven't started developing.
Actually ii am stucked in the beginning. I have RSA implementation in C.
Now i have to implement the same in Java.
In C I was getting private key after passing My Corporate Key into the Function R_DecodePEMBlock of class R_ENCODE.c

So can you please tell me is there any class in java also, using which i can retrieve the Private Key.

Thanks,
Tarun Khandelwal
11 years ago
Hello All,

I am implementing RSA for a Project.
Now, i have a string using which i have to generate private keys.
When i saw the C implementation for the same, i got that there is library R_ENCODE.c which is having a Function R_DecodePEMBlock. This function takes the Common String as argument and return me with the Object of Private Key.
Can anyone tell me how to implement this in java. So that i can have Private key and than i can use RSA for decryption.

Thanks,
Tarun Khandelwal
11 years ago
Hello Everyone,

I am stucked between signed and unsigned bits in C and java.
Actually i converting 2 byte into an int using "((unsigned int)((unsigned int)cipherBuf[0] << 8)) | (unsigned int)(cipherBuf[1])" .
So when i am getting bytes 1, 240 in C, its converting it to 496.
But since Java does not entertain unsigned bits, i am getting 1, -16 as a set of bytes.
I am not getting how to convert this set to int.
In java i have used following statement "((int) ((int) cipherBuf[0] << 8)) | (int) (cipherBuf[1])".

can anyone help me.
It would be great to find the solution as soon as possible.
11 years ago
Hello Everyone,

I have to use DES Encryption.
But the Key is coming from C# code. And that is having double Bytes Character.
So when i am using that Key in my code, i am getting Key Length more than what i need.
Eg. Key coming from C# code :- zkouškaa, Which returns me Bytes :- 122, 107, 111, 117, -59, -95, 107, 97, 97.
Since in C# it takes the bytes as unsigned , there String is returning only 8 bytes that can be used to construct key. But With Java its returning 9 Bytes , which is making the Problem.

Can anyone please help me with the Issue.

I have one more thing.
The Key coming is in Hexa Format, so is there any way that i can directly use Hex String as Key?
Would that be better or Possible?.

Thanks,
Tarun Khandelwal
11 years ago
Hello All,

I am having the same Problem.
I tried shipping jar externally but then i am getting NoClassDefFound Error for SunJCE_b class.
Can you please tell me how can i ship the jar successfully.

Thanks,
Tarun Khandelwal
11 years ago
Hello Everyone,

I have the solution to add jar files to my project. But Now when i am adding the Bouncy Castle Library :- jce-jdk13-146.jar, i am getting an error :-
.

Can anyone tell me why this issue is coming as now am using the jar itself.
Now what i am doing is,


classes folder :- myClasses
BC lib lib/jce-jdk13-146.jar

Now i am creating a jar for both, setting Classpath as lib in Manifest file.

So Final Structure is myJar.jar
myClasses
lib
jce-jdk13-146.jar
META-INF
Manifest.MF
11 years ago
Thank you for your response. But i am not getting how to add a jar file as dependency to class path of the device.
And if i am extracting the jar its signature is lost and than i could not use its class files.


Thanks and Regards,
Tarun Khandelwal
11 years ago
Hello Tim,

Thanks for your reply.
I didn't got you. Are you saying that i should all the BC classes at run time that are being used by my code?
Adding Bouncy Castle will do the task?

Can you provide with a code snippet.
It would be great.

And i have constraint to JDK version.
As device on which i am working is having that version only.

Thanks and Regards,
Tarun Khandelwal
11 years ago
Hello All,

I am doing development in an embedded project and i am using Bouncy Castle for AES Encryption.
Now when i am adding Bouncy Castle as Security Provider, i am getting error in initializing the Cipher.
This is happening when i deploy my project on device.
When i am running my code in eclipse its working fine.
When i investigated further, i found that while deploying i am extracting the jar provided by the BC.
So code is not getting correct signature.

So can anyone can tell me how to use Bouncy Castle jar library in embedded device as i cannot access root of the device and add that to Class Path.

library i am using is jce-jdk13-146.jar and i am using Java JDK 1.3.

Please find the code inline



It would be Great to have a solution as soon as possible.
11 years ago