dcsimg
Results 1 to 7 of 7

Thread: VB6 - Generate ECC Key DLL

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    772

    VB6 - Generate ECC Key DLL

    Attached is a DLL program that generates an ECC (Elliptical Curve Cryptography) Key, and a sample program to utilize it. Each side in the exchange creates a Public/Private key, and sends the Public Key to the other side. Each side then uses its own Private Key, and the Public Key received from the other end to create a common Shared Secret that can be used as a Session Key.

    A standard DLL is used because it can combine 12 different API calls into one common routine that can be used by a VB program. For this purpose, I used the Standard DLL AddIn from Dansoft Australia http://www.dansoftaustralia.net/developers/vb.htm

    Like some of the BCrypt calls, the DLL will return different information, depending on what information was supplied. If both the Public Key and Private Key are empty, it will return the internal Public\Private Keys and a single byte "0" The Public Key is sent to the other end, and the Private Key is used in the second call. On the second pass, the user supplies the Private Key that it earlier created, and the Public Key that it received from the other end. It should return the 32 byte Shared Secret. If an error occurred, a single byte will be returned with the number of the call that failed.

    I transferred the entire byte arrays because they are relatively small, but in theory you should be able to just use a pointer to the first element of the array. Of course, if you do that, you will also have to supply the length of the array.

    What I really wanted was the raw shared secret, but Microsoft seems to want to hash it first. I have not found a way to get the raw secret by itself, and I am still looking. If anyone can offer a suggestion, I am certainly willing to listen.

    J.A. Coutts
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by couttsj; Dec 10th, 2015 at 12:27 PM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2015
    Posts
    1,353

    Re: VB6 - Generate ECC Key DLL

    These dll's won't work outside the programms that was compiled in VB6. This addin don't initialize a runtime and a project therefore you can't use most of things such as class, forms etc. Also it doesn't work with the multithreading programms. Author of this addin uses old technique known as substitution of the linker. Indeed specified function is being exported from dll, but it doesn't perform any initializations of the runtime. Therefore you can't use this dll in other programs written by other languages. This dll will work only in VB6-compiled programs, but with the restrictions.
    You can avoid it using two approach:
    1. Write project-independent code technique (ie exclude project specified members such as class, forms, objects, variants etc), and using apis that declared in tlb without usesgetlasterror attribute). I had written such dll and exe. Just there are much restrictions, i used only apis and the calculating.
    2. Initialize project before using project specified members. There are several technique. One day i wrote the articles about creating dlls. Here is the basis of the dll creation, and here is using dll in other processes. My English is bad therefore you can ask a questions to me.

  3. #3
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: VB6 - Generate ECC Key DLL

    Quote Originally Posted by The trick View Post
    My English is bad therefore you can ask a questions to me.[/LIST]
    No joke, I see your English has improved a lot. Keep up posting!

    My English is not superior, but Lavolpe always understand me even I spoke in half piece, it is because he has superior knowledge in VB6 language. So,at here,VB6 knowledge is much important than English itself. Keep up practice!
    Last edited by Jonney; Dec 9th, 2015 at 05:55 PM.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    772

    Re: VB6 - Generate ECC Key DLL

    The trick;
    Please forgive me if I am wrong, but it is my understanding that when a DLL is first called upon, the operating system searches the current directory, the Windows directory, and the Windows System directory for the library file. Once found, it's own copy is loaded onto the Heap. So each calling program has it's own working copy of the library file. Now it is entirely possible that other languages might not understand a variable such as a byte array, but I have no way of testing that. It seems to me that as long as one stuck to using variables common to C++ such as long, there should not be an issue. When I examine the DLL with Dependency Walker. it comes up with 2 warnings: "Warning: At least one delay-load dependency module was not found." and
    "Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module." But then again many other library files come up with the same warning, and it traces back to IEFRAME.DLL and MFPLAT.DLL.

    Any idea how I can recover the raw Shared Secret? The only solution I have found so far is to write my own "Do Nothing" Hash and register it with CNG. Unfortunately that is beyond my current capabilities.

    J.A. Coutts

  5. #5
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 - Generate ECC Key DLL

    What the trick is trying to say - is a standard DLL doesn't automatically load and initialize the VB Runtime. So your routines will most likely crash if called from another language.

    (Also check out his link - he has an awesome example of how to use a typelib and initalize the runtime right when the DLL is loaded.)
    Last edited by DEXWERX; Dec 10th, 2015 at 09:49 AM.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    772

    Re: VB6 - Generate ECC Key DLL

    Quote Originally Posted by DEXWERX View Post
    What the trick is trying to say - is a standard DLL doesn't automatically load and initialize the VB Runtime. So your routines will most likely crash if called from another language.

    (Also check out his link - he has an awesome example of how to use a typelib and initalize the runtime right when the DLL is loaded.)
    That makes sense. If the DLL needs the VB runtime to execute, it must be initialized before using the DLL. When called from a VB program, the runtime is already initialized.

    Thanks for the clarification.

    J.A. Coutts

  7. #7
    Frenzied Member
    Join Date
    Feb 2015
    Posts
    1,353

    Re: VB6 - Generate ECC Key DLL

    Once found, it's own copy is loaded onto the Heap.
    No. To virtual memory.
    So each calling program has it's own working copy of the library file.
    No. All modules loads to memory pages (usually 4096 bytes), each page has attributes. When 10 programs use single dll, windows doesn't load 10 times this dll (it would demand 10x more memory), just it uses the single copy of this dll that was loaded first time. When you modify (for instance modify code, or data) page that contains a section of the dll, system does local copy of this page and changer process will works with one. Same for any PE file. You can create the special shared section, that will used by all process. For example memory mapped files work by this principle.
    Any idea how I can recover the raw Shared Secret? The only solution I have found so far is to write my own "Do Nothing" Hash and register it with CNG. Unfortunately that is beyond my current capabilities.
    I don't understand because i didn't work with cryptography-API.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width