CryptographicException: Bad Data - when storing public key only in key store on encrypting machine

Discussion in 'ASP .Net Security' started by pmkatz, Aug 25, 2004.

  1. pmkatz

    pmkatz Guest

    I am working on a system in which a web server will contain the Public
    Key from an RSA Key Pair and it will be stored in a key store (in
    machine keys). This key will be used to encrypt data.

    A second machine that is in another location will have the public and
    private key stored in a key store (also in machine keys). This key
    will be used to decrypt data that was encrypted on the web server.

    The problem that I am having is that if both the public and private
    keys are not stored on the web server (in the key store at the time the
    data is encrypted) then the second machine is unable to decrypt the
    data and instead the following message is returned:

    Exception Type: System.Security.Cryptography.CryptographicException
    Message: Bad Data.

    However, if the web server has the complete pair in it's key store,
    everything works as expected.

    The following scenario shows the same behavior but it can be performed
    on a single machine. Can anyone explain why?

    1. Generate a key pair using the RSACryptoServiceProvider
    2. Persist the key pair to an xml file (using ToXMLStringMethod)
    3. Persist the public key only to an xml file (also using
    ToXMLStringMethod)
    4. Load the Public Key only into a key store (I'm using machine keys
    store)
    5. Encrypt some data (using key in new key store) and record the output
    6. Delete the key store created in step 4.
    7. Load the Key Pair (public and private) into a key store
    9. Decrypt the output created in step 5 with key found in store created
    in step 7 and notice that an error message occurs:

    Exception Type: System.Security.Cryptography.CryptographicException
    Message: Bad Data.

    Any insight would be much appreciated. Thanks!
    pmkatz, Aug 25, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dei401
    Replies:
    0
    Views:
    781
    Dei401
    Feb 2, 2005
  2. =?Utf-8?B?ZnJlcXVuZW5jeQ==?=

    CryptographicException Bad Data in Windo

    =?Utf-8?B?ZnJlcXVuZW5jeQ==?=, Jul 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    611
    =?Utf-8?B?ZnJlcXVuZW5jeQ==?=
    Jul 20, 2005
  3. jaekim

    CryptographicException: Bad Data

    jaekim, Sep 6, 2003, in forum: ASP .Net Security
    Replies:
    3
    Views:
    274
    jaekim
    Sep 7, 2003
  4. z f
    Replies:
    0
    Views:
    177
  5. Replies:
    1
    Views:
    376
    MikeS
    Aug 27, 2006
Loading...

Share This Page