AES encriptation

Hi, first my english is bad.
I have this code for AES enc/dec
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.io.*;
* This program generates a AES key, retrieves its raw bytes, and
* then reinstantiates a AES key from the key bytes.
* The reinstantiated key is used to initialize a AES cipher for
* encryption and decryption.
public class AES {
String palabra;
byte[] par;
SecretKeySpec skeySpec;
//IvParameterSpec IvParameters;
public AES(String mesagge){
palabra="The Password";
par=palabra.getBytes();
skeySpec = new SecretKeySpec(par,"AES");
byte[] cc=encripta(mesagge);
String real=desencripta(cc);
* Turns array of bytes into string
* @param buf     Array of bytes to convert to hex string
* @return     Generated hex string
public static String asHex (byte buf[]) {
StringBuffer strbuf = new StringBuffer(buf.length * 2);
int i;
for (i = 0; i < buf.length; i++) {
if (((int) buf[i] & 0xff) < 0x10){
     strbuf.append("0");
strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
return strbuf.toString();
public static void main(String[] args) throws Exception {
String message="This is just an example";
System.out.println(message);
AES aes=new AES(message);
public byte[] encripta(String mensage){
try{
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted=cipher.doFinal(mensage.getBytes());
System.out.println("encrypted string: " + asHex(encrypted));
return encrypted;
}catch(Exception e){
e.printStackTrace();
return null;
public String desencripta(byte[] mensage){
try{
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] original=cipher.doFinal(mensage);
String originalString = new String(original);
return originalString;
}catch(Exception e){
e.printStackTrace();
return "";
I have the following error
java.security.InvalidKeyException: Invalid AES key length: 96
at com.sun.crypto.provider.SunJCE_e.a(DashoA12275)
at com.sun.crypto.provider.SunJCE_i.a(DashoA12275)
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.AESCipher.engineInit(DashoA12275)
at javax.crypto.Cipher.a(DashoA12275)
at javax.crypto.Cipher.a(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
at com.archicentro.scav.encriptador.AES.encripta(AES.java:77)
at com.archicentro.scav.encriptador.AES.<init>(AES.java:39)
at com.archicentro.scav.encriptador.AES.main(AES.java:69)
Can help me with this?

you should know the key length for AES.that's where the mistake is.

Similar Messages

  • Won't connect to the internet/wi-fi

    I recently downloaded the new softwear for my playbook and since then it wont connect to wifi. It wont bridge with my bb cause o2 messed up my email and pin so i cannot use that anyway
    but when im at home even when i enter the router pins and press the wps button still nothing ive tried re booting the router and re starting my play book but nothing
    HELP

    Try updating the router firmware. Then try setting it up to WPA or WPA2 Security with AES encription. You will then have to enter the network password. Try it and report back.

  • Does mPC 51PV = Junk?

    Hello,
    I've had three of these machines, each one has broken and I've already sent 2 of them back - and now the third ones is as good as dead.
    Is this board a load of rubbish or what?  Has anyone else had problems with this?
    I build it as follows:
    Spec:
    MEGA mPC 51PV + wifi
    LG DVD-recorder IDE GSA-4040B
    Maxtor DiamondMax Plus9 80GB SATA
    Corsair 2x1GB DDR2 800MHz PC2-6400 XMS2 CL5 1.9V Matched Pair
    AMD Athlon 64 X2 3800+ / 2x512KB / 65W, ADO3800CUBOX
    Samsung SM940N 19" LCD
    It all works in this setup, but then I plug in a second LCD to the DVI port on the machine.  This kills everything and the machine never boots again, crashing during the bios boot, before it even gets to booting the OS.
    I decided to write off the DVI port, and buy a Sparkle GeForce 7300 PCIex card.  Installing this, also kills the machine - It's dead even if I remove the card and go back to the working configuration.
    The two I returned were tested and confirmed dead by eBuyer.  I haven't tested the CPU and ram separately, though I've tried single ram modules at a time, and the first machine reinstalled windows and ran a partition management CD without an issue - it takes a fair bit of effort to move and copy a partition, so I'd have thought any major problems would have surfaced then.  It just seems to die as soon as I try to get two screens going, in any way.
    It's likely I'll return this 3rd one and buy a shuttle PC, it's annoying as the nearest spec is nearly twice the price.  You get what you pay for it seems!

    Hello,
    I have a similar problem:
    Spec:
    MEGA mPC 51PV + wifi
    LG DVD-recorder IDE GSA-4040B
    Maxtor DiamondMax Plus9 80GB SATA
    Corsair 2x1GB DDR2 800MHz PC2-6400 XMS2 CL5 1.9V Matched Pair
    AMD Athlon 64 X2 3800+ / 2x512KB / 65W, ADO3800CUBOX
    2 x Samsung SM940N 19" LCD
    When I power up, somtimes it hangs during POST, sometimes just before booting.  I have to turn it off on the back to get it back to life.  Occasionally if fails to boot windows properly too, showing garbage on the screen, and sometimes the bios screen breaks up and the bios crahses.
    Having failed to get VGA+DVI ports to work as dual head, I also bought a SPARKLE NX7300GS. 512MB (256MB) however the boot problems still happened, though I've been able to run dual head, one screen on each graphics card (onboard, pciex).
    Any wisdom would be appreciated - I'll post back with any more detailed fault information I can find...
    Incidentally, does it definitey /not/ do dual head onboard?  Why the 2 graphics ports otherwise?
    I've also had a few issues with the wireless network card: Using WPA/WPA2-PSK AES encription, it seems to have difficulty connecting, and wont work at all with the driver from windows update.

  • Multiple issues arose after upgrading Airport Extreme firmware to 7.41

    I recently upgraded my Airport Extreme firmware to 7.4.1 and instantly all my windows machine had issues connecting to the wifi, my Apple TV could no longer connect including a Nokia E71. The only devices connecting were the MacBook and iPhones. For the Windows machines i resolved this by forcing to authenticate using WPA2 AES encription. But the Apple TV and E71 couldn't connect. Also some VPN connection issues arose with my windows machines (iPsec). After 2 days of reluctancy to downgrade the firmware, i was left with no option other than to downgrade to 7.3.2.
    I am 100% sure there is a problem with the new firmware, downgrading fixed all the issues without any configuration adjustment.
    Apple you dropped the ball on this one, when are we getting a patch to 7.4.1?
    Message was edited by: Macinit

    Open Airport Utility. Select the airport from the list on the left (if you have more than one) and then choose Manual Setup.
    On the Summary tab that opens, click on Version (that's the word Version, not the version number next to it). A drop-down arrow appears - click it and you should get a list of versions to choose from. 7.3.2 seems OK. Pick it and the device will downgrade and restart.

  • Can no longer connect to encripted wireless.

    Hello,
    I am running a wired and WPA TKIP Encripted wireless network through a WRT350N and Netopia DSL modem. I have a Western Digital Mybook Premium 500GB hard drive connected for storage.
    The system had included 2 XP Home PCs one using a Linksys WMP54GS Wireless PCI adapter and the other using a Netgear “G” USB adapter configured through Windows since the Netgear software would only do WEP.  There are also 2 laptops one being an older model with the Linksys “G” PCMCIA and a newer Core2Duo using Intel Proset.
    February I built a New PC which I connected via CAT5 which required moving the WRT350N, modem and 500GB MyBook into the computer room. In this room we also have our Dual mode 2.4 Ghz Linksys CIT300 Skype phone and our 2.4Ghz main phone. The new PC also has a Logitech G7 mouse using 2.4Ghz wireless. Everything ran smoothly for just over a month.
     Around the same time as the start of the network connection Issues I swapped the Motherboard in the New PC with an SLI version and set the machine back up still using CAT5 and no wireless.
    I cannot say for certain that we didn’t have any issues before the time of the swap but it did become very noticeable around the same time and I just want to cover all the bases.
    What happened is the wireless PCs slowed down a bit and then the Netgear connected PC started to have disconnect issues that were very noticeable since it was the machine that pulls our e-mail. We then noticed the Linksys G Desktop having connection speed issues and then finally all the wireless machines will no longer connect via encrypted wireless at all. If I reset the Router they connect without a problem. I can change the SSID and turn off the SSID Broadcast without a problem but the moment I turn on WPA Personal, TKIP, and set a password they all lose connection and will refuse to connect. I have sat down at each machine and deleted the wireless profiles and set them up with all the same SSID, Security, and keys but they will not connect.
    I even ran Net Stumbler on my Laptop to look for other wireless networks but only find one on Channel 11. Mine shows up too but at Channel 1 using the 40Mhz channel. Network mode is set to Mixed, Radio band is auto, Wide Channel is auto, Standard channel is also Auto.  
    Is there anything else I may be missing? I have reset the router many times and have tried restoring from saved configurations but nothing works at all. The only thing that works now is the wired connection. L
    I sure hope Linksys reads these forums because they sure do not read their tech support e-mails!
    I look forward to any help.
    Thanks,
    Martin

    First of all, re-download and re-install the latest firmware for your router.  After installing the latest firmware, make sure you reset the router to factory defaults, then set up the router from scratch.
    Next, make sure you have a unique SSID (don't use "linksys" ), and turn on SSID broadcast.  Turning on SSID broadcast makes it easier for your computers to find and stay connected to your router.   I used to recommend that SSID broadcast be turned off for security reasons, but this is no longer required because new "cracking" techniques have made this old trick useless.
    As a test, turn off all your 2.4 GHz devices and unplug them from the wall.  This would include your phones, wireless mouse, and any Bluetooth, wireless baby monitors, microwave ovens, wireless keyboards, etc.   Also, turn off any 5+ GHz phones, as some of these also use the 2.4 GHz band.   See if this makes a difference.
    Since your Netgear "would only do WEP", I don't understand how you ever got it to work before with WPA encryption.  Please explain.  Are you saying that the Windows software was doing the WPA for you? 
    Update you computers with the latest drivers for your wireless adapters.
    As infinityx mentioned, update Windows XP to at least SP2.
    It sounds like you may have the Intel Pro Wireless 2200bg card.  If so, this card is known to have connection problems.  The problems with this card worsened with a recent Windows update, but were fixed with the latest driver.  Go to the Intel web site and download and install the latest drivers.
    Also, you can try another channel on your router.  Since you have a neighbor on 11, try any channel 1 thru 6.  (Always try to stay at least +5 or -5 channels from your strongest neighbors.).
    Message Edited by toomanydonuts on 03-16-200704:01 AM

  • IPad: Open AES-encrypted zip files?

    Is there an app which allows one to open zip files that were encrypted with AES-128 or AES-256?  There was a discussion last year (https://discussions.apple.com/message/12429143) saying that there were none at the time, but I'm hoping for some progress since then.  GoodReader, Filer LIte, and USB Disk Pro all failed to read files encrypted with either algorithm.  Thanks,
    John

    Is there an app which allows one to open zip files that were encrypted with AES-128 or AES-256?  There was a discussion last year (https://discussions.apple.com/message/12429143) saying that there were none at the time, but I'm hoping for some progress since then.  GoodReader, Filer LIte, and USB Disk Pro all failed to read files encrypted with either algorithm.  Thanks,
    John

  • Cisco AnyConnect VPN client and 256 AES encryption in IE8

    Hey,
    We have a site that we are trying to connect to with the AnyConnect VPN client version 2.5.3055 on Windows XP SP3. As soon as we enter the site info and hit select, it says a connection was unable to be established.
    I believe this has to do with the encryption, its set up with 256 bit AES. We are only able to install IE8, which on XP only supports up to 128 bit encryption, so in IE8 the page will not load. To fix that issue we installed firefox which supports 256 bit encryption. We can get to the page there, but when we go to connect to the same site VIA the VPN client it still will not connect. It will work fine on a windows 7 box with IE9 installed from the same network.
    My question mainly pertains to how the AnyConnect client connects on the back end. Does it use Internet explorer's SSL layer by default? Or does it have its own? If it connects through internet explorer, is there a way to change it to firefox so it will actually be able to open up a connection?
    Thank you for your answers in advance,
    John

    Hey Jeff,
    Thanks for answering that question. Hmm, so it doesnt go through the browsers SSL layer. We have systems on the same network (same proxy, firewall, vlan, etc). All the systems with windows XP SP3 and IE8/IE7 can not connect to the VPN (they arent even able to start the connection and ask for proxy/logon info.), all the systems with windows 7 and IE9 can. Same setups on each one as far as the security policies go as well. I thought it may have to do with the 256 bit encryption that they are using.
    If thats not the case, what else could be causing the problem? weve tested it on about 5 XP machines and 5 Win 7 machines, same results on each. Connects on Win 7, does not connect on Win XP.
    Thanks,
    John

  • PKCS11 : Unable to generate AES token using C_GenerateKey function

    Hi All,
    I am using the Eracom's PSE HSM module. They have provided me with the PKCS11 Java interface. I am trying to generate a 128 bit AES secret key with the C_GenerateKey method. However, I keep getting a "incomplete template" exception. I am not sure what constitues a complete CK_ATTRIBUTES template when it comes to generating AES secret keys in PKCS11. This is the template that i have used for this purpose:-
    public static void generateKey(CK_SESSION_HANDLE session,
                   CK_MECHANISM_TYPE mechanismType, String keyName, boolean bPrivate,
                   CK_OBJECT_HANDLE hKey) {
              CK_MECHANISM keyGenMech = new CK_MECHANISM(mechanismType);
              CK_ATTRIBUTE[] template = { new CK_ATTRIBUTE(CKA.TOKEN, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.SENSITIVE, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.LABEL, keyName.getBytes()),
                        new CK_ATTRIBUTE(CKA.EXTRACTABLE, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.DERIVE, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.VERIFY, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.EXPORTABLE, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.ENCRYPT, CK_BBOOL.TRUE),
                        new CK_ATTRIBUTE(CKA.WRAP, CK_BBOOL.TRUE),
                        new CK_ATTRIBUTE(CKA.UNWRAP, CK_BBOOL.TRUE),
                        new CK_ATTRIBUTE(CKA.MODIFIABLE, CK_BBOOL.TRUE),
                        new CK_ATTRIBUTE(CKA.SIGN, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.DECRYPT, CK_BBOOL.TRUE),
                        new CK_ATTRIBUTE(CKA.IMPORT, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.EXPORT, CK_BBOOL.FALSE),
                        new CK_ATTRIBUTE(CKA.KEY_SIZE, new Long(128)) };
              CryptokiEx.C_GenerateKey(session, keyGenMech, template,
                        template.length, hKey);
         }I am passing "AES_KEY_GEN as the mechanism as defined in PKCS11. Since PKCS11 is a standard, key generation templates ideally should not vary accross implementations.
    Any help on this is greatly appreciated.

    I just had this same problem.
    I fixed it by using
    new CK_ATTRIBUTE(CKA.VALUE_LEN, new Long(16))  // 128 bit AES keyinstead of using CKA.KEY_SIZE. The documentation states that CKA.KEY_SIZE only applies to eliptic curves.

  • Invalid stream header Exception - AES PBE with SealedObject

    I am trying to do an PBE encryption with AES algorithm and SunJCE provider, using the SealedObject class to encrypt/decrypt the data...
    And Im still getting the "invalid stream header" exception. Ive searched this forum, readed lots of posts, examples etc...
    Here is my code for encryption (i collected it from more classes, so hopefully I didnt forget anything...):
        //assume that INPUT_STREAM is the source of plaintext
        //and OUTPUT_STREAM is the stream to save the ciphertext data to
        char[] pass; //assume initialized password
        SecureRandom r = new SecureRandom();
        byte[] salt = new byte[20];
        r.nextBytes(salt);
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);
        SecretKey pbKey = factory.generateSecret(keySpec);
        SecretKeySpec key = new SecretKeySpec(pbKey.getEncoded(), "AES");
        Cipher ciph = Cipher.getInstance("AES/CTR/NoPadding");
        ciph.init(Cipher.ENCRYPT_MODE, key);
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        int ch;
        while ((ch = INPUT_STREAM.read()) >= 0) {
          byteOut.write(ch);
        SealedObject sealed = new SealedObject(byteOut.toByteArray(), ciph);
        BufferedOutputStream bufOut = new BufferedOutputStream(OUTPUTSTREAM);
        ObjectOutputStream objOut = new ObjectOutputStream(bufOut);   
        objOut.writeObject(sealed);
        objOut.close();
      }And here is my code for decrypting:
        //assume that INPUT_STREAM is the source of ciphertext
        //and OUTPUT_STREAM is the stream to save the plaintext data to
        char[] pass; //assume initialized password
        SecureRandom r = new SecureRandom();
        byte[] salt = new byte[20];
        r.nextBytes(salt);
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);
        SecretKey pbKey = factory.generateSecret(keySpec);
        SecretKeySpec key = new SecretKeySpec(pbKey.getEncoded(), "AES");
        BufferedInputStream bufIn = new BufferedInputStream(INPUT_STREAM);    //MARK #1
        ObjectInputStream objIn = new ObjectInputStream(bufIn);   
        SealedObject sealed = (SealedObject) objIn.readObject();   
        byte[] unsealed = (byte[]) sealed.getObject(key);          //MARK #2
        ByteArrayInputStream byteIn = new ByteArrayInputStream(unsealed);
        int ch;
        while ((ch = byteIn.read()) >= 0) {
          OUTPUT_STREAM.write(ch);
        OUTPUT_STREAM.close();Everytime I run it, it gives me this exception:
    Exception in thread "main" java.io.StreamCorruptedException: invalid stream header: B559ADBE
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
         at javax.crypto.SunJCE_i.<init>(DashoA13*..)
         at javax.crypto.SealedObject.unseal(DashoA13*..)
         at javax.crypto.SealedObject.getObject(DashoA13*..)
         at oopsifrovanie.engine.ItemToCrypt.decrypt(ItemToCrypt.java:91)  //MARKED AS #2
         at oopsifrovanie.Main.main(Main.java:37)    //The class with all code below MARK #1I've also found out that the hashCode of the generated "key" object in the decrypting routine is not the same as the hashCode of the "key" object in the ecrypting routine. Can this be a problem? I assume that maybe yes... but don't know what to do...
    When I delete the r.nextBytes(salt); from both routines, the hashCodes are the same, but that's not the thing I want to do...
    I think, that the source of problem can be this part of code (generating the key):
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);
        SecretKey pbKey = factory.generateSecret(keySpec);
        SecretKeySpec key = new SecretKeySpec(pbKey.getEncoded(), "AES");But I derived it from posts like: [http://forums.sun.com/thread.jspa?threadID=5307763] and [http://stackoverflow.com/questions/992019/java-256bit-aes-encryption] and they claimed it's working there...
    Is there anyone that can help me?
    Btw, I don't want to use any other providers like Bouncycastle etc. and I want to use PBE with AES and also SealedObject to store the parameters of encryption...

    Yes, it really uses only one Cipher object, but it does decoding in a little nonstandard (not often used) way, by using the SealedObject class and its getObject(Key key) method. You can check these links for documentation: [http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#SealedObject] and [http://java.sun.com/javase/6/docs/api/javax/crypto/SealedObject.html] So the question is, why it doesn't work also with the AES routines, because it should.
    Btw, according to [http://java.sun.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunJCEProvider] PBEWithSHA1AndDESede/CBC/PKCS5Padding is a valid JCE algorithm for the Cipher class.
    Firstly, I was generating the key for AES enc./decryption this way and it was working:
    char[] pass; //assume initialized password
    byte[] bpass = new byte[pass.length];
        for (int i = 0; i < pass.length; i++) {
          bpass[i] = (byte) pass;
    SecretKeySpec key = new SecretKeySpec(bpass, "AES");
    But I think, that it really wasn't secure, so I wanted to build a key from the password using the PBE.
    Maybe there's also a way how to do this part of my AES PBE algorithm: *KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);* manually (with my own algorithm), but I dont know how to do it and I'd like it to be really secure.
    Btw, thanks for your will to help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Is there a way to retrieve files encripted up by Apples Backup?

    I have some files on an external hard drive that were backed up (encripted?) by Apples Backup a couple years ago.  I would like to restore that data and retrieve some photos.  Is thare a program or method to accomplish this?  Thanks for any help with this.
    Joe

    These files were encrypted by the Apple program "Backup" that was available until 2011 or so.  The program is no longer available on the app store.  When I purchased a new computer they were somehow missed when I migrated my data over to the new machine.   I am looking for a program that can open them.  I do have the original password.  I am also looking around locally someone with a mac running Snow Leopard or earlier.  Thanks for answering.

  • Problem with RSA/AES and the wrapped Key

    Hallo!
    For a server-client communications, I would like to use a hybrid encryption.
    For this I create an object of a serializable class that contains several properties, including the data that are to be transferred from A to B (Object, encrypted by AES), and the AES key, but wrapped by RSA (byte []).
    My basic problem is, that if I send the wrapped key, I get at the destination another byte array and thus the key can not be decoded:
    java.security.InvalidKeyException: Invalid AES key length: 256 bytes
    When I look at the string representation of the byte array before sending and immediate after receiving, the byte arrays are diffrent. Why?
    Extract from the encrypt method:
    TransportObject obj = new TransportObject();
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        SecureRandom random = new SecureRandom();
        keygen.init(random);
        Key key = keygen.generateKey();
        Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
        cipher.init(Cipher.WRAP_MODE, publicKey);
        byte[] wrappedKey = cipher.wrap(key);
    // Here I put the byte array in the object to be transmitted
        obj.setKey(wrappedKey);Extract from the decrypt method:
    / / Here I read the byte array from the received object
    byte[] wrappedKey = obj.getKey();
    Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
    cipher.init(Cipher.UNWRAP_MODE, privateKey);
    Key key = cipher.unwrap(wrappedKey, "AES", Cipher.SECRET_KEY);Here is the class that is serialized:
    import java.io.Serializable;
    public class TransportObject implements Serializable {
        private static final long serialVersionUID = 5044061539587999682L;
        private byte[] key;
        private String type;
        private byte[] data;
        public static final int STRING = 1;
        public static final int INT = 2;
        public static final int CHAR = 3;
        public TransportObject() {}
        public TransportObject(byte[] key, String type, byte[] data) {
            this.key = key;
            this.type = type;
            this.data = data;
        public byte[] getKey() {
            return key;
        public void setKey(byte[] key) {
            this.key = key;
    }Sending is done via:
    TransportObject obj = rsa.encrypt(objectToSend, keys.getPublicKey());
    ObjectOutputStream os =
        new ObjectOutputStream(socket.getOutputStream());
    os.writeObject(obj);
    os.flush();Receiving via
    ois = new ObjectInputStream(
        new BufferedInputStream(socket.getInputStream()));
    TransportObject obj = (TransportObject) ois.readObject();
    Object receivedObject = rsa.decrypt(obj, keys.getPrivateKey());Somehow, I hang down here.
    Do I overlook something? Do I have an error in reasoning?
    Thanks for any help!
    Best regards
    Sebastian Gohres
    Edited by: Spencer82 on Aug 7, 2010 9:06 AM
    Edited by: Spencer82 on Aug 7, 2010 9:08 AM

    Do I overlook something? Do I have an error in reasoning?I think at least 2.
    1. Don't do this. The general problem has been solved. The solution is called TLS, and Java provides a API called the JSSE for you to use.
    2.If you insist on rolling your own, don't specify NoPadding. Use PKCS1Padding. If you are going to use NoPadding, then you must provide your own padding scheme, which you have not.

  • Can't Connect To WPA-PSK/AES

    I've read through dozens of posts here and on other sites, but still can't figure this out.
    At home, I have a D-Link DI-634M wireless router. We have two laptops (Toshiba and IBM) that connect to it just fine, but I can't get my new iPhone 3G to connect. The Wireless Settings page on the router looks like this:
    SSID: SomethingLikeThis
    Channel: Auto Channel Select enabled
    Super G Mode: Disabled
    Transmission Rate: Auto
    802.11g Only Mode: Disabled
    SSID Broadcast: Disabled
    Security Mode: WPA-PSK
    WPA Mode: WPA
    Cipher Type: AES
    Passphrase: Looks something like this sentence, for a total of 63 characters.
    When I try to add the network to my iPhone, I get the error that it can't connect. But, in the network settings, it will now show the SSID, with the encryption icon and the signal strength meter. I select it, get prompted for the password again, but still can't connect.
    Just checked the logs on the router, and I can see an INFO message that says "Wireless system with MAC address nnnnnnnnnnnnn associated", showing the MAC address of my iPhone. I don't see anything after that to indicate any error with that device.
    I upgraded the firmware in the router to the latest release (Feb/2008). I've tried changing the Cipher Type from AES to TKIP, and even "TKIP and AES".
    What am I missing here?
    Thanks!

    Sorry, forgot to mention that when I turn off encryption it works fine. But, even though I don't broadcast my SSID, I'd never run a wireless router without at least some basic encryption. Just tried changing the password to not have spaces, and now it works fine. That's strange, since I didn't have any problems with any other wireless devices connecting when the password did have spaces.
    Thanks a million!!!!

  • Windows 8.1 Pro Bitlocker AES 256-bit cypher question

    Hi, all
    Have an odd situation I cannot make any sense of. I have a desktop PC running Windows 8.1 Pro. I launched gpedit.msc and changed Bitlocker’s cypher strength from the default AES 128-bit to AES 256-bit.
    I then connected a brand new Western Digital 4TB external drive (model WDBFJK0040HBK-04) to the PC via USB 3.0, and Bitlocker-encrypted the drive. Opened a command prompt window as administrator, ran “manage-bde –status” for the drive in question,
    which indicated the drive was encrypted with the 128 bit cypher strength, instead of 256 bits, as I had selected. Have unencrypted, rebooted and re-encrypted the drive time and again, always with the same results.
    When connecting the same external 4TB drive to a Windows Server 2012 R2 Essentials in which I had made the exact same changes via gpedit.msc,
    I can encrypt it with the 256-bit cypher strength, with no problems.
    No TPM is used in either scenario, just a passphrase.
    Anyone has any idea why my 256-bit setting is being ignored in the Windows 8.1 Pro machine?
    Thanks
    Arsene
    ArseneL

    Well, running rsop.msc in my Server 2012 R2 machine does show my 256-bit bitlocker setting took, however, running rsop.msc in my Win 8.1 Pro machine shows it did not, which explains the problem I am having.
    Now all I have to do is find out why my request is not taking, even though I am logged in as an admin.
    Thanks!!
    ArseneL

  • Bit Locker encription Problem not showing in my control panel

    i am using windows 7 64 home premium
    in my control panel 
    Bit
    Locker encription driver is not showing 
    please guide me how i will about how this driver will show in my control panel 

    BitLocker is not available in Windows 7 Home Premium, you need to be running Windows 7 Enterprise or Ultimate to be able to use BitLocker.
    Blogging about Windows for IT pros at
    www.theexperienceblog.com

  • Decryption of image using AES in windows 8.1

     Hi ,
        I am developing an app in windows 8.1, in which I got image in decryption format ,
    it was encrypted using AES and I know the key
    I tried in oneway but i am getting an error "The supplied user buffer is not valid for the requested operation"
    please help how to decrypt the image and bind it to ui
    Thanks
    Sarvesh
    sarvesh

    Hi Sarvesh,
    I've replied you in another thread, please feel free to check it :)
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for