FAQ
I am trying to write a Golang client for a C# dotnet server that uses
RSA PKCS.

The current client implementation is pretty simple in C#.

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.ToXmlString(false);

I am sending everything to the server correctly and am getting back a
successful response, however, I am getting an error when decrypting the
response.

decrypted, decErr := rsa.DecryptPKCS1v15(rand.Reader, pKey, fromXML)


The decErr is not nil.

I was wondering if anyone had experience with writing an RSA client for a
C# server and can offer their experiences.

So far, I tried changing the decryption to OAEP with a sha1 hash. That did
not work. The exchange is happening using SOAP. I am parsing the body of
the soap response successfully so I don' t believe the problem with how I'm
using SOAP.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Tomwilde at Nov 6, 2013 at 10:51 am

    On Wednesday, November 6, 2013 12:49:09 AM UTC+1, jamra wrote:

    The decErr is not nil.
    So, what is it?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Daniel Theophanes at Nov 6, 2013 at 6:43 pm
    I suggest you inspect the content of the MS XML file you are generating.
    Crypto in C# land is a pain, especially when trying to access basic
    functions.

    If you don't want to change your C# code, you'll need to use the xml
    package to unpack the special packing MS gives you. However, I would
    suggest not using the method: ToXmlString(...) at all and find a different
    method.
    On Tuesday, November 5, 2013 3:49:09 PM UTC-8, jamra wrote:

    I am trying to write a Golang client for a C# dotnet server that uses
    RSA PKCS.

    The current client implementation is pretty simple in C#.

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
    rsa.ToXmlString(false);

    I am sending everything to the server correctly and am getting back a
    successful response, however, I am getting an error when decrypting the
    response.

    decrypted, decErr := rsa.DecryptPKCS1v15(rand.Reader, pKey, fromXML)


    The decErr is not nil.

    I was wondering if anyone had experience with writing an RSA client for a
    C# server and can offer their experiences.

    So far, I tried changing the decryption to OAEP with a sha1 hash. That
    did not work. The exchange is happening using SOAP. I am parsing the body
    of the soap response successfully so I don' t believe the problem with how
    I'm using SOAP.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jamra at Nov 6, 2013 at 11:31 pm
    INIT_CONNECTION = `<?xml version="1.0" encoding="utf-8"?>
    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
    <InitConnection xmlns="http://tempuri.org/">
    <sPublicKey>{% PARAMS %}</sPublicKey>
    </InitConnection>
    </soap12:Body>
    </soap12:Envelope>`
    EXCHANGE_PARAMS = `<RSAKeyValue><Modulus>{% modulus
    %}</Modulus><Exponent>{% exponent %}</Exponent></RSAKeyValue>`

    This is the string I sniffed from the current C# client with Fiddler. I
    added {% modulus %} and {% exponent %} strings as tokens to replace with
    the golang public key N and E values. Then I use html.EscapeString on
    EXCHANGE_PARAMS to match what comes out of C#. Why do they html escape the
    xml parts of the string? One can only guess.
    On Wednesday, November 6, 2013 10:43:42 AM UTC-8, Daniel Theophanes wrote:

    I suggest you inspect the content of the MS XML file you are generating.
    Crypto in C# land is a pain, especially when trying to access basic
    functions.

    If you don't want to change your C# code, you'll need to use the xml
    package to unpack the special packing MS gives you. However, I would
    suggest not using the method: ToXmlString(...) at all and find a different
    method.
    On Tuesday, November 5, 2013 3:49:09 PM UTC-8, jamra wrote:

    I am trying to write a Golang client for a C# dotnet server that uses
    RSA PKCS.

    The current client implementation is pretty simple in C#.

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
    rsa.ToXmlString(false);

    I am sending everything to the server correctly and am getting back a
    successful response, however, I am getting an error when decrypting the
    response.

    decrypted, decErr := rsa.DecryptPKCS1v15(rand.Reader, pKey, fromXML)


    The decErr is not nil.

    I was wondering if anyone had experience with writing an RSA client for a
    C# server and can offer their experiences.

    So far, I tried changing the decryption to OAEP with a sha1 hash. That
    did not work. The exchange is happening using SOAP. I am parsing the body
    of the soap response successfully so I don' t believe the problem with how
    I'm using SOAP.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Agl at Nov 8, 2013 at 4:14 pm
    The XML string that you provided, even with your omissions, is 512 bytes.
    That's too large to contain in an RSA encrypt. (Unless you have more than a
    4096-bit key.)

    So it's likely that the encryption is more complex than you think it is.
    Can you provide a (throwaway) private key and example ciphertext?


    Cheers

    AGL

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jamra at Nov 6, 2013 at 11:31 pm
    The RSA errors are intentionally vague

    crypto/rsa: decryption error


    It doesn't say much.

    I guess my question is to anyone who got things working in a similar
    environment. Are there padding issues that I should know about?

    I tried OAEP as well and that didn't work. Here is the line:
    decrypted, decErr := rsa.DecryptOAEP(sha1.New(), rand.Reader, pKey,
    fromXML, nil)

    I am passing nil for the label parameter. I don't know what I should pass
    in there.

    On Tuesday, November 5, 2013 3:49:09 PM UTC-8, jamra wrote:

    I am trying to write a Golang client for a C# dotnet server that uses
    RSA PKCS.

    The current client implementation is pretty simple in C#.

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
    rsa.ToXmlString(false);

    I am sending everything to the server correctly and am getting back a
    successful response, however, I am getting an error when decrypting the
    response.

    decrypted, decErr := rsa.DecryptPKCS1v15(rand.Reader, pKey, fromXML)


    The decErr is not nil.

    I was wondering if anyone had experience with writing an RSA client for a
    C# server and can offer their experiences.

    So far, I tried changing the decryption to OAEP with a sha1 hash. That
    did not work. The exchange is happening using SOAP. I am parsing the body
    of the soap response successfully so I don' t believe the problem with how
    I'm using SOAP.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 5, '13 at 11:58p
activeNov 8, '13 at 4:14p
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase