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.

Similar Messages

  • Error: Illegal use of when -style tag without choose as its direct paren

    Hi,
    I'm using the Code:
    <c:choose>
    <c:when test="${empty param.usernaseme}" >
    <B>Hello <c:out value="${param.usernaseme}" /></B>
    </c:when>
    <c:otherwise>
    unknown user name.
    </c:otherwise>
    </c:choose>
    and keep geting the Error:
    Illegal use of <when>-style tag without <choose> as its direct parent
    As far as know
    the code is OK.
    Declare Is OK (Other thigs using <c:out /> working)
    thanks for your halp
    Shimon

    Hi,
    I'm using the Code:
    <c:choose>
    <c:when test="${empty param.usernaseme}" >
    <B>Hello <c:out value="${param.usernaseme}" /></B>
    </c:when>
    <c:otherwise>
    unknown user name.
    </c:otherwise>
    </c:choose>
    and keep geting the Error:
    Illegal use of <when>-style tag without <choose> as its direct parent
    As far as know
    the code is OK.
    Declare Is OK (Other thigs using <c:out /> working)
    thanks for your halp
    Shimon

  • Error "Illegal use of 1PC resource in transaction" with Websphere 4.0

    Hello All:
    I am developing with the webpshere application developer 4.0.0 old version because the proyect requirements.
    I am connecting with jdbc driver to an Oracle DDBB.
    I use the OracleConnectionPoolDataSource driver.
    When i try to modify or enter new data at the DDBB at the console appears the error at the topic:
    Illegal use of 1PC resource in transaction
    I have only one database set with that driver and i think that i use only one instance of the DDBB.
    I have been looking at documentation and inet and this type of error appears when you try to use two instance of the same database or one instance of two diferent databases at the same time with an 1PC (one phase commit) driver. And it does appear that is the case.
    I have found at google the following link at the IBM webpage:
    http://www-1.ibm.com/support/docview.wss?rs=0&org=SW&doc=4000986
    that refers to my error and offers an efix for the websphere application server. I have tried to aply the patch but it doesn't aply well.
    Can someone who has used or is using this version of the websphere help me with this error please?
    thx in advance
    SkN

    I just figured this out on my own. After looking again at the SQL Server views, I noticed they all still had the text column selected in the view even though we're not importing the column into the OWB repository view definition. I recreated all the views w/o the text columns and re-validated the maps. Problem solved.

  • 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.

  • 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

  • Decrypt Error using 2-way SSL

    I am exposing a stateless Session bean as a webservice and have setup truststore/keystore to allow clients access using 2-way SSL. Recently one of the clients beagn to get TLS Alert 51 - Decrypt Error during the SSL handshake, right after "HANDSHAKEMESSAGE: CertificateVerify". Other clients of 2-way SSL don't appear to have any issues.
    Has anyone seen this?
    Thanks
    Peter
    some SSl debug follows:
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <SSLTrustValidator returns: 0>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <Trust status (0): NONE>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <HANDSHAKEMESSAGE: ClientKeyExchange RSA>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <SSLFilter.isActivated: false>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <isMuxerActivated: false>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <SSLFilter.isActivated: false>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <30911879 SSL3/TLS MAC>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <30911879 received HANDSHAKE>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <HANDSHAKEMESSAGE: CertificateVerify>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <NEW ALERT with Severity: FATAL, Type: 51
    java.lang.Exception: New alert stack
         at com.certicom.tls.record.alert.Alert.<init>(Unknown Source)
         at com.certicom.tls.record.handshake.HandshakeHandler.fireAlert(Unknown Source)
         at com.certicom.tls.record.handshake.ServerStateReceivedClientKeyExchange.handle(Unknown Source)
         at com.certicom.tls.record.handshake.HandshakeHandler.handleHandshakeMessage(Unknown Source)
         at com.certicom.tls.record.handshake.HandshakeHandler.handleHandshakeMessages(Unknown Source)
         at com.certicom.tls.record.MessageInterpreter.interpretContent(Unknown Source)
         at com.certicom.tls.record.MessageInterpreter.decryptMessage(Unknown Source)
         at com.certicom.tls.record.ReadHandler.processRecord(Unknown Source)
         at com.certicom.tls.record.ReadHandler.readRecord(Unknown Source)
         at com.certicom.tls.record.ReadHandler.readUntilHandshakeComplete(Unknown Source)
         at com.certicom.tls.interfaceimpl.TLSConnectionImpl.completeHandshake(Unknown Source)
         at javax.net.ssl.impl.SSLSocketImpl.startHandshake(Unknown Source)
         at com.bea.sslplus.CerticomSSLContext.forceHandshakeOnAcceptedSocket(Unknown Source)
         at weblogic.security.utils.SSLContextWrapper.forceHandshakeOnAcceptedSocket(SSLContextWrapper.java:128)
         at weblogic.t3.srvr.SSLListenThread$1.execute(SSLListenThread.java:484)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    >
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <write ALERT, offset = 0, length = 2>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <close(): 7828>
    ####<May 22, 2007 1:58:21 PM GMT> <Debug> <TLS> <CPNT> <weblogicPROD> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <000000> <SSLIOContextTable.removeContext(ctx): 9723897>

    I too am struggling with SSL but I was given some help by BEA. This does not help me since It seems like the proxy jar I download from the WS Home Page wants to go directly to the JPD not the jws. This example of two way SSL should work for you. I am including the Main class but not the generated files it refers to. I don't know how to attach files to the news groups. The key thing it to make use of the adapters. The Impl and Port are part of the downloaded proxy.
    public static void main(String[] args) throws Exception {
    // set weblogic ServiceFactory
    System.setProperty("javax.xml.rpc.ServiceFactory", "weblogic.webservice.core.rpc.ServiceFactoryImpl");
    // set weblogic client protocol handler
    System.setProperty("java.protocol.handler.pkgs", "weblogic.webservice.client");
    // set the SSL adapter
    SSLAdapterFactory adapterFactory = SSLAdapterFactory.getDefaultFactory();
    WLSSLAdapter adapter = (WLSSLAdapter) adapterFactory.getSSLAdapter();
    // two-way SSL you must loadLocalIdentity to provide certs back to the server
    FileInputStream clientCredentialFile = new FileInputStream ("./client/clientcred.pem");
    String pwd = "canpass";
    adapter.loadLocalIdentity(clientCredentialFile, pwd.toCharArray());
    adapter.setVerbose(true);
    adapter.setTrustedCertificatesFile("./config/ca1024.pem");
    adapter.setStrictChecking(false);
    adapterFactory.setDefaultAdapter(adapter);
    adapterFactory.setUseDefaultAdapter(true);
    String a = null;
    if (args.length < 1) {
    a = "Sample String";
    } else {
    a = args[0];
    ToUpper_Impl lookup = new ToUpper_Impl();
    ToUpperPort value = lookup.gettoUpperPort();
    String result = value.toUpper(a);
    System.out.println(result);
    }

  • HT4864 I am using Entourage and followed all the instructions above and still getting IMAP Server error.  Error msg:Security failure.  Data decryption error.

    I am using Entourage and followed all the instructions above and still getting IMAP Server error.  Error msg:Security failure.  Data decryption error.

  • Illegal use of LONG datatype error message when i create materialized view

    Hello to all
    I want create read only materialized view replication environment two of our tables have LONG datatype when i create materialized view against on them
    I recieve this error message
    CREATE MATERIALIZED VIEW MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID AS SELECT * FROM MDB.TOAD_PLAN_TABLE@arahisto
    Error report:
    SQL Error: ORA-00997: illegal use of LONG datatype
    00997. 00000 - "illegal use of LONG datatype"
    Do you know any resort solution for it?
    thanks

    You can not use longs in materialized views over a database link, you can however take a part of a long over to a materialized view.
    I have gotten this to work in the past l had to create a PL/SQL function that you can use to extract the character data from the long column and use that to
    as part of the function you will need to pass in the columns of the table that will identify the unique records so you can pick out the long column
    example function
    -- you will need to make sure this funtion is in the remote location as you can not select longs accross a DB LINK.
    CREATE OR REPLACE FUNCTION MDB.TOAD_PLAN_LONG_CONV
    (pass in the primary key columns for the table)
    RETURN VARCHAR2
    IS
    v_long VARCHAR2(32767) ;
    BEGIN
    BEGIN
    -- need to select the long column into the PL/SQL variable
    SELECT long_column
    INTO v_long
    FROM MDB.TOAD_PLAN_TABLE
    WHERE key_columns = passed columns ;
    EXCEPTION
    WHEN OTHERS THEN
    IF SQLCODE = '-01406' THEN
    NULL ;
    ELSE
    RAISE ;
    END IF ;
    END ;
    RETURN SUBSTR(v_long,1,4000) ;
    END ;
    Then when you create the materialized view utilize that function on the long column.
    create or replace materialized view MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID
    AS
    SELECT column1, .... columnx,
    MDB.TOAD_PLAN_LONG_CONV@arahisto (primary key column list) as long_column_name
    FROM MDB.TOAD_PLAN_TABLE@arahisto ;
    See if this will work for you? Keep in mind however this solution will not get the entire long column only as much as a PL/SQL variable will hold of it.
    Mike

  • Error Illegal access to the viewer. Please use a valid URL

    Hi, One question:
    Illegal access to the viewer. Please use a valid URL?
    Pls, any comment with this error.
    Regards
    LEJS

    Check the KBA 1892338 - Error: "illegal access to the viewer, please use a valid url" while viewing webi reports from BI Launchpad.This may be because of licence being expired.

  • Hey I'm getting an error when I'm using an AU plugin its saying"Host Error: illegal midi databyte2 an my logic crashes any tips? thanks

    hey I'm getting an error when I'm using an AU plugin its saying"Host Error: illegal midi databyte2 an my logic crashes any tips? thanks

    There is a minor issue with Logic where Logic sends corrupt midi data
    to plugins when recording in loopmode (looptool),
    we've released a hotfix for ElectraX 1.2 as well as fixed this in
    ElectraX 1.3 (currently in beta).
    ElectraX 1.3 is set for release in early July and if I remember
    correct the current ElectraX demo also has the fix included,
    so redownloading/reinstalling the demo should take care of it.
    In the meanwhile another possible workaround is to switch off
    loopmode when recording.
    from TONE 2

  • Rsa Decrypt Not Working.. Please Help

    Hi everyone,
         I am new to java card development. I have been trying to use RSA encryption in my Applet. I finally got the encryption working but the decryption is showing Illegal Use Error. Any kind of help is appreciated.
    public class RSAsample extends Applet{
    byte[] rsaPublic = new byte[4];
    byte[] rsaPrivate = new byte[4];
    byte[] rsaPublicMod = new byte[4];
    RSAPrivateKey pri ;
    RSAPublicKey pub ;
    private final static byte INS_ENCRYPT = (byte) 0x20;
    private final static byte INS_DECRYPT = (byte) 0x30;
    KeyPair pair ;
    private RSAsample() {
      super();
      register();
    public static void install(byte bArray[], short bOffset, byte bLength)
      throws ISOException {
      new RSAsample();
    public boolean select() {
      pair = new KeyPair(KeyPair.ALG_RSA, (short) 512);
      pair.genKeyPair();
    pri = (RSAPrivateKey) pair.getPrivate();
    pub = (RSAPublicKey) pair.getPublic();
      return super.select();
    public void deselect() {
      super.deselect();
       public void process(APDU apdu) throws ISOException {
        byte[] buffer = apdu.getBuffer();
        switch(buffer[ISO7816.OFFSET_INS])
        case INS_ENCRYPT:
        encrypt(apdu);
        break;
        case INS_DECRYPT:
        decrypt(apdu);
        break;
    private void decrypt(APDU apdu) {
      byte[] buffer = apdu.getBuffer();
      byte byteRead = (byte)(apdu.setIncomingAndReceive());
      short size = 0;
      try{
      Cipher cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
      cipher.init(pri, Cipher.MODE_DECRYPT);
      size =  cipher.doFinal(buffer, ISO7816.OFFSET_CDATA, (short)byteRead, buffer,
      (short) 0);
      catch(CryptoException e)
      switch(e.getReason())
      case CryptoException.ILLEGAL_USE:
      ISOException.throwIt(ISO7816.SW_DATA_INVALID);
      break;
      case CryptoException.ILLEGAL_VALUE:
      ISOException.throwIt(ISO7816.SW_FILE_INVALID);
      break;
      case CryptoException.INVALID_INIT:
      ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
      break;
      case CryptoException.NO_SUCH_ALGORITHM:
      ISOException.throwIt(ISO7816.SW_FILE_INVALID);
      break;
      case CryptoException.UNINITIALIZED_KEY:
      ISOException.throwIt(ISO7816.SW_FILE_FULL);
      break;
      default:
      ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
      break;
      apdu.setOutgoing();
      apdu.setOutgoingLength(size);
      apdu.sendBytes((short)0, size);
    private void encrypt(APDU apdu) {
      byte[] buffer = apdu.getBuffer();
      byte byteRead = (byte)(apdu.setIncomingAndReceive());
      short size = 0;
      try{
      Cipher cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
      cipher.init(pub, Cipher.MODE_ENCRYPT);
      size =  cipher.doFinal(buffer, ISO7816.OFFSET_CDATA, (short)byteRead, buffer,
      (short) 0);
      catch(CryptoException e)
      switch(e.getReason())
      case CryptoException.ILLEGAL_USE:
      ISOException.throwIt(ISO7816.SW_DATA_INVALID);
      break;
      case CryptoException.ILLEGAL_VALUE:
      ISOException.throwIt(ISO7816.SW_FILE_INVALID);
      break;
      case CryptoException.INVALID_INIT:
      ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
      break;
      case CryptoException.NO_SUCH_ALGORITHM:
      ISOException.throwIt(ISO7816.SW_FILE_INVALID);
      break;
      case CryptoException.UNINITIALIZED_KEY:
      ISOException.throwIt(ISO7816.SW_FILE_FULL);
      break;
      default:
      ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
      break;
      apdu.setOutgoing();
      apdu.setOutgoingLength(size);
      apdu.sendBytes((short)0, size);
    Also if this is wrong can you share a sample code using RSA Encryption and Decryption.
    Thanks

    Hi,
    You code looks perfectly fine.
    Looking at the error code i think you are sending some invalid data for decryption operation.
    You should send data which was encrypted using the same PublicKey other wise it will fail while matching the Padding or Data Blocks.
    For better understanding Encrypt some data and immediately use the output data for Decrypt operation and it should work fine.
    Let me know if you face any difficulties.
    BR,
    PPT

  • SSLException while handshaking: Peer sent alert: Alert Fatal: decrypt error

    Hello everybody,
    I am tryining to establish a connection from SAP PI 7.0 to an external web service that requires SSL with client authentication. I am using the SOAP adapter for that. The private key of us and the public key of the web service were installed in the VA in the TrustedCAs view. In the corresponding receiver channel configuration I have ticked "Configure Certificate Authetication" and selected appropriate entries in "Keystore Entry" and "Keystore View".
    Whenever I send a message through the channel I am getting though an error during the SSL handshake: Decrypt error.
    Below is the SSL debug log
    ssl_debug(15): Sending v3 client_hello message to services.bloomberg.com:443, requesting version 3.1...
    ssl_debug(15): Received v3 server_hello handshake message.
    ssl_debug(15): Server selected SSL version 3.1.
    ssl_debug(15): Server created new session 81:ED:F8:61:3B:51:8E:70...
    ssl_debug(15): CipherSuite selected by server: TLS_RSA_WITH_AES_256_CBC_SHA
    ssl_debug(15): CompressionMethod selected by server: NULL
    ssl_debug(15): Server does not supports secure renegotiation.
    ssl_debug(15): Received certificate handshake message with server certificate.
    ssl_debug(15): Server sent a 2048 bit RSA certificate, chain has 3 elements.
    ssl_debug(15): ChainVerifier: No trusted certificate found, OK anyway.
    ssl_debug(15): Received certificate_request handshake message.
    ssl_debug(15): Accepted certificate types: RSA, DSA
    ssl_debug(15): Accepted certificate authorities:
    ssl_debug(15):   CN=XXXXXXXXXXXXXXXXXXXXXXXX
    ssl_debug(15):   CN=VeriSign Class 3 International Server CA - G3,OU=Terms of use at https://www.verisign.com/rpa (c)10,OU=VeriSign Trust Network,O=VeriSign, Inc.,C=US
    ssl_debug(15):   CN=VeriSign Class 3 Public Primary Certification Authority - G5,OU=(c) 2006 VeriSign, Inc. - For authorized use only,OU=VeriSign Trust Network,O=VeriSign, Inc.,C=US
    ssl_debug(15): Received server_hello_done handshake message.
    ssl_debug(15): Sending certificate handshake message with RSA client certificate...
    ssl_debug(15): Sending client_key_exchange handshake...
    ssl_debug(15): Sending certificate_verify handshake message...
    ssl_debug(15): Sending change_cipher_spec message...
    ssl_debug(15): Sending finished message...
    ssl_debug(15): Received alert message: Alert Fatal: decrypt error
    ssl_debug(15): SSLException while handshaking: Peer sent alert: Alert Fatal: decrypt error
    ssl_debug(15): Shutting down SSL layer...
    My first assumption was that it might be caused by missing public key of other side's server in the TrustedCAs view. Now I have assured that we have this key installed (although I am currious why there is still the "ChainVerifier: No trusted certificate found" message in the log).
    Does somebody have an idea what could cause this SSL handshake failure?
    Best regards,
    Maxim

    The XPI inspector gave more understanding of the situation. It shows which certificates the remote server is sending, which client certificate is used for authentication and many other topics. Interesting enough the XPI inspector shows that PI trusts the server key whereas the NWA log at the very same time tells that it doesn't. I have posted an OSS message asking to explain why there is this discrepancy.

  • "llegal character in path at index" Error While Using wsimport from ant.

    Hi,
    I am getting the following error, while using wsimport from ant build script. you have the details below. I dont have a clue on this error.
    Error :
    wsimport:
    [echo] Generating the client stubs
    [wsimport] error: Unable to parse "HelloService_schema1.xsd" : Illegal character in path at index 25: file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
    [wsimport] line 0 of file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
    [wsimport] error: Unable to parse "HelloService_schema1.xsd" : Illegal character in path at index 25: file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
    [wsimport] line ? of file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
    [wsimport] error: Element "{http://endpoint.helloservice/}sayHello" not found.
    Java WebService :
    package helloservice.endpoint;
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    @WebService()
    public class Hello {
    private String message = new String("Hello, ");
    @WebMethod()
    public String sayHello(String name) {
    return message + name + ".";
    Ant Build.xml
    <project name="${project.name}" basedir="." default="ear">
         <property file="WS_build.properties"/>
         <target name="init">
              <!-- Path Setting-->
              <echo description="Setting the path for the project"/>
              <path id="classpath">
                   <fileset dir="${lib.dir}" includes="*.jar"/>          
                   <fileset dir="${commonWSLib.dir}" includes="*.jar"/>
              </path>
              <!-- WSGen -->
              <echo description="WSGEN Definition"/>
              <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
                   <classpath>
                        <path refid="classpath"/>
                   </classpath>
              </taskdef>
              <!-- WS Import-->
              <echo description="WSImport Definition" />
              <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
                   <classpath>
                        <path refid="classpath"/>
                   </classpath>
              </taskdef>
         </target>
         <target name="Compile" depends="init">
              <echo description="Compiling the project"/>
              <mkdir dir="${build.dir}"/>
              <mkdir dir="${build.dir}/classes"/>
              <javac destdir="${build.dir}/classes" srcdir="${java.base}">
                   <classpath>
                        <path refid="classpath"/>
                   </classpath>
              </javac>
              <copy todir="${build.dir}/classes">
                   <fileset dir="${java.base}" excludes="**/*.java"/>
              </copy>
         </target>
         <target name="wsgen" depends="Compile">
                   <echo message="Generating the wsdl file[${project.name}Service.wsdl]" />
                   <mkdir dir="${service.dir}"/>
                   <mkdir dir="${service.dir}/server"/>
                   <mkdir dir="${service.dir}/server/classes"/>
                   <mkdir dir="${service.dir}/server/src"/>          
                   <mkdir dir="${service.dir}/server/wsdl"/>                    
                   <wsgen sei="${sei.class}" destdir="${service.dir}/server/classes" genwsdl="true"
                   sourcedestdir="${service.dir}/server/src" resourcedestdir="${service.dir}/server/wsdl">
                        <classpath>
                             <path refid="classpath" />
                             <pathelement location="${build.dir}/classes" />
                        </classpath>
                   </wsgen>
         </target>
         <target name="copy" depends="wsgen">
                   <echo message="Copying class and config files into ${web-inf.dir} folder" />
                   <copy todir="${web-inf.dir}">
                        <fileset dir="${build.dir}"/>
                        <fileset dir="${service.dir}/server" includes="**/*.class"/>
                        <fileset dir="." includes="${lib.dir}/*.jar"/>
                   </copy>
                   <copy todir="${web-inf.dir}/${lib.dir}">
                        <fileset dir="${commonWSLib.dir}" includes="*.jar"/>
                   </copy>
                   <copy todir="${web-inf.dir}">
                        <fileset dir="${web-inf.dir}" includes="**/*.xml"/>
                   </copy>
         </target>
         <!-- Create the WAR file     -->
         <target name="war" depends="copy">
              <echo message="Creating the war file [${project.name}.war]" />     
              <mkdir dir="${dist.dir}"/>
              <mkdir dir="${dist.dir}/server"/>
              <war destfile="${dist.dir}/server/${project.name}.war" webxml="${web-inf.dir}/web.xml" basedir="${web.dir}"/>
         </target>
         <target name="wsimport" depends="war">
              <echo message="Generating the client stubs" />          
              <mkdir dir="${service.dir}"/>
              <mkdir dir="${service.dir}/client"/>
              <mkdir dir="${service.dir}/client/classes"/>
              <mkdir dir="${service.dir}/client/src"/>     
              <wsimport wsdl="${basedir}/${service.dir}/server/wsdl/${project.name}.wsdl"
                   destdir="${service.dir}/client/classes"
                   package="${wsimport.package}"
                   sourcedestdir="${service.dir}/client/src">
              </wsimport>
         </target>
         <target name="clientjar" depends="wsimport">
    <echo message="Creating the client jar file [${project.name}Client.jar] " />
    <copy todir="${service.dir}/client/classes">
    <fileset dir="${service.dir}/client/src"/>
    </copy>
    <mkdir dir="${dist.dir}/client"/>
                   <tstamp>
                   <format property="TODAY" pattern="yyyy-MM-dd hh:mm:ss" />
                   </tstamp>
    <jar destfile="${dist.dir}/client/${project.name}Client.jar"
    basedir="${service.dir}/client/classes">
                   <manifest>
                   <attribute name="Built-By" value="${user.name}"/>
                   <attribute name="Built-Date" value="${TODAY}"/>
                   <attribute name="Implementation-Version" value="${version}-b${build.number}"/>
              </manifest>
              </jar>          
    <mkdir dir="${dist.dir}/client"/>
         </target>
         <!-- JAR THE ENGINE -->
         <target name="enginejar" depends="clientjar">
         <echo message="Creating the engine jar file for local call [${project.name}.jar] " />
              <!-- <copy todir="${build.dir}/classes">
                        <fileset dir="." includes="${config.dir}/hibernate.cfg.xml"/>           
         </copy> -->
              <tstamp>
                   <format property="TODAY" pattern="yyyy-MM-dd hh:mm:ss" />
              </tstamp>
         <jar destfile="${dist.dir}/server/${project.name}.jar"
         basedir="${build.dir}/classes">
                   <manifest>
                        <attribute name="Built-By" value="${user.name}"/>
                        <attribute name="Built-Date" value="${TODAY}"/>
                        <attribute name="Implementation-Version" value="${version}-b${build.number}"/>
              </manifest>
              </jar>          
              </target>
              <!-- GENERATE EAR FOR THE ENGINE -->
              <target name="ear" depends="enginejar" >
                   <echo message="Creating the ear file [${project.name}.ear]" />
                   <ear destfile="${dist.dir}/server/${project.name}.ear" appxml="META-INF/application.xml">
                   <fileset dir="${dist.dir}/server" includes="${project.name}.war"/>
              </ear>
                   <antcall target="clean"></antcall>
              </target>
              <!-- CLEAN UP THE FOLDERS     -->
              <target name="clean">
                   <echo message="Cleaning up folders " />          
                   <delete dir="${build.dir}"/>
                   <delete dir="${service.dir}"/>
                   <delete dir="${web-inf.dir}/classes"/>
                   <delete dir="${web-inf.dir}/lib"/>
                   <echo message="${project.name}.ear, ${project.name}.war, ${project.name}.jar and ${project.name}Client.jar is available in project's ${dist.dir} folder"/>
              </target>
    </project>
    Generated wsdl(HelloService.wsdl) :
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <definitions targetNamespace="http://endpoint.helloservice/" name="HelloService" xmlns:tns="http://endpoint.helloservice/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
    <types>
    <xsd:schema>
    <xsd:import namespace="http://endpoint.helloservice/" schemaLocation="HelloService_schema1.xsd"/>
    </xsd:schema>
    </types>
    <message name="sayHello">
    <part name="parameters" element="tns:sayHello"/>
    </message>
    <message name="sayHelloResponse">
    <part name="parameters" element="tns:sayHelloResponse"/>
    </message>
    <portType name="Hello">
    <operation name="sayHello">
    <input message="tns:sayHello"/>
    <output message="tns:sayHelloResponse"/>
    </operation>
    </portType>
    <binding name="HelloPortBinding" type="tns:Hello">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="sayHello">
    <soap:operation soapAction=""/>
    <input>
    <soap:body use="literal"/>
    </input>
    <output>
    <soap:body use="literal"/>
    </output>
    </operation>
    </binding>
    <service name="HelloService">
    <port name="HelloPort" binding="tns:HelloPortBinding">
    <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
    </port>
    </service>
    </definitions>
    Generated : HelloService_schema1.xsd
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xs:schema version="1.0" targetNamespace="http://endpoint.helloservice/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="sayHello" type="ns1:sayHello" xmlns:ns1="http://endpoint.helloservice/"/>
    <xs:complexType name="sayHello">
    <xs:sequence>
    <xs:element name="arg0" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="sayHelloResponse" type="ns2:sayHelloResponse" xmlns:ns2="http://endpoint.helloservice/"/>
    <xs:complexType name="sayHelloResponse">
    <xs:sequence>
    <xs:element name="return" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    If u need any other information let me know.

    This has been resolved by uploading relevant jar file

  • Dbms_crypto - avoid error when using different key in lower environment

    Hello Experts,
    We are using Oracle 11.2.0.2. We are planning to implement dbms_crypto to encrypt few columns. We clone the data from production to lower environment ( DEV, QC).
    For the lower environments, we do not want to get the sensitive data from production and do not plan to use same key. Rather than getting an error when using differnt key, is it possible to get a different resultset back.
    In other words, we want the implementation to be same across environments but want to use a diffent key in lower environment and get different result (or garbage).
    Any suggestions would be greatly appreciated.
    While testing this logic, I am getting following error when using differnt key to decrypt. It works fine if I use same key.
    Error at line 1
    ORA-28817: PL/SQL function returned an error.
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 44
    ORA-06512: at line 19
    DECLARE
      l_credit_card_no    VARCHAR2(19) := '1234 5678 9012 3456';
      l_ccn_raw           RAW(128) := UTL_RAW.cast_to_raw(l_credit_card_no);
    l_key               RAW(128) := UTL_RAW.cast_to_raw('abcdefgh');
       l2_key               RAW(128) := UTL_RAW.cast_to_raw('12345678');
      l_encrypted_raw     RAW(2048);
      l_decrypted_raw     RAW(2048);
    BEGIN
      DBMS_OUTPUT.put_line('Original  : ' || l_credit_card_no);
      l_encrypted_raw := DBMS_CRYPTO.encrypt(src => l_ccn_raw,
                                             typ => DBMS_CRYPTO.des_cbc_pkcs5,
                                             key => l_key);
      DBMS_OUTPUT.put_line('Encrypted : ' || RAWTOHEX(UTL_RAW.cast_to_raw(l_encrypted_raw)));
      l_decrypted_raw := DBMS_CRYPTO.decrypt(src => l_encrypted_raw,
                                             typ => DBMS_CRYPTO.des_cbc_pkcs5,
                                             key => l2_key); --**Using different key to decrypt
      DBMS_OUTPUT.put_line('Decrypted : ' || UTL_RAW.cast_to_varchar2(l_decrypted_raw));
    END;Thank you.

    If I understand what you are trying to do ... and I may not ... it is not going to work.
    SQL> DECLARE
      2   l_credit_card_no VARCHAR2(19) := '1612-1791-1809-2605';
      3   l_ccn_raw RAW(128) := utl_raw.cast_to_raw(l_credit_card_no);
      4   l_key1     RAW(128) := utl_raw.cast_to_raw('abcdefgh');
      5   l_key2     RAW(128) := utl_raw.cast_to_raw('zyxwvuts');  -- alternate key used to attempt a different decryption
      6 
      7   l_encrypted_raw RAW(2048);
      8   l_decrypted_raw RAW(2048);
      9  BEGIN
    10    dbms_output.put_line('Original : ' || l_credit_card_no);
    11 
    12    l_encrypted_raw := dbms_crypto.encrypt(l_ccn_raw, dbms_crypto.des_cbc_pkcs5, l_key1);
    13 
    14    dbms_output.put_line('Encrypted : ' || RAWTOHEX(utl_raw.cast_to_raw(l_encrypted_raw)));
    15 
    16    l_decrypted_raw := dbms_crypto.decrypt(src => l_encrypted_raw, typ => dbms_crypto.des_cbc_pkc
    s5, key => l_key1);
    17 
    18    dbms_output.put_line('Key1 : ' || utl_raw.cast_to_varchar2(l_decrypted_raw));
    19 
    20    l_decrypted_raw := dbms_crypto.decrypt(src => l_encrypted_raw, typ => dbms_crypto.des_cbc_pkc
    s5, key => l_key2);
    21 
    22    dbms_output.put_line('Key2 : ' || utl_raw.cast_to_varchar2(l_decrypted_raw));
    23  END;
    24  /
    Original : 1612-1791-1809-2605
    Encrypted : 3534443342333642353141363846384237463732384636373943374630364234323243334539383042323135
    Key1 : 1612-1791-1809-2605
    DECLARE
    ERROR at line 1:
    ORA-28817: PL/SQL function returned an error.
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 44
    ORA-06512: at line 20

  • DBMS_CRYPTO.DECRYPT-Error in decryption.

    Hi all,
    i created encryption and decryption program using DBMS_CRYPTO package.as a whole both encryption and decryption working fine.but when i used the decrypt part alone using stored encrypted data(RAW DataType) it showing some internal error,kindly help me in this issue.i provided the details here,
    * I encrypted a string using dbms_crypto.encrypt and stored that string in a column which i created as RAW datatype format.
    *The program i used is ,
    DECLARE
    op VARCHAR2(500) ;
    op_raw raw(2000);
    ip raw(2000);
    num_key_bytes NUMBER := 256/8; -- key length 256 bits (32 bytes)
    key_bytes_raw RAW (32); -- stores 256-bit encryption key
    encryption_type PLS_INTEGER := -- total encryption type
    DBMS_CRYPTO.ENCRYPT_AES256 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
    BEGIN
    SELECT pass INTO ip FROM user_test WHERE user_id =309;
    /*this pass is of format RAW,it storing the ouput of DBMS_CRYPTO.ENCRYPT */
    /*above query fetches F130E5785F8DAE2D59972FB9B7B74BE4 as output */
    /*word used for encryption is 'secret' */
    key_bytes_raw := DBMS_CRYPTO.RANDOMBYTES (num_key_bytes);
    DBMS_OUTPUT.PUT_LINE ('ip :' || ip);
    op_raw := DBMS_CRYPTO.DECRYPT( src =>ip , typ => encryption_type, KEY => key_bytes_raw );
    DBMS_OUTPUT.PUT_LINE ('op_raw :'||op_raw);
    op:= UTL_I18N.RAW_TO_CHAR (op_raw , 'AL32UTF8');
    DBMS_OUTPUT.PUT_LINE ('op :'||op);
    END;
    * The Error i getting is ,
    Error report:
    ORA-28817: PL/SQL function returned an error.
    ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
    ORA-06512: at "SYS.DBMS_CRYPTO", line 41
    ORA-06512: at line 14
    28817. 00000 - "PL/SQL function returned an error."
    *Cause:    A PL/SQL function returned an error unexpectedly.
    *Action:   This is an internal error. Contact Oracle customer support.
    kindly help me in this issue as soon as possible.
    Thanks in advance,
    Jeevanand.K
    Edited by: Jeevanand K on Oct 26, 2010 2:08 AM

    Hi,
    there is a note on Metalink for this: "DBMS_CRYPTO.DECRYPT - ORA-28817 ORA-06512 at DBMS_CRYPTO_FFI", it has id 956603.1.
    Herald ten Dam
    http://htendam.wordpress.com

Maybe you are looking for

  • How do I convert an HTML webpage to a PDF in Acrobat Pro?

    I have the Mac version of Adobe Acrobat Pro and I have a plethora of HTML that need to be converted into PDFs. I've searched Google for about an hour without any success and I usually come here if I can't find an answer. This is my step process so fa

  • Solved: INTERNAL_ERROR when creating container with Java on Vista

    I don't know what the root cause is, but I've got a solid test case. If I maintain a reference to the Environment used to create my XmlManager, then openContainer will barf up a mysterious INTERNAL_ERROR. Setting my reference to the Environment to nu

  • BADI's/Exits for FBRA transaction

    Hi All,   Iam reversing a cleared document through FBRA transaction but while reversing the transaction is changing the existing cleared document record in BSAD table and creating one more record with reversed document. While changing the existing re

  • Firefox does not open site when i type just site name like "yahoo search"...my earlier version did it

    I downloaded latest beta version of firefox. It does not open sites when i type just the site name like "yahoo search" or "youtube" etc... I have to type the complete address like"youtube.com" or "facebook.com" While earlier version of firefox did it

  • Final Cut and After Effects on separate comps

    I have just recently had the need to use after effects for some video projects. The problem is that I have After effects on my computer and Final cut pro on my schools edit bays. Is there a way to make a reference movie that I can bring to my comp, t