ASN1 bad tag value met on EnvelopedData.Decrypt str

From: Kristine (wingsforwheels_at_hotmail.com)
Date: 09/23/04

  • Next message: Peter Dam: "GINA WinLogon WLX_SAS_TYPE_SC_INSERT event"
    Date: 23 Sep 2004 08:41:55 -0700
    
    

    Users are being linked to our site, and the URL passed to us contains
    encrypted data (encrypted by JAVA). The site that is passing the URL
    to us and encrypting the parameter has my public key/certificate.
    When I try to decrypt using CAPICOM the "ASN1 bad tag value met" error
    is raised. I checked the decoded text on the ANS1 dump tool and it
    did not raise any errors. I've included my code below, if anyone sees
    anything wrong with it please let me know (this is the first time I've
    implemented the asynchronous/key pair).

    Would this error be raised if my private key was not found? Is there
    anyway to check that it was found? I did verify that the private key
    is associated with the certificate.

    Set Store = Server.CreateObject("CAPICOM.Store")
    Store.Open CAPICOM_LOCAL_MACHINE_STORE, "MY" ,0
    Set Certificates = Store.Certificates.Find(CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME,
    SubjectName)

    Response.Write("<br>Certificate found: " & Store.Certificates.Count)

    If Store.Certificates.Count > 0 then
            Set EnvelopedData = Server.CreateObject("CAPICOM.EnvelopedData")
            EnvelopedData.Recipients.Add Store.Certificates(1)
            Message = Request.QueryString("query")
            Response.write "<p>Encrypt= " & Message
            'EnvelopedData.Decrypt Message <---ERROR HERE
            'str_out = EnvelopedData.Content
            'response.write "<p>Decrypt= " & str_out
    Else
            response.write "<P>Could not find certificate."
    End If


  • Next message: Peter Dam: "GINA WinLogon WLX_SAS_TYPE_SC_INSERT event"

    Relevant Pages

    • Re: RA doesnt work after encrypting in XP
      ... >I am setting up a standard procedure for encrypting the data folders on ... > as deleting the RA private key using certmgr.msc. ... This works fine and I am able to decrypt them as ...
      (microsoft.public.win2000.security)
    • Re: Remote signing of large files
      ... about 'Remote signing of large files': ... the signing of this message digest. ... [Encrypting with the private key allows anyone ... of the private key, or that the private key has been compromised.] ...
      (Debian-User)
    • Re: cryptological confusion
      ... it's not so much a misconception as a change in the ... preferred phraseology. ... the "encrypting with the private key" ...
      (sci.crypt)
    • Re: Encrypt with Private key, Decrypt with Public Key (RSACryptoServiceProvider)
      ... Encryption with an RSA private key is mainly used for generating ... and then send it to someone so they can verify (with your public key, ... > portion/public portion, mainly because I AM CURIOUS AND I WONT GIVE MY ... > public portion of the key if I am encrypting with the private portion. ...
      (microsoft.public.dotnet.security)
    • Re: Importing PEM private keys
      ... > unencrypted private key, and the CSP doesn't provide a NULL cipher as ... > forced to try encrypting, passing in session keys etc. but it all ... key in a usable format. ... The .pem file contains the body, which is a Base64 encoded private-key. ...
      (microsoft.public.platformsdk.security)