md5 encryption in OpenCL

Discussion in 'Mac Programming' started by Cbswe, Jan 21, 2011.

  1. Cbswe macrumors member

    Joined:
    Jan 11, 2010
    #1
    Hi!

    I have a quick question.

    How challenging would it be to write a md5 encrypter in OpenCL?

    Me and my friend is thinking of writing our bachelor essay about such an implementation and the possible speed advantage.

    Any comment and/or view is appreciated!
     
  2. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
    It all depends on your programming skills. MD5 is a very well documented algorithm and porting it shouldn't be an issue at all, given there are some VERY low level examples of how to implement it.
     
  3. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
  4. Cbswe thread starter macrumors member

    Joined:
    Jan 11, 2010
    #4
    That was what we thought as well. The only part that's worrying is that OpenCL is not the easiest language to write in and we have no previous experience in it.

    However, we got 2.5 years of academic studies in computer science and have learned a lot of languages before as well.

    Right you are. Sorry :) It's a cryptographic hash function.
     
  5. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #5
    Look at the MD5 algorithm. Can you find any operations that you can do in parallel?
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Is MD5 CPU or I/O bound?

    I would have assumed the latter since it has been around since CPUs were not much more than fancy abacuses :p And of course it's goal is to take lots of data in and spit out something much smaller.

    And that too of course.

    B
     
  7. Cbswe thread starter macrumors member

    Joined:
    Jan 11, 2010
    #7

    I'm sorry, I must have misunderstood the algorithm then. I got the understanding that it worked on 128 bits at a time.
     
  8. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #8
    512 bits according to Wikipedia, but the accumulated hash from the previous 512 bit sections is used in calculating the hash for the current section, so you can't easily parallelize it.

    (If they were completely separable, how would you tell the difference between a 1024 bit stream composed of 512 bit sections A then B vs. B then A?)

    http://en.wikipedia.org/wiki/MD5

    I may certainly not be understanding it right either, so feel free to correct me if I'm wrong.

    B
     
  9. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #9
    MD5 adds a bit of padding and stores the data size at the end of the stream, so that you have a multiple of 512 bits. These are split into sixteen 32 bit units, and tons of dependent operations performed on these 32 bits, mixing them with the other 32 bits all the time and doing different operations on each of the 32 bit units.

    You have no chance of using OpenCL in any meaningful way, no chance of using SSE, no chance even of using 64 bit capabilities of a processor except for the fact that it has more registers, but then you lose out because the algorithm requires 32 bit shift operations. Every step is dependent on each previous step.
     
  10. Cbswe thread starter macrumors member

    Joined:
    Jan 11, 2010
    #10
    Thanks! You saved me and my friend from a lot of trouble! :)

    We decided to find another problem that's certain to be parallely calculable.

    I might have realized the absurdity of the proposal if I wasn't so sleep deprecated today and the deadline for the proposal is tonight :)

    Macrumor forum is a lifesaver.
    Thanks guys!
     

Share This Page