RSA decryption Error: Data must start with zero

Because of some reasons, I tried to use RSA as a block cipher to encrypt/decrypt a large file. When I debug my program, there some errors are shown as below:
javax.crypto.BadPaddingException: Data must start with zero
     at sun.security.rsa.RSAPadding.unpadV15(Unknown Source)
     at sun.security.rsa.RSAPadding.unpad(Unknown Source)
     at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:356)
     at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:394)
     at javax.crypto.Cipher.doFinal(Cipher.java:2299)
     at RSA.RRSSA.main(RRSSA.java:114)
From breakpoint, I think the problem is the decrypt operation, and Cipher.doFinal() can not be operated correctly.
I searched this problem from google, many people met the same problem with me, but most of them didn't got an answer.
The source code is :
Key generation:
package RSA;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.logging.Level;
import java.util.logging.Logger;
public class GenKey {
      * @param args
                 * @author tang
     public static void main(String[] args) {
          // TODO Auto-generated method stub
             try {
                  KeyPairGenerator KPG = KeyPairGenerator.getInstance("RSA");
                  KPG.initialize(1024);
                  KeyPair KP=KPG.genKeyPair();
                  PublicKey pbKey=KP.getPublic();
                  PrivateKey prKey=KP.getPrivate();
                  //byte[] publickey = decryptBASE64(pbKey);
                  //save public key
                  FileOutputStream out=new FileOutputStream("RSAPublic.dat");
                  ObjectOutputStream fileOut=new ObjectOutputStream(out);
                  fileOut.writeObject(pbKey);
                  //save private key
                      FileOutputStream outPrivate=new FileOutputStream("RSAPrivate.dat");
                  ObjectOutputStream privateOut=new ObjectOutputStream(outPrivate);
                             privateOut.writeObject(prKey)
     }Encrypte / Decrypt
package RSA;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.security.Key;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Cipher;
//import sun.misc.BASE64Decoder;
//import sun.misc.BASE64Encoder;
public class RRSSA {
      * @param args
     public static void main(String[] argv) {
          // TODO Auto-generated method stub
            //File used to encrypt/decrypt
             String dataFileName = argv[0];
             //encrypt/decrypt: operation mode
             String opMode = argv[1];
             String keyFileName = null;
             //Key file
             if (opMode.equalsIgnoreCase("encrypt")) {
             keyFileName = "RSAPublic.dat";
             } else {
             keyFileName = "RSAPrivate.dat";
             try {
             FileInputStream keyFIS = new FileInputStream(keyFileName);
             ObjectInputStream OIS = new ObjectInputStream(keyFIS);
             Key key = (Key) OIS.readObject();
             Cipher cp = Cipher.getInstance("RSA/ECB/PKCS1Padding");//
             if (opMode.equalsIgnoreCase("encrypt")) {
             cp.init(Cipher.ENCRYPT_MODE, key);
             } else if (opMode.equalsIgnoreCase("decrypt")) {
             cp.init(Cipher.DECRYPT_MODE, key);
             } else {
             return;
             FileInputStream dataFIS = new FileInputStream(dataFileName);
             int size = dataFIS.available();
             byte[] encryptByte = new byte[size];
             dataFIS.read(encryptByte);
             if (opMode.equalsIgnoreCase("encrypt")) {
             FileOutputStream FOS = new FileOutputStream("cipher.txt");
             //RSA Block size
             //int blockSize = cp.getBlockSize();
             int blockSize = 64 ;
             int outputBlockSize = cp.getOutputSize(encryptByte.length);
             /*if (blockSize == 0)
                  System.out.println("BLOCK SIZE ERROR!");       
             }else
             int leavedSize = encryptByte.length % blockSize;
             int blocksNum = leavedSize == 0 ? encryptByte.length / blockSize
             : encryptByte.length / blockSize + 1;
             byte[] cipherData = new byte[outputBlockSize*blocksNum];
             //encrypt each block
             for (int i = 0; i < blocksNum; i++) {
             if ((encryptByte.length - i * blockSize) > blockSize) {
             cp.doFinal(encryptByte, i * blockSize, blockSize, cipherData, i * outputBlockSize);
             } else {
             cp.doFinal(encryptByte, i * blockSize, encryptByte.length - i * blockSize, cipherData, i * outputBlockSize);
             //byte[] cipherData = cp.doFinal(encryptByte);
             //BASE64Encoder encoder = new BASE64Encoder();
             //String encryptedData = encoder.encode(cipherData);
             //cipherData = encryptedData.getBytes();
             FOS.write(cipherData);
             FOS.close();
             } else {
            FileOutputStream FOS = new FileOutputStream("plaintext.txt");
             //int blockSize = cp.getBlockSize();
             int blockSize = 64;
             //int j = 0;
             //BASE64Decoder decoder = new BASE64Decoder();
             //String encryptedData = convert(encryptByte);
             //encryptByte = decoder.decodeBuffer(encryptedData);
             int outputBlockSize = cp.getOutputSize(encryptByte.length);
             int leavedSize = encryptByte.length % blockSize;
             int blocksNum = leavedSize == 0 ? encryptByte.length / blockSize
                       : encryptByte.length / blockSize + 1;
             byte[] plaintextData = new byte[outputBlockSize*blocksNum];
             for (int j = 0; j < blocksNum; j++) {
             if ((encryptByte.length - j * blockSize) > blockSize) {
                  cp.doFinal(encryptByte, j * blockSize, blockSize, plaintextData, j * outputBlockSize);
                  } else {
                  cp.doFinal(encryptByte, j * blockSize, encryptByte.length - j * blockSize, plaintextData, j * outputBlockSize);
             FOS.write(plaintextData);
             //FOS.write(cp.doFinal(encryptByte));
             FOS.close();
}Edited by: sabre150 on Aug 3, 2012 6:43 AM
Moderator action : added [ code] tags so as to make the code readable. Please do this yourself in the future.
Edited by: 949003 on 2012-8-3 上午5:31

1) Why are you not closing the streams when writing the keys to the file?
2) Each block of RSA encrypted data has size equal to the key modulus (in bytes). This means that for a key size of 1024 bits you need to read 128 bytes and not 64 bytes at a time when decrypting ( this is probably the cause of your 'Data must start with zero exception'). Since the input block size depends on the key modulus you cannot hard code this. Note - PKCS1 padding has at least 11 bytes of padding so on encrypting one can process a maximum of the key modulus in bytes less 11. Currently you have hard coded the encryption block at 64 bytes which is OK for your 1024 bits keys but will fail for keys of modulus less than about 936 bits.
3) int size = dataFIS.available(); is not a reliable way to get the size of an input stream. If you check the Javadoc for InputStream.available() you will see that it returns the number of bytes that can be read without blocking and not the stream size.
4) InputStream.read(byte[]) does not guarantee to read all the bytes and returns the number of bytes actually read. This means that your code to read the content of the file into an array may fail. Again check the Javadoc. To be safe you should used DataInputStream.readFully() to read a block of bytes.
5) Reading the whole of the cleartext or ciphertext file into memory does not scale and with very large files you will run out of memory. There is no need to do this since you can use a "read a block, write the transformed block" approach.
RSA is a very very very slow algorithm and it is not normal to encrypt the whole of a file using it. The standard approach is to perform the encryption of the file content using a symmetric algorithm such as AES using a random session key and use RSA to encrypt the session key. One then writes to the ciphertext file the RSA encrypted session key followed by the symmetric encrypted data. To make it more secure one should actually follow the extended procedure outlined in section 13.6 of Practical Cryptography by Ferguson and Schneier.

Similar Messages

  • Javax.crypto.BadPaddingException: Data must start with zero

    Actually, I didn't write the entire codes, most of it was written by someone here, and I only tried to add a method. Here:
    public class RSAEncrypt {
        private KeyPair keys;
        private Cipher rsaCipher;
        public RSAEncrypt() throws GeneralSecurityException {
            KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
            keygen.initialize(512);
            keys = keygen.generateKeyPair();
            rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        public byte[] encrypt(byte[] message) throws GeneralSecurityException {
            rsaCipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
            return rsaCipher.doFinal(message);
        public byte[] decrypt(byte[] encryptedMessage) throws GeneralSecurityException {
             rsaCipher.init(Cipher.DECRYPT_MODE, keys.getPrivate());
             return rsaCipher.doFinal(encryptedMessage);
         * @param args
        public static void main(String[] args) throws Exception {
             String message = "The quick brown fox ran away";
             System.out.println("Message: " + message);
             byte[] encrypted = new RSAEncrypt().encrypt(message.getBytes());
            System.out.println("Cipher Text: " + HexBin.encode(encrypted));
            byte[] decrypted = new RSAEncrypt().decrypt(encrypted);
            System.out.println("Decrypted Text: " + decrypted);
    }The idea is that the program should encrypt the String, "The quick brown fox ran away," which it does. But when it gets to this line:
    byte[] decrypted = new RSAEncrypt().decrypt(encrypted);i get the error: javax.crypto.BadPaddingException: Data must start with zero.
    But here's the funny thing: If I edit the codes so that the encryption and decryption are done in the constructor, it works! Here:
    public class RSAEncrypt {
        private KeyPair keys;
        private Cipher rsaCipher;
        public RSAEncrypt() throws GeneralSecurityException {
            KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
            keygen.initialize(512);
            keys = keygen.generateKeyPair();
            rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
            rsaCipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
            String message = "The quick brown fox ran away";
            byte[] cipherText = rsaCipher.doFinal(message.getBytes());
            System.out.println(new BASE64Encoder().encode(cipherText));
            rsaCipher.init(Cipher.DECRYPT_MODE, keys.getPrivate());
            byte[] decryptedText = rsaCipher.doFinal(cipherText);
            String dText = new String(decryptedText);
            System.out.println(dText);
         * @param args
        public static void main(String[] args) throws Exception {
             new RSAEncrypt();
    }So, I'm confused. The Data must start with zero error is coming up when I pass encrypted data to a method for decryption, but it doesn't come out when I run everything in one method or in the constructor. Why???
    Also, when performing RSA encryption (or decryption) on a plaintext stored in a file (not a big file, just a file with probably one or two lines), this is what I do (and it works):
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    cipher.init(Cipher.ENCRYPT_MODE, pubKey);
    CipherInputStream cis = new CipherInputStream(new FileInputStream(new File("message.txt")),cipher);My question is, I do see some people doing this as well:
    cipher.doFinal(byteArray);The fact that I don't have this in my code when encrypting data from a file, that's ok, right? I don't need to do a ".doFinal()" method, do I?
    Edited by: glenak on Aug 19, 2010 4:26 AM

    glenak wrote:
    I don't quite understand, but if you mean this:
    String message = "The quick brown fox ran away";
    System.out.println("Message: " + message);
    RSAEncrypt rsaEncrypt = new RSAEncrypt();
    Creates and instance of RSAEncrypt with a new random RSA key pair.
    byte[] encrypted = rsaEncrypt.encrypt(message.getBytes());Encrypts with the random public key created in the first instance.
    System.out.println("Cipher Text: " + HexBin.encode(encrypted));
    RSAEncrypt rsaDecrypt = new RSAEncrypt();Creates and second instance of RSAEncrypt with a new random RSA key pair nothing to do with the first instance.
    byte[] decrypted = rsaDecrypt.decrypt(encrypted);Attempts to decrypt the ciphertext created with the public key of the first instance using the private key of the second, and totally unrelated, instance.
    System.out.println("Decrypted Text: " + decrypted);I still get the "Data must start with zero" error.
    If you could show me an example of what you mean, it would help very muchNo example is required. You cannot encrypt with the public key of one key pair and expect to decrypt with the private key of a totally independent key pair.

  • Control record must start with tag EDI_DC40, not E1LFA1M

    Hi,
    I am trying sxample <b>FILE>XI>IDOC ADAPTER-->R/3</b>
    I am getting error as
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Call Adapter
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIAdapter</SAP:Category>
      <SAP:Code area="IDOC_ADAPTER">ATTRIBUTE_IDOC_RUNTIME</SAP:Code>
      <SAP:P1>MSGGUID F95236609A0C11D98F65000D56714443: Control record must start with tag EDI_DC40, not E1LFA1M</SAP:P1>
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Error: MSGGUID F95236609A0C11D98F65000D56714443: Control record must start with tag EDI_DC40, not E1LFA1M</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Do i have to apply the note saying Apply the Support pack SP 11(Note No)  792957.
    Currently I have XI 3.0 SR1.
    Or can i try the similar example with some other IDOC.
    Please Help me in this.
    Thanks a lot
    Deepti

    Hi Deepti,
    I have got the same problem but after rescheduling the message its fine on the XI end. But at the R/3 End the status is still red with status number 56 (IDoc with errors added)Idoc used is CREMAS03. what might be the possible errors.
    Please help me.
    Regards,
    Gopesh Kumar Agarwal

  • How to form an Endeca query where a field must start with certain letters

    hi, Is it possible to form an Endeca query to retrieve a field that must start with certain letters? Say like get all users who's first letter is 'A' ? I checked with Range filters but it is supporting only numerical fields as well as Wild card search. But nothing worked well so far. any suggestion?

    Yes. Here's the gist of how it works:
    Typeahead is commonly implemented by enabling wildcard search on one or more Dimensions. An AJAX query is sent out containing the beginning of a search term. A controller in the app layer answers that AJAX query and formulates an Endeca Dimension Search query. It sends that off to the Endeca MDEX engine. Endeca responds with relevant Dimension matches. The controller returns these to the client who made the AJAX request. They are rendered as hyperlinks that lead to a particular navigation state in the catalog.

  • Can Check Number be start with zero?

    Dear all,
                   I knew that check number on SBO is numeric but check number of my country some number can start with zero and it effected to check number printing form. So, I'm not sure whether we can set check number to be charactor or not. Or how to apply for this issue, pls. suggest.
    Thanks you very much.
    Angnam

    Hi,
    It is not possible to set check number as alphanumeric, you can use remarks field to enter check number or any other filed that you think is not required and can be used as check number.
    it is not possible to add UDF in checks for payment . if you are using payment method checks tab, you can use UDF.
    Thanks,
    Neetu

  • What about numbers that start with Zero

    When I enter numbers that start with Zero (EX: 08794) in a cell, Numbers automatically drops the zero. I WANT THE ZERO. How can I do that. I've tried changing the formula to numerals and automatic. Same thing.

    Numbers starting with zeros are usually "labels" rather than "numbers" used in further calculations. If that's the case with yours, the easiest solution is to set the format of the cells where the 'numbers' will be inserted to Text.
    An alternate, useful only if all of the 'numbers' are the same length (eg. five digit zip codes) is to set a Custom format for the cell(s).
    Use the Cell Format Inspector ("42" button in the Inspector) to apply either of these settings.
    Regards,
    Barry

  • Option must start with -

    The server log has the following exception. Any ideas what the cause is?
    The server is in c:\sun but the JDK1.6 is in "C:\Program Files\Java." Is the problem to do with the space in "Program Files"? This was where the installation program defaulted to.
    [#|2007-07-29T12:37:22.344+0100|SEVERE|sun-appserver-pe9.0|javax.enterprise.tools.launcher|_ThreadID=10;_ThreadName=main;|launcher.jvmoptions_exception
    com.sun.enterprise.admin.util.InvalidJvmOptionException: Invalid Jvm Option Files/Java/jdk1.5.0_06/jre/lib/ext;C:/Sun/SDK/domains/domain1/lib/ext;C:/Sun/SDK/javadb/lib. Option must start with -.
         at com.sun.enterprise.admin.util.JvmOptionsElement.checkValidOption(JvmOptionsHelper.java:390)
         at com.sun.enterprise.admin.util.JvmOptionsElement.<init>(JvmOptionsHelper.java:277)
         at com.sun.enterprise.admin.util.JvmOptionsHelper.<init>(JvmOptionsHelper.java:66)
         at com.sun.enterprise.tools.launcher.ProcessLauncher.buildInternalCommand(ProcessLauncher.java:596)
         at com.sun.enterprise.tools.launcher.ProcessLauncher.buildCommand(ProcessLauncher.java:434)
         at com.sun.enterprise.tools.launcher.ProcessLauncher.process(ProcessLauncher.java:234)
         at com.sun.enterprise.tools.launcher.ProcessLauncher.main(ProcessLauncher.java:158)

    Solution
    Hi,
    It is what I guessed as the web page explains. The domain.xml file does not recognize any equipment name that has an acute in it. That was my case. So I have changed the name of my equipment and the problem was resolved when I installed the GlassFish again.
    Thanks for all of you about to visit my posts
    See you around,
    Oggie
    PS:
    Here I leave you the tag in the domain.xml that causes the problem,
    <jms-service addresslist-behavior="random" addresslist-iterations="3" default-jms-host="default_JMS_host" init-timeout-in-seconds="60" reconnect-attempts="3" reconnect-enabled="true" reconnect-interval-in-seconds="5" type="EMBEDDED">
            <jms-host admin-password="admin" admin-user-name="admin" host="Jose" name="default_JMS_host" port="7676"/>
          </jms-service>I hope this time you get it like me

  • Simple RSA decryption error

    Hi All
    I am trying a very simple RSA implementations. I am not able to decrypt the data correctly. Please find my code below,
    import java.math.BigInteger;
    import java.util.Random;
    public class SimpleRSA {
         public static BigInteger p, q, N, v, k, d;
         public static void main(String[] args) {
              // p & q are prime numbers
              Random myRandom = new Random(0);
              p = BigInteger.probablePrime(32, myRandom);
              q = BigInteger.probablePrime(32, myRandom);
              System.out.println("Value of p:" + p);
              System.out.println("Value of q:" + q);
              // N = pq
              N = p.multiply(q);
              System.out.println("Value of N:" + N);
              // v = (p-1)*(q-1)
              v =
                   (p.subtract(BigInteger.valueOf(1))).multiply(
                        q.subtract(BigInteger.valueOf(1)));
              System.out.println("Value of v:" + v);
              // Compute k such that gcd(k, v) = 1
              k = new BigInteger("3");
              while(v.gcd(k).intValue() > 1) k = k.add(new BigInteger("2"));
              System.out.println("Value of k:" + k);
              // Compute d such that (d * k)%v = 1
              d = k.modInverse(v);
              System.out.println("Value of d:" + d);
              System.out.println("Public Key (k,N): (" + k + "," + N + ")");
              System.out.println("Private Key (d,N): (" + d + "," + N + ")");
              // Encryption
              String text = "Welcome to Java";
              System.out.println("Sample text:" + text);
              byte[] cipherData = text.getBytes();
              BigInteger a = new BigInteger(cipherData);
              System.out.println("BigInteger a:" + a);          
              BigInteger b = a.modPow(k, N);
              System.out.println("Encrypted data:" + b);
              // Decryption
              BigInteger c = b.modPow(d, N);
              byte[] decryptedData = c.toByteArray();          
              String plainText = new String(decryptedData);
              System.out.println("Decrypted data:" + plainText);     
    The answer I am getting is like this
    Value of p:3139482721
    Value of q:3180579707
    Value of N:9985375032889742747
    Value of v:9985375026569680320
    Value of k:7
    Value of d:4279446439958434423
    Public Key (k,N): (7,9985375032889742747)
    Private Key (d,N): (4279446439958434423,9985375032889742747)
    Sample text:Welcome to Java
    BigInteger a:1446156601937412646258
    Encrypted data:9678387382297663676
    Decrypted data:r��`�>B[/i]
    Please help me in this regard.
    Regards
    Kathirvel

    "m" (the integer rep of the message) must be strictly less than "N" (p*q). Look at the output - your p and q are too small for your data. Tryp = BigInteger.probablePrime(512, myRandom);
    q = BigInteger.probablePrime(512, myRandom);and try again.
    Then, go back and re-read the description of the RSA algorithm:
    http://en.wikipedia.org/wiki/RSA
    ("Applied Cryptography" would be bettr - but Wikipedia is at least a good start...)
    Grant

  • Error, in Getting started with Labview. Chapter 3, part 4.

    Hi.
    Still struggling on, trying to find the time to work through the "Getting Started with LabVIEW" document.
    Only 19 days left to go, and I'm still only in chapter 3!...
    Right.  In the "Saving Data When Prompted by a User" exersise, part 4...
    4.   Right-click the Signals input of the Write To Measurement File
          Express VI and select Insert Input/Output from the shortcut menu to
          insert the Comment input.
    Problem is, that option is greyed out, so not available!...
    I did what the instructions said, I right clicked on the "Signals" input, and it doesnt do what it says on the tin!
    Any pointers?   Please don't mention search the help, I've crashed the entire LV environment 3 times now, trying to search for something in there.  It's OK if it finds someting, but it seems to bomb at times, when there is some ambiguity when searching.
    Also, I won't be able to do anyting with any replies for a day or two, as I have to go up country to a customer, and mess about with hot oil, high volts, and lots of RF.  It never ends.   (I've still got the day job to do, while trying to fight my way through this "evaluation".   30 days of "Use" would be better, than 30 calendar days for some of us.)
    Regards.
    Dave Baxter.
    Technical Manager: AR-UK Ltd.
    AR United Kingdom
    OK... Who let the smoke out?

    Hi Dennis, and everyone else..
    That is not how it looks when first dropped on the BD.  On my machine, it is partialy expanded by default, after you clear the Configure dialog that pops up ocupying most of the screen.
    Again, if it makes a difference to the way the Right Click shortcut menu works, it should be documented in the Getting Started document, especialy as it seems to be a critical point.
    OK, explain this...
    I've just rubbed out the save to file VI, cleaned up the broken wires etc, and then planted a new one on the BD.   Once I cleared the Configure dialog that covers up most of the screen before you see it the first time, the VI was partialy expanded.  I forget the exact list, but "Signals" was not at the top.
    I did *EXACTLY* the same again, deleted it, cleaned up, and then planted a fresh new one.   That DID appear that time with nothing but the "Signals" item showing, and two down caretts below that, indicating more items.
    So......
    Why the different behaviour each time, on the same BD, in the same session.   Some underlying working data not being correctly initialised when invoked?  Of course, that never happens, right? ('C' programmes eh?)
    Trying some more, it seems the behaviour loosley depends on just how close to the edge of the While loop grey border you place it.   Odd.   I have a 1280x800 screen to play with, and a 1280x1024 second screen I use for the Getting Started document.  That is the absolute maximum I can have, due to hardware limits.
    I also find, that if you fully expand the "Write to Measurement File" VI block, then fully collapse it, then expand it again, all the items in that list have changed places!  Why?
    I had noticed earlier that there is no uniformity in the layout of even the items common to many if not all VI blocks (error in, and error out to name but two) Sometimes one is above the other, sometimes the other way round, sometimes they are not even ajacent to each other.   Has that been done as a source of minor ammusement or something?
    Talking to another colegue here, who just wandered in to see how I was getting on with this.  Seems he also has tried the introductory entry into LV (V8.something) in the past.  But he too, found too many things that behaved differently from one time to another, so abandoned it as a lost cause, then decided to learn how to use Visual Basic with NI-GPIB IO instead.   Not without issues either he said, but at least it all behaves exactly the same, each and every time.
    End of the day now...
    Regards.
    Dave B.
    OK... Who let the smoke out?

  • HWS file error when not starting with Ch 0

    Hello,
    I used the "niScope EX Save to File - HWS Low Level - Single Channel Stream.vi" as my starting point and added 8 channels for a 5105 card. Although this is a complex Queue-based vi, it works fine as long as my RAID is fast enough.
    However, we have need to take data from channels 4 to 7 and not start with Ch 0. When I do this, my LabVIEW HWS reader does not see any data, nor does the MATLAB code I have written to read our HWS files.
    Looking at the file in HDFView, I see that the data starts in vector0 and not vector1, as when I record Channels 0 to 3.
    Perhaps I need to use the HDF5 LabVIEW code to force the writing to a different location in the HDF file?
    Thanks for your help.

    Hello,
    I was out of the office Mon. and Tues. I took out a section that just collects one 5105 card in a steaming, continuous collect mode. This is part of a much bigger VI and I included the “Helper Aps” folder that has all the sub-VIs for that larger app. There are more sub-VIs than you need for “5105 Cont Collect.vi”, but it should run once you tell it where the sub-VIs are. Included is a quick-look reader I use to look at the data.
    The data file Ch_0_to_3_5105-0.hws can be read, but the Ch_4_to_7_5105-0.hws file cannot.
    Thank you for your help.
    Attachments:
    5105_Cont_Collect.zip ‏3267 KB

  • EPub validation errors for chapters starting with an anchored image

    I am generating an epub file using InDesign CS5.5.
    I have set up a TOC and selected it during the epub export. It has one level based on my paragraph style “Caption” and works perfectly when I test the ePub file on iBooks.
    Most chapters start with an image, followed by a caption (in paragraph style “Caption”, the same as I’m using to generate the TOC) underneath.
    Images are anchored (using the blue box) to this caption in the Indesign file.
    I have forced a page break before the image in the export to epub to ensure the image comes at the top of the page.
    So far so good. All looks great and everything, including TOC, works perfectly in iBooks on my iPad and in Adobe Digital Editions.
    However, my file will not validate because the TOC markers in the chapters which begin with the anchored image are missing – even though the TOC works perfectly as I’ve mentioned earlier.
    As far as I can make out from the HTML, the anchored image is overriding the TOC marker, hence the error.
    I’ve manually edited the chapter files concerned for now as I’m under time pressure to finish the job, but I’d really appreciate any advice on how to set up my InDesign file to avoid this error in the first place for future books.
    (I’ve tried anchoring the image to a space before the caption text, and anchoring it to a soft and hard return but no joy. I could start the page with the caption followed by the image and force the break after the image instead of before it to solve the problem but my client wants the image at the start of the chapter and I agree it looks much better that way round…….)
    Any suggestions much appreciated.
    I can post the HTML code the Indesign export is generating and the edited code if that helps at all.

    Hi Steve,
    Thanks for your quick response.
    I have Version 7.5 of InDesign CS5.5. Not sure if that includes the patch? If not, where would I get the patch from?
    On the error, here are a couple of examples from the first 2 chapters - it occurs in every chapter that begins with an image:
    ERROR         OEBPS/toc.ncx         23       62       'toc_marker-2': fragment identifier is not defined in 'OEBPS/Inspirational_Love_V1-1.html'
    ERROR         OEBPS/toc.ncx         29       62       'toc_marker-3': fragment identifier is not defined in 'OEBPS/Inspirational_Love_V1-2.html'
    Also, here's an example of the original HTML generated by the export which is missing the TOC marker:
    <div class="Basic-Text-Frame">
    <p class="para-style-override-1"> <img
    src="images/VX61_Fogra_USM_fmt.jpeg" alt="VX61_Fogra_USM.jpg"
    height="467" width="1400" /> </p>
    <p class="Caption">Refuge Cove, Wilson's Promontory, Vic</p>
    And here's the corrected code which validates:
    <div class="Basic-Text-Frame">
    <p class="para-style-override-1"> <img
    src="images/VX61_Fogra_USM_opt.jpeg" alt="VX61_Fogra_USM.jpg"
    height="467" width="1400" /> </p>
    <p id="toc_marker-4" class="Caption">Refuge Cove, Wilson’s
    Promontory, Vic</p>
    Thanks for your help.

  • Value should start with zero

    Hi experts
    I have a target field whose values should generate starting from zero
    I am using gen_row_num but it starts from 1
    Any Suggestions Please
    Thanks
    Madhu

    Hello
    So, you need the value to be one less than the one that is generated?  Simple maths suggests subtracting 1 from the generated value will give you what you require. 
    gen_row_num() - 1
    Michael

  • Backup fails with a CPIO error even though starting with DD

    Hi All,
    I have started a db backup of a sap system directly onto a tape.
    I am using DD since size of each datafile is more than 2 GB.
    In a total of 112 data files, 109 got copied but suddenly, the following error came and brbackup got terminated.
    This has happened for the second time and that too after using a separate set of tapes.
    Can you please provide me your views on it. I am unable to understand why should the error contain "CPIO" if i am using DD.
    The parameter settings have been made correctly in the init<SID>.sap file.
    Regards,
    Hari Kishan
    BR0351I Restoring /oracle/OBC/sapbackup/.tape.hdr0
    BR0355I from /dev/rmt726.1 ...
    BR0278E Command output of 'LANG=C cd /oracle/OBC/sapbackup && LANG=C
    cpio -iuvB .tape.hdr0 < /dev/rmt726.1':
    Can't read input
    If you want to go on, type device/file name when ready
    10 blocks
    .tape.hdr0
    BR0280I BRBACKUP time stamp: 2009-12-09 00.57.43
    BR0279E Return code from 'LANG=C cd /oracle/OBC/sapbackup && LANG=C
    cpio -iuvB .tape.hdr0 < /dev/rmt726.1': 0
    BR0359E Restore of /oracle/OBC/sapbackup/.tape.hdr0 from /dev/rmt726.1
    failed due to previous errors
    BR0218E Checking label on volume in device /dev/rmt726.1 failed
    BR0056I End of database backup: becbufwv.ant 2009-12-09 00.57.43
    BR0280I BRBACKUP time stamp: 2009-12-09 00.57.45
    BR0054I BRBACKUP terminated with errors

    Hello,
    in addition to all the backup files, brbackup will always write one more file to the tape, right at the beginning. This file is called .tape.hdr0. It contains, in essence, the name of the tape and date of the current backup. As far as I know this file will always be written by cpio, no matter what your tape_copy_command is. At the end brbackup will check this file again, and that step failed here.
    So it seems there is a problem with either your tape or your tape drive.
    But don't worry about cpio!
    hope this helps

  • RSA Decryption Error - Illegal Use

    Hi there,
    i have a crypthographic problem using a JavaCard application and a Java host application.
    On the card i create a cipher object and a private/public key:
    Cipher cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1_OAEP, false);
    KeyPair kP = new KeyPair(KeyPair.ALG_RSA, KeyBuilder.LENGTH_RSA_1984);
    kP.genKeyPair();
    RSAPublicKey app_public_key = (RSAPublicKey) kP.getPublic();
    RSAPrivateKey app_private_key = (RSAPrivateKey) kP.getPrivate();There are two functions on the card to send the modulus and the exponent from the public key to the host application using two APDUs.
    private void sendModulus(APDU apdu)
         byte[] buffer = apdu.getBuffer();
         short modLength = app_public_key.getModulus(buffer, (short)ISO7816.OFFSET_CDATA);
         apdu.setOutgoing();
         apdu.setOutgoingLength(modLength);
         apdu.sendBytesLong(buffer, (short)ISO7816.OFFSET_CDATA, modLength);
    private void sendExponent(APDU apdu)
         byte[] buffer = apdu.getBuffer();
         short expLength = app_public_key.getExponent(buffer, (short)ISO7816.OFFSET_CDATA);
         apdu.setOutgoing();
         apdu.setOutgoingLength(expLength);
         apdu.sendBytesLong(buffer, (short)ISO7816.OFFSET_CDATA, expLength);
    }On the host i request the modulus and the exponent and build the public key:
    public void getAppMod() throws TerminalException
                      //get modulus
         ResponseApdu response = send(new CommandApdu("0x00 0xAA 0x01 0x00"));
         System.out.println(response.getStatusHexString());
         byte[] modulus = response.getData().toByteArray();
                      //get exponent
         ResponseApdu response = send(new CommandApdu("0x00 0xAA 0x02 0x00"));
         System.out.println(response.getStatusHexString());
         byte[] exponent = response.getData().toByteArray();
                      RSAPublicKeySpec kSpec = new RSAPublicKeySpec(new BigInteger(1, mod), new BigInteger(1, exp));
         KeyFactory kFac = KeyFactory.getInstance("RSA");
         RSAPublicKey app_rsa_publicKey = (RSAPublicKey)kFac.generatePublic(kSpec);
    }Now i create a cipher object on the host application, encrypt a message with this public key and send it to the card:
    Security.addProvider(new BouncyCastleProvider());
    Cipher cipher = Cipher.getInstance("RSA", "BC");
    cipher.init(Cipher.ENCRYPT_MODE, app_rsa_publicKey);
    byte[] cipherData = cipher.doFinal(bData); //bData is the message and cipherData the encrypted 248byte message.On the card now im trying to decrypt it with the private key.
    byte[] buffer = apdu.getBuffer();
    short bytesRead = apdu.setIncomingAndReceive();
    cipher.init(app_private_key, Cipher.MODE_DECRYPT);
    short messageLength = cipher.doFinal(buffer, (short)ISO7816.OFFSET_CDATA, bytesRead, buffer, (short)ISO7816.OFFSET_CDATA);
    }But the "doFinal" method throws an "ILLEGAL_USE" Exception...
    I dont know what to do now....
    Is it possible that the "BouncyCastle" Cipher object on the host side does not fit the cipher object on the card side ? because the key was transfered correctlly :(
    is there any provider i can use whre i dont need a free library like bouncycastle ?
    Thanks for helping...
    Edited by: 963778 on 08.10.2012 01:56

    Hi again,
    i think i solved my problem.
    So far it seems it wasnt the same RSA padding on card an host.
    After create the cipher on the card this way:
    cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);And on the host this way:
    cipher = Cipher.getInstance("RSA/NONE/PKCS1Padding", "BC");it works fine from host to card.
    The other way from card to host i get an "unknown block type" error.

  • IllegalException :JDOM comment: Comment data cannot start with a hyphen

    This morning i noticed that JDOM cannot read a XML document that has a comment with syntax <!-- -. If you look closer i have 3 hyphens instead of 2 which is the normal syntax of a comment begining.
    But my fate, i ended up having a big XML file with comments all over the document like this
    <!-- -============ Browse ======================= -->
    Watching this comment there is a space followed by a 3rd hyphen. Don't know why the document owner did like this.
    I was looking for a better way to do a search and replace of the <!-- - to <!-- before i open the document for JDOM parsing. Coming from C# world, i know there is a XMLDocument doc = new XMLDocument() class where we can load a file in memory and do some edits and save the document. Is there any API like that in Java, and whats the best search replace strategy?
    Any help would be appreciated.

    -su option starts the JDeveloper in single user mode. The system directory will be created inside the JDev installation itself (as opposed to the normal - Documents and Settings folder).
    You don't need to start the JDev with that option always. That suggestion was because you were getting the error.
    As far as the error is concerned, I believe it is something to do with space in folder - "Documents and settings". You might want to check out that registry entry NtfsDisable8dot3NameCreation again. My guess is, you would've set the registry entry before the installation, but you might need to restart the machine after setting that registry entry to take effect. And then could've started the installation.
    -Arun

Maybe you are looking for

  • ITunes sync with multiple computers

    Help for a newbie please! I have a Windows 7 laptop running iTunes and syncing up with my iPhone beautifully.  My goal is to sync that library with another computer (Windows XP desktop) so that they're independent of one another.  However, I do need

  • Disable / Deactivate Update Price button in Sales order creation

    Hi Gurus, My requirement is to disable the 'Price Update' button in the item --> conditions screen while creating or changing the sale sorder. A set of users should not be able to update the prices using 'Update Pricing' button. Is there any way to d

  • Cound not find any entry in table EDP12 for a partner provided in IDOC data

    Hi All, I have an inbound IDOC for a purchase order. If a put a query to the table EDP12 for the partner  or message type (ORDERS) provided in the IDOC data, I do not get any entry for this. Could you please enlighten me on this... Thanks, Sanjeet

  • Comcast & Airport Extreme Correct IP Address?

    Apple Support had to help me setup my new Airport Extreme Router, as it turned out, due to a Comcast Internet problem in my area. Everything appears to be working correctly now, however, what is the correct default Apple Extreme IP Address?  I found

  • Problem with Permissions while accessing Portal Content

    Dear All, Im facing some problems with the permission in accessing the portal content. When i right click on any of the folders in the catalog displayed under the System Administration - > System Configuration -> System Landscape -> Content directory