How to store a RSA pair key in Java Key Store (jks) and VS

Hi Everyone ,
I have generated a RSA pair key . now I need to store my public key in a Java Key Store (.jks file) . and then I need to read this .jks file in another application and get this public key to use for verification .
I'll appreciate it if anyone could help me with this matter with a sample code for import/export public key to/from a java key store file or any hints.
Best Regards,
Vivian

I don't think this makes sense. How have you generated an RSA key pair and where is the result stored?

Similar Messages

  • How can I calculate the total time in java?

    Hello!
    I need to calculate the total time!
    For example I have start time:
              Format formatter1;
              Date date1 = new Date();
              formatter1 = new SimpleDateFormat("hh:mm:ss");
              String startTime = formatter1.format(date1);
              //startTime = "14:20:40";
    And I have finish time:
              Format formatter2;
              Date date2 = new Date();
              formatter2 = new SimpleDateFormat("hh:mm:ss");
              String finishTime = formatter2.format(date2);
              //finishTime = "08:30:55";
    So, after manually calculating, I get total time: "18:10:15"
    How can I calculate the total time in java? (Using formatter1 and formatter2 I suppose)
    What I need is to print "total 18:10:15"
    Thanks!

    800512 wrote:
    I did the following but, I think something is wrong here:
    I defined before: Date date1 = new Date(); Date date2 = new Date();
    And it should be exactly 5 seconds between them.
    I found delta between date1 and date2:
    Format formatter = new SimpleDateFormat("HH:mm:ss");
              long timeInMilliFromStart = date1.getTime() - date2.getTime() ;
              Date date3 = new Date(timeInMilliFromStart);
              String timeInSecFromStart = formatter.format(date3);
    and I get always
    //timeInSecFromStart = 02:00:05
    But it should be exactly 00:00:05.
    What can be a problem?Because, like I said, a Date measure an instant in time, not a duration. So when you have 5000 ms, and you turn that into a Date, that means 5 sec. after the epoch, which works out to 1/1/1970 00:00:05.000 GMT.
    As I mentioned, if you're not currently in GMT, then you have to set the TZ of the DateFormat to GMT. Right now, it's showing you the time in your TZ. If you included the date in your SimpleDateFormat, you'd see either 1/1/1970 or 12/31/1969, depending on which TZ you're in.
    Bottom line: You're trying to use these classes in a way they're not meant for, and while you can get the results you want for a limited set of inputs if you understand what these classes do and how to work with that, it's a brittle approach and comes with all kinds of caveats.

  • Why iCloud only allows store documents created by Pages, Numbers or Key Note ? How can I "iCloud" documents created with Word Mac or Excel mac??

    Why iCloud only allows store documents created by Pages, Numbers or Key Note ? How can I "iCloud" documents created with Word Mac or Excel mac??

    Oscar66 wrote:
    Why iCloud only allows store documents created by Pages, Numbers or Key Note ? How can I "iCloud" documents created with Word Mac or Excel mac??
    iwork for ios accepts for upload and also happily opens all your Microsoft office files, from Office97 standard doc/xls/ppt to the 2011 versions of docx,xlsx,pptx and various other of these format extensions.
    Notice : the upload feature in www.icloud.com is only active if you in fact own these apps on your iPhone/Pad/pod. it is not a feature of iWork for the Mac ( iwork09 ) which itself is not icloud capable at all.

  • How  to use the RSA  key files generated by Crypto++ in java

    Hi - Good day to all :)
    I have two RSA key files(private key file and public key file) generated by Crypto++ 5.2.1:
    code here:
    void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed)
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
         HexEncoder privFile(new FileSink(privFilename));
         priv.DEREncode(privFile);
         privFile.MessageEnd();
         RSAES_OAEP_SHA_Encryptor pub(priv);
         HexEncoder pubFile(new FileSink(pubFilename));
         pub.DEREncode(pubFile);
         pubFile.MessageEnd();
    }generated private key is:
    30820273020100300D06092A864886F70D01010105000482025D3082025902010002818100E19891D888651221AF315B369873F01910D097F554723EE8748FA230F2B954EBEFC57CB402DD03333BA9514AB5256EF92BE714C710D166A1D86CB7A11EFB4499506826AB873F5036B92F07BBB3ABB8F562646DE6E11031C46542633605FDE4A31E0E0A8651B4BC7743C18266D664E59E713D7595ED3D3B6C2F94C6072E276171020111028180425A0CC7372CC918F74AC07978221970C8B5D25736F46CDAF51B2FB40B27735473B28E16D3AA6A5A5CD7724326382FB2B28F4258AA97F1026CD4AE7AAEC25F77D54DF69BB3979E2893EBB071DA5752871BC8C60F9B5546C466F3103884D6B67FADCD51B17899991989507CB16F45DD76EC0DEDA1BD979ED1A101179F9687E9E5024100FFCAAEF814F12DCBDF20D4CFDD5007738DAAE45AE7EC2FD8E23A9EFCA85FADCAF61B03BFEA6FE6023E78700F804C4C275375A85BC367FE39D5FB2E0F0A4555F7024100E1C797A20FB108ADAFECDB025665FF500FDBB4F0829BAAE95833C046005DCA593F6C2437CD3A9AB7CC04372F422B0EE2C7FED87AA53821366962AE0CBDAD89D702402D23C48621D035421851167F08F00150A08791B5B074F96282469486F0895AE794D7973FFC31DD4BB0ABD78A43D13A9D8732E1799AF43BEC16B3DAF3986696B30240351FE7716D1A98A156921569F6361DF4B86FEE56B551CDDC8D395A6AD2E8E4513C1971EF031CD91C3000FDED00829A173E1DD895540D34FDBE71925D59CE7AC9024014A4347A1E7408FBB0A9AE5064FA58CAF2BCA5C00B8082A46EECABFA5CBF61364FEE81E2C049F399A2F601C802DD54A6D9340FABE62D6D1F913026C8B3764AFEI use this key in java
    BufferedInputStream input=new BufferedInputStream(new FileInputStream("privateKey"));
              int size= input.available();
              byte[]buffer=new byte[size];
              input.read(buffer);
    X509EncodedKeySpec lX509EncodedKeySpec = new X509EncodedKeySpec(buffer);
              PrivateKey lPrivateKey = KeyFactory.getInstance("RSA").generatePrivate(lX509EncodedKeySpec);there is a exception,at generatePrivate() method
    at sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:294)
         at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:171)
         at java.security.KeyFactory.generatePrivate(KeyFactory.java:322)
         at test.Main.main(Main.java:27)any body can help me?

    X509 is for public keys, not private keys. You need PKCS8 using PKCS8EncodedKeySpec on the hex decoded private key string.
    Your method for reading the private key from the file is flawed. The method available() does not guarantee to give you the file length. This is easy to prove since files can be longer than Integer.MAX_VALUE and available() returns an 'int'. To get the file length use File.length() which returns a 'long'. Also, reading from an InputStream using
    input.read(buffer); does not guarantee to read all the bytes. For that you need to use something like DataInputStream.readFully().

  • Updating ipod touch to os5.1  got an error message "cannot connect the ipod touch because the pairing record is missing"   don't know what this means or how to fix but am stuck, only option is to answer ok and close the error box.  Any ideas?

    Updating ipod touch to os5.1  got an error message "cannot connect the ipod touch because the pairing record is missing"   don't know what this means or how to fix but am stuck, only option is to answer ok and close the error box.  Any ideas?

    #1
    - Try another cable. The cable for 5G iPod (lightning connector) seems to be more prone to failure than the older cable.
    - If a 5G iPod               
    Iphone 5 lightning port charging problem - SOLUTION!
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar
    #1.1 n/a because the errror message overrides it
    #2 see #1
    #3 iOS: Device not recognized in iTunes for Mac OS X
    But could be caused by #1
    #4 Covered by previous ones
    #5 Obvious jpegs are photos and thus will not sync as videos. Also see:
    iTunes: May be unable to transfer videos to iPhone, iPad, or iPod
    iTunes: Frequently asked questions about viewing and syncing videos
    #6 iOS: If you can't back up or restore from a backup in iTunes
    First #7 See #6
    Second #7 You have so many other problems resolve those first
    #8 Resolve other problems first

  • HT4718 How come I can't download anything from mac app store?

    How come I can't download anything from mac app store?
    I've tried everything it all started when my apple app store icon in the doc disappeared.
    It will not go to the Mac App Store
    I have a MacBook Pro 2010 intel
    os mac mountain lion 10.8.6 however I do not have the original copy that was downloaded from the app store when I bought it.
    I NEED TO DO A CLEAN INSTALL TO GET MY APP STORE ICON BACK
    Please if anyone can help apple doesn't seem to care?

    If you need to reinstall Mac OS X 10.8.x (there is no 10.8.6 yet, by the way), restart your Mac, hold down the Option key so you see all the bootable partitons, and boot to the Recovery Partition. From there you can reinstall Mountain Lion. You will need a good Internet connection.
    For more details, see:
    http://support.apple.com/kb/HT4718
    Regards.

  • How to find programatically the length of a private key?

    Hello,
    I generate a keystore and a private key in it with the command:
    keytool -genkey -v -alias myPrivKey -keyalg RSA -keysize 4096I then can access the private key with the following code:
    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
    InputStream is = new FileInputStream("/path/to/keystore", keyStorePassword);
    ks.load(is);
    KeyStore.PasswordProtection protParam = new KeyStore.PasswordProtection(privKeyPassword);
    KeyStore.PrivateKeyEntry privKeyEntry = (KeyStore.PrivateKeyEntry)ks.getEntry("myPrivKey", protParam);
    PrivateKey privKey = privKeyEntry.getPrivateKey();How can I get the length of the private key using the PrivateKey privKey object in my code? In this case I know it is 4096, but how can I find the lengths of arbitrary rsa private keys?
    Thank you very much for your answers in advance.
    Regards
    Rambius

    RSAPrivateKey privKey = (RSAPrivateKey)privKeyEntry.getPrivateKey();
    BigInteger modulus = privKey.getModulus();
    int length = modulus.bitLength(); // See the Javadoc for details

  • How to download the same song(track) with different keys? iTunes seems to think I have already downloaded the song and will not download the song in a different key of the Demo Track

    How to download the same song(track) with different keys? iTunes seems to think I have already dowloaded the song and will not let me download the song in a different key or the Demo.

    Hello Jigz19,
    It sounds like you are unable to play a couple of songs from your library becuase you get a message that the computer is unauthorized to play, but other content purchased that same day works without issue. I would verify that the affected songs were purchased with the same Apple ID first:
    Recovering a forgotten iTunes Store account name
    http://support.apple.com/kb/ht1920
    Open iTunes
    Highlight one of the items you have purchased (You can find your purchases in your Purchases playlist).
    Choose File > Get Info.
    Click the Summary tab.
    The Account Name area will list the account used to purchase the item. Unless you have changed accounts, this is your iTunes Store account name.
    If so, then delete the songs:
    How to delete content you've downloaded from the iTunes Store, App Store, iBooks Store, or Mac App Store
    http://support.apple.com/kb/HT5772
    Then re download them with this article:
    Download past purchases
    http://support.apple.com/kb/ht2519
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • How to query in bpm to generate next seq key

    Hi,
    I am working in 5.7 and DB2, I am able to insert a record in a table using Fuego.Sql.SqlObject.store() provided i assign the primary key value
    prmary key needs to be generated using 'SELECT NEXT VALUE FOR BPMPR.BPM_KEY_SEQ FROM SYSIBM.SYSDUMMY1'
    This query returns the next seq number outside bpm. but when i use it with in bpm, it complains : Unexpected value
    Suggest me how to get the sequence key which is returned by 'SELECT NEXT VALUE FOR BPMPR.BPM_KEY_SEQ FROM SYSIBM.SYSDUMMY1' query.
    I cannot use 'SELECT max(rqstKey) as nxtrqstKey FROM BPMPR.TABLE' to get the primary key value
    Thanks!

    Hi
    The first thing you might want to try is to change your logic in ALBPM to use Dynamic SQL to run your query.
    Here's the syntax that might work. The logic below assumes you named your database External Resouce "DbWithTheMostest".
    nextId as String[]
    query as String = "SELECT NEXT VALUE as nxtRqstKey FOR BPMPR.BPM_KEY_SEQ FROM SYSIBM.SYSDUMMY1"
    externalResourceName as String = "DbWithTheMostest"
    for each row in executeQuery(DynamicSQL, sentence : query, implname : externalResourceName) do
    // keep adding customer names to the array until all the customers have been added
    nextId[] = " " + row["nxtRqstKey "]
    end
    The second thing you might want to try is to catalog an SQL Query (vs. SQL). During the introspection, you'll be prompted to enter your sql.
    Hope this helps,
    Dan

  • My computer had to be restored at the apple store. When they did it my Microsoft word, powerpoint, and excel were all deleted! How can I get them back? Who do I talk to, Apple or Microsoft?

    My computer had to be restored at the apple store. When they did it my Microsoft word, powerpoint, and excel were all deleted! How can I get them back? Who do I talk to, Apple or Microsoft?

    you are responsible for reinstalling any apps.  It is not Apples responsibility as outline the the service agreement.  Do you have the product key? 

  • How to get reed of the arrows to the itunes store?

    Hi,
    On itunes 1.8 reappear the arrows leading to the itunes store, as in the version 1.7. The thing is, in the version 1.7 you were able to make them "disappear" with the Edition > Preferences > General (sorry if the directories' name aren't right, my itunes is in french).
    But, in the 1.8 version, it looks (to me) like you can't possibly do it. Especially when you check the help which tells you to do exactly as in version 1.7 (Edition > Preferences...), but the box you are supposed to "un-tick" is simply not there.
    How can I simply make them disappear?
    Thx 4 ur help!
    PS: Sorry if the subject was already post somewhere, I just couldn't find the answer anywhere...

    To remove the arrows on a Windows copy of iTunes:
    1) Shutdown iTunes
    2) Backup your prefs file
    C:\Users\(youruser)\AppData\Roaming\Apple Computer\iTunes\iTunesPrefs.xml
    3) Edit the file in a real text editor that understands UNIX linefeeds (notepad++, ultraedit, vi, etc) and paste the following lines below the <dict> line under <key>User Preferences</key>:
    <key>show-store-arrow-links</key>
    <data>
    AA==
    </data>
    4) Start iTunes and you should be set.
    Tip courtesy of Rodalpho Carmichael
    Just as a tip, it will be clearer to most people if you don't post software version numbers in reverse as is the case with dates in many European countries. Reversing software version numbers will just confuse things. The current version of iTunes is 8.0.1 and should be referred to that way so that it's clear what version you really have. It's obvious with iTunes, but with other software might not be so clear what you mean.
    Regards.
    Message was edited by: Dave Sawyer

  • How do I remove an unwanted update from the App Store?

    Ok,
    So I open the App Store and there's a update awaiting me. Some App called CodeBox by one Vadim Shpakovski version 1.6 Released 7 April 2012
    So I check it over, check the app out and what it's all about. The App costs £6.99 and it's designed for developers. Simply I don't want the **** thing and I never applied or activated the app for purchase.
    I've looked everywhere and there's no delete update or remove update.
    Can anyone enlighten me as to how to remove the unwanted update?
    Thanks All.
    <Edited by Host>

    You installed a hacked app, originally from the Mac App Store. It contains the receipt for a different app, downloaded using an account that you don't control. You need to identify and remove the hacked app.
    Important: The app you need to remove is not necessarily the one named in the App Store alert. For example, if the App Store says you need to update "Twitter," the hacked app may be "Angry Birds" or something else entirely. Don't make any assumptions about which app you're looking for. To find it, you have to carry out a systematic search.
    Triple-click anywhere in the line of text below on this page to select it:
    kMDItemAppStoreHasReceipt=1
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    In the Finder, press command-F to open a search window, or select
    File ▹ Find
    from the menu bar. In the search window, select
    Search: This Mac
    from the row of tokens below the toolbar. Below that is a popup menu initially showing Kind. From that menu, select  Other...
    A sheet will drop down. In that sheet, select Raw Query and click OK or press return.
    Now there will be a text box to the right of popup menu. Click in that box and paste (command-V).
    The search window will show all the App Store products you've installed. Compare those search results with the list of your purchases from the App Store. To see the complete list, you may need to unhide hidden purchases. If any apps were download from the App Store using other Apple ID accounts that you control, sign in to the store under each of those ID's and check the purchases.
    At least one of the items listed in the search window is not among your purchases in the App Store. Move each such item to the Trash. You may be prompted for your administrator password. Empty the Trash.
    Log out and log back in. Test.

  • How do I remove an old username from the app store when using the update function

    How do I remove an old username from the app store when using the update function.
    I purchased my Mac used.  The former owners username prepopulates when I try to perform the updated function on the app store.  It does not allow me to use a different user name.    I have created my own username and password.  I have even been able to purchase items from the app store, it's just when I use the update function it does populate with my username.  Any help is appreciated.

    The first thing to do with a second-hand computer is to erase the internal drive and install a clean copy of OS X. You — not the previous owner — must do that. How you do it depends on the model, and on whether you already own another Mac. If you're not sure of the model, enter the serial number on this page. Then find the model on this page to see what OS version was originally installed.
    1. You don't own another Mac.
    If the machine shipped with OS X 10.4 or 10.5, you need a boxed and shrink-wrapped retail Snow Leopard (OS X 10.6) installation disc from the Apple Store or a reputable reseller — not from eBay or anything of the kind. If the machine has less than 1 GB of memory, you'll need to add more in order to install 10.6. Preferably, install as much memory as it can take, according to the technical specifications.
    If the machine shipped with OS X 10.6, you need the installation media that came with it: gray installation discs, or a USB flash drive for some MacBook Air models. For early MBA models, you may need a USB optical drive or Remote Disc. You should have received the media from the previous owner, but if you didn't, order replacements from Apple. A retail disc, or the gray discs from another model, will not work.
    To boot from an optical disc or a flash drive, insert it, then reboot and hold down the C key at the startup chime. Release the key when you see the gray Apple logo on the screen.
    If the machine shipped with OS X 10.7 or later, you don't need media. It should boot into Internet Recovery mode when you hold down the key combination option-command-R at the startup chime. Release the keys when you see a spinning globe.
    2. You do own another Mac.
    If you already own another Mac that was upgraded in the App Store to the version of OS X that you want to install, and if the new Mac is compatible with it, then you can install it. Use Recovery Disk Assistant to create a bootable USB device and boot the new Mac from it by holding down the C key at the startup chime. Alternatively, if you have a Time Machine backup of OS X 10.7.3 or later on an external hard drive (not a Time Capsule or other network device), you can boot from that by holding down the option key and selecting it from the row of icons that appears. Note that if your other Mac was never upgraded in the App Store, you can't use this method.
    Once booted in Recovery, launch Disk Utility and select the icon of the internal drive — not any of the volume icons nested beneath it. In the Partition tab, select the default options: a GUID partition table with one data volume in Mac OS Extended (Journaled) format. This operation will permanently remove all existing data on the drive.
    After partitioning, quit Disk Utility and run the OS X Installer. You will need the Apple ID and password that you used to upgrade. When the installation is done, the system will automatically reboot into the Setup Assistant, which will prompt you to transfer the data from another Mac, its backups, or from a Windows computer. If you have any data to transfer, this is usually the best time to do it.
    Then run Software Update and install all available system updates from Apple. To upgrade to a major version of OS X newer than 10.6, get it from the Mac App Store. Note that you can't keep an upgraded version that was installed by the previous owner. He or she can't legally transfer it to you, and without the Apple ID you won't be able to update it in Software Update or reinstall, if that becomes necessary. The same goes for any App Store products that the previous owner installed — you have to repurchase them.
    If the previous owner "accepted" the bundled iLife applications (iPhoto, iMovie, and Garage Band) in the App Store so that he or she could update them, then they're linked to that Apple ID and you won't be able to download them without buying them. Reportedly, Apple customer service has sometimes issued redemption codes for these apps to second owners who asked.
    If the previous owner didn't deauthorize the computer in the iTunes Store under his Apple ID, you wont be able to  authorize it immediately under your ID. In that case, you'll either have to wait up to 90 days or contact iTunes Support.

  • How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks

    How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks

    http://support.apple.com/kb/ht5621

  • I need to update my apps in the App Store, but when i try to update, the Sign Up Apple ID pop up box came out with different Apple ID. How can I change it to mine? My iTunes Store already login with my own Apple ID.

    I need to update my apps in the App Store, but when i try to update, the Sign Up Apple ID pop up box came out with different Apple ID. How can I change it to mine? My iTunes Store already log in with my own Apple ID.

    Just now you said the other Apple ID stored inside it, is that mean all my data back up in that the other ID?

Maybe you are looking for

  • T61 no longer recognizes DVD super-multi drive

    My T61 for some reason has stopped recognizing my DVD super-multi drive (GSA-U10N).  I do not use the optical drive often, so I am not sure when during the past couple of months this occured.  I have tried finding it using Lenovo System Toolbox and D

  • Sequence no in ageing report PLD

    Hi,                           I have setup  sequencel nos for A/R Invoices. In the ageing report for customers PLD  I want to display the sequence no also.                                                  Can you guide me how to do that? Regards, Sek

  • ToolTip appearence of a JButton having a hot key/Mnemonic set

    Hi, I have facing a problem in the TOOLTip of a JButton. Using UIManager.put("Tooltip.background", Color.black); & UIManager.put("Tooltip.foreground", Color.red); or overriding the createToolTip() method we can change the ToolTip bg & fg color. But i

  • How do I clear History  are

    How do I clear history in Safari, the clear button in both settings and in the bookmarks is greyed out

  • Cache configuration overrides

    So i have a cache config with several caches and schemes defined, the below is a snippet for one cache. What i'd like to do is override the high/low units setting in a an environment specific way. Eg, One prod installation might get a different value