Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

ECDH without IPv6

  • 16-05-2009 2:17am
    #1
    Closed Accounts Posts: 1,567 ✭✭✭


    here is way to use WiteG ECDSA library to implement ECDH

    the WiteG random function should be replaced by mersenne twister

    [php].686p
    .mmx
    .model flat,stdcall
    option casemap:none
    option prologue:none
    option epilogue:none

    include gfp.inc
    include ecp.inc
    include random.inc

    includelib gfp.lib
    includelib ecp.lib
    includelib random.lib

    extern KEY_BASEPOINT:DWORD

    .data?
    pubKey1 db 48 dup (?)
    pubKey2 db 48 dup (?)
    prvKey1 db 16 dup (?)
    prvKey2 db 16 dup (?)
    commonPointA db 48 dup (?)
    commonPointB db 48 dup (?)

    .code
    start:
    ;A & B do:
    invoke random, 0, 0
    invoke set_N

    ;Alice do:
    @: invoke random, offset prvKey1, 16
    invoke fixmod, offset prvKey1
    invoke comparezero, offset prvKey1
    jz @B

    ;Bob do:
    @: invoke random, offset prvKey2, 16
    invoke fixmod, offset prvKey2
    invoke comparezero, offset prvKey2
    jz @B

    ;A & B do:
    invoke set_P

    ;Alice do:
    invoke ECP_Mul, offset prvKey1, offset KEY_BASEPOINT, offset pubKey1

    ;now Alice send pubKey1 to Bob

    ;Bob do:
    invoke ECP_Mul, offset prvKey2, offset KEY_BASEPOINT, offset pubKey2
    ;now Bob send pubKey2 to Alice

    ;A & B receive pubKeys, they check if those pubKeys are valid points
    ;on common constant elliptic curve and if points arent in infinite

    ;Alice do:
    mov esi, offset commonPointA
    invoke ECP_Mul, offset prvKey1, offset pubKey2, esi

    assume esi: ptr ECPOINT

    lea esi, [esi].X

    ;Bob do:
    mov edi, offset commonPointB
    invoke ECP_Mul, offset prvKey2, offset pubKey1, edi

    assume edi: ptr ECPOINT

    lea edi, [edi].X

    ;established key is X coordinate, under esi for Alice, under edi for Bob
    ;both should have the same number

    ;its only our check ;)
    invoke compare, esi, edi

    jz @we_have_THEKEY
    xor eax, eax
    ret

    @we_have_THEKEY:

    ;both should have the same number
    nop

    ;now they can use some KDF (key derivation function) to create key for symmetric encryption
    nop
    xor eax, eax
    inc eax

    ret
    end start[/php]

    i suppose the point of this is to show how an attacker could use ECDH to hide details of an attack...what would you do in this situation?

    i'm sure everyone has their own way..but its relative to the problem.


Advertisement