Facebook Export issue - session key validity?

Love the new feature to upload to Facebook/Flickr - however, everything has been working fine until this morning, went to upload a jpg to Facebook and I get the following error message:
"Bridge encountered and error while exporting: Session key invalid or no longer valid."
The very same file just exported to Flickr no problems. Tried resetting the Module (re-creating from scratch), logged back into Facebook through Bridge, re-authorized, even restarted Bridge and made a completely new file to try in case that jpg was corrupt. Same error every time. I blame Facebook, just wondering if there's a workaround.
Cheers on CS5!

Sorry, should've mentioned, I did run the updater beforehand and am currently having these issues in 4.0.2.1
EDIT 1:
Solved (see below), per other post:
In the export panel choose the tiny menu icon top right and click on manage modules. In this view there is also a toothed wheel icon. Click on it and choose reinstall all modules. After this you should restart Bridge.
EDIT 2:
Not so solved - worked for awhile, then suddenly stopped working, tried reinstalling all the modules again, restarting Bridge and now cannot repair the Facebook functionality. Submitting as bug, since only 'fix' is temporary and unreliable.
Message was edited by: ficholasnorneris

Similar Messages

  • IPhoto/Facebook export issues

    My iPhoto is not exporting to Facebook properly. Either it simply does nothing after I click on the appropriate buttons (when it used to say " X photos upload to your Facebook Album", or it crashes and closes or it uploads the incorrect photos. I have never had trouble before. I have sent a report to Apple with every crash, and even added comments. I searched online and found no help.  One time, I got an error message about rebuilding iPhoto, which I have done. I have also  backed up my iPhoto to my external hard drive. Can anyone tell me anything else that I can try? Please note, I am not tech savvy. I buy Apple products because they are easy for me to use and have never owned a PC ( Apple since the iic, but still, it is all Greek to me.)  I can follow simple instructions, but am no "Genius".  Thank you!

    Not if you export them via the File ➙ Export ➙ File Export menu with these two checkboxes checked
    and (if you want the file names to reflect what you changed the Title to)
    That will embed the metadata into the image file and, if FB can read the IPTC fields in the image file, will be displayed in FB (I don't use FB so don't know if it does read the iPTC metadata of image files).

  • IMovie to Facebook exporting issues. What Can I do??

    Im trying to share an imovie video to FB but gives incorrect user name or password error, and I already verified that the info is correct. What can I do?

    Rather than upload to Facebook using the Share>Facebook method built in to iMovie, firstly export the project using Share>Export Movie. Share it to your Desktop. Now in Facebook you can upload the video quite independently from iMovie by using Facebook's uploader.
    In Facebook, click on Photos near the top of the page. You should see a row of thumbnails and text labelled Friends, Photos, Map and Likes.
    Now in Photos, in the top right corner click on the box named "Add Videos". In the window that opens you can navigate to your video on your Mac.
    John
    Message was edited by: John Cogdell

  • Using 128bit key Blowfish and any export issues

    Hi,
    I want to use blowfish (symmetric key algorithm) in my product and which will be shipped outside US. Reading Sun's documentation I am bit confused and I am not sure if the jce package is going to be available outside the US.
    Has anyone used the default available symmetric key algorithms in the JCE package (javax.crypto.*) and faced any export control issues ?
    Please let me know.
    Thanks
    RT
    Here is a sample code
    String ks = "123456789123456";
    kb = ks.getBytes();
    SecretKeySpec key = new SecretKeySpec(kb,"blowfish");
    Cipher cipher = Cipher.getInstance("blowfish");
    // Initialisation of cipher object for Encryption.
    cipher.init(Cipher.ENCRYPT_MODE, key);

    1. the issue is rather an import issue for some countries, than an export issue for US as far as you use jre>=1.4 .
    you can read the
    'Downloading the "Unlimited Strength" Jurisdiction Policy Files'
    section of
    http://java.sun.com/products/jce/javase.html
    2. The restricted (defualt) shipped version already covers Blowfish if you mind that.
    3. I use Blowfish with restricted (default) version of JCE in applications deployed in europe and have not heard of customer complaining sofar: they are supposed to use webstart or jre1.5.

  • Facebook Export Shows Partial Album List

    I am using Facebook Exporter with the latest version of Bridge, and the latest Export modules.  Both Bridge and the Modules themselves have been updated as of today.  I've been able to successfully export to Facebook, but the issue is that the Albums window does not display all of my albums.  There are more than 5 albums missing from the list.  Anyone have the same issue?

    HAVE probelm with the FACEBOOK EXPORT too
    when I first installed it did not work at all
    then it did- it seemed to me a log in issue-
    whenit worked it was GREAT! I never has the problem of not seeing the album names, it always logged me out of FB for my next visit
    however every photo I uploaded to FB from Bridge export is now gone!! last two days
    All the albums created in the Bridge interface are gone and all the pictures into other albums that were not uploaded by Bridge are still in FB but not any I added via Bridge
    using CS5
    tried to update modules says no updates
    using win xp sp3
    error I get when trying to connect to FB is
       "error": {
          "type": "OAuthException",
          "message": "Error validating application."

  • Exporting SSL Private Key

    In the midst of an apocalyptic SSL install in 10.4 server. Currently, I am trying to install a wildcard cert via Server Admin, which may have been a mistake. After smashing my head for a week, I tried a new tack and rebuilt the system keychain and attempted to install the certificate; this failed at the level of Server Admin. However, in Keychain Access I am showing the SSL cert, public and private keys, and the CA's cert, all valid.
    Since I know of no other way to do get KA talking to SA so that I can actually use this certificate, I am trying to export the valid certs and keys to import. My problem is this, the certs and public key export fine, the private key fails returning an error of Unable to Export CLINTERNALERROR. I double checked that root is enabled in netinfo. Any ideas on how to rectify this?

    I believe you have to run Keychain Access as root to export the private key.
    sudo /Applications/Utilities/Keychain Access.app/Contents/MacOS/Keychain Access

  • How can we export the Primary key values (along with other data) from an Advantage database?

    One of our customers is moving from our application (which uses Advantage Database Server) to another application (which uses other database technology). They have asked us to help export their data, so that they can migrate it to another database system. So far, we have used the Advantage Data Architect (ARC32) "Export Table Structures as Code" functionality to generate SQL. We used the "Include existing data" option. The SQL contains the necessary code to recreate the tables and indexes. The customer's IT staff will alter the SQL statements as necessary for their new system.
    However, there is an issue with the Primary Keys in these table. The resulting INSERT statements use AutoInc as the type for the Primary Key in each Table. These INSERT statements contains "DEFAULT" for the value of each of these AutoInc fields. The customer would like to output an integer value for each of these Primary Key values in order to maintain referential integrity in their new system.
    So far, I have not found any feature of ARC32 that allows us to export the Primary Key values. We had been using an older version of ARC32, since our application does not use the latest version of ADS. I did download the latest version of ARC32 (11.10), but it does not appear to include any new functionality that would facilitate doing this sort of export.
    Can somebody tell me if there is such a feature in ARC32?
    Or, is there is another Advantage tool to facilitate what we are trying to accomplish?
    If there are no Advantage tools to provide such functionality, what else would you suggest?

    George,
      It sounds like the approach you are using is the correct one. This seems to be the cleanest solution to me especially since the customer is able to modify the generated SQL statements for their new system.
      In order to preserve the AutoInc values I would recommend altering the table and changing the field datatype from AutoInc to Integer. Then export the table as code which will export the actual values. After the tables have been created on the new system they can change the field datatype back to an AutoInc type if necessary.
    Regards,
    Chris Franz

  • Any way to stop facebook exporter from using version names as the caption

    I tried the Aperture 3 facebook export and it is using the version names as the caption. If I change the caption on facebook it then changes the version name in my aperture library when it syncs with facebook. Is there anyway to have it use the caption meta data field instead? You would think if they had that option for mobile me they would have it for FB too.

    Add me to the list of people interested by this issue - but AFAIK there is no way to change this. Let's hope Apple fixes this soon.

  • Session key and MAC generation in SCP '02' i='15'

    Hi,
    I am trying send a PUT KEY command and it resolves to '6982' after a '9000' EXTERNAL AUTHENTICATE.
    I suspect that my encryption is causing the problem.(not really sure!)
    I compare my session keys to some that ppl had derived and posted on the forum and I don't really get what they did.
    I am trying to find out if I'm deriving the correct session keys or not?!?!
    e.g
    //Calculating session keys with
    //static key = '404142434445464748494a4b4c4d4e4f' (keyData)
    //sequence counter = '003b'
    //"0101" + sequenceCounter + "000000000000000000000000" for session CMAC key (data)
    //"0102" + sequenceCounter + "000000000000000000000000" for session RMAC key (data)
    //"0181" + sequenceCounter + "000000000000000000000000" for session DEK key (data)
    //"0182" + sequenceCounter + "000000000000000000000000" for session ENC key (data)
    //sessionCMAC is :3213860da8f8d9796794cbcec43ef7a23213860da8f8d979: with sequence counter:003b (result)
    //sessionRMAC is :042a687f6e0dd3f80eabf1e5d51ccefe042a687f6e0dd3f8: with sequence counter:003b (result)
    //sessionDEK is :1fe31370c22354e3b90d6b8ad5686d371fe31370c22354e3: with sequence counter:003b (result)
    //sessionENC is :94a47ad54ffbf423fe4a9d915befab5294a47ad54ffbf423: with sequence counter:003b (result)
    <code>
    if (keyData.length == 16) {
    byte[] temp = (byte[]) keyData.clone();
    keyData = new byte[24];
    System.arraycopy(temp, 0, keyData, 0, temp.length);
    System.arraycopy(temp, 0, keyData, 16, 8);
    DESedeKeySpec keySpec = new DESedeKeySpec(keyData);
    SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("DESede");
    SecretKey key = secretKeyFactory.generateSecret(keySpec);
    IvParameterSpec iv = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
    Cipher desedeCBCCipher = Cipher.getInstance("DESede/CBC/NoPadding");
    desedeCBCCipher.init(Cipher.ENCRYPT_MODE, key, iv);
    byte[] result = desedeCBCCipher.doFinal(data);
    if (result .length == 16) {
    byte[] temp = (byte[]) result .clone();
    result = new byte[24];
    System.arraycopy(temp, 0, result , 0, temp.length);
    System.arraycopy(temp, 0, result , 16, 8);
    keySpec = new DESedeKeySpec(result);
    secretKeyFactory = SecretKeyFactory.getInstance("DESede");
    key = secretKeyFactory.generateSecret(keySpec);
    </code>
    I use the same encrytion to derive KeyCheckValue with
    newKey ='505152535455565758595a5b5c5d5e5f', data = '0000000000000000'
    and it results to : '6d377e' (of course the last 3 bytes)
    Even though my CMAC session key is different from others (e.g "RLopes" in "http://192.9.162.102/thread.jspa?threadID=5365173&tstart=363" and I have seen it in others too and its really odd to me that its slightly different if you take a close look you will get what i mean) i get the EXTERNAL AUTHENTICATION to work.
    If there is anyone who is 100% sure meaning he/she got other commands to work after EXTERNAL AUTHENTICATE using CMAC please help me verify the keys I got?
    Can he/she test with his code to see if he/she is getting the same session keys or check value?
    Thanks in advance
    Kamran

    Hi,
    Here is the Class and thanks for the tip, I've honestly tried these <code></code> but didn't work and I know it is indeed annoying without the tags :D
    I really hope it helps...
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package terminalpcsc;
    import java.lang.Exception;
    import java.security.GeneralSecurityException;
    import java.security.Key;
    import java.security.SecureRandom;
    import java.util.List;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import javax.security.sasl.AuthenticationException;
    import javax.smartcardio.*;
    * @author Kamran
    * @param args the command line arguments
    public class Main {
        private static CardChannel channel;
        private static Card card;
        private static int CHALLENGE_LENGTH = 8;
        private static byte[] keyDiversification = new byte[10];
        private static byte[] keyInformation = new byte[2];
        private static byte[] sequenceCounter = new byte[2];
        private static byte[] cardChallenge = new byte[6];
        private static byte[] cardCryptogram = new byte[8];
        private static byte[] hostChallenge = new byte[8];
        private static byte[] hostCryptogram = new byte[8];
        private static String keyDiversificationHexString;
        private static String keyInformationHexString;
        private static String sequenceCounterHexString;
        private static String cardChallengeHexString;
        private static String cardCryptogramHexString;
        private static String hostChallengeHexString;
        private static String hostCryptogramHexString;
        private static byte[] sessionCMAC;
        private static byte[] sessionDEK;
        private static byte[] sessionENC;
        private static byte[] sessionRMAC;
        private static byte[] icvNextCommand;
        private static IvParameterSpec ivAllZeros = new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
        private static byte[] staticKey = hexStringToByteArray("404142434445464748494a4b4c4d4e4f4041424344454647");
        private static byte[] newKey = hexStringToByteArray("505152535455565758595a5b5c5d5e5f");
        private static byte[] CMAC;
         * @param args the command line arguments
        public static void main(String[] args) throws Exception {
            initiateCardChannel();
            String apduString = generateSelectAPDU("a000000003535041");
            byte[] bufferC = hexStringToByteArray(apduString);
            CommandAPDU capdu = new CommandAPDU(bufferC);
            System.out.println("Sending APDU Select AID: " + byteArrayToHexString(bufferC));
            ResponseAPDU rapdu = channel.transmit(capdu);
            System.out.println("Sending Apdu: Done!");
            System.out.println("Waiting For Response...");
            byte[] bufferR = rapdu.getData();
            String responseData = byteArrayToHexString(rapdu.getBytes());
            System.out.println("Response: " + responseData);
            apduString = generateInitializeUpdateAPDU();
            bufferC = hexStringToByteArray(apduString);
            capdu = new CommandAPDU(bufferC);
            System.out.println("Sending APDU Initialize Update: " + byteArrayToHexString(bufferC));
            rapdu = channel.transmit(capdu);
            System.out.println("Sending Apdu: Done!");
            System.out.println("Waiting For Response...");
            bufferR = rapdu.getData();
            responseData = byteArrayToHexString(rapdu.getBytes());
            System.out.println("Response: " + responseData);
            // protocol 01
            //System.arraycopy(bufferR,0,keyDiversification,0,10);
            //System.arraycopy(bufferR,10,keyInformation,0,2);
            //System.arraycopy(bufferR,12,cardChallenge,0,8);
            //System.arraycopy(bufferR,20,cardCryptogram,0,8);
            // protocol 02
            System.arraycopy(bufferR, 0, keyDiversification, 0, 10);
            System.arraycopy(bufferR, 10, keyInformation, 0, 2);
            System.arraycopy(bufferR, 12, sequenceCounter, 0, 2);
            System.arraycopy(bufferR, 14, cardChallenge, 0, 6);
            System.arraycopy(bufferR, 20, cardCryptogram, 0, 8);
            keyDiversificationHexString = byteArrayToHexString(keyDiversification);
            keyInformationHexString = byteArrayToHexString(keyInformation);
            sequenceCounterHexString = byteArrayToHexString(sequenceCounter);
            cardChallengeHexString = byteArrayToHexString(cardChallenge);
            cardCryptogramHexString = byteArrayToHexString(cardCryptogram);
            System.out.println("keyDiversification: " + keyDiversificationHexString);
            System.out.println("keyInformation: " + keyInformationHexString);
            System.out.println("sequenceCounter: " + sequenceCounterHexString);
            System.out.println("cardChallenge: " + cardChallengeHexString);
            System.out.println("cardCryptogram: " + cardCryptogramHexString);
            System.out.println("Calculating Session Keys... encryption with CBC");
            //E.4.1 GP 2.1.1
            sessionCMAC = deriveEncryptionCBC(staticKey, hexStringToByteArray("0101" + sequenceCounterHexString + "000000000000000000000000"));
            System.out.println("sessionCMAC is :" + byteArrayToHexString(sessionCMAC) + ": with sequence counter:" + sequenceCounterHexString);
            sessionRMAC = deriveEncryptionCBC(staticKey, hexStringToByteArray("0102" + sequenceCounterHexString + "000000000000000000000000"));
            System.out.println("sessionRMAC is :" + byteArrayToHexString(sessionRMAC) + ": with sequence counter:" + sequenceCounterHexString);
            sessionDEK = deriveEncryptionCBC(staticKey, hexStringToByteArray("0181" + sequenceCounterHexString + "000000000000000000000000"));
            System.out.println("sessionDEK is :" + byteArrayToHexString(sessionDEK) + ": with sequence counter:" + sequenceCounterHexString);
            sessionENC = deriveEncryptionCBC(staticKey, hexStringToByteArray("0182" + sequenceCounterHexString + "000000000000000000000000"));
            System.out.println("sessionENC is :" + byteArrayToHexString(sessionENC) + ": with sequence counter:" + sequenceCounterHexString);
            System.out.println("Calculating and Verifying Card Cryptogram...");
            byte[] signature = cbcMACSignature(hexStringToByteArray(hostChallengeHexString + sequenceCounterHexString + cardChallengeHexString + "8000000000000000"), sessionENC);
            String signatureHexString = byteArrayToHexString(signature);
            if (signatureHexString.equalsIgnoreCase(cardCryptogramHexString)) {
                System.out.println("signature is :" + signatureHexString + "\ncardCryptogram is :" + cardCryptogramHexString + " \nCard cryptogram authenticated");
                apduString = generateExternalAuthenticateAPDU();
                bufferC = hexStringToByteArray(apduString);
                capdu = new CommandAPDU(bufferC);
                System.out.println("Sending APDU External Authenticate: " + byteArrayToHexString(bufferC));
                rapdu = channel.transmit(capdu);
                System.out.println("Sending Apdu: Done!");
                System.out.println("Waiting For Response...");
                bufferR = rapdu.getData();
                responseData = byteArrayToHexString(rapdu.getBytes());
                System.out.println("Response: " + responseData);
                apduString = generatePutKeyAPDU();
                bufferC = hexStringToByteArray(apduString);
                capdu = new CommandAPDU(bufferC);
                System.out.println("Sending APDU Put Key: " + byteArrayToHexString(bufferC));
                rapdu = channel.transmit(capdu);
                System.out.println("Sending Apdu: Done!");
                System.out.println("Waiting For Response...");
                bufferR = rapdu.getData();
                responseData = byteArrayToHexString(rapdu.getBytes());
                System.out.println("Response: " + responseData);
            } else {
                System.out.println("signature is :" + signatureHexString + "\ncardCryptogram is :" + cardCryptogramHexString + " \nCard cryptogram is not authenticated");
            releaseCardChannel();
        public static byte[] cbcMACSignature(byte[] data, byte[] sessionSENC) throws AuthenticationException {
            IvParameterSpec params =
                    new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
            if (sessionSENC.length == 16) {
                byte[] temp = (byte[]) sessionSENC.clone();
                sessionSENC = new byte[24];
                System.arraycopy(temp, 0, sessionSENC, 0, temp.length);
                System.arraycopy(temp, 0, sessionSENC, 16, 8);
            byte[] temp = null;
            SecretKey secretKey = new SecretKeySpec(sessionSENC, "DESede");
            try {
                Cipher cbcDES = Cipher.getInstance("DESede/CBC/NoPadding");
                cbcDES.init(Cipher.ENCRYPT_MODE, secretKey, params);
                temp = cbcDES.doFinal(data);
            } catch (GeneralSecurityException e) {
                e.printStackTrace();
            byte[] signature = new byte[8];
            System.arraycopy(temp, temp.length - 8, signature, 0, signature.length);
            return signature;
        // generateInitialUpdateAPDU()
        //CLA '80'
        //INS '50' INITIALIZE UPDATE
        //P1 'xx' Key Version Number
        //P2 '00' Reference control parameter P2
        //Lc '08' Length of host challenge
        //Data 'xx xx…' Host challenge
        //Le '00'
        //RESPONSE TEMPLATE
        //Key diversification data 10 bytes
        //Key information 2 bytes
        //Card challenge 8 bytes
        //Card cryptogram 8 bytes
        public static String generateInitializeUpdateAPDU() throws Exception {
            hostChallenge = generateHostChallenge();
            hostChallengeHexString = byteArrayToHexString(hostChallenge);
            return "8050000008" + hostChallengeHexString + "00";
        //CLA '80' or '84'
        //INS 'D8' PUT KEY
        //P1 'xx' Reference control parameter P1 Key Version Number -- '00' is new key  range is '01' to '7F'
        //P2 'xx' Reference control parameter P2 Key Identifier     -- '00' to '7F'
        //Lc 'xx' Length of data field
        //Data 'xxxx..' Key data (and MAC if present)
        //Le '00'
        public static String generatePutKeyAPDU() throws Exception {
            String keyCheckValue = new String();
            //keyCheckValue = keyCheckValue.substring(keyCheckValue.length() - (3 * 2));
            keyCheckValue = byteArrayToHexString(deriveEncryptionECB(newKey, hexStringToByteArray("0000000000000000")));
            keyCheckValue = keyCheckValue.substring(keyCheckValue.length() - (3 * 2));
            System.out.println("keyCheckValue :" + keyCheckValue + " 3DES ECB, key is new key '505152535455565758595a5b5c5d5e5f5051525354555657', data is 8 zeroes");
            String encryptedNewKey = byteArrayToHexString(deriveEncryptionECB(sessionDEK, newKey));
            //System.out.println("sessionDEK.getEncoded() :" + sessionDEK.getEncoded() + " len is:" + sessionDEK.getEncoded().length);
            System.out.println("encryptedNewKey :" + encryptedNewKey);
            //testing newKey
            String dataField = "01" + "8010" + encryptedNewKey + "03" + keyCheckValue + "8010" + encryptedNewKey + "03" + keyCheckValue + "8010" + encryptedNewKey + "03" + keyCheckValue;
            // String dataField2 = "01" + "8010" + byteArrayToHexString(newKey) + "03" + keyCheckValue + "8010" + byteArrayToHexString(newKey) + "03" + keyCheckValue + "8010" + byteArrayToHexString(newKey) + "03" + keyCheckValue;
            System.out.println("datafield to calculate cmac :" + dataField);
            System.out.println("icv to calculate cmac is previous mac first 8 byte sessionCMAC in CBC single des :" + byteArrayToHexString(icvNextCommand));
            CMAC = generateCMac2((byte) 0x84, (byte) 0xD8, (byte) 0x00, (byte) 0x81, hexStringToByteArray(dataField), sessionCMAC, icvNextCommand);
            System.out.println("data field with des padding for encryption (encryption in CBC sessionENC) :" + desPadding(dataField));
            String dataField3 = byteArrayToHexString(deriveEncryptionCBC(sessionENC, hexStringToByteArray(desPadding(dataField))));
            System.out.println("data field after encryption :" + dataField3);
            Integer CMACLen = byteArrayToHexString(CMAC).length() / 2;
            System.out.println("CMACLen :" + CMACLen);
            Integer dataFieldLen = dataField3.length() / 2;
            System.out.println("dataFieldLen :" + dataFieldLen);
            Integer intLc = dataFieldLen + CMACLen;
            System.out.println("intLc :" + intLc);
            String hexLc = Integer.toString(intLc, 16);
            System.out.println("hexLc :" + hexLc);
            return "84D80081" + hexLc + dataField3 + byteArrayToHexString(CMAC) + "00";
        //generateExternalAuthenticateAPDU()
        //CLA '84'
        //INS '82' EXTERNAL AUTHENTICATE
        //P1 'xx' Security level  --'03' C-DECRYPTION and C-MAC.--'01' C-MAC.'00' No secure messaging expected.
        //P2 '00' Reference control parameter P2
        //Lc '10' Length of host cryptogram and MAC
        //Data 'xx xx…' Host cryptogram and MAC
        //Le Not present
        public static String generateExternalAuthenticateAPDU() throws Exception {
            System.out.println("Calculating and Verifying Host Cryptogram...");
            hostCryptogram = cbcMACSignature(hexStringToByteArray(sequenceCounterHexString + cardChallengeHexString + hostChallengeHexString + "8000000000000000"), sessionENC);
            hostCryptogramHexString = byteArrayToHexString(hostCryptogram);
            System.out.println("hostCryptogram is :" + hostCryptogramHexString);
            CMAC = generateCMac2((byte) 0x84, (byte) 0x82, (byte) 0x03, (byte) 0x00, hostCryptogram, sessionCMAC, new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
            return "8482030010" + hostCryptogramHexString + byteArrayToHexString(CMAC);
        // generateSelectAPDU()
        //CLA '00' ISO/IEC 7816-4 command
        //INS 'A4' SELECT
        //P1 'xx' Reference control parameter P1 --'04' select by name
        //P2 'xx' Reference control parameter P2 --'00' First or only occurrence --'02' Next occurrence
        //Lc 'xx' Length of AID
        //Data 'xxxx..' AID of Application to be selected
        //Le '00'
        // RESPONSE TEMPLATE
        //'6F' File Control Information (FCI template) Mandatory
        //'84' Application / file AID Mandatory
        //'A5' Proprietary data Mandatory
        //'73' Security Domain Management Data (see Appendix F for detailed coding) Optional
        //'9F6E' Application production life cycle data Optional
        //'9F65' Maximum length of data field in command message Mandatory
        public static String generateSelectAPDU(String AID) throws Exception {
            String AIDlen = Integer.toString(AID.length() / 2, 16);
            if (AIDlen.length() == 1) {
                AIDlen = "0" + AIDlen;
            System.out.println("00A40400" + AIDlen + AID);
            return "00A40400" + AIDlen + AID;
        public static String byteArrayToHexString(byte[] b) throws Exception {
            String result = "";
            for (int i = 0; i < b.length; i++) {
                result +=
                        Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
            return result;
        public static void initiateCardChannel() throws CardException {
            System.out.println("Connecting to Java Card...");
            TerminalFactory factory = TerminalFactory.getDefault();
            List<CardTerminal> terminals = factory.terminals().list();
            System.out.println("Terminals Detected: " + terminals);
            // get the first terminal
            System.out.println("Connecting to: " + terminals + "...");
            CardTerminal terminal = terminals.get(0);
            System.out.println("Connected to: " + terminals);
            // establish a connection with the card
            System.out.println("Connecting to Java Card...");
            card = terminal.connect("T=0");
            System.out.println("Connected to card: " + card);
            System.out.println("Obtaining Channel...");
            channel = card.getBasicChannel();
            System.out.println("Connecting to Channel: " + channel.getChannelNumber());
        public static void releaseCardChannel() throws CardException {
            System.out.println("Disconnection all...");
            card.disconnect(false);
            System.out.println("Disconnection Done");
            System.out.println("*END*");
        public static byte[] hexStringToByteArray(String s) {
            int len = s.length();
            byte[] data = new byte[len / 2];
            for (int i = 0; i < len; i += 2) {
                data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
            return data;
        //To generate the derivation data:
        public static byte[] deriveEncryptionCBC(byte[] keyData, byte[] data) throws GeneralSecurityException {
            //Key key = getSecretKey(keyData);
            if (keyData.length == 16) {
                byte[] temp = (byte[]) keyData.clone();
                keyData = new byte[24];
                System.arraycopy(temp, 0, keyData, 0, temp.length);
                System.arraycopy(temp, 0, keyData, 16, 8);
            SecretKey secretKey = new SecretKeySpec(keyData, "DESede");
            IvParameterSpec dps =
                    new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
            String algorithm = "DESede/CBC/NoPadding";
            Cipher desedeCBCCipher = Cipher.getInstance(algorithm);
            desedeCBCCipher.init(Cipher.ENCRYPT_MODE, secretKey, dps);
            byte[] result = desedeCBCCipher.doFinal(data);
            //adjustParity(result);
            return result;
        public static byte[] deriveEncryptionECB(byte[] keyData, byte[] data) throws GeneralSecurityException {
            //Key key = getSecretKey(keyData);
            if (keyData.length == 16) {
                byte[] temp = (byte[]) keyData.clone();
                keyData = new byte[24];
                System.arraycopy(temp, 0, keyData, 0, temp.length);
                System.arraycopy(temp, 0, keyData, 16, 8);
            SecretKey secretKey = new SecretKeySpec(keyData, "DESede");
            String algorithm = "DESede/ECB/NoPadding";
            Cipher desedeCBCCipher = Cipher.getInstance(algorithm);
            desedeCBCCipher.init(Cipher.ENCRYPT_MODE, secretKey);
            byte[] result = desedeCBCCipher.doFinal(data);
            //adjustParity(result);
            return result;
         * Adjust a DES key to odd parity
         * @param key
         *            to be adjusted
        public static byte[] adjustParity(byte[] key) {
            for (int i = 0; i < key.length; i++) {
                int akku = (key[i] & 0xFF) | 1;
                for (int c = 7; c > 0; c--) {
                    akku = (akku & 1) ^ (akku >> 1);
                key[i] = (byte) ((key[i] & 0xFE) | akku);
            return key;
        public static byte[] generateCMac2(byte cla, byte ins, byte p1, byte p2, byte[] dataField, byte[] SMacSessionKey, byte[] icv) throws GeneralSecurityException, Exception {
            if (SMacSessionKey.length == 16) {
                byte[] temp = (byte[]) SMacSessionKey.clone();
                SMacSessionKey = new byte[24];
                System.arraycopy(temp, 0, SMacSessionKey, 0, temp.length);
                System.arraycopy(temp, 0, SMacSessionKey, 16, 8);
            byte[] cMac = new byte[8];
            byte[] padding = {(byte) 0x80, 0, 0, 0, 0, 0, 0, 0};
            int paddingRequired = 8 - (5 + dataField.length) % 8;
            byte[] data = new byte[5 + dataField.length + paddingRequired];
            //Build APDU
            data[0] = cla;
            data[1] = ins;
            data[2] = p1;
            data[3] = p2;
            data[4] = (byte) ((byte) dataField.length + (byte) 0x08);
            System.arraycopy(dataField, 0, data, 5, dataField.length);
            System.arraycopy(padding, 0, data, 5 + dataField.length, paddingRequired);
            System.out.println("data to calculate mac :" + byteArrayToHexString(data));
            System.out.println("icv to calculate mac :" + byteArrayToHexString(icv));
            Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding");
            Cipher singleDesCipher = Cipher.getInstance("DES/CBC/NoPadding", "SunJCE");
            SecretKeySpec desSingleKey = new SecretKeySpec(SMacSessionKey, 0, 8, "DES");
            SecretKey secretKey = new SecretKeySpec(SMacSessionKey, "DESede");
            //Calculate the first n - 1 block. For this case, n = 1
            IvParameterSpec ivSpec = new IvParameterSpec(icv);
            singleDesCipher.init(Cipher.ENCRYPT_MODE, desSingleKey, ivSpec);
            byte ivForLastBlock[] = singleDesCipher.doFinal(data, 0, 8);
            int blocks = data.length / 8;
            for (int i = 0; i < blocks - 1; i++) {
                singleDesCipher.init(Cipher.ENCRYPT_MODE, desSingleKey, ivSpec);
                byte[] block = singleDesCipher.doFinal(data, i * 8, 8);
                ivSpec = new IvParameterSpec(block);
            int offset = (blocks - 1) * 8;
            cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivSpec);
            cMac = cipher.doFinal(data, offset, 8);
            ivSpec = new IvParameterSpec(new byte[8]);
            singleDesCipher.init(Cipher.ENCRYPT_MODE, desSingleKey, ivSpec);
            icvNextCommand = singleDesCipher.doFinal(cMac);
            return cMac;
        public static byte[] generateHostChallenge() {
            byte[] hostChallenge = new byte[CHALLENGE_LENGTH];
            SecureRandom random = new SecureRandom();
            random.nextBytes(hostChallenge);
            return hostChallenge;
        public static String desPadding(String hexString) {
            System.out.println("String to pad before:" + hexString);
            hexString = hexString + "80";
            int hexStringLen = hexString.length() / 2;
            int padding = 8 - (hexStringLen % 8);
            for (int i = 0; i < padding; i++) {
                hexString = hexString + "00";
            System.out.println("String to pad after :" + hexString);
            return hexString;
    }Thanks in advance
    Kamran

  • When i try to install iPlanet App Server on NT, I do not get screen to enter license key valid for evaluation. --- " cache File Read error"

    When i try to install iPlanet App Server on NT, I do not get screen to enter license key valid for evaluation.
    Also during installation screens an error window is displayed saying "cache File Read error -- Could not read ProductKey entry from the cache file "

    Hi,
    I also get the following message:
    "Could not read ProductKey entry from the cache file"
    I have no idea how to provide the installation software with the key. I also tried "keycheck.exe"
    Do you have a solution for this problem? Did you finish the installation?
    Christian

  • Very Very Urgent Issue: Restricted Key Figure does not return any data

    Hi all,
    Please help me solving this urgent issue.
    created customer exit variable on characterstics version and also
    other customer exit variable on Value type.
    I coded that in variable exit. Problem is when I include these in
    restrickted keyfigure My query does not return me any data.
    But if I remove from restrickted key firgure and put it as normal
    charaterstics I see the variable is getting populated.
    Also in RSRT the SQl generated when these are included in RKF is not
    correct.
    I debugged and know they are getting populated. As when included in RKF
    I can also see the values of customer exit variables from information
    tab.
    I also know that there is data in cube for those restrictions.
    I posted one OSS Notes regarding this urgent issue. But got no reply from SAP.
    FYI: We are using BEx 3.5 Browser SAP GUI 6.4 Patch 20 BW Patch 11
    Thanks
    SAP BW
    **Please do not post the same question twice: Very Urgent Issue: Restricted Key Figure does not return any data

    Hi,
    Everyone out there this is very urgent. If someone can help me solving this problem.
    We are using BEx 3.5 Browser SAP GUI 6.4 Patch 20 BW Patch 11.
    I posted one oss notes also regarding this issue. But got no reply from SAP.
    So, Please help me solving this issue.
    Thanks
    SAP BW

  • Problems with exporting after Facebook export installation

    Hi there,
    I installed the Facebook exporter app and then discovered my iPhoto is too old (it is iPhoto 4). Thereafter I was unable to export anything because my mac would crash. So I uninstalled the app and since then my normal export button is missing. I found a forum on this site, where the same problem was solved, but this was for someone with iLife 08 and required a reinstallation from disk.
    The problem is, I bought OS X 10.5 recently but not iLife, so my iPhoto etc is from the old days. I would be totally, infinitely and unbelievably grateful if someone could help me out here, because I currently cannot export anything from iPhoto. Which disk do I use for reinstallation? When I bought my mac it had 10.3 on it. How do I reinstall iPhoto when my operating system is new? Help!
    Cheers,
    Kerry

    Thanks for that - unfortunately I have lost disk number 1 and can only find disk number 2. Honestly, I never thought I'd need them, and they've been packed and unpacked at least 4 times since I bought the computer.
    I am trying to get the disk from mac friends - I'll see what happens. If anyone knows how to get hold of these old disks, or another work-around, I'd be very grateful...
    cheers and thanks again,
    Kerry

  • How do I remove the Facebook Exporter for iPhoto?

    Hello,
    I have recently installed v1.0.8 of Facebook Exporter for iPhoto, and it hangs on the first picture I attempt to upload. It is unusable. I had found the previous version 1.0.6 which worked great and downloaded that, and subsequently attempted to install it. However, the installer errors out stating that there is already a previous version installed. The v1.0.6 and v1.0.8 installers, do not have an uninstall feature either. Direct support for this package is impossible from the developer.
    I'm asking if anyone could lay out exactly what I need to remove in order that I can proceed with downgrading to the v1.0.6 once again. I have asked in other forums(not here) and have had only "upgrade all your software to the latest versions and everything should work" answers, which were and are completely useless. If an upgrade is required of something, please be specific as to why.
    Note that, I have already performed this function as outlined here, http://www.facebook.com/help/?faq=222897111055523, which simply describes deleting a folder in their install directory. This has not worked, meaning the removal has worked, however reinstalling the previous version envokes the error about a later version.
    Versions involved;
    MacBook Pro, 2.53ghz, core 2 duo
    MacOS v10.6.8
    iPhoto '09, v8.1..2 (424)
    Thanks,
    Mark

    To unpin a Tile
    Tap and hold the Tile you want to remove from Start.
    Tap Unpin .

  • Problems with the Facebook Exporter in iPhoto 08

    Has anybody successfully used the Facebook Exporter plugin for iPhoto? Every time I try to upload multiple photos, it has a bar saying "Exporting 1/{whatever number}", but then comes up with the following error:
    "Couldn't upload photo "{photo number}" because an unknown error occurred."
    ...and it gives me the option of:
    "Back to Facebook Exporter" or "Review Facebook Album"
    ...if I click on the latter, it goes to Facebook and shows that the first Photo has indeed uploaded successfully. So I've been going through doing it one at a time but that is pretty tedius!
    Any ideas what I'm doing wrong? It doesn't matter what the photo's are, it does it every time.
    Cheers.
    AD.

    Must have been a dodgy version of the exporter as having downloaded an update it works fine...

  • How to defer the primary key validation to commit time

    Hi
    Is it possible to defer the primary key validation to commit time? I don't know why the framework checks for the unique key constraint immediately after inserting the row and before committing it. This causes "Too many objects match the primary key oracle.jbo.Key[null]" error if the user presses the create new record button multiple times before filling and saving the previous records.
    Thanks,
    Ferez

    Dear M.Jabr,
    Many thanks for your reply. I have access to the database but I prefer to use an ADF workaround to this problem rather than a DB workaround. I am not sure but I think that there should be a way to defer or disable primary key constraint in ADF.
    Anyway, I tried to make the primary key constraint DEFERRABLE in DB using PL/SQL developer but an error occurred (the name is used by another object) which I don't know why.
    Thanks,
    Ferez

Maybe you are looking for

  • Drill Down Report gives an error for General Ledger.

    Hi, I'm using the transaction GCAC to compare general ledger with profit centre accounting.While drilling down the report for PCA, the report works fine and gets drilled down to the invoice in SAP.But I get an error when I try to drill down the repor

  • ABAP Webdynpro cannot display value help, combo box properly in IE ?

    Hi WDA expert, I have problem developing webdynpro in NW 7.0 EHP1 SPS02. All the combo box, value help, drop down input did not properly display using IE 7.0 / 8.0. It is something like create another  blank input beside the original object. but ever

  • First LID close works, but state never changes back to open

    I am using a Razer Blade 14" with linux-ck kernel (although I have tested in the main kernel and the issue remains). I like to be able to close the lid to suspend. But it is not working properly. Note: I am using cat /proc/acpi/button/lid/LID0/state

  • Anyone know anything about drop down listings?

    I would like to know if anyone here can give me any advise as to how I might go about getting my drop down menus to have to ability to compile a personalized list. I'm sure you are familiar with what I am referring to. I build custom computers and I

  • Moving Average price, Std price and FIFO

    Hi folks, It seems our client wants to use FIFO valuation for its items rather than Moving Average because FIFO gives them an actual price for their Finished Goods (the client does not have any manufacturing). I beleive the question the client wants