The Sandbox Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

GetKey Util - RSA key mgr (like sn but different)

Back to Forum: The Sandbox
  • User profile image
    staceyw

    Note: this is a fx2.0 build and will not compile or run in 1.1.

    SN.exe lacks some features that would help when working with and debugging apps that use RSA key pairs. This utility came out of my search to more easily get and set RSA keys from files and containers inside and outside my programs.  Some of the more interesting features are:
    - Import and export RSA keys to/from XML strings or CSP key blobs.
    - Create keys right to container without going to file first.
    - View CSP blob in snk file and/or container in hex or XML format.
    - New key to file and container at same time.
    - New key to console in blob or XML.

    This was really more of a good example of using my updated CmdParser project which allows you to easily work with simple to very complex command lines in your console apps.  The CmdParser project is also included in the zip.  If you just want to play with GetKey.exe, the binary and supporting cmdparser.dll is in the bin/debug dir of the GetKey project.

    The Usage help of GetKey is below.  Note the command parameters are orginized into Sets.  The first set is to create a NewKey of any supported size.  Can store in Container or File.  If File, can store to XML.  Second Set allows you to view a key from File and store in another file or Container.  Can also just export the public part.  Third Set same as File, but works with Containers instead of files.  The last allows you to delete a container.  This does not yet do any assembly signing as SN is can be used for that, however it could be added.  Also included is the RsaKeyMgr class that allows all the same things from within your code.  So you can create keys from GetKey at console and use from your program using RsaKeyMgr class.  Or create within your program and view with GetKey.exe.

    Usage:
    GetKey -NewKey [-KeySize int32] [-OutFile string] [-OutContainer string] [-XML] [-MachineStore boolean] [-Quiet]
    GetKey [-OutFile string] [-OutContainer string] [-XML] -File string [-PublicOnly] [-Quiet]
    GetKey [-OutFile string] [-OutContainer string] [-XML] -Container string [-MachineStore boolean] [-PublicOnly] [-Quiet]
    GetKey -Container string [-MachineStore boolean] -Delete [-Quiet]

    Parameters:
    Container    - Container to get key from.
    Delete       - Delete the key from named container.
    File         - File to read key from.  File format can be CSP (i.e. SNK) format or XML format.
    KeySize      - RSA key size. Default is 1024. Range is 384-16384 in 8 bit increments.
    MachineStore - Use the Machine store instead of the default User store.
    NewKey       - Creates a new RSA key pair.
    OutContainer - Container to write key.
    OutFile      - File to write key.
    PublicOnly   - Get only the public version of the key.
    Quiet        - Suppress all output other then error messages.
    XML          - Output key as formatted XML string instead of the default CSP blob format.

    Note: For detailed help, use -?? or -help.

    Hope this can be of some use.
    --
    William Stacey [MVP]

  • User profile image
    Arash_​Aghlara

    Where is the file and source to download?

    Arash

  • User profile image
    staceyw

    Click the "[Save]" link at the bottom of the post.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.