How to save secret key in the NSS certDB and then retrieve it through Java?

Hi,
I 'm pretty new trying to handle keying material for NSS fips mode.
After following the guidelines from http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#NSS I need my code to use SecretKeyFactory method generateSecret with DESedeKeySpec parameter in the following way:
Provider nss = new sun.security.pkcs11.SunPKCS11(configFileName);
Security.addProvider(nss);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede", nss);
DESedeKeySpec keySpec = new DESedeKeySpec(new String("abcdefghijklmnopqrstuvw").getBytes("UTF-8"));
SecretKey key = keyFactory.generateSecret(keySpec);
The question is: what are the steps needed to save secret key "abcdefghijklmnopqrstuvw" in NSS certDB in the fips mode (nssModule = fips in pkcs#11 conf. file) and how should it be retrieved in the Java code?
Any help will be appreciated...

OK...I didn't test this in FIPS mode, but it works in keystore mode (which says persistent storage of keys)
KeyGenerator kg = KeyGenerator.getInstance("DESede",nss);
kg.init(192);  //yields 168-bit key
SecretKey tripleDesKey = kg.generateKey();
KeyStore.SecretKeyEntry skEntry = new KeyStore.SecretKeyEntry(tripleDesKey);
ks.setEntry(randAlias, skEntry, new KeyStore.PasswordProtection(password));I was generating some random bytes and base64'ing them to get a random alias on each execution of the program. I'd also loop through and print out the aliases before I generated another key to ensure it was storing the key in between runs which it was.
Command-line proof the keys are in db:
symkeyutil -L -d .
Enter Password or Pin for "NSS Certificate DB":
     Name            Len Strength     Type    Data
NSS Certificate DB:
7i/XoKcaLhU=          24    168         des3  <restricted>
Yzjt7W+AIgc=          24    168         des3  <restricted>
RkOTZssCEQM=          24    168         des3  <restricted>
S2BHRcFUyAA=          24    168         des3  <restricted>
secretKeyAlias        24    168         des3  <restricted>
R/DaVy1z1MM=          24    168         des3  <restricted>
IdpdnIDzOYs=          24    168         des3  <restricted>
SeVASW8PrOc=          24    168         des3  <restricted>
c6Ml/9I7thQ=          24    168         des3  <restricted>Edited by: dstutz on May 15, 2008 12:28 PM
Edit again:
I changed the mode in the cfg file to fips and used modutil to change module to fips mode and it still works...all the keys I created in keystore mode are still there and I can add new ones.
C:\nss>symkeyutil -L -d .
Enter Password or Pin for "NSS FIPS 140-2 Certificate DB":
     Name            Len Strength     Type    Data
NSS FIPS 140-2 Certificate DB:
LmsZDBaaCw8=          24    168         des3  <restricted>
EQaX3wdJ1cY=          24    168         des3  <restricted>
7i/XoKcaLhU=          24    168         des3  <restricted>
Yzjt7W+AIgc=          24    168         des3  <restricted>
RkOTZssCEQM=          24    168         des3  <restricted>
S2BHRcFUyAA=          24    168         des3  <restricted>
secretKeyAlias        24    168         des3  <restricted>
UsY23mwSzEM=          24    168         des3  <restricted>
B/auMw2OTvE=          24    168         des3  <restricted>
coqyCAAJpsk=          24    168         des3  <restricted>
vVBHLg1r3cY=          24    168         des3  <restricted>
R/DaVy1z1MM=          24    168         des3  <restricted>
IdpdnIDzOYs=          24    168         des3  <restricted>
SeVASW8PrOc=          24    168         des3  <restricted>
c6Ml/9I7thQ=          24    168         des3  <restricted>Edited by: dstutz on May 15, 2008 12:56 PM

Similar Messages

  • As soon as I open Firefox, it asks if I want to save my tabs for the next session and then quits (not a crash).

    Mac OS X, Firefox v3.6. I've disabled all of my extensions and went as far as to uninstall and reinstall the application. Still having the same issue. The program automatically tries to close itself after opening.

    Continue to have this issue. It seems almost as if there is a script waiting for Firefox to open which closes the application.
    If I open in normal mode, Firefox just closes after 2 seconds after opening - no crash report. If I open in safe mode, I get the prompt to save tabs for next session before it closes.
    Anyone else have this problem? Occurs across multiple user accounts on the same machine in Snow Leopard.
    I've even tried installing Firefox 4 beta - same problem.

  • How do you save your DVD to your Hard Drive, and then convert to iPod?

    Hello everyone, I was wondering how you save your DVD to your hard drive and then convert it to the iPod Video.
    Please respond.
    P.S.
    I know that it's been discussed all the time, but none of the posts are useful for me.
    Thanks

    Hi,
    The best option is to pull the card out and plug to your computer UNLESS your computer does not have a card reader. If your computer did not have a card reader, you need to map the cardreader on your printer to your network using the following method:
        http://h10025.www1.hp.com/ewfrf/wc/document?lc=en&dlc=en&cc=us&docname=c00149194
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I have a custom template.  When I edit it and try to save it asks me to name it and then I end up with an additional custom template.  How do I edit the template and save the changes without creating another template?

    I have a custom template.  When I edit it and try to save it asks me to name it and then I end up with an additional custom template.  How do I edit the template and save the changes without creating another template?

    Hi Atrec,
    If you don't need your old custom template, save your changes with the same template name. It will tell you that this template exists and will ask you Replace? Say yes (if you do want to replace the old with the new!)
    To delete unwanted templates, go to Finder > Menu > Go and press the option key. Your Library will show in the Go Menu. Navigate to Library > Application Support > iWork > Numbers > Templates > My Templates.
    Delete any unwanted template by dragging it to the Trash or click on it then command-delete.
    Having gone to all that trouble to find My Templates folder, right click (or control click) on it and Make Alias. Drag the Alias to any convenient place for a quick way to get back to that folder.
    Regards,
    Ian.

  • Secret key for the OpenPGP?????

    What am I getting the message "enter passphrase to unlock the secret key for the OpenPGP certificate:..."  when I try to send email via AOL on my Mac?  My gmail account is fine.  I can't send email via my AOL account from my computer any longer because it is requiring a passphrase which I do not have nor ever set up.  My gmail account is fine.  Help!

    Uninstall GPGTools by following the developer's instructions.
    How can I uninstall your software? / FAQ / Knowledge Base - GPGTools Support

  • I am trying to save a document with the new pages and it will only save as a zip file any ideas on how to change this?

    I am trying to save a document with the new Pages and it is only saving as a ZIP file anyone know how to fix this or choose a different file type?

    Take a look at the FileSelector
    First make sure the FileSelector is expanded so you can see the directory and sidebar. That's what the little disclosure triangle up by the filename is for. Once the FS has been expanded to look like the above picture, look to see what subdirectory has been selected. Use the SideBar to select an appropriate one.

  • How to remove the sort function on the drill down and then save

    how to remove the sort function on the drill down and then save in the  change local view of the Query
    Is it possible to change the porperties of any characteristic in the local view and then save?
    If so please post the answer.

    I do not think that option is possible.
    Regards,
    Venkata Boga.

  • Before I upgraded my iPad mini, you could turn off apps to save battery power by double clicking the control button and then holding your finger on the app button until the minus sign appeared.  That doesn't work anymore.  How do you turn off the apps wit

    Before I upgraded my iPad mini, you could turn off apps to save battery power by double clicking the control button and then holding your finger on the app button until the minus sign appeared.  That doesn't work anymore.  How do you turn off the apps with ios7

    Now you swipe downward, the app will appear and you delete, keep scolling to the right as in the past.  With the new operating system you also swipe downward to get the search bar to find an app

  • How to save a fmb in the database thru command prompt?

    Hi,
    How to save a fmb in the database thru command prompt?
    I have around 25 fmb template files which needs to be saved in the database.Every time when we apply the new dump , we need to resave the templates in the database to compile other application related fmb files.Its a time consuming process and Monotonous for me. Is there anyway to save the forms in the database thru batch file, so that just I have to execute the batch file every time.
    Expecting your earliest feedback.
    Thanks & Regards,
    G.S -
    [email protected] / [email protected]

    Hi Frank,
    Thanks for your feeback.
    I am using forms6i.Basically our application was migrated from 4.5 to 6i two years back. Due to some reasons our technical team members are insisting us to store the template FMB's into the database to do the coding activities at site.
    Once in a month we are receiving the live dump for test database.Hence the problem.
    Please suggest the easiest way to store the template FMBs in the database.
    Thanks & Regards,
    G.S

  • How to save slices selected by the slice-select-tool ?

    How to save slices selected by the slice-select-tool ? In the past, I select several slices in edit window and saved for web(ctrl+alt+shift+s) But now, selected slices are unselected in the Save-for-web dialog except first slice.
    I'm sorry my short english.

    How to save slices selected by the slice-select-tool ? In the past, I select several slices in edit window and saved for web(ctrl+alt+shift+s) But now, selected slices are unselected in the Save-for-web dialog except first slice.
    I'm sorry my short english.

  • How to download a form from the web, complete and save it?

    How to download a form from the web, complete and save it?

    Download Adobe Reader. If the form author allows filling out digitally, you can do so and save it again.
    Mylenium

  • So I stuck a key into one of the USB ports and then a message came up and it crashed straight away and now it won't turn back on.(the message was to do with the USB port taking to much power when there wasn't anything besides the key) help?

    Please help! My mac is about 6 months old and I was just playing with my keys and stuck it in the USB port and then it crashed and won't turn on, it's not picking up the charger (the little led light isn't on) and pressing the power button does absolutely nothing

    Don't be so surprised, people have stuck worse things in worse places before and it was on purpose
    +1
    How am I meant to get the the apple menu if the laptop won't then on
    Reset the SMC first. If this doesn't work, reset PRAM. Move down troubleshoot with links below. First, SMC reset for MBP models 2009 and later:
    Shut down the computer.
    Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
    On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
    Release all the keys and the power button at the same time.
    Press the power button to turn on the computer. 
    Note: The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.
    Intel-based Macs: Resetting the System Management Controller (SMC)
    Resetting your Mac's PRAM and NVRAM
    Resolve startup issues and perform disk maintenance with Disk
    Troubleshooting: My computer won't turn on

  • My G5 won't boot up. The Gray screen comes on and it thinks about it until the fan revs up like it is about to explode. A friend said to start it up with the OS disk and then go to utilities. Didin't work. Any suggestions? Isn't there a key stroke to help

    Oh, so this is where I ask my question. Sorry, first time here. As I was saying in my long intro, the gray screen come up and the thing is spinning at the bottom, but nothing happens. Then the fan starts reving up like it is about to explode and I have to manually shut it off. A friend told me to start it up with the OS disk and then go to utilities. I couldn't find the thing, so I went out and bought another. Needless to say, it didn't work. Is there a key stroke to help jump start the machine? How can I get into this thing? I would prefer not to take it in because there are a lot of things on there I don't want just anyone to have access to.Thanks, in advance, for your help!

    The last time you had to hold down cmd opt pr more than twice was a decade ago....
    G5? PowerPC? 10.5? or earlier....
    https://discussions.apple.com/community/desktop_computers/power_mac?view=discuss ions
    Apple has a number of resources like "Power or Startup Quick Assist"
    http://support.apple.com/kb/HT1149
    Your drive does need to be repaired, and best things to buy are another backup recovery drive, with a small OS X partition; a copy of Disk Warrior is expensive @ $90 but excellent and best.
    Never bother with or use the drive or reinstall while there are errors. Don't take a "clean' bill from Apple Disk Utility to mean there are no errors. Only that it didn't find what it looked for.
    http://www.macintouch.com/readerreports/harddrives/topic4557.html#d12aug2010
    http://www.alsoft.com/DiskWarrior/index.html
    A quick search "keyboard shortcuts" takes you here:
    http://support.apple.com/kb/HT1343
    how to resolve and fix startup issues with fsck and disk utility:
    http://support.apple.com/kb/TS1417
    http://macperformanceguide.com/Mac-HowToClone-backup.html
    http://macperformanceguide.com/Mac-HowToClone.html
    How to use DU to backup and restore
    http://support.apple.com/kb/HT1553
    http://www.alsoft.com/DiskWarrior/index.html
    http://www.bombich.com/ccc_features.html
    Make sure to have multiple backup sets and of your system so if there is a serious problem, you can just erase and restore to be back runninig.
    Sounds like your G5 though needs PMU reset, not PRAM, and the best way for those is to clear nvram instead. might even want to check for dust; tell what System Profile says (later) as to "PowerMacX,Y" or "MacProX,1"
    http://www.apple.com/support/powermac or /macpro
    http://www.apple.com/support/sitemap/
    The Utility menu is on the menu bar of an "OS X Install DVD" and at the point where you get to but stop at "install....' for OS X. you probably do need to install OS X on another drive to work from.
    Oh, a real severe issue and damage to the drive directory or filesystem CAN in cases prevent booting from DVD (the system still tries to find and see what boot volumes are present) and can help to pull or disconnect the drive. Putting a drive in a FW case to turn on after startup is very useful.

  • I bought a used macbook air,  it didn't come with the flash drive to do a factory reset.  Can I download the info needed and save it to my own flash drive and then do a factory reset?  If not what can I do?

    I bought a used macbook air,  it didn't come with the flash drive to do a factory reset.  Can I download the info needed and save it to my own flash drive and then do a factory reset?  If not what can I do?

    If it originally shipped with Mac OS X 10.6.8 or earlier, click here, phone Apple, and order a replacement.
    If it originally shipped with Mac OS X 10.7 or newer, restart it with the Option, Command, and R keys held down.
    (113079)

  • I have a G4 Quicksilver that no longer works, but the hd may still be good. How can I get files off the G4 hd and onto my new iMac?

    I have a G4 Quicksilver 2001 that no longer works, but the hd may still be good. How can I get files off the G4 hd and onto my new late 2013 iMac?

    Also, how do I boot the G4 into FireWire Target Disk mode?
    First, the G4 must be able to start to use FWTDM. If it can start, hold the t key at boot until you get a "screensaver pattern" that looks like this:
    If the G4 is attached via a FireWire cable to a newer Mac with a FireWire port, the G4's hard drive will appear on the other Mac's desktop just as if it were any external drive. A USB cable won't work for FWTDM.
    Just wondering if the drive in my G4, which I believe may be an ATA drive will also work in an enclosure for a SATA drive?
    No. ATA (actually "PATA" or "IDE") and SATA are different interfaces. PATA external enclosures are now very hard to find. You best and least expensive option is the adaptor that BDAqua linked. One of its connectors is for PATA drives.

Maybe you are looking for

  • Archiving a Smart Mailbox to a RAW Message Source using Automator?

    In MAIL I can set a smart mailbox to say get emails from ("any" recipient contains [email protected]) But in Automator when I use the Filter messages in mail I can't be that broad with my selection, I can only select sender, and not ANY recipient. Be

  • To create a procedure in a procedure

    Hi, I am trying to do sth like this. I am trying to create a procedure within an anonymmous PL/SQL block and i am basically trying to execute the newly created procedure there. This example (although wrong) would give a fair idea of what I am trying

  • Plug in architecture

    I am trying to create a vi that would have different options available, depending on an ini file.  Each option is associated with a vi that would be called dynamically and shown in a subpanel.  I wanted to to do this, because I want a simpler way to

  • Error 20413, SCVMM 2012 R2

    Hi! I tried to run command "Refresh Virtual Machines" on cluster node in VMM. And i have an error: Error (20413) VMM encountered a critical exception and created an exception report at C:\ProgramData\VMMLogs\SCVMM.74251b88-e0b8-43d0-986f-0f47295dc772

  • Premiere Pro has encountered an error. Volumes error.

    OS 10.8.2 PR CS 5.5 First let me mention that directly after this problem occurs I recieve the messaage error 'Pr has encountered a serious problem....' and then it crashes on me. Working on a project with multiple video tracks and multiple audio tra