Diffie-Hellman Implementation-Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Badri Mohan

    #1

    Diffie-Hellman Implementation-Help

    Hi guys,
    Anyone tried to do a Diffie-Hellman encryption and decryption totally in c#.
    Any ideas?

    Right now i do it as a separate win32 dll
    and use PInvoke from c#..

    Anyone tried of doin that entirely in C#..

    Any exchange of ideas is appreciated.
    Thanks and waiting for replies.

    Badri


  • David Bolt

    #2
    Re: Diffie-Hellman Implementation-Help

    Badri,
    Somehow I think this is not the correct newsgroup, but while your here...
    So you already have a dll, is it one you wrote, or one someone else
    supplied? If you wrote it, then it should be a straight forward, although
    possibly lengthy, task to re-write using C#. Especially since it was
    probably written in C or C++ in the first place.
    Regards
    Dave
    "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote in message
    news:eUH$vwfuDH A.2168@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Hi guys,
    > Anyone tried to do a Diffie-Hellman encryption and decryption totally in[/color]
    c#.[color=blue]
    > Any ideas?
    >
    > Right now i do it as a separate win32 dll
    > and use PInvoke from c#..
    >
    > Anyone tried of doin that entirely in C#..
    >
    > Any exchange of ideas is appreciated.
    > Thanks and waiting for replies.
    >
    > Badri
    >
    >[/color]


    Comment

    • Sébastien Pouliot

      #3
      Re: Diffie-Hellman Implementation-Help

      Badri,

      It should be easy - from a mathematical point of view. Manipulating big
      integers is probably the main problem.
      I know two ways to solve it.
      a. Use the BigInteger class from the Mono project
      (http://www.go-mono.com) or it's ancestor at CodeProject;
      b. Use the bigInteger class from Microsoft that is included in Visual J#
      redist.

      Good luck!
      --
      Sebastien Pouliot
      spouliot@videot ron.ca


      "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote in message
      news:eUH$vwfuDH A.2168@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Hi guys,
      > Anyone tried to do a Diffie-Hellman encryption and decryption totally in[/color]
      c#.[color=blue]
      > Any ideas?
      >
      > Right now i do it as a separate win32 dll
      > and use PInvoke from c#..
      >
      > Anyone tried of doin that entirely in C#..
      >
      > Any exchange of ideas is appreciated.
      > Thanks and waiting for replies.
      >
      > Badri
      >
      >[/color]


      Comment

      • Pieter Philippaerts

        #4
        Re: Diffie-Hellman Implementation-Help

        "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote[color=blue]
        > Anyone tried to do a Diffie-Hellman encryption and decryption totally in[/color]
        c#.[color=blue]
        > Any ideas?
        > Right now i do it as a separate win32 dll
        > and use PInvoke from c#..
        > Anyone tried of doin that entirely in C#..[/color]

        As Sébastien mentioned, you can use the Mono BigInteger class to implement
        it. That's exactly what I've done, so if you're interested here's the code:

        It appears to work perfectly but I haven't tested whether it's compatible
        with other Diffie Hellman implementations . I assume it is, but I'd like to
        verify that before I officially publish the code. I would appreciate it if
        you could verify this for me, since you already have a working DH
        implementation. I tried to write a C# wrapper around the CryptoAPI to verify
        my managed code, but I ran into some problems.

        Regards,
        Pieter Philippaerts


        Comment

        • Pieter Philippaerts

          #5
          Re: Diffie-Hellman Implementation-Help

          "Pieter Philippaerts" <Pieter@nospam. mentalis.org> wrote[color=blue]
          > It appears to work perfectly but I haven't tested whether it's compatible
          > with other Diffie Hellman implementations .[/color]

          I just tested against Cipher448's implementation, and everything worked
          perfectly.

          Regards,
          Pieter Philippaerts


          Comment

          • Pieter Philippaerts

            #6
            Re: Diffie-Hellman Implementation-Help

            "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote[color=blue]
            > Anyone tried to do a Diffie-Hellman encryption and decryption totally in[/color]
            c#.[color=blue]
            > Any ideas?
            > Right now i do it as a separate win32 dll
            > and use PInvoke from c#..
            > Anyone tried of doin that entirely in C#..[/color]

            As Sébastien mentioned, you can use the Mono BigInteger class to implement
            it. That's exactly what I've done, so if you're interested here's the code:

            It appears to work perfectly but I haven't tested whether it's compatible
            with other Diffie Hellman implementations . I assume it is, but I'd like to
            verify that before I officially publish the code. I would appreciate it if
            you could verify this for me, since you already have a working DH
            implementation. I tried to write a C# wrapper around the CryptoAPI to verify
            my managed code, but I ran into some problems.

            Regards,
            Pieter Philippaerts


            Comment

            • Pieter Philippaerts

              #7
              Re: Diffie-Hellman Implementation-Help

              "Pieter Philippaerts" <Pieter@nospam. mentalis.org> wrote[color=blue]
              > It appears to work perfectly but I haven't tested whether it's compatible
              > with other Diffie Hellman implementations .[/color]

              I just tested against Cipher448's implementation, and everything worked
              perfectly.

              Regards,
              Pieter Philippaerts


              Comment

              • Badri Mohan

                #8
                Re: Diffie-Hellman Implementation-Help

                Hey thats a cool implementation. .
                One more Question ..
                Will it run under Mono in Linux..???
                Thanks and waiting for reply..

                "Pieter Philippaerts" <Pieter@nospam. mentalis.org> wrote in message
                news:eS0AEVluDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
                > "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote[color=green]
                > > Anyone tried to do a Diffie-Hellman encryption and decryption totally in[/color]
                > c#.[color=green]
                > > Any ideas?
                > > Right now i do it as a separate win32 dll
                > > and use PInvoke from c#..
                > > Anyone tried of doin that entirely in C#..[/color]
                >
                > As Sébastien mentioned, you can use the Mono BigInteger class to implement
                > it. That's exactly what I've done, so if you're interested here's the[/color]
                code:[color=blue]
                > http://www.mentalis.org/downloads/DH.zip
                > It appears to work perfectly but I haven't tested whether it's compatible
                > with other Diffie Hellman implementations . I assume it is, but I'd like to
                > verify that before I officially publish the code. I would appreciate it if
                > you could verify this for me, since you already have a working DH
                > implementation. I tried to write a C# wrapper around the CryptoAPI to[/color]
                verify[color=blue]
                > my managed code, but I ran into some problems.
                >
                > Regards,
                > Pieter Philippaerts
                >
                >[/color]


                Comment

                • Badri Mohan

                  #9
                  Re: Diffie-Hellman Implementation-Help

                  Thanks for the reply...David
                  Actually everthing works fine for me when there is a wrapper created but it
                  does not run under Mono in Linux..
                  It says thereis a Out of sync error..
                  Any guesses??

                  "David Bolt" <davebolt@compu serve.com> wrote in message
                  news:uc4FP0guDH A.4056@TK2MSFTN GP11.phx.gbl...[color=blue]
                  > Badri,
                  > Somehow I think this is not the correct newsgroup, but while your here...
                  > So you already have a dll, is it one you wrote, or one someone else
                  > supplied? If you wrote it, then it should be a straight forward, although
                  > possibly lengthy, task to re-write using C#. Especially since it was
                  > probably written in C or C++ in the first place.
                  > Regards
                  > Dave
                  > "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote in message
                  > news:eUH$vwfuDH A.2168@TK2MSFTN GP10.phx.gbl...[color=green]
                  > > Hi guys,
                  > > Anyone tried to do a Diffie-Hellman encryption and decryption totally in[/color]
                  > c#.[color=green]
                  > > Any ideas?
                  > >
                  > > Right now i do it as a separate win32 dll
                  > > and use PInvoke from c#..
                  > >
                  > > Anyone tried of doin that entirely in C#..
                  > >
                  > > Any exchange of ideas is appreciated.
                  > > Thanks and waiting for replies.
                  > >
                  > > Badri
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Pieter Philippaerts

                    #10
                    Re: Diffie-Hellman Implementation-Help

                    "Badri Mohan" <bmohan@NOSPAMu ncc.edu> wrote in message[color=blue]
                    > Hey thats a cool implementation. .
                    > One more Question ..
                    > Will it run under Mono in Linux..???
                    > Thanks and waiting for reply..[/color]

                    Yes, it will -- in fact, I just emailed the code to Sébastien to include it
                    in the Mono runtime.
                    However there's a bug in the official BigInteger implementation
                    [http://bugzilla.ximian.com/show_bug.cgi?id=51229] that may cause the
                    Diffie-Hellman implementation to malfunction. The BigInteger class that I
                    used for the Diffie-Hellman implementation contains a work-around for this
                    bug.

                    Regards,
                    Pieter Philippaerts


                    Comment

                    Working...