Digital signature problem

Here is my code . in this d value of 'v' shouls come equal to 'r' but its nt coming.please tell me what is the problem in this??
import java.io.*;
import java.nio.charset .*;
import java.util.Random;
import java.math.*;
//import java.acm.util.RandomGenerator;
class key
public static void main(String args[])
               String sm="I AM A SUDENT OF COMPUTER SCIENCE";
     //this is the starting of first module i.e. key generation
               try
                    String s11="13";
                    int a1=Integer.parseInt(s11);
                    double a=(double)a1;
                    byte[] q = new byte[20];
                    q=s11.getBytes("UTF8" );
                    System.out.println("Prime number q="+a1);
                    String s1="4";
                    int b=Integer.parseInt(s1);
                    double b1=(double)b;
                    System.out.println(b);
                    byte[]z= new byte[20];
                    z=s1.getBytes("UTF8" );
                    System.out.println("Random number z="+z);
                    byte[] p=new byte [256];     
     int c=((a1*b)+1);
                    double c1=(double)c;
                    String s2=Double.toString(c);
                    p=s2.getBytes("UTF8");
     System.out.println("Prime number p="+c);
                    //java.util.Random generator = new java.util.Random(System.currentTimeMillis());
                    //public class RandomGenerator extends Random
                    //RandomGenerator rgen = RandomGenerator.getInstance();
                    //double h=rgen.nextDouble(0.0,c-1);
                    Random ra=new Random();
                    //double h=((c-1)*(ra.nextDouble()));
                    double h=35;
                    //double h=(Math.random()*(c-1));
                    //double h=ra.nextDouble(0.0,c-1);
                    //double h=(generator.nextDouble()*(c-1)); // 0.0 <= d < 1.0
                    System.out.println("The value of h="+h);
                    double g1=(Math.pow(h,b));
                    double d=(g1%c);
                    //String s3=Double.toString(d);
                    //byte[]g=new byte[20];
                    //g=s3.getBytes("UTF8");
                    System.out.println("The value of g="+d);
                    //public class RandomGenerator extends Random
                    //RandomGenerator rgen = RandomGenerator.getInstance();
                    // double x=rgen.nextDouble(0.0,a);
                    //double x=(Math.random()*(a));
                    //double x = (generator.nextDouble()*a); // 0.0 <= d < 1.0
                    //double x=ra.nextDouble(0.0,a);
                    //int x=(ra.nextInt(a1));
int x=2;
double x1=(double)x;
                    //double x1=(double)x;
                    //double x=8;
                    System.out.println("The value of x="+x);
                    String s4=Double.toString(x);
                    byte[]rno1=new byte[20];
                    rno1=s4.getBytes("UTF8");
                    System.out.println(rno1);
                    double y1=((Math.pow(d,x1))%c1);
                    System.out.println("The value of y="+y1);
                    String s5=Double.toString(y1);
                    byte[]y=new byte[20];
                    y=s5.getBytes("UTF8");
                    System.out.println(y);
                    System.out.println("THE VALUE OF PUBLIC KEY="+c+","+a+","+d+","+y1);
                    System.out.println("THE VALUE OF PRIVATE KEY="+x);
                    //This ends the process of key generation
                    //Now starts the next module of signing
                    //public class RandomGenerator extends Random
                    //RandomGenerator rgen = RandomGenerator.getInstance();
                    //double k= rgen.nextDouble(0.0, a);
                    //double k=(ra.nextDouble()*a);
                    //double k=(Math.random()*(a));
                    //double k =(generator.nextDouble()*a); // 0.0 <= d < 1.0
                    //double k=ra.nextDouble(0.0,c-1);//                    int k=(ra.nextInt(a1));
                    //double k1=(double)k;
int k=4;                         
double k1=(double)k;
                    //double k=11;
                    System.out.println("The value of k="+k);
                    String s6=Double.toString(k1);
                    byte[]n=new byte[20];
                    n=s6.getBytes("UTF8");
                    System.out.println("The value of nonce="+n);
                    double r1=(((Math.pow(d,k1))%c1)%a1);
                    System.out.println("The value of r="+r1);
                    String s7=Double.toString(r1);
                    byte[]r=new byte[20];
                    r=s7.getBytes("UTF8");
                    System.out.println("The value of r="+r1);
                    int h1 =10;
/* for (int i = 0; i < sm.length(); i++) {
h1= 31*h1 + sm.charAt(i);
                    System.out.println(h1);*/
                    double hash=(double)h1;
                    System.out.println("The value of hash code="+hash);
                    //double s12=(((hash/k1)+(x1*r1))%a1);
                    double a11=(hash+(x1*r1));
                    double s12=((a11/k1)%a1);
                    System.out.println("The value of s="+s12);
                    String s8=Double.toString(s12);
                    byte[]s=new byte[20];
                    s=s8.getBytes("UTF8");
                    System.out.println("The value of s="+s);
                    System.out.println("THE VALUE OF SIGNATURE= ("+r1+","+s12+" )");
                    //The process of signing is complete
                    //Now starts the process of verifying
                    double m=1/s12;
                    double w=(m%a1);
                    System.out.println("The value of w="+w);
                    double u1=((hash*w)%a1);
                    System.out.println("The value of u1="+u1);
                    double u2=((r1*w)%a1);
                    System.out.println("The value of u2="+u2);
                    double m1=(Math.pow(d,u1));
                    System.out.println(m1);
                    double m2=(Math.pow(y1,u2));
                    System.out.println(m2);
                    double v=(((m1*m2)%c1)%a1);
                    //double v=((((Math.pow(d,u1))*(Math.pow(y1,u2)))%a)%b);
                    System.out.println("The value of v="+v);
               catch(Exception e)
}

Do not use doubles or floats for arithmetic mod n, ever! Even for small examples, the BigInteger class is very easy to use. You'll be using the add, subtract, etc. methods, but also the mod, modPow, and modInverse methods. So, your code might start out looking like this:
java.math.BigInteger;
class Key
    public static void main (String [] args)
        String sm="I AM A SUDENT OF COMPUTER SCIENCE";
        BigInteger q = BigInteger.valueOf(13);
        System.out.println("Prime number q=" + q);
        // ...and so on...
}

Similar Messages

  • Digital Signature problem : Adobe forms

    Hi Experts,
    I am facing one issue in Adobe forms while implementing Digital Signature in one of the Custom Adobe form. I am following some steps as mentioned in the below link
    <link to blocked site removed by moderator>
    The problem is when I execute my Adobe form I am not getting SIGN button in my generated form as mentioned in the link.
    I am using Adobe Live cycle designer 8.2 and Adobe reader 9.
    Please help me out on this since I am new to Adobe forms as well.
    Thanks
    VJ
    Moderator message: this is the wrong forum, please have a look in the forum for "SAP Interactive Forms by Adobe".
    Edited by: Thomas Zloch on Oct 21, 2011 1:56 PM

    Apart from the above question can anybody guide me whether do we need Adobe Acrobat instead of Adobe reader to implement  Digital Signature in Adobe form.
    Looking forward towards some useful suggestions!!
    Thanks
    VJ

  • SAPGENPSE Conversion into PSE File for Digital Signature problem

    Hello,
    Would anyone help me with this problem
    I am trying to create a PSE file for implementing the Digital Signature in a Report following the Note 1300880 . When I try to create the PSE FILE.
    Use the SAPGENPSE tool to import the file in PCKS#12 format using the command import_p12 as follows:
    rem convert pkcs12 file to pse
    sapgenpse import_p12 -p CSD_01.pse -x a0123456789 -z a0123456789 CSD_01.p12
    when I run the command I get this error:
    C:\SAPGENPSE\ntintel>sapgenpse import_p12 -p CSD_01.pse -x a0123456789 -z a01234
    56789 CSD_01.p12
    import_p12: Can't create PSE.
    ERROR in af_create: (4352/0x1100) could not flush : "SW-PSE"
    ERROR in create_PSE: (4352/0x1100) could not flush : "SW-PSE"
    ERROR in modified_PSEFile: (4352/0x1100) could not flush : "SW-PSE"
    ERROR in flush_PSEFile: (1283/0x0503) Can't write file : "C:\Documents and Setti
    ngs\Administrador\sec\CSD_01.pse"
    ERROR in aux_OctetString2file: (1283/0x0503) Can't write file : "C:\Documents an
    d Settings\Administrador\sec\CSD_01.pse"
    C:\SAPGENPSE\ntintel>
    I would appreciate any help.

    Hi
    I solved my Issue.  SAPGENPSE failed with only  import_p12  error.
    I had misspelt , fat fingers.
    In AIX I ran     env
    Check to see    SECUDIR=/usr/sap/SID/DVEMBS03/sec  
    I had a spelling mistake and saw the wrong entry.
    To set this up, do this in your Instance profile or right before you run the sapgenpse
    setenv SECURDIR /usr/sap/FSB/DVEMBS03/sec     Insert your right SID of course.
    Also just run     sapgenpse  and it will tell you if you have set the environment correctly..
    Worked like a charm, certificate created.

  • Livecycle & Reader 8, digital signatures problem

    Hello,
    I created a pdf document including digital signature field in livecycle. When saving and opening the document in acrobat 8 pro signing works fine, i.e. I click the signing field and it prompts for digital signature ID & password.
    But, when I click the field in Reader 8 (not pro version), nothing happens. It doesn't prompt for digital signature ID.
    I clearly set the version limit in livecycle to be reader 7 and upwards (not pro versions).

    you need to "enable usage rights in Adobe Reader.." using Acrobat 8 before Reader can sign.

  • 2011 email router digital signature problem

    Hi,
    We're running 2011 on premise with the email router feeding a queue for service items.
    We've recently seen a number of emails that hit the mail box but don't ever get processed by the email router. There are no errors in the event logs that we can see, it just seems to ignore them.
    What we are noticing though is that the emails that get missed have digital signatures on them.
    Has anyone come across this before? There doesn't appear to be anything about this is any of the documentation that we can see.
    I've searched high and low for any information on this but I've drawn a blank everywhere.
    Thanks in advance.

    Hi,
    my guess is that it could be due to email is not send directly to primary SMTP which is configured in email router for your queue, it could be possible this email is send to other alias and if this is the case CRM ignores those email.
    for e.g. here is how you mail box is set up
            [email protected]  (mail box, primary SMTP, configured as queue in CRM to send recieve mail )
            [email protected] (alias for above mailbox)
    so if email is send to "[email protected]" it will be received in outlook mail box but CRM will not pick it as it does not have any matching queue set up for this.
    MayankP
    My Blog
    Follow Me on Twitter

  • Digital Signature problem with 8.2.3

    In my group, some associates have Adobe Professoinal 8.1.3 (me included) and others have 8.2.3.  I am having people digitally sign documents using their PKI token given to us by the company.  When digitally signing, I am still able to write in my own reason in the reason drop-down, but the users with 8.2.3 are unable to do so.  Ultimately, I have 2 questions:
    1)  How can I enable those users of 8.2.3 to write in their own reasons?
    2)  How can I clean up that drop-down list and delete reasons that I don't use at all or stopped using?
    Thanks.

    Hi,
    Here is how to enable the Reason field to show on the Sign dialog:
    Select the Edit > Preferences menu item (Windows), or the Acrobat > Preferences menu item (Mac)
    Select Security from the Categories list box
    Click the Advanced Preferences button on the Security Preferences panel
    Select the Creation tab on the Digital Signatures Advanced Preferences dialog
    Select the Show reasons when signing checkbox. I would also highly recommend you select the Include signature's revocation status when signing checkbox as well.
    Click the OK button on the Digital Signatures Advanced Preferences dialog
    Click the OK button on the Preferences dialog
    The Reasons are stored in the registry at HKEY_CURRENT_USER\Software\Adobe\Adobe Acrobat\<version>\Security\cPubSec\cReasons on Windows on in the corresponding location in the plist file in the users Preferences folder on the Mac.
    Steve

  • Acrobat 8 Standard Digital Signature Problems

    Running Acrobat 8 Standard under Windows Vista Ultimate, both fully updated. Acrobat works fine BUT I cannot certify or sign docs because I always get the following error message:
    Creation of this signature could not be completed.
    Certificate parsing error:
    Error encountered while BER decoding:
    regardless of what Digital ID I use (Windows or Adobe), as if Adobe was unable to access the digital ID files...

    Guccio,
    This discussion forum is specific for e-licensing and ALM related issues. Please use the Acrobat for Windows forum for your question (forum URL: http://www.adobeforums.com/cgi-bin/webx/.ee6b2f2/)

  • OS X 10.6.4. digital signature problem

    When i try to update it to 10.6.5 it gets stuck because of this error:
    'certificate is not valid'
    I just got this MacBook and want it to run on 10.6.6. But i don't know what is wrong with it.
    Can someone help me?

    I had the same problem at first. There is a switch on the back right side of the camera that selects camera, video, or playback. Switching it to playback caused it to be recognized by OSX.

  • XML Digital Signature Problem - Enveloping Signature

    Hi there,
    While i was running the sample GenEnveloping class, i got this error:
    >>
    java.lang.NoClassDefFoundError: java/net/URISyntaxException
         at org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory.newReference(DOMXMLSignatureFactory.java:56)
         at org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory.newReference(DOMXMLSignatureFactory.java:51)
         at GenEnveloping.main(GenEnveloping.java:47)
    Exception in thread "main"
    <<
    I'm working on websphere 5.0; i've already added the following jar/classpath variables to websphere and to my project:
    xmldsig.jar, xmlsec.jar, xws-security.jar.
    I've surfed through the threads in this forum and i realized that this problem is related to missing jar. so what i want is the list of jar to add to my environment and project if it is possible or if this list already exists somewhere in a thread, just let me know.
    Thanks in advance for your help.

    Hi again,
    I don't think it's a missing jar problem because i've added the following jar which i found in the build.xml document which come with the GenEnveloping class in the sample folder:
    xmldsig.jar, jaxp-api.jar, dom.jar, xercesImpl.jar, xmlsec.jar, xalan.jar, commons-logging.jar.
    and still the same error.
    Any help is appreciated.
    Thanks.

  • XML Digital Signature Problem

    I am using the javax.xml.crypto.dsig.XMLSignatureFactory to generate XML Signatures. Now when I try to validate the generated signature with java, the validation succeeds, however when I attempt the validation with .NET the validation fails.
    Java adds a break line after the 76th character to produce separate lines. On the other hand .NET does not exhibit this behavior.
    Please help...........
    String inputXMLPath = "C:\\wessam\\GATS-CBE-20110404-0013.xml";
    String outSignedPath = "C:\\efOut.xml";
    XMLSignatureFactory factory =
    XMLSignatureFactory.getInstance("DOM", (Provider)Class.forName("org.jcp.xml.dsig.internal.dom.XMLDSigRI").newInstance());
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Document doc = dbf.newDocumentBuilder().parse(new File(inputXMLPath));
    NodeList nl =
    doc.getElementsByTagNameNS("http://cbe.gatsfile.efinance.com.eg",
    "GATSFile");
    Node node = nl.item(0);
    XMLStructure content = new DOMStructure(node);
    DigestMethod digestMethod =
    factory.newDigestMethod(DigestMethod.SHA1, null);
    Reference reference = factory.newReference("#GATSFile", digestMethod);
    SignedInfo signedInfo =
    factory.newSignedInfo(factory.newCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE,
    (C14NMethodParameterSpec)null),
    factory.newSignatureMethod(SignatureMethod.RSA_SHA1,
    null),
    Collections.singletonList(reference));
    KeyInfoFactory kif = factory.getKeyInfoFactory();
    X509Data x509d =
    kif.newX509Data(Collections.singletonList(getCertificate()));
    KeyInfo keyInfo = kif.newKeyInfo(Collections.singletonList(x509d));
    XMLObject obj =
    factory.newXMLObject(Collections.singletonList(content),
    "GATSFile", null, null);
    DOMSignContext dsc = new DOMSignContext(getPrivateKey(), doc);
    XMLSignature signature =
    factory.newXMLSignature(signedInfo, keyInfo, Collections.singletonList(obj),
    null, null);
    signature.sign(dsc);
    FileOutputStream fos = new FileOutputStream(outSignedPath);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer trans = tf.newTransformer();
    trans.transform(new DOMSource(doc), new StreamResult(fos));
    fos.close();
    }

    user13461536 wrote:
    I am using the javax.xml.crypto.dsig.XMLSignatureFactory to generate XML Signatures. Now when I try to validate the generated signature with java, the validation succeeds, however when I attempt the validation with .NET the validation fails.
    Java adds a break line after the 76th character to produce separate lines. On the other hand .NET does not exhibit this behavior.These line breaks should be properly normalized by a standards-compliant canonicalizer. However, if you are using JDK 7, try setting the following property which will eliminate the line breaks when you generate the signature:
    java -Dcom.sun.org.apache.xml.internal.security.ignoreLineBreaks=true ...

  • Digital Signature Problems

    I have a pdf with multiple signature fields. When somebody signs it in 9.x everything is fine, but when somebody signs it in a version earlier than 9.0 it does not work. The signature fields do not even show up. Somebody signed the pdf in 8.x and sent it back to me. I opened in 9.x, and I could not see the signature fields. Is there a compability issue between these versions. The pdf contains javascript and is a dynamic pdf if that matters. Thanks in advance.

    You might want to post this in the LiveCycle Designer forum here, if you haven't already.

  • I am getting error :digital signature for this package is incorrect--

    I have completed a clean install and have installed OS 9.2 as well as OS 10.3
    and OS 10.4.2 from install DVDs apparently successfully. Now when I attempt to install the software updates for my computer, I get error that the digital signature of this package is incorrect and may have been corrupted since signed by apple. I have previously had all software up to date using software update/s etc. So how do I fix this digital signature Problem??
    Harold

    Hi, Harold and baltwo —
    (1) Harold, I agree with baltwo's advice to try using "stand-alone" downloads as a short-term "work-around."  But I realize this may be unsatisfying — if the error becomes chronic.
    (2) baltwo's advice to search Apple's KnowledgeBase is normally a very useful resource — but in this instance, only provides links to a few articles about the topic as it relates to OS 9, Mail.app, and OS X Server. If you'd like to read background info about the current usage of digital signatures, you'll find info that's a bit more relevant from:
        •  Help »» Mac Help »» "What is a digital identity" and "certificate"
        •  an ADC search (using, e.g., [ exact phrase: "digital signature" and all the words:
           "OS X" ] as terms)
        •  a Google•Mac search.
    However, in terms of resolving your situation, I'm inclined to think that most of the search results will be academic. If you search through these discussions to see others' Software Update problems and solutions, you'll find this error message is relatively common — and seems to represent a number of conditions (based on the differing solutions).
    (3) I haven't noticed a cogent solution that spans these problems. But the troubleshooting process outlined in KnowledgeBase Articles 106695: Troubleshooting Automatic Software Update in Mac OS X and 106692: Troubleshooting installation and software updates may be helpful. As the latter suggests, you may want to try logging-in to a temporary "test" administrator account as a means to determine whether your account's keychain is implicated specifically. (...or another user-specific issue.)
    Please post back to discuss your progress.
    Good luck!
    Dean

  • Please help me with the digital signature validation problem?

    Please help me with the digital signature validation problem?

    Hi
    Execute the program in the Debuggin mode.
    In the Debugger Window
    Select Breakpoint -> Break point at -> Breakpoint at source code Menu Item and enter the details of the program/include/line no..
    Activate the System Debugger On from the Settings Menu.
    Hope this would help you.
    Murthy
    Edited by: Kalyanam Seetha Rama Murthy on Jul 18, 2008 7:20 AM

  • Problems getting multiple digital signatures in Acrobat Reader form

    I have a Word document that I converted to a form in Acrobat 9 Pro. I added two separate digital signature fields, one for a conference presenter and the other for the conference planner to sign. There are also a number of text fields where presenters give bio information. I saved the document using the Extend functionality so that a user who only has Acrobat Reader would be able to fill in the form, sign/save it, and then send it on to the conference planner. The first part is working fine. However, once the first user signs/saves the document, the extended functionality goes away. When the conference planner receives the document, it is essentially locked. She cannot sign and save.
    Is what I'm trying to do possible? I feel like this would be fairly commonplace, but I may be going about it the wrong way. Thank you for any pointers.
    -Brian 

    Hi Steve,
    I have met similar problem. Using Adobe 9.4 I have prepared document with three signature fileds. I did signature in one of the field and then did extension to Reader. When I checked the propierties of document it occured that signing was not allowed. I couldn't sign it second time (not saying of Reader's user).
    Is there missing any plug-in or something is wrong with a configuration (mentioned "Nothing has happened when signed" was set up)?
    Wlodek

  • Problem creating PKCS# 12 Digital Signature in Adobe Reader X - where do I confirm the Password?

    I cannot create a PKCS# 12 Digital Signature in Adobe Reader X. It says the passwords don't match when I create it. The problem is, I never was asked to confirm the P/W when I created it. It asked once for the P/W and then the only thing I can do is click "Finish" and then it says my P/W don't match. I am able to create a DS on my other computer using Reader 9 (and it did ask me to confirm the P/W when creating). I have re-booted my computer and still it will not work.

    You'll need to ask in the Acrobat Pro forum. There are people there with expertise who can answer this. I use Acrobat myself, but I'm a novice when it comes to signature settings.

Maybe you are looking for

  • Forms application returns "ORA-01403 no data found" exception on Windows 7

    Hi everyone, I am currently involved in an application compatibility project for an O/S migration from Windows XP to Windows 7. We have a legacy Oracle Dev6i P18 Forms application that has been working perfectly on Windows XP for the last decade or s

  • Problem with FM profitcenter_change

    Hi,      Friends, can anyone help me how to use function module profitcenter_change? Actually I have a requirement to change an existing report that used to create a profit center from a flat file.    Now the new requirement is that if there is an ex

  • Make something happen after 4 MCs Play

    Hi, I need to have 4 buttons that play 4 different MCs. I want a 5th MC to play after all 4 MCs have been played. Any ideas on how to do this in AS2? Thanks. Dan

  • 9i Connection Manager Resource Leak?

    I am experiencing serious performance problems with the Connection Manager gateway (CMGW.exe) that ships with Oracle9i for Windows NT/2K. There appears to be a memory leak after the first connection to the Connection Manager is made. I've come across

  • Photoshop CS6 on multiple computers

    I received Photoshop CS6 for Christmas - can I load it on both my desktop and laptop