Problem signing data

Hi,
I have the following code snippet. The signing of a 256 byte(2048 bit input stream) fails. The exception that I catch is ILLEGAL USE. I am just straight away passing the input stream for signing without any preprocessing of the i/p steam.
However, the signing fails. Anybody, who is familiar with this problem please help.
The code:
try{
          privKey = (RSAPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_PRIVATE, keySize, false);
     privKey.setExponent(privExponent, (short)0, (short)256);
     privKey.setModulus(privModulus, (short)0, (short)256);
     catch(CryptoException e){
if (e.getReason() == CryptoException.NO_SUCH_ALGORITHM)
ISOException.throwIt(ALGO_ERROR);
          else
if (e.getReason() == CryptoException.ILLEGAL_VALUE)
ISOException.throwIt(ILL_VAL);
          else
ISOException.throwIt(KEYGEN_FAILED);
     try{
     signature = Signature.getInstance(Signature.ALG_RSA_SHA_PKCS1, false);
          signature.init(privKey, Signature.MODE_SIGN);
          }catch(CryptoException e)
               ISOException.throwIt(SIGNINIT_ERROR);
     try{
          outputlen = signature.sign(buf, (short) 0, (short)length, outbuf, (short) 0);
          }catch(CryptoException e)
          if (e.getReason() == CryptoException.UNINITIALIZED_KEY)
ISOException.throwIt(ALGO_ERROR);
          else
if (e.getReason() == CryptoException.ILLEGAL_USE)
ISOException.throwIt(ILL_VAL);
          else
ISOException.throwIt(SIGNATURE_FAILED);
          }

Sorry, my previous post was a little inaccurate. The limitation is on RSA encryption. For a signature, your data is hashed (using SHA1 in this instance) and this hash is then encrypted with the private key.
What happens if you try to sign a few bytes (say 8)? Your code looks fine to me. I have tried something similar myself and it works. I use CRT keys as my card does not support non-crt private keys (that could even be part of the problem but I would expect the key building to fail then). You can try checking the key is initialised first (privKey.isInitialized())?
package oracle.forum;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.security.KeyBuilder;
import javacard.security.KeyPair;
import javacard.security.Signature;
* @author sfarmer
public class Dummy extends Applet {
     public final static boolean ECHO = true;
     private Signature sig;
     private KeyPair keys;
     public Dummy() {
          sig = Signature.getInstance(Signature.ALG_RSA_SHA_PKCS1, false);
          keys = new KeyPair(KeyPair.ALG_RSA_CRT, KeyBuilder.LENGTH_RSA_2048);
          keys.genKeyPair();
     public static void install(byte[] bArray, short bOffset, byte bLength) {
          // GP-compliant JavaCard applet registration
          new oracle.forum.Dummy().register(bArray, (short) (bOffset + 1),
                    bArray[bOffset]);
     public void process(APDU apdu) {
          // Good practice: Return 9000 on SELECT
          if (selectingApplet()) {
               return;
          short lc = apdu.setIncomingAndReceive();
          byte[] buf = apdu.getBuffer();
          switch (buf[ISO7816.OFFSET_INS]) {
          case (byte) 0x00:
               sig.init(keys.getPrivate(), Signature.MODE_SIGN);
               short len = sig.sign(buf, ISO7816.OFFSET_CDATA, lc, buf, (short) 0);
               apdu.setOutgoingAndSend((short) 0, len);
               break;
          default:
               // good practice: If you don't know the INStruction, say so:
               ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}Cheers,
Shane

Similar Messages

  • Problem in Date

    Hello,
    I have table with one date coloumn having rows 2000 rows.
    Out of 2000 rows, arround 1550 rows are having data 09/04/2002.
    other rows are having 05/04/2002.
    Problem is : If I run a following i gets 0 rows selected.
    SELECT COUNT(*) FROM TABLENAME WHERE TXNDT='09/04/2002'.
    If I run the same with following query then I gets the result.
    SELECT COUNT(*) FROM TABLENAME WHERE TXNDT>='09/04/2002'.
    I got result as 1550 rows selected.
    Please help me in the matter. If I give = sign then no output is
    generating even though there is records and i gets the output if
    i give >= sign.
    If this is the problem I might be facing lots of problem in date
    matching coding, which i have used in many applications.
    I have migrated my database from 7.3 to 8i recently. if this is the
    problem please reply...
    Thanks
    Ramesh Ganji

    Hi,
      Bear in mind that the date in your table includes time.
      (maybe you insert the record using SYSDATE).
      Your where-clause's '09/04/2002' does not include time.
      Note that '09/04/2002 00:00:01' is greater than '09/04/2002'!
      So there are 2 ways to go.
      1. Truncate the time in date column of your table.
         UPDATE your_table SET date_col = TRUNC(date_col);
      OR
      2. If you want to retrieve record in specific date, e.g. 09/04/2002,
         use the following SQL format:
         SELECT *
         FROM   your_table
         WHERE  date_col BETWEEN TO_DATE('20020409', 'YYYYMMDD') AND
                                 TO_DATE('20020409235959', 'YYYYMMDDHH24MISS');
    Hope help you   

  • Problem signing on to facetime on my ipad

    problem signing on to facetime on my ipad

    (A) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.
    (B) Reset all settings
    Settings>General>Reset>Reset all settings
    Note: Data will not be affected but settings will be reset.

  • C3: problem signing to yahoo mail (invalid id)

    Hi,
    I'm using C3-00.
    a)I've been trying to sign in to yahoo mail, either using the Opera Mini or the mail application, but got "Invalid ID or password" message. I'm sure my id and password is correct coz have no problems signing using PC.
    b)I also cannot play video from youtube. Is there anything I need to do?
    Please help. Thanx.

    If your loginis correct there is no reason you can't login to Yahoo mail ! Have you tried deleting your mailbox on the C3 and setting up again ?
    YouTube will need a decent 3G signal or wifi to work properly as you need a decent data rate to stream video, also what client are you using ? Try this
    m.youtube.com
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • 'Error while signing data-Private key or certificate of signer not availabl

    Hello All,
    In my message mapping I need to call a web service to which I need to send a field value consist of SIGNED DATA.
    I am using SAP SSF API to read the certificate stored in NWA and Signing the Data as explained in
    http://help.sap.com/saphelp_nw04/helpdata/en/a4/d0201854fb6a4cb9545892b49d4851/frameset.htm,
    when I have tested using Test tab of message mapping  it is working fine and I am able to access the certificate Keystore of NWA(we have created a keystore view and keystore entry to store the certificate) and generate the signed data ,but when I test end to end scenario from ECC system,it is getting failed in mapping with the error
    ' Error while signing data - Private key or certificate of signer not availableu2019.
    Appreciate your expert help to resolve this issue urgently please.
    Regards,
    Shivkumar

    Hi Shivkuar,
    Could you please let me know how you were trying to achieve the XML signature.
    We have a requirement where we have to sign the XML document and need to generate the target document as following structure.
    <Signature>
         <SignedInfo>
             <CanonicalizationMethod />
             <SignatureMethod />
             <Reference>
                     <Transforms>
                     <DigestMethod>
                     <DigestValue>
             </Reference>
        <Reference /> etc.
      </SignedInfo>
      <SignatureValue />
      <KeyInfo />
      <Object>ACTUAL PAYLOAD</Object>
    </Signature>
    I am analyzing the possibility of using the approach that is given in the help sap link that you have posted above. Any inputs will be apprecited.
    Thanks and Regards,
    Sami.

  • Problem while  data processing TRANSACTION data from DSO to CUBE

    Hi Guru's,
    we are facing problem while  data processing TRANSACTION data from DSO to CUBE. data packets  processing very slowly  and updating .Please help me regarding this.
    Thanks and regards,
    Sridhar

    Hi,
    I will suggest you to check a few places where you can see the status
    1) SM37 job log (give BIrequest name) and it should give you the details about the request. If its active make sure that the job log is getting updated at frequent intervals.
    2) SM66 get the job details (server name PID etc from SM37) and see in SM66 if the job is running or not. See if its accessing/updating some tables or is not doing anything at all.
    If its running and if you are able to see it active in SM66 you can wait for some time to let it finish.
    3) RSMO see what is available in details tab. It may be in update rules.
    4) ST22 check if any short dump has occured.
    You can also try SM50 / SM51 to see what is happening in the system level like reading/inserting tables etc.
    If you feel its active and running you can verify by checking if the number of records has increased in the cube.
    Thanks,
    JituK

  • Having a problem with dates when I send my numbers doc to excel. dates are all out and that they have to cut and paste individual entries onto their spreadsheet. Any idea how I can prevent this

    having a problem with dates when I send my numbers doc to excel. dates are all out and that they have to cut and paste individual entries onto their spreadsheet. Any idea how I can prevent this.
    I'm using Lion on an MBP and Numbers is the latest version

    May you give more details about what is wrong with your dates ?
    M…oSoft products aren't allowed on my machines but I use LibreOffice which is a clone of Office.
    When I export from Numbers to Excel and open the result with LibreOffice, the dates are correctly treated.
    To be precise, dates after 01/01/1904 are correctly treated. dates before 01/01/1904 are exported as strings but, as it's flagged during the export process, it's not surprising.
    Yvan KOENIG (VALLAURIS, France) mardi 3 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : http://public.me.com/koenigyvan
    Please : Search for questions similar to your own before submitting them to the community
    For iWork's applications dedicated to iOS, go to :
    https://discussions.apple.com/community/app_store/iwork_for_ios

  • Problem with date format when ask prompt web-intelligence

    Bo XIR2 with 5 SP. Instaled on Windows 2003 with support Russian.
    Inside BO every labels, buttons - use russian. But when invoke web-report and Prompt appear there is problem with date format.
    Looks like korean format of date 'jj.nn.aaa H:mm:ss'.  I see system settings of date in Win .. everything right
    What i have to do?
    Where i can change format date for bo?

    GK, try this...
    decode(instr(packagename.functionname(param1 ,param2),'2400'), 0, to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" hh24mi'),'mm/dd/yyyy hh24mi'),'mm/dd/yyyy hh24mi'),
                                                                      to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" "2400"')+1,'mm/dd/yyyy "0000"'),'mm/dd/yyyy "0000"'))-Marilyn

  • Problem with Date format

    Got one more problem Merilyn and Radhakrishnan...
    Regarding the soln y provided me earler with the thread "Problem with date format"...
    What is happening is....I am able to change the 2400 to 0000 but when it is changed from 2400 on jan 1st to 0000 the hour is changing but not the date....the date still remains as jan 1st instead of jan 2nd....
    Eg: Jan 1st 2400 -- changed to -- jan1st 0000
    instead of jan 2nd 0000
    Could you please help me in this issue...
    Thanks,
    GK

    GK, try this...
    decode(instr(packagename.functionname(param1 ,param2),'2400'), 0, to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" hh24mi'),'mm/dd/yyyy hh24mi'),'mm/dd/yyyy hh24mi'),
                                                                      to_date(to_char(to_date(rtrim(packagename.functionname(param1 ,param2),'(PT)'), 'Month dd, yyyy "at" "2400"')+1,'mm/dd/yyyy "0000"'),'mm/dd/yyyy "0000"'))-Marilyn

  • Problem with date calculation

    I am a rookie in SAP i have a small problem with date.Do we have any function module to find out the first day in a month if we give out the system current date ?? Pls help me out.

    Hi,
    As Ganesan told,you can do.
    Here is the sample code.
    data v type sy-datum.
    data d type DTRESR-WEEKDAY.
    v+6(2) = '01'.
    v4(2) = sy-datum4(2).
    v0(4) = sy-datum0(4).
    CALL FUNCTION 'DATE_TO_DAY'
      EXPORTING
        date          = v
    IMPORTING
       WEEKDAY       = d.
    write d.

  • Problem with date format from Oracle DB

    Hi,
    I am facing a problem with date fields from Oracle DB sources. The date format of the field in DB table is 'Date base type is DATE and DDIC type is DATS'.
    I mapped the date fields to Date characters in BI. Now the data that comes to PSA is in weird format. It shows like -0.PR.09-A
    I have changing the field settings in DataSource  to internal and external and also i have tried mapping these date fields to text fields with out luck. All delivers the same format.
    I have also tried using conversion routines like, CONVERSION_EXIT_IDATE_INPUT to change format. It also delivers me the same old result.
    If anybody of you have any suggestions or if anybody have you experienced such probelms, Please share your experience with me.
    Thanks in advance.
    Regards
    Varada

    Thanks for all your reply. I can only the solutions creating view in database. I want some solution to be done in BI. I appreciate if some of you have idea in it.
    The issue again in detail
    I am facing an issue with date fields from oracle data. The data that is sent from Oracle is in the format is -0.AR.04-M. I am able to convert this date in BI with conversion routine in BI into format 04-MAR-0.
    The problem is,  I am getting data of length 10 (Output format) in the format -0.AR.04-M where the month is not in numericals. Since it is in text it is taking one character spacing more.
    I have tried in different ways to convert and increased the length in BI, the result is same. I am wondering if we can change the date format in database.
    I am in puzzle with the this date format. I have checked other Oracle DB connections data for date fields in BI, they get data in the format 20.081.031 which will allow to convert this in BI. Only from the system i am trying creating a problem.
    Regards
    Varada

  • Problem with date format dd/mm/yyyy. But I need to convert yyyy-mm-dd.

    Dear friends,
    I have the problem with date format. I receiving the date with the format dd/mm/yyyy. But I can upload to MySQL only in the format of yyyy-mm-dd.
    how should I handle this situation, for this I've created these code lines.But I have some problem with these line. please help me to solve this problem.
    String pattern = "yyyy-mm-dd";
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    try {
    Date date = format.parse("2006-02-12");
    System.out.println(date);
    } catch (ParseException e) {
    e.printStackTrace();
    System.out.println(format.format(new Date()));
    this out put gives me Tue Apr 03 00:00:00 IST 2007
    But I need the date format in yyyy-mm-dd.
    regards,
    maza
    thanks in advance.

    Thanks Dear BalusC,
    I tried with this,
    rs.getString("DATA_SCAD1")// where the source from .xls files
    String pattern = "yyyy-MM-dd";
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    try {
    Date date = format.parse("DATA_SCAD1");
    System.out.println(date);
    } catch (ParseException e) {
    e.printStackTrace();
    System.out.println(format.format(new Date()));
    this out put gives me Tue Apr 03 00:00:00 IST 2007
    But I want to display the date format in yyyy-mm-dd.
    regards,
    maza

  • Problem signing in to adobe reader. Have a valid account but keeps coming up 'network error'.

    Had a problem signing in to my adobe reader account for about a week now.
    Use the PDF pack to convert Excel into PDF and have been using this for 6 months without any previous issues.
    Just comes up with 'network error occurred while trying to sign in' but my network is working fine and no other problems with my computer or network.
    I have tried unloading and reinstalling the PDF pack but makes no difference.
    Completely stuck, please help!

    Hi Sara,
    Thanks for the quick response.
    I am using the latest version or Reader XI.
    I can log in direct through cloud.acrobat.com so that is a way around the
    issue but I still need the use of the PDF pack ideally.
    If I try to log in to acrobat.com via the adobe Reader XI homepage then it
    comes up with the following - "We cant seem to find the internet. Please
    check your connection and try again"
    I am using my home wifi connection with no problems on any other computers
    or devices.

  • "evdre encountered a problem retrieving data from the webserver"

    Hi
    We are using a big report which takes very long time to expand and sometimes we get the error message "evdre encountered a problem retrieving data from the webserver" when expanding the report, but not very often for most of our users. But we have one user who gets this error message almost every second time he expands the report. This user have a computer with same capacity as the rest of us, can there be some setting on the computer or in the client installtion the cause this problem?
    We are using BPC 5.1 SP 5
    /Fredrik

    Hi,
    This error occurs usually if we have huge data in combination of our dimensions.
    Even, if the selection of your memberset is not apt to the combination of the data present in the back end, you may encounter a data retrival error.
    regards
    sashank

  • Error while signing data-Private key or certificate of signer not available

    Hello All,
    I am new to PI.  I am currently stuck with an issue. The scenario is as explained below.
    We need to check for the service availability before processing the data. So, we test for the RFC connection first from the ECC system. During this process, we access the digital certificate stored in the PI system so that it can be validated and allowed to consume this intended service.
    Error :
    When we trigger the RFC test from the  ECC system, we get an error stating ' Error while signing data -  Private key or certificate of signer not available '. But when we test the same functionality within PI system(Locally), we does not encounter any such error. The certificate is maintained and it appears fine.
    The communication channels are stored with logon credentials.
    Can anyone please help me with this error or provide your valuable inputs. Thanks in advance.
    Regards,
    Shivkumar

    Hello,
    When we trigger the RFC test from the ECC system, we get an error stating ' Error while signing data - Private key or certificate of signer not available '.
    This should be normal behavior since the certificates are not installed in ECC SSL folders of Strust. Why not just install the certificates in the ECC system, perform an ICM restart and do a retest? After all, the certificates would both be the same in PI and ECC.
    Hope this helps,
    Mark

Maybe you are looking for