Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!

Gianluca Neri

Greenhorn
+ Follow
since Jan 13, 2020
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 Gianluca Neri

Hello,

I hope this is the right section to post my question. We are working with telco sim cards using the javax.smartcardio library. We are able to read a parameter value we know to be present on the card by the CardChannel class and the transmit method. But we are not able to scan the whole card in order to read and list all the parameters and the values stored.

Is there anyone who has had the same problem or can you suggest a way?

Thanks
1 month ago
They are in my company, other dep.. For the moment we have sent an email and all we can do is wait with confidence.
I hope we are close to solving the puzzle.
I'll update you as soon as I have news.

Thanks and have a nice day!


1 month ago
I have read and agree.
At the moment, as you say, we have no choice knowing that the target system has limits.
We are trying to engage the team that manages it in order to share what we found.
Only this is a challenging activity when you have to go through the communication processes of a large company. :-)
1 month ago
Hi Stephan,

Why not ECB?

Where can I find a list of options with pros and cons?
We must use blowfish because we have to send the encoded strings to an old system.
Anyway at this point we investigate on our behalf about which one is correctly recognized by the destination.

Thanks
1 month ago
We have solved using the following solution:

1. Passing the option "Blowfish/ECB/NoPadding" to the getInstance function.



2. Encoding the result of the method as below:

         
In this manner every output string has the same length.

Thanks to all for the support!
1 month ago
Thanks for your first answer.
I confirm the sentence of Stephan: ”given different plain text strings (but all of the same length), encrypting them all with the same key SHOULD (but itsn’t) produce ciphertext strings that all have the same length.”
I try to provide more details. First of all about your questions:

•  Are all plain texts really the same length?
Yes (length=32, expected also in output)
•  Are they all really encrypted with the same key?
Yes
•  The plain text string is converted to a byte array in a platform dependent fashion.
Ok
•  No feedback mode and padding scheme are specified when getting an instance of the cipher.
Ok

You can find below some examples. Please, note the last 2 that have a different length (they are shorter compared to the previous with the same size, never happened until now that they were longer).

***************Example 1**********************
input string: 740E7B7D4116A48382D374688BBA7C87
encryptBlowfish with to_string: [B@2509657d
encryptBlowfish Base64.getEncoder().encode: [B@21e73d60
final value Hex.encodeHexString: 57304A414D6A55774F5459314E32513D
*************** Example 2**********************
input string: 07F58E9965E3F82170CC4E794B0CE1C2
encryptBlowfish with to_string: [B@7833ebd2
encryptBlowfish Base64.getEncoder().encode: [B@2a1da2d5
final value Hex.encodeHexString: 57304A414E7A677A4D3256695A44493D
*************** Example 3**********************
input string: 673F75945A4FEC095D6FD0207AC70C50
encryptBlowfish with to_string: [B@45c37f33
encryptBlowfish Base64.getEncoder().encode: [B@194e314d
final value Hex.encodeHexString: 57304A414E44566A4D7A646D4D7A4D3D
*************** Example 4**********************
input string: AF010C9C902D13DC9D7C48D2504F11BC
encryptBlowfish with to_string: [B@1621bf43
encryptBlowfish Base64.getEncoder().encode: [B@74d753a6
final value Hex.encodeHexString: 57304A414D5459794D574A6D4E444D3D
*************** Example 4**********************
input string: 9274BA06F02429C204193BE6575D2804
encryptBlowfish with to_string: [B@7785754a
encryptBlowfish Base64.getEncoder().encode: [B@596107c
final value Hex.encodeHexString: 57304A414E7A63344E5463314E47453D
*************** Example 5**********************
input string: B91064F4666FB23FD9363098EAE22A4E
encryptBlowfish with to_string: [B@52258ca8
encryptBlowfish Base64.getEncoder().encode: [B@67476514
final value Hex.encodeHexString: 57304A414E5449794E54686A5954673D
*************** Example 6**********************
input string: 8A6679CACEB6ABDEFAF540886EA37A16
encryptBlowfish with to_string: [B@d9a5f7b
encryptBlowfish Base64.getEncoder().encode: [B@13b06f4f
final value Hex.encodeHexString: 57304A415A446C684E57593359673D3D
*************** Example 7**********************
input string: 3EE1C3A94FEEFB1AA9900D149F7C8753
encryptBlowfish with to_string: [B@6f427c
encryptBlowfish Base64.getEncoder().encode: [B@2f90a998
final value Hex.encodeHexString: 57304A414E6D59304D6A646A
*************** Example 8**********************
input string: BE5B584F582E5D36DDA990723B2D126D
encryptBlowfish with to_string: [B@75f258
encriptedki encryptBlowfish Base64.getEncoder().encode: [B@2e110442
final value Hex.encodeHexString: 57304A414E7A566D4D6A5534  

Key=0123456789ABCDEF0123456789ABCDEF (used in all examples).

We semplified the code:



Here are some questions:

- If the value to encrypt and the key are exadecimal strings how do we convert them in a byte array? Should we use string.getBytes() or DatatypeConverter.parseHexBinary(string)?
- Is it correct that an exadecimal 32 character (16 byte) value with a 32 characters (16 byte) key produces as blowfish encrypted value a 23 byte array?
- How can we convert the 23 byte array into a fixed 32 character exadecimal string?
- The resulti if Cipher.dofinal for blowfish algorithm is a base64 encrypted byte array?

Thanks
1 month ago
Hello,

We're trying to encode several input strings with the same length (32) applying Blowfish + Hex encoding.
The problem is that not always the final coded strings have the same length as we expect (32 length strings).
Below you find the code used. Please, can you help to suggest what's wrong?

Thanks a lot!



Best regards
1 month ago