Javax.crypto.spec.SecretKeySpec seems to ignore the last bit in every byte

Hi All,
I am having a problem with the SecretKeySpec class in JCE 1.2.2. I am using DES as algorithm, and a 8 byte long key. I am passing a hex array of 16 characters (each 2 representing a byte) and create a byte array of length 8 from that hex array. For example, the following "A12C3D4E5F6A7B8E" is equivalent to a byte array, having the values of the bytes (in signed byte) [-95, 44, 61, 78, 95, 106, 123, -114]. It works perfectly but what I observed is, if one of the bytes looks like "5E" and I change it to "5F," the code still works, the encrypted text using the key created with "5E" key is decrypted correctly using the "5F" key. It doesn't work if the byte is "E5" and I change it to "F5," and this led me to think that the SecretKeySpec implementation ignores the last bit of every byte (uses just the high 7 bits.)
Anybody came accross this before? Any help appreciated.
THanks,
Marius

As I said, "every implementation I'm aware of ignores them". They're not used during en/decryption, they exist only to provide (marginal) evidence that the key might have been mangled in-transit. Many implementations just skip that step. Note that i'm not saying this is a good thing - it's just been my experience.
The 64-bit quntity you're playing with is NOT "the key" - the DES key is the 56 bits that do not include the parity bits. Ignoring the parity-bits doesn't yield more keys that will do the same decryption, since the parity bits aren't used by DES itself.
The net? Don't worry about it. It's the 56 bits that are the important ones.
Grant

Similar Messages

  • NoClassDefFoundError javax.crypto.spec.secretkeyspec from console

    Hello, I have done a program in eclipse, using the JCE to encrypt and decrypt some messages using AES. In the eclipse graphical interface it works perfect, but if i run it from console, i mean like this
    java -jar org.eclipse.osgi_3.6.0.v20100517.jar -console -configuration config_path -clean -dev file:dev.properties_path
    It works but throw the exception
    NoClassDefFoundError javax.crypto.spec.secretkeyspec
    I think there must be something wrong with the java path because JCE is already inside the jre environment. I need to know how can i indicate in the command line, the right path to the JCE
    I am working on windows
    Thank you!

    yes, i mean
    NoClassDefFoundError javax.crypto.spec.SecretKeySpec
    but i wrote it fast and i didn't realize....
    My output for java -version is
    java version "1.6.0_21"
    Java (TM) SE Runtime Environment (build 1.6.0_21-b06)
    Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)
    So i think that outside eclipse i am using the good one, then i don't know why it doesn't work. Actually, i forgot to say that in the log file, i get this exception message:
    !ENTRY org.eclipse.osgi 4 0 2010-10-15 11:35:12.273
    !MESSAGE Application error
    !STACK 1
    java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:150)
    So maybe this is the real problem. I am sorry but i am not really used to launch java applications from console (i always do it with eclipse) so, i don't really know if i need some more parameters or what happen.
    My config.ini file is the same that eclipse uses when it launches the application, and the dev.properties file is also the same.

  • Javax.crypto.* and javax.crypto.spec.* problem with MHP receiver

    Hello to everyone, I started to program in MHP 1.0.2 on a MHP receiver and now i'm practicing in encrypting and decrypting. I load from the smart card in the MHP receiver an X509Certificate object (I have it both in byte[] form, called certArray, and X509Certificate object, called "certificate"). What i'd like to do is to :
    1)calculate digest of the certificate (line 1 and 2 of the following code)
    2) encrypt the digest using the same algorithm of the certificate (see line 3 and 4)
    The problem is generated at line 3 : the receiver, probably, doesn't find the class of the algorithm of encrypting. It is important to notice that the instruments to encrypt/decrypt are included in javax.crypto and javax.crypto.spec packages.
    MessageDigest md = MessageDigest.getInstance("SHA");
    byte[] digest = md.digest(certArray);
    Cipher encrypt = Cipher.getInstance(certificate.getSigAlgName());
    encrypt.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
    The error message, in the log file, is the following :
    [0#1:2] java.security.NoSuchAlgorithmException: SHA1withRSA not found
         [0#1:2]      at javax.crypto.Cipher.getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.encrypt()V(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.cardInserted(Lopencard/core/event/CardTerminalEvent;)V(Unknown Source)
         [0#1:2]      at opencard.core.event.EventGenerator.createEventsForPresentCards(Lopencard/core/event/CTListener;)V(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.register()V(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.startXlet()V(Unknown Source)
         [0#1:2]      at java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
         [0#1:2]      at tv.osmosys.application.AppManager$XletApp.xletStart()Z(Unknown Source)
         [0#1:2]      at tv.osmosys.application.AppManager$XletApp.loop0(Ltv/osmosys/application/AppManager$XletAction;)V(Unknown Source)
         [0#1:2]      at tv.osmosys.application.AppManager$XletApp.run()V(Unknown Source)
         [0#1:2]      at java.lang.Thread.run()V(Unknown Source)
         [0#1:2]      at java.lang.Thread.startup(Z)V(Unknown Source)
    My question(s) is : how can I include javax.crypto and javax.crypto.spec in the Xlet application to upload it onto the MHP receiver?? Is it possibile to do so?
    Eventually, do other libraries exist to use encrypting algorithms, included in MHP? The version I use of MHP is 1.0.2. Thank you! Bye!

    Hello to everyone, I started to program in MHP 1.0.2 on a MHP receiver and now i'm practicing in encrypting and decrypting. I load from the smart card in the MHP receiver an X509Certificate object (I have it both in byte[] form, called certArray, and X509Certificate object, called "certificate"). What i'd like to do is to :
    1)calculate digest of the certificate (line 1 and 2 of the following code)
    2) encrypt the digest using the same algorithm of the certificate (see line 3 and 4)
    The problem is generated at line 3 : the receiver, probably, doesn't find the class of the algorithm of encrypting. It is important to notice that the instruments to encrypt/decrypt are included in javax.crypto and javax.crypto.spec packages.
    MessageDigest md = MessageDigest.getInstance("SHA");
    byte[] digest = md.digest(certArray);
    Cipher encrypt = Cipher.getInstance(certificate.getSigAlgName());
    encrypt.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
    The error message, in the log file, is the following :
    [0#1:2] java.security.NoSuchAlgorithmException: SHA1withRSA not found
         [0#1:2]      at javax.crypto.Cipher.getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.encrypt()V(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.cardInserted(Lopencard/core/event/CardTerminalEvent;)V(Unknown Source)
         [0#1:2]      at opencard.core.event.EventGenerator.createEventsForPresentCards(Lopencard/core/event/CTListener;)V(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.register()V(Unknown Source)
         [0#1:2]      at it.csp.SecurelabXlet.startXlet()V(Unknown Source)
         [0#1:2]      at java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
         [0#1:2]      at tv.osmosys.application.AppManager$XletApp.xletStart()Z(Unknown Source)
         [0#1:2]      at tv.osmosys.application.AppManager$XletApp.loop0(Ltv/osmosys/application/AppManager$XletAction;)V(Unknown Source)
         [0#1:2]      at tv.osmosys.application.AppManager$XletApp.run()V(Unknown Source)
         [0#1:2]      at java.lang.Thread.run()V(Unknown Source)
         [0#1:2]      at java.lang.Thread.startup(Z)V(Unknown Source)
    My question(s) is : how can I include javax.crypto and javax.crypto.spec in the Xlet application to upload it onto the MHP receiver?? Is it possibile to do so?
    Eventually, do other libraries exist to use encrypting algorithms, included in MHP? The version I use of MHP is 1.0.2. Thank you! Bye!

  • HT2357 So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    Fantastic!  Didn't work at first so restarted App store and tried again.  This time it asked 'ignore update'.  All gone!

  • Javax.crypto.spec.*

    I am trying to encrypt passwords and have been given a code snipper which tries to import "javax.crypto.spec.*". Can you tell me what jar this is in and where to get it.
    Thanks.

    It appears to be new in 1.4.0.

  • Reg:FCC to ignore the last field name

    Hi...
       I am using FCC in the reciver file adapter.
    the output structure is like
    94,ESSAR,,,,,,,D,0000100226,10000,12/13/1 KURLA EAST,MUMBAI,,400025,006398765432,,2009-03-24 00:00:00.0,0000100226,20202789,,,,SUCCESS,,
    /home/corpuser/Disbursement/DD
    I am achieving the above structure. But in that i dont want the last field name "/home/corpuser/Disbursement/DD".
    Can you please tell how to ignore the last field name in the receiver file adapter using FCC.
    Thanks & Regards,
    Leela

    94,ESSAR,,,,,,,D,0000100226,10000,12/13/1 KURLA EAST,MUMBAI,,400025,006398765432,,2009-03-24 00:00:00.0,0000100226,20202789,,,,SUCCESS,,
    /home/corpuser/Disbursement/DD
    I am achieving the above structure. But in that i dont want the last field name "/home/corpuser/Disbursement/DD".
    Can you please tell how to ignore the last field name in the receiver file adapter using FCC.
    Completely with Jai on that.
    Dont do that mapping itself. Handle such conditions in your mapping.
    Is there any specific reason why you can do so?

  • How do I set a reminder for the last day of every month

    Have I missed something? But how do you set a reminder for the last day of every month to recurr indefinatley in iOS6? Sorry if this is really simple but I just can't seem to work it out. Any help gratefully received.

    Hey Mattye88 not sure if you have seen but actully you can do this, but for some reason you have to use Siri.  If you bring up Siri and say "set a reminder ever 4 weeks from next wednesday to check the gas meter" it will set one and it will work just fine, I have reminders to water a Bonsai every three days and it works fine it just shows as custom repeat on the user interface.  Alas it seems you can not use Siri to set one for the end of the month though which is why I am in this threed.  Still hope it helps you to know how to sort this problem atleast.

  • How do you make a event reoccur on the last weekday of every month?

    How do you make a event reoccur on the last weekday of every month in lightning?
    This can be done in outlook and lightning accepts and properly handles the event from a outlook user.

    Hi,
    It seems it cannot be done. You can add your vote to this bug report if you want to keep informed:
    [https://bugzilla.mozilla.org/show_bug.cgi?id=390620 Bug 390620 - Event / Task recurrence options for "Last Working Day" and "First Working Day" of the month]

  • How to set a calendar reminder for the last Friday of every month?

    I need to set a reminder to go off on the Monday following the last Friday of every month. I could settle for a reminder on the last Friday of every month and then delay the reminder by a couple of days, but I'm not sure where to start. Does anyone know how to do this?

    I found an App that solved my problem called "Calendar Tools"
    It is a plug in that allows you to have custom repeat rules.
    Check it out!

  • I have the CC Photography subscription. The last several days, every time I bring up Photoshop, I get a window stating "Sign In Required" and "Terms and Conditions for Trial Software". Why? This is not trial software.

    I have the CC Photography subscription. The last several days, every time I bring up Photoshop, I get a window stating "Sign In Required" and "Terms and Conditions for Trial Software". Why? This is not trial software.

    Asked to sign in after paying may help
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    or
    Chat Now button near the bottom for Activation and Deactivation problems may help
    http://helpx.adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html

  • HT3275 Has anyone come across the red "i" message saying "The backup disk image "/Volumes/Chris...(the last bit being) iMac.sparsebundle" is already in use? This has prevented my time machine from backing up from this morning (5th Dec 2012).

    Has anyone come across the red "i" message saying "The backup disk image "/Volumes/Chris...(the last bit being) iMac.sparsebundle" is already in use."?
    As of yesterday (4th Dec 2012) everything was fine, no trouble or problems at all. Wake up this morning, turn on the computer and when it came time to backup itself, the message occurred above and this has prevented my time machine from backing up from this morning (5th Dec 2012) ever since then.
    Everything on my computer is up-to-date but this problem still persists displaying this message practically every hour, on the hour and nothing is getting backedup!
    If you know what is going on and more importantly, how to fix this, I would be indebted to you for sharing your knowledge with me on this subject.
    Thank you.

    Welcome to the Apple Support Communities
    See > http://pondini.org/TM/C12.html

  • Was there a problem with the last update? Every time I try to watch a video on the net it goes back to the home screen

    Was there a problem with the last update? Every time I try to watch videos it goes back to the home screen

    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • My contacts disappeared for no apparent reason. However, all of my contacts (updated even to the last bit) in my Macbook Air are still there. How do bring my contacts back to my phone?

    My contacts disappeared for no apparent reason. However, all of my contacts (updated even to the last bit) in my Macbook Air are still there. How do bring my contacts back to my phone?

    Hi perriejunn!
    They might actually be the same Apple ID. When you have an email and use it to log into iCloud it will create an iCloud alias for you. I have an @live.no appleID, which also has an @iCloud.com alias that are otherwise identical.
    If you log into applied.apple.com with the @gmail.com account you should see the @iCloud.com as an "alternate" email address.
    You might also have created a new iCloud account/Apple ID when you used iCloud the first time. Then this @iCloud.com will not be connected to you @gmail.com address or any other mail addresses. You can then log out of that Apple ID at Settings>iCloud and log in with this @gmail.com Apple ID and sync contacts.

  • How can I put something in for the last Wednesday of every month

    How can I put something in for the last Wednesday of every month

    I don't believe there is such a custom repeat option with the iPhone's Calendar app, but if you are syncing calendar events with a supported calendar app on your computer or syncing calendar events over the air with an email account that supports it with an option to create such a custom repeating event with the online calendar, set up the custom repeating event there.

  • I get my itunes 10 to download so far but at the last bit it freezes on the download and I cant get any further!! gggrrr anybody have an answer??

    I get itunes 10 to download so far but at the last bit it freezes and I cant get it to finish!! grrr
    this has happened 5 times now!!!! HELP PLEASE???

    I don't know of a definite answer for this.
    Things you could try:
    Restart your PC.
    Try a different browser.
    Failing that, get a friend to download the installer for you and put it on a USB memory stick for you.

Maybe you are looking for

  • Problem displaying a graph

    I am trying to display a line graph from a given arrays of integers, which are stores as x and y points consecutively. (ie. int values[] = {x0,y0,x1,y1,etc...}) However, after I compiled and run the code, no graph is displayed. What's wrong?... impor

  • I can't get Java to work

    Hi, I am running OSX version 10.7.5 and safari 6.0.2 (7536.26.17). It is a clean install onto a new drive. I want to be able to use Java but cannot get it to work. I have made sure that safari is running in 64 bit mode and that Java is enabled in the

  • Should Sim Card be removed before selling?

    I just sold my old iPhone 3G & 3GS. I did a Erase of all content and settings, but should I remove the Sim Cards before I ship? The new iPhone 4 has a smaller Sim Card and I didn't need to transfer my sim cards from my old phones. Thanks, Nick

  • Unterminated String Constant error

    I am getting this error on clicking any of the record in the tree list view Anyone is aware of this issue with OTM Thanks Gajananp

  • Logic for MVER table update

    Hi Experts, Can anyone let me know how this table MVER updates. What are all the mvt type it will consider for updation. Your fast reply is appreciated. Thanks, Suresh